openapi: 3.0.0
info:
  title: rezio API 串接文件 - B2B 同業
  description: '> **Beta（測試版）** — 本 API 目前為測試版。API 方案仍在規劃中，開通採申請制，介面仍可能調整，異動將於本文件公告。申請開通請聯絡 <a href="mailto:service@rezio.io">service@rezio.io</a>。


    本文件提供 B2B 串接使用，可對指定店家，進行查詢產品、查詢可售日期場次、查詢預定資訊、新增訂單、取消訂單的操作。B2B API 的開通請來信 <a href="mailto:service@rezio.io">service@rezio.io</a>；「商店代號 (UUID)」與「分銷商 API 串接金鑰」由供貨的店家提供。'
  contact:
    name: rezio API Support
    email: service@rezio.io
  version: 0.0.17
servers:
- url: https://b2b.rezio.io
  description: Production
paths:
  /b2b/product:
    get:
      tags:
      - B2B
      summary: 查詢產品清單
      operationId: getProducts
      responses:
        '200':
          $ref: '#/components/responses/product_list_response'
        '401':
          $ref: '#/components/responses/unauthorized_response'
      security:
      - X-Auth-Store: []
        X-Auth-Distr: []
  /b2b/{productUuid}/{salesOptionId}/sessions:
    get:
      tags:
      - B2B
      summary: 查詢產品可買的日期跟場次
      operationId: querySalesOption
      parameters:
      - $ref: '#/components/parameters/product_uuid_in_path'
      - $ref: '#/components/parameters/sales_option_uuid_in_path'
      - $ref: '#/components/parameters/start_date_in_query'
      - $ref: '#/components/parameters/end_date_in_query'
      responses:
        '200':
          $ref: '#/components/responses/query_sales_option_response'
        '401':
          $ref: '#/components/responses/unauthorized_response'
      security:
      - X-Auth-Store: []
        X-Auth-Distr: []
  /b2b/{productUuid}/bookingInfo:
    get:
      tags:
      - B2B
      summary: 查詢預定資訊
      operationId: queryBookingInfo
      parameters:
      - $ref: '#/components/parameters/product_uuid_in_path'
      responses:
        '200':
          $ref: '#/components/responses/booking_response'
        '401':
          $ref: '#/components/responses/unauthorized_response'
      security:
      - X-Auth-Store: []
        X-Auth-Distr: []
  /b2b/order:
    post:
      tags:
      - B2B
      summary: 下訂單
      operationId: orderProduct
      requestBody:
        $ref: '#/components/requestBodies/order_request_body'
      responses:
        '200':
          $ref: '#/components/responses/order_response'
        '401':
          $ref: '#/components/responses/unauthorized_response'
      security:
      - X-Auth-Store: []
        X-Auth-Distr: []
  /b2b/order/{orderNo}:
    get:
      tags:
      - B2B
      summary: 查詢訂單
      operationId: getOrder
      parameters:
      - $ref: '#/components/parameters/order_number_in_path'
      responses:
        '200':
          $ref: '#/components/responses/get_order_response'
        '401':
          $ref: '#/components/responses/unauthorized_response'
      security:
      - X-Auth-Store: []
        X-Auth-Distr: []
  /b2b/{orderNo}/applyCancel:
    post:
      tags:
      - B2B
      summary: 取消訂單
      operationId: applyCancel
      parameters:
      - $ref: '#/components/parameters/order_number_in_path'
      requestBody:
        $ref: '#/components/requestBodies/cancel_request_body'
      responses:
        '200':
          $ref: '#/components/responses/cancel_response'
        '401':
          $ref: '#/components/responses/unauthorized_response'
      security:
      - X-Auth-Store: []
        X-Auth-Distr: []
components:
  schemas:
    pickup_request:
      title: 傳入 接送資料
      properties:
        id:
          description: 接送資訊ID (SYSTEM類型使用)
          type: string
          example: 2a9263c8-d98c-4121-b609-5a51755c6c1f
        request:
          description: 接送需求 (CUSTOM類型使用)
          type: string
          example: 煙波大飯店 花蓮縣花蓮市中美路142號
        time:
          description: 接送時間 (CUSTOM類型使用 需在 startTime ~ endTime 之間)
          type: string
          example: '13:30'
      type: object
    pickup_response:
      title: 回傳 接送資料
      properties:
        id:
          description: 接送資訊ID
          type: string
          example: 2a9263c8-d98c-4121-b609-5a51755c6c1f
        type:
          description: '接送類型: SYSTEM/ CUSTOM'
          type: string
          example: SYSTEM
        label:
          description: 接送位置說明
          type: string
          example: 花蓮火車站正門
        address:
          description: 接送地址
          type: string
          example: 花蓮縣花蓮市國聯一路100號
        vehicle:
          description: 接送車輛 (限CUSTOM類型使用)
          type: string
          example: 豪華轎車
        instructions:
          description: 詳細接送指引
          type: string
          example: 請在火車站右側等待區，找尋穿綠色背心的工作人員報到
        date:
          description: 接送日期
          type: string
          example: '2021-08-18'
        startTime:
          description: 接送開始時間
          type: string
          example: '13:00'
        endTime:
          description: 接送結束時間
          type: string
          example: '13:50'
        latitude:
          description: 接送地點座標緯度
          type: string
          example: '23.9938653'
        longitude:
          description: 接送地點座標經度
          type: string
          example: '121.6022198'
      type: object
    bookingInfo_result:
      title: 預訂資訊回傳資料
      properties:
        key:
          description: 資料鍵值
          type: string
          example: firstName
        title:
          description: 顯示文字
          type: string
          example: 名
        type:
          description: 資訊類型
          type: string
          example: string
        option:
          description: 可選內容
          type: array
          items:
            description: 內容字串
            type: string
            example: mobile
        required:
          description: 是否必填
          type: boolean
          example: true
      type: object
    bookingInfoType:
      title: 預訂資訊類型與成單資料對應
      description: "\n| type            \t|資料|範例|\n|-----------------\t|------------------------------------------------------------------\t|--------------------------------------------------------------------\t|\n| string          \t| \"{key}\": \"{值}\"                                              \t| \"firstName\": \"name\"                                            \t|\n| email           \t| \"{key}\": \"{值}\"                                              \t| \"email\": \"test@test.test\"                                      \t|\n| date            \t| \"{key}\": \"Y-m-d\"                                             \t| \"birthday\": \"2021-01-01\"                                       \t|\n| datetime        \t| \"{key}\": \"Y-m-d H:i:s\"                                       \t| \"departureDateTime\": \"2021-12-20 10:20:00\"                     \t|\n| phone           \t| \"{key}\":{\"countryCode\":國碼, \"number\":\"電話\"}            \t| \"mobile\": {\"countryCode\":886, \"number\":\"987654321\"}        \t|\n| shoe            \t| \"{key}\":{\"type\":\"option內類別\", \"value\":200}             \t| \"shoeSize_mm\": {\"type\":\"Man\", \"value\":275}                 \t|\n| bool            \t| \"{key}\": true                                                  \t| \"31a95a4e-a5e2-4b7c-8c5a-f7a417403b83\": false                    \t|\n| list            \t| \"{key}\":[\"{值1}\",\"{值2}\",\"{值3}\"]                        \t| \"a74aeff8-c350-467a-aa18-7d4a6ec6a412\": [\"A\",\"B\"]            \t|\n| duringItinerary \t| \"{key}\": {\"type\":\"option內選項\", \"value\":\"對應的資料\"} \t| \"contactAccount\": {\"type\":\"mobile\", \"value\":\"987654321\"} \t|"
      type: object
    error_code:
      title: 錯誤代碼表
      description: "結果代碼。成功為 `S0000`；業務錯誤時 HTTP 仍為 200，需以本欄位判斷成敗。\n\n|錯誤代碼|錯誤原因|\n| ------------ \t| ---------------------------------\t                                                                |\n| V0001     \t|缺少參數|\n| V0002     \t|參數格式有誤|\n| E0002     \t|查無資料|\n| F0001     \t|發生錯誤(需看codeMessage)|\n| B0001     \t|加購項目(extras)訂購數量有誤|\n| B0002     \t|查無此時段可銷售的行程|\n| B0003     \t|未選擇接送項目|\n| B0004     \t|選擇的接送項目有誤|\n| B0005     \t|選擇的接送時間不在可接送範圍內|\n| B0006     \t|未選導覽服務語言|\n| B0007     \t|選擇的語言有誤|\n| B0008     \t|預訂資訊選項有誤|\n| B0009     \t|未帶必填的預訂資訊|\n| B0010     \t|purchaseContent資料有誤 查無項目|\n| B0011     \t|purchaseContent訂購數量有誤|\n| B0012     \t|旅客資訊數量有誤|\n| B0013     \t|訂購的加購項目(extras)不存在|"
      type: string
      example: S0000
  responses:
    product_list_response:
      description: OK
      content:
        application/json:
          schema:
            properties:
              code:
                $ref: '#/components/schemas/error_code'
              codeMessage:
                description: 回傳訊息
                type: string
                example: SUCCESS
              data:
                description: 回傳資料
                properties:
                  products:
                    description: 行程清單
                    type: array
                    items:
                      properties:
                        id:
                          description: 行程 ID
                          type: string
                          example: 2c935076-ac44-41cf-943f-8e5fdd29bdf1
                        productCode:
                          description: 行程代碼
                          type: string
                          example: MN8SEH
                        title:
                          description: 行程標題
                          type: string
                          example: '[測試票券] 花蓮｜滑翔傘飛行體驗、俯瞰壯麗的太平洋'
                        language:
                          description: 導覽服務語言
                          properties:
                            audioHeadset:
                              description: 語音導覽機語言
                              type: array
                              items:
                                description: 語言代碼
                                type: string
                              example:
                              - en
                              - cmn
                            guide:
                              description: 導遊語言
                              type: array
                              items:
                                description: 語言代碼
                                type: string
                              example:
                              - en
                              - cmn
                            translation:
                              description: 景點導覽語言
                              type: array
                              items:
                                description: 語言代碼
                                type: string
                              example:
                              - en
                              - cmn
                            written:
                              description: 紙本資料語言
                              type: array
                              items:
                                description: 文字代碼
                                type: string
                              example:
                              - en-US
                              - ja-JP
                              - zh-CN
                              - zh-TW
                          type: object
                        extras:
                          description: 可加購品
                          type: array
                          items:
                            properties:
                              id:
                                description: 可加購品ID
                                type: string
                                example: 9b2b7cfc-fd35-4481-8cb3-ef64caaff442
                              label:
                                description: 加購品名
                                type: string
                                example: GOPRO影片
                              priceType:
                                description: 可加購品類型：ORDER/QUANTITY<br><b>ORDER<b>：按訂單加購類型(可買數量最大為1); <b>QUANTITY</b>：可按加購品下訂數量訂購)
                                type: string
                                example: ORDER
                              quantity:
                                description: 可買數量 (-1代表無限量)
                                type: number
                                example: 1.0
                              price:
                                description: 價錢
                                type: number
                                example: 500.0
                            type: object
                        salesOptions:
                          description: 行程套餐列表
                          type: array
                          items:
                            properties:
                              id:
                                description: 套餐ID
                                type: string
                                example: c8873111-73ff-4218-b0cf-c40796f05e01
                              title:
                                description: 套餐名稱
                                type: string
                                example: 滑翔傘飛行體驗＋GOPRO全程攝影
                            type: object
                      type: object
                type: object
            type: object
    query_sales_option_response:
      description: OK
      content:
        application/json:
          schema:
            properties:
              code:
                $ref: '#/components/schemas/error_code'
              codeMessage:
                description: 回傳訊息
                type: string
                example: SUCCESS
              data:
                description: 回傳資料
                properties:
                  sessions:
                    description: 可買場次資訊
                    properties:
                      id:
                        description: 場次ID
                        type: string
                        example: b3ca9362-22de-4a24-b9c7-2fb866624ca8
                      startDate:
                        description: 開始日期
                        type: string
                        example: '2021-08-18'
                      startTime:
                        description: 開始時間
                        type: string
                        example: '14:00'
                      endDate:
                        description: 結束時間
                        type: string
                        example: '2021-08-18'
                      endTime:
                        description: 結束時間
                        type: string
                        example: '15:00'
                      currencyCode:
                        description: 貨幣符號
                        type: string
                        example: TWD
                      prices:
                        description: 套餐售價
                        type: array
                        items:
                          properties:
                            id:
                              description: 套餐計價ID
                              type: string
                              example: 76d2d935-4a55-4c09-80df-42311e7bbaa9
                            type:
                              description: '計價類型(身份別/項目): PERSON/ ITEM'
                              type: string
                              example: PERSON
                            label:
                              description: 名稱
                              type: string
                              example: Participant
                            price:
                              description: 售價
                              type: number
                              example: 3000.0
                          type: object
                      quotaAvailable:
                        description: 可售數量 (-1:無限量)
                        type: number
                        example: 20.0
                      pickup:
                        description: 接送資訊
                        properties:
                          departure:
                            description: 去程接送資訊
                            type: array
                            items:
                              $ref: '#/components/schemas/pickup_response'
                          return:
                            description: 回程接送資訊
                            type: array
                            items:
                              $ref: '#/components/schemas/pickup_response'
                        type: object
                    type: object
                type: object
            type: object
    order_response:
      description: OK
      content:
        application/json:
          schema:
            properties:
              code:
                $ref: '#/components/schemas/error_code'
              codeMessage:
                description: 回傳訊息
                type: string
                example: SUCCESS
              data:
                description: 回傳資料
                properties:
                  orderNo:
                    description: 訂單編號
                    type: string
                    example: DS210713SN4361
                  currencyCode:
                    description: 幣別
                    type: string
                    example: TWD
                  totalAmount:
                    description: 付款金額
                    type: number
                    format: float
                    example: 3200.0
                  vouchers:
                    description: 憑證資訊(只有即時確認，而且使用 rezio QR Code 的行程才可立刻取得憑證資訊)
                    type: array
                    items:
                      properties:
                        qrCodeStr:
                          description: QR Code 字串，請產生標準QR Code (ISO 18004)
                          type: string
                          example: rezio://redeem?code=1234567890
                      type: object
                type: object
            type: object
    get_order_response:
      description: OK
      content:
        application/json:
          schema:
            properties:
              code:
                $ref: '#/components/schemas/error_code'
              codeMessage:
                description: 回傳訊息
                type: string
                example: SUCCESS
              data:
                description: 回傳資料
                properties:
                  orderNo:
                    description: 訂單編號
                    type: string
                    example: DS210713SN4361
                  status:
                    description: 訂單狀態：CANCELED / NEW_UNPAID / NEW_PAID / PENDING / CONFIRMED / CHECKIN / NO_SHOW / CANCELING / CANCEL_REQUESTED / DEPARTED
                    type: string
                    example: CONFIRMED
                  currencyCode:
                    description: 幣別
                    type: string
                    example: TWD
                  totalAmount:
                    description: 付款金額
                    type: number
                    format: float
                    example: 3200.0
                  vouchers:
                    description: 憑證資訊
                    type: array
                    items:
                      properties:
                        qrCodeStr:
                          description: QR Code 字串，請產生標準QR Code (ISO 18004)
                          type: string
                          example: rezio://redeem?code=1234567890
                        redeemTimes:
                          description: 已核銷次數
                          type: integer
                          example: 1
                        totalRedeemableTimes:
                          description: 憑證可核銷次數
                          type: integer
                          example: 1
                        status:
                          description: 憑證狀態：NONE：尚無憑證 / VALID：可使用 / USED：已核銷 / LOCKED：等待取消中 / INVALID：已失效 / EXPIRED：已過期
                          type: string
                          example: USED
                          enum:
                          - NONE
                          - VALID
                          - USED
                          - LOCKED
                          - INVALID
                          - EXPIRED
                        usedAt:
                          description: 核銷時間
                          type: string
                          example: '2021-07-21 10:01:00'
                        invalidAt:
                          description: 實際作廢時間
                          type: string
                          example: ''
                        sessionStartAt:
                          description: 訂購場次的開始時間 (票券型的為空值)
                          type: string
                          example: '2021-07-21 10:00:00'
                        sessionEndAt:
                          description: 訂購場次的結束時間 (票券型的為空值)
                          type: string
                          example: '2021-07-21 12:00:00'
                        ticketStartAt:
                          description: 票券型起始時間 (一般憑證為空值)
                          type: string
                          example: ''
                        ticketEndAt:
                          description: 票券型結束時間 (一般憑證為空值)
                          type: string
                          example: ''
                      type: object
                type: object
            type: object
    cancel_response:
      description: OK
      content:
        application/json:
          schema:
            properties:
              code:
                $ref: '#/components/schemas/error_code'
              codeMessage:
                description: 回傳訊息
                type: string
                example: SUCCESS
              data:
                description: 回傳資料
                type: object
            type: object
    booking_response:
      description: OK
      content:
        application/json:
          schema:
            properties:
              code:
                $ref: '#/components/schemas/error_code'
              codeMessage:
                description: 回傳訊息
                type: string
                example: SUCCESS
              data:
                description: 回傳資料
                properties:
                  bookingInfo:
                    description: 預訂資訊
                    properties:
                      contact:
                        description: 聯絡資訊
                        type: array
                        items:
                          $ref: '#/components/schemas/bookingInfo_result'
                      order:
                        description: 旅客代表
                        type: array
                        items:
                          $ref: '#/components/schemas/bookingInfo_result'
                      participant:
                        description: 旅客資訊
                        type: array
                        items:
                          $ref: '#/components/schemas/bookingInfo_result'
                    type: object
                type: object
            type: object
    unauthorized_response:
      description: 認證失敗（未帶或帶錯 `X-Auth-Store` / `X-Auth-Distr`）
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                example: 401
                description: 固定為 401
              status:
                type: string
                example: error
                description: 固定為 error
              message:
                type: string
                example: Unauthorized access
                description: 錯誤說明
  parameters:
    product_uuid_in_path:
      name: productUuid
      in: path
      description: 行程ID
      required: true
      schema:
        type: string
        example: 2c935076-ac44-41cf-943f-8e5fdd29bdf1
    sales_option_uuid_in_path:
      name: salesOptionId
      in: path
      description: 套餐ID
      required: true
      schema:
        type: string
        example: c8873111-73ff-4218-b0cf-c40796f05e01
    start_date_in_query:
      name: startDate
      in: query
      description: 起始日期
      required: true
      schema:
        type: string
        example: '2021-08-18'
    end_date_in_query:
      name: endDate
      in: query
      description: 結束日期
      required: true
      schema:
        type: string
        example: '2021-08-19'
    order_number_in_path:
      name: orderNo
      in: path
      description: 訂單編號
      required: true
      schema:
        type: string
        example: DS210709GC0272
  requestBodies:
    order_request_body:
      description: 下訂單
      required: true
      content:
        application/json:
          schema:
            required:
            - productId
            - salesOptionId
            - sessionId
            - sessionDate
            - sessionTime
            - language
            - extras
            - pickup
            - purchaseContent
            - bookingInfo
            properties:
              productId:
                description: 行程ID
                type: string
                example: 2c935076-ac44-41cf-943f-8e5fdd29bdf1
              salesOptionId:
                description: 套餐ID
                type: string
                example: c8873111-73ff-4218-b0cf-c40796f05e01
              sessionId:
                description: 場次ID
                type: string
                example: b3ca9362-22de-4a24-b9c7-2fb866624ca8
              sessionDate:
                description: 指定預約日期
                type: string
                example: '2021-08-18'
              sessionTime:
                description: 指定場次時段
                type: string
                example: '14:00'
              language:
                description: 指定導覽服務語言 (對應"查詢商品清單"導覽服務語言內項目，對應的項目有值時必填)
                properties:
                  audioHeadset:
                    description: 指定語言-語音導覽機
                    type: string
                    example: en
                  guide:
                    description: 指定語言-導遊
                    type: string
                    example: en
                  translation:
                    description: 指定語言-景點導覽
                    type: string
                    example: en
                  written:
                    description: 指定語言-紙本資料
                    type: string
                    example: en-US
                type: object
              extras:
                description: 可加購品清單，不需加購請帶[]
                type: array
                items:
                  properties:
                    id:
                      description: 加購品ID
                      type: string
                      example: 9b2b7cfc-fd35-4481-8cb3-ef64caaff442
                    quantity:
                      description: 加購品購買數量 (數值需>0, priceType = "ORDER" 最多只能帶1)
                      type: number
                      example: 1.0
                  type: object
              pickup:
                description: 接送資料
                properties:
                  departure:
                    $ref: '#/components/schemas/pickup_request'
                  return:
                    $ref: '#/components/schemas/pickup_request'
                type: object
              purchaseContent:
                description: 購買內容 (只帶要購買項目(quantity > 0))
                type: array
                items:
                  properties:
                    id:
                      description: purchase content ID
                      type: string
                      example: 76d2d935-4a55-4c09-80df-42311e7bbaa9
                    quantity:
                      description: 購買數量
                      type: number
                      example: 1.0
                  type: object
              bookingInfo:
                description: 訂位資料
                properties:
                  contact:
                    description: 聯絡資訊 (依預訂資訊 key 值改變)
                    type: array
                    items:
                      properties:
                        firstName:
                          type: string
                          example: Fiona
                      type: object
                  order:
                    description: 旅客代表 (依預訂資訊 key 值改變)
                    type: array
                    items:
                      properties:
                        firstName:
                          type: string
                          example: Lin
                      type: object
                  participant:
                    description: 旅客資訊 (依預訂資訊 key 值改變)
                    type: array
                    items:
                      type: array
                      items:
                        properties:
                          firstName:
                            type: string
                            example: Fiona
                        type: object
                type: object
            type: object
    cancel_request_body:
      description: 取消訂單
      required: true
      content:
        application/json:
          schema:
            required:
            - reason
            properties:
              reason:
                description: 取消訂單的理由
                type: string
                example: Reschedule my trip
            type: object
  securitySchemes:
    X-Auth-Store:
      type: apiKey
      description: 商店代號 Store UUID<br>- 請填入店家的商店代號(UUID)。
      name: X-Auth-Store
      in: header
    X-Auth-Distr:
      type: apiKey
      description: 分銷商 API 串接金鑰 Distributor API Key<br>- 請填入分銷商 API 串接金鑰。
      name: X-Auth-Distr
      in: header
tags:
- name: B2B
  description: B2B
