{
 "name": "[노드 한 장] Stop and Error · 환율이 이상하면 멈추기",
 "nodes": [
  {
   "id": "a1",
   "name": "Run manually",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    100
   ],
   "parameters": {}
  },
  {
   "id": "a2",
   "name": "Get USD rates",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    220,
    100
   ],
   "parameters": {
    "url": "https://open.er-api.com/v6/latest/USD",
    "options": {}
   }
  },
  {
   "id": "a3",
   "name": "Pick KRW rate",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    440,
    100
   ],
   "parameters": {
    "jsCode": "// 테스트용: true로 바꾸면 일부러 만든 이상값(13.25원)으로 바꿔요\nconst FORCE_BAD = false;\n\nconst r = $input.first().json;\nreturn [{ json: {\n  result: r.result,\n  usd_krw: FORCE_BAD ? 13.25 : r.rates.KRW,\n  updated: r.time_last_update_utc,\n  test_bad_value: FORCE_BAD\n} }];"
   }
  },
  {
   "id": "a4",
   "name": "Rate looks wrong?",
   "type": "n8n-nodes-base.if",
   "typeVersion": 2.2,
   "position": [
    660,
    100
   ],
   "parameters": {
    "conditions": {
     "options": {
      "caseSensitive": true,
      "leftValue": "",
      "typeValidation": "loose",
      "version": 2
     },
     "conditions": [
      {
       "id": "c1",
       "leftValue": "={{ $json.usd_krw }}",
       "rightValue": 500,
       "operator": {
        "type": "number",
        "operation": "lt"
       }
      },
      {
       "id": "c2",
       "leftValue": "={{ $json.usd_krw }}",
       "rightValue": 3000,
       "operator": {
        "type": "number",
        "operation": "gt"
       }
      },
      {
       "id": "c3",
       "leftValue": "={{ $json.result }}",
       "rightValue": "success",
       "operator": {
        "type": "string",
        "operation": "notEquals"
       }
      }
     ],
     "combinator": "or"
    },
    "options": {}
   }
  },
  {
   "id": "a5",
   "name": "Stop: bad rate",
   "type": "n8n-nodes-base.stopAndError",
   "typeVersion": 1,
   "position": [
    900,
    0
   ],
   "parameters": {
    "errorMessage": "=환율이 이상해요: 1달러 = {{ $json.usd_krw }}원. 저장하지 않고 멈춥니다."
   }
  },
  {
   "id": "a6",
   "name": "OK: save rate",
   "type": "n8n-nodes-base.set",
   "typeVersion": 3.4,
   "position": [
    900,
    200
   ],
   "parameters": {
    "assignments": {
     "assignments": [
      {
       "id": "f1",
       "name": "status",
       "type": "string",
       "value": "OK · 저장 진행"
      },
      {
       "id": "f2",
       "name": "usd_krw",
       "type": "number",
       "value": "={{ $json.usd_krw }}"
      }
     ]
    },
    "options": {}
   }
  }
 ],
 "connections": {
  "Run manually": {
   "main": [
    [
     {
      "node": "Get USD rates",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Get USD rates": {
   "main": [
    [
     {
      "node": "Pick KRW rate",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Pick KRW rate": {
   "main": [
    [
     {
      "node": "Rate looks wrong?",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Rate looks wrong?": {
   "main": [
    [
     {
      "node": "Stop: bad rate",
      "type": "main",
      "index": 0
     }
    ],
    [
     {
      "node": "OK: save rate",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "timezone": "Asia/Seoul",
  "executionOrder": "v1"
 },
 "meta": {
  "templateCredsSetupCompleted": false,
  "source": "datapopcorn.ai/workflow/nodes"
 }
}