{
  "name": "Client API CRUD Flow Test",
  "description": "거래처(Client) 관리 API 전체 CRUD 플로우 테스트 - 로그인, 목록조회, 생성, 단건조회, 수정, 토글, 삭제",
  "version": "1.0",
  "config": {
    "baseUrl": "",
    "timeout": 30000,
    "stopOnFailure": true
  },
  "variables": {
    "user_id": "{{$env.FLOW_TESTER_USER_ID}}",
    "user_pwd": "{{$env.FLOW_TESTER_USER_PWD}}",
    "test_client_code": "TEST-{{$timestamp}}",
    "test_client_name": "테스트거래처_{{$timestamp}}"
  },
  "steps": [
    {
      "id": "login",
      "name": "1. 로그인",
      "method": "POST",
      "endpoint": "/login",
      "body": {
        "user_id": "{{user_id}}",
        "user_pwd": "{{user_pwd}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.access_token": "@isString"
        }
      },
      "extract": {
        "token": "$.access_token"
      }
    },
    {
      "id": "list_clients",
      "name": "2. 거래처 목록 조회",
      "method": "GET",
      "endpoint": "/clients",
      "params": {
        "page": 1,
        "size": 10
      },
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.current_page": 1
        }
      },
      "extract": {
        "total_before": "$.data.total"
      }
    },
    {
      "id": "create_client",
      "name": "3. 거래처 생성",
      "method": "POST",
      "endpoint": "/clients",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "client_code": "{{test_client_code}}",
        "name": "{{test_client_name}}",
        "contact_person": "테스트담당자",
        "phone": "02-1234-5678",
        "email": "test@example.com",
        "address": "서울시 강남구 테스트로 123",
        "business_no": "123-45-67890",
        "business_type": "서비스업",
        "business_item": "소프트웨어개발",
        "is_active": true
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "extract": {
        "client_id": "$.data.id",
        "client_code": "$.data.client_code"
      }
    },
    {
      "id": "show_client",
      "name": "4. 거래처 단건 조회",
      "method": "GET",
      "endpoint": "/clients/{{create_client.client_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "{{create_client.client_id}}",
          "$.data.client_code": "{{create_client.client_code}}",
          "$.data.name": "{{test_client_name}}"
        }
      }
    },
    {
      "id": "update_client",
      "name": "5. 거래처 수정",
      "method": "PUT",
      "endpoint": "/clients/{{create_client.client_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "client_code": "{{create_client.client_code}}",
        "name": "{{test_client_name}}_수정됨",
        "contact_person": "수정담당자",
        "phone": "02-9999-8888",
        "email": "updated@example.com",
        "address": "서울시 서초구 수정로 456"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.contact_person": "수정담당자"
        }
      }
    },
    {
      "id": "verify_update",
      "name": "6. 수정 확인 조회",
      "method": "GET",
      "endpoint": "/clients/{{create_client.client_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.contact_person": "수정담당자",
          "$.data.phone": "02-9999-8888"
        }
      }
    },
    {
      "id": "toggle_inactive",
      "name": "7. 거래처 비활성화 토글",
      "method": "PATCH",
      "endpoint": "/clients/{{create_client.client_id}}/toggle",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.is_active": false
        }
      }
    },
    {
      "id": "toggle_active",
      "name": "8. 거래처 활성화 토글",
      "method": "PATCH",
      "endpoint": "/clients/{{create_client.client_id}}/toggle",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.is_active": true
        }
      }
    },
    {
      "id": "search_client",
      "name": "9. 거래처 검색",
      "method": "GET",
      "endpoint": "/clients",
      "params": {
        "q": "{{test_client_name}}",
        "page": 1,
        "size": 10
      },
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.total": "@isNumber"
        }
      }
    },
    {
      "id": "delete_client",
      "name": "10. 거래처 삭제",
      "method": "DELETE",
      "endpoint": "/clients/{{create_client.client_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "verify_delete",
      "name": "11. 삭제 확인 (404 예상)",
      "method": "GET",
      "endpoint": "/clients/{{create_client.client_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [404],
        "jsonPath": {
          "$.success": false
        }
      }
    }
  ]
}
