/app/ordering/stores:
  get:
    tags:
      - ordering
    description: Return all the stores available for online ordering
    operationId: listPublishedStores
    security:
      - bearerAuth: []
    responses:
      $ref#4xx: "../responses/4xx.yaml"
      200:
        description: list of stores
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: "#/components/schemas/OnlineOrderingStore"

/app/ordering/{storeid}:
  get:
    tags:
      - ordering
    description: Return a store menu for ordering
    operationId: loadPublishedStore
    parameters:
      - $ref#storeid: "../parameters/storeid.yaml"
    security:
      - bearerAuth: []
    responses:
      $ref#4xx: "../responses/4xx.yaml"
      200:
        description: all data needed for making an online Order
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OnlineOrderingStore"

/app/ordering/{storeid}/order:
  post:
    tags:
      - ordering
    description: Submit an order
    operationId: submitOrder
    parameters:
      - $ref#storeid: "../parameters/storeid.yaml"
      - $ref#captcha: "../parameters/captcha.yaml"
    security:
      - bearerAuth: []
    requestBody:
      required: true
      description: The Order to be created
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/OnlineOrder"
    responses:
      $ref#4xx: "../responses/4xx.yaml"
      200:
        description: the Result of submitting Order
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OnlineOrderResponse"

/app/ordering/{storeid}/check-status/{id}:
  get:
    tags:
      - ordering
    description: Return true if the order has been handled successfully. Use for submit order by websocket.
    operationId: checkOrderStatus
    parameters:
      - $ref#storeid: "../parameters/storeid.yaml"
      - $ref#id: "../parameters/objectid.yaml"
    security:
      - bearerAuth: []
    responses:
      $ref#4xx: "../responses/4xx.yaml"
      200:
        description: True if order has been handled successfully
        content:
          application/json:
            schema:
              type: boolean

/app/ol-order/{storeid}/{orderId}:
  get:
    tags:
      - ordering
    description: Load order online detail
    operationId: loadOrder
    parameters:
      - $ref#storeid: "../parameters/storeid.yaml"
      - name: orderId
        in: path
        required: true
        description: order id
        schema:
          type: string
    security:
      - bearerAuth: []
    responses:
      $ref#4xx: "../responses/4xx.yaml"
      200:
        description:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OnlineOrder"

/app/ordering/stores/{storeId}/orders/{orderId}:
  get:
    tags:
      - ordering
    description: Load online order
    operationId: getOnlineOrder
    parameters:
      - name: storeId
        in: path
        required: true
        description: store id
        schema:
          type: string
      - name: orderId
        in: path
        required: true
        description: order id
        schema:
          type: string
    security:
      - bearerAuth: []
    responses:
      $ref#4xx: "../responses/4xx.yaml"
      200:
        description: Online order
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OnlineOrder"

/app/ordering/stores/{storeId}/orders/{orderId}/payment-request:
  delete:
    tags:
      - ordering
    description: Delete payment request of given online order
    operationId: deleteOnlineOrderPR
    parameters:
      - name: storeId
        in: path
        required: true
        description: store id
        schema:
          type: string
      - name: orderId
        in: path
        required: true
        description: order id
        schema:
          type: string
    security:
      - bearerAuth: []
    responses:
      $ref#4xx: "../responses/4xx.yaml"
      200:
        description: Payment request has been successfully deleted from order

/app/ordering/stores/{storeId}/orders/{orderId}/payments:
  post:
    tags:
      - ordering
    description: Create online order payment
    operationId: postOnlineOrderPayment
    parameters:
      - name: storeId
        in: path
        required: true
        description: store id
        schema:
          type: string
      - name: orderId
        in: path
        required: true
        description: order id
        schema:
          type: string
    security:
      - bearerAuth: []
    requestBody:
      required: true
      description: Payment info
      content:
        application/json:
          schema:
            type: object
            properties:
              token:
                description: Apple Wallet payment token
                type: string
              number:
                description: Credit card number (last 4 digits)
                type: string
              paymentRequestId:
                description: Payment request id 
                type: string
    responses:
      $ref#4xx: "../responses/4xx.yaml"
      200:
        description: Post payment result, must check for details
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OnlineOrderResponse"
