{
  "name": "Client API CRUD 테스트",
  "description": "거래처(Client) API 전체 CRUD 테스트 - 생성, 조회, 수정, 토글, 삭제 포함. business_no, business_type, business_item 신규 필드 검증 포함.",
  "version": "1.0",
  "config": {
    "baseUrl": "https://api.sam.kr/api/v1",
    "apiKey": "{{$env.FLOW_TESTER_API_KEY}}",
    "timeout": 30000,
    "stopOnFailure": true
  },
  "variables": {
    "user_id": "{{$env.FLOW_TESTER_USER_ID}}",
    "user_pwd": "{{$env.FLOW_TESTER_USER_PWD}}",
    "test_client_code": "TEST_CLIENT_{{$timestamp}}"
  },
  "steps": [
    {
      "id": "login",
      "name": "1. 로그인 - 토큰 획득",
      "method": "POST",
      "endpoint": "/login",
      "body": {
        "user_id": "{{variables.user_id}}",
        "user_pwd": "{{variables.user_pwd}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.access_token": "@isString"
        }
      },
      "extract": {
        "token": "$.access_token"
      }
    },
    {
      "id": "create_client",
      "name": "2. 거래처 생성 (신규 필드 포함)",
      "method": "POST",
      "endpoint": "/clients",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "client_code": "{{variables.test_client_code}}",
        "name": "테스트 거래처",
        "contact_person": "홍길동",
        "phone": "02-1234-5678",
        "email": "test@example.com",
        "address": "서울시 강남구 테헤란로 123",
        "business_no": "123-45-67890",
        "business_type": "제조업",
        "business_item": "전자부품",
        "is_active": "Y"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber",
          "$.data.client_code": "{{variables.test_client_code}}",
          "$.data.name": "테스트 거래처",
          "$.data.business_no": "123-45-67890",
          "$.data.business_type": "제조업",
          "$.data.business_item": "전자부품"
        }
      },
      "extract": {
        "client_id": "$.data.id"
      }
    },
    {
      "id": "list_clients",
      "name": "3. 거래처 목록 조회",
      "method": "GET",
      "endpoint": "/clients?page=1&size=20&q=테스트",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.data": "@isArray",
          "$.data.current_page": 1
        }
      }
    },
    {
      "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": "{{variables.test_client_code}}",
          "$.data.business_no": "123-45-67890",
          "$.data.business_type": "제조업",
          "$.data.business_item": "전자부품"
        }
      }
    },
    {
      "id": "update_client",
      "name": "5. 거래처 수정 (신규 필드 변경)",
      "method": "PUT",
      "endpoint": "/clients/{{create_client.client_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "name": "테스트 거래처 (수정됨)",
        "contact_person": "김철수",
        "business_no": "987-65-43210",
        "business_type": "도소매업",
        "business_item": "IT솔루션"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.name": "테스트 거래처 (수정됨)",
          "$.data.contact_person": "김철수",
          "$.data.business_no": "987-65-43210",
          "$.data.business_type": "도소매업",
          "$.data.business_item": "IT솔루션"
        }
      }
    },
    {
      "id": "toggle_client",
      "name": "6. 거래처 활성/비활성 토글 (N으로)",
      "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_client_back",
      "name": "7. 거래처 토글 복원 (Y로)",
      "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": "list_active_only",
      "name": "8. 활성 거래처만 조회",
      "method": "GET",
      "endpoint": "/clients?only_active=1",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.data": "@isArray"
        }
      }
    },
    {
      "id": "delete_client",
      "name": "9. 거래처 삭제",
      "method": "DELETE",
      "endpoint": "/clients/{{create_client.client_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "verify_deleted",
      "name": "10. 삭제 확인 (404 예상)",
      "method": "GET",
      "endpoint": "/clients/{{create_client.client_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [404],
        "jsonPath": {
          "$.success": false
        }
      }
    }
  ]
}