{
  "name": "구독 관리 플로우",
  "description": "구독 등록 → 사용량 조회 → 일시 정지 → 재개 → 갱신 → 해지 플로우 테스트",
  "version": "1.0",
  "config": {
    "baseUrl": "",
    "timeout": 30000,
    "stopOnFailure": true
  },
  "variables": {
    "user_id": "{{$env.FLOW_TESTER_USER_ID}}",
    "user_pwd": "{{$env.FLOW_TESTER_USER_PWD}}"
  },
  "steps": [
    {
      "id": "login",
      "name": "로그인",
      "method": "POST",
      "endpoint": "/api/v1/login",
      "body": {
        "user_id": "{{user_id}}",
        "user_pwd": "{{user_pwd}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.access_token": "@isString"
        }
      },
      "extract": {
        "token": "$.access_token"
      }
    },
    {
      "id": "list_subscriptions",
      "name": "구독 목록 조회",
      "method": "GET",
      "endpoint": "/api/v1/subscriptions",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "queryParams": {
        "page": 1,
        "per_page": 10
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      }
    },
    {
      "id": "create_subscription",
      "name": "구독 등록",
      "method": "POST",
      "endpoint": "/api/v1/subscriptions",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "plan_id": 1,
        "billing_cycle": "monthly",
        "start_date": "2025-01-01",
        "payment_method": "card",
        "auto_renew": true
      },
      "expect": {
        "status": [200, 201],
        "jsonPath": {
          "$.success": true
        }
      },
      "extract": {
        "subscription_id": "$.data.id"
      },
      "continueOnFailure": true
    },
    {
      "id": "get_subscription_detail",
      "name": "구독 상세 조회",
      "method": "GET",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.id": "@isNumber"
        }
      },
      "continueOnFailure": true
    },
    {
      "id": "get_usage",
      "name": "사용량 조회",
      "method": "GET",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}/usage",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "queryParams": {
        "period": "current"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      },
      "continueOnFailure": true
    },
    {
      "id": "suspend_subscription",
      "name": "구독 일시 정지",
      "method": "POST",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}/suspend",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "reason": "테스트용 일시 정지"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      },
      "continueOnFailure": true
    },
    {
      "id": "verify_suspended",
      "name": "정지 상태 확인",
      "method": "GET",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.status": "suspended"
        }
      },
      "continueOnFailure": true
    },
    {
      "id": "resume_subscription",
      "name": "구독 재개",
      "method": "POST",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}/resume",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      },
      "continueOnFailure": true
    },
    {
      "id": "renew_subscription",
      "name": "구독 갱신",
      "method": "POST",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}/renew",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "extend_months": 1
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      },
      "continueOnFailure": true
    },
    {
      "id": "update_subscription",
      "name": "구독 수정",
      "method": "PUT",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "auto_renew": false
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      },
      "continueOnFailure": true
    },
    {
      "id": "export_usage",
      "name": "사용량 내역 내보내기",
      "method": "GET",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}/export",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "queryParams": {
        "format": "xlsx",
        "period": "last_month"
      },
      "expect": {
        "status": [200]
      },
      "continueOnFailure": true
    },
    {
      "id": "cancel_subscription",
      "name": "구독 해지",
      "method": "POST",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}/cancel",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "body": {
        "reason": "테스트 완료",
        "cancel_immediately": true
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true
        }
      },
      "continueOnFailure": true
    },
    {
      "id": "verify_cancelled",
      "name": "해지 상태 확인",
      "method": "GET",
      "endpoint": "/api/v1/subscriptions/{{create_subscription.subscription_id}}",
      "headers": {
        "Authorization": "Bearer {{login.token}}"
      },
      "expect": {
        "status": [200],
        "jsonPath": {
          "$.success": true,
          "$.data.status": "cancelled"
        }
      },
      "continueOnFailure": true
    }
  ]
}
