openapi: 3.0.1
info:
  title: Windelivery Public API
  description: |-

    # Introduction

    This is the Windelivery Public API that will allow customers and partners to connect to the different services offered such as: 
    POS order integration, menu and price integration, delivery driver requests...

    ## What is Windelivery?

    Windelivery is a Home Delivery Broker (HDB), a platform for the integrated management of the **lifecycle of food home delivery orders**. 
    This tool channels incoming orders to simplify and centralize the different channels in a unified way (via aggregators, app, corporate 
    web application for the service, call centre, kiosks or virtual assistants). It also allows interaction with other services such as: 
    last mile services, POS, payment methods, CRM...


    ## What services can you use?

    Depending on your business needs, you can use the following services to differentiate yourself from the competitors. 
    Services can be categorized into two parts: order input services and operational services.

    ### Order Input Services

    #### Aggregators

    <img src="https://apidocs.windelivery.io/assets/img/glovo_round.png" alt="Glovo Logo" width="125" style="margin: 10px;"/>
    <img src="https://apidocs.windelivery.io/assets/img/uber_eats_round.png" alt="Uber Eats Logo" width="125" style="margin: 10px;"/>
    <img src="https://apidocs.windelivery.io/assets/img/justeat_round.png" alt="JustEat Takeaway Logo" width="125" style="margin: 10px;"/>
    <img src="https://apidocs.windelivery.io/assets/img/deliveroo_round.png" alt="Deliveroo Logo" width="125" style="margin: 10px;"/>
    <!--- <img src="https://apidocs.windelivery.io/assets/img/rappi_round.png" alt="Rappi Logo" width="125" style="margin: 10px;"/> --->
    <img src="https://apidocs.windelivery.io/assets/img/bolt_round.png" alt="Bolt Logo" width="125" style="margin: 10px;"/>

    #### Corporate Web

    Some Windelivery websites are:

    - <a href="https://www.burgerking.es/" target="_blank">Burger King Spain</a> and <a href="https://www.burgerking.pt/" target="_blank">Burger King Portugal</a>.
    - <a href="https://adomicilio.vips.es/" target="_blank">VIPS Spain</a> and <a href="https://adomicilio.ginos.es/" target="_blank">GINOS Spain</a>.
    - <a href="https://deliverfly.iberia.com/" target="_blank">Iberia Deliverfly</a>.
    - <a href="https://orders.goiko.com/" target="_blank">Goiko Spain</a>
    - <a href="https://delivery.dunkin.es/" target="_blank">Dunkin Spain</a>

    For more information on creating a corporate e-commerce website, please <a href="mailto:info@windelivery.io">contact us</a>.

    #### Kiosks

    For more information on the installation of kiosks, please <a href="mailto:info@windelivery.io">contact us</a>.

    #### Virtual Assistants

    For more information on order input using virtual assistants and chatbots, please <a href="mailto:info@windelivery.io">contact us</a>.


    ### Operational Services

    #### POS

    <img src="https://apidocs.windelivery.io/assets/img/ncr_round.png" alt="NCR Logo" width="125" style="margin: 10px;"/>
    <img src="https://apidocs.windelivery.io/assets/img/toshiba_round.png" alt="Toshiba Logo" width="125" style="margin: 10px;"/>
    <img src="https://apidocs.windelivery.io/assets/img/winrest_round.png" alt="Winrest Logo" width="125" style="margin: 10px;"/>
    <img src="https://apidocs.windelivery.io/assets/img/lightspeed_round.png" alt="LightSpeed Logo" width="125" style="margin: 10px;"/>


    #### 3PL

    <img src="https://apidocs.windelivery.io/assets/img/mox_round.png" alt="MOX Logo" width="125" style="margin: 10px;"/>
    <img src="https://apidocs.windelivery.io/assets/img/stuart_round.png" alt="Stuart Logo" width="125" style="margin: 10px;"/>
    <img src="https://apidocs.windelivery.io/assets/img/ecoscooting_round.png" alt="Ecoscooting Logo" width="125" style="margin: 10px;"/>


    #### ERP/CRM 

    For more information on integration with ERP and CRM, please <a href="mailto:info@windelivery.io">contact us</a>

    # Getting Started

    ## Basics

    Version 1 of this API has the following features:
      - It is **REST based**.
      - All operations are built on basic **HTTP methods**: GET, POST, PUT, PATCH, DELETE. 
      - All **response codes** follow the HTTP standard.
      - All connections are encrypted with **HTTPS over SSL**.
      - There are **no restrictions** on the number of requests or origin.
      - The **maximum response time** is 30ms.

    ## Status Codes

    ### Successful Responses

    #### 200 OK

    #### 201 Created

    #### 202 Accepted

    #### 204 No Content

    ### Error Responses

    All error responses always follow the same structure:
    
    <br />

    ``` json
    {
      "error": "<<ERROR_CODE>>",
      "error_description": "<<Description of the error that occurred>>"
    }
    ```

    #### 400 Bad Request

    #### 401 Unauthorized

    #### 403 Forbidden

    #### 404 Not Found

    #### 408 Request Timeout

    ## API Credentials

    ## Client Libraries

    ## i18n

    ## Guides

    ## Changelog

    ### 2022-02-28

    <span class="badge new">NEW</span> Add `image_url` to [ModifierGroup Model](#cmp--schemas-modifiergroup).

    ### 2022-02-02
    
    <span class="badge new">NEW</span> Add `id` to all menu items.

    <span class="badge new">NEW</span> Add `name` to [Menu Model](#cmp--schemas-menu).

    <span class="badge change">CHANGE</span> Change `event` to `context` in the Webhook requests.

    <span class="badge change">CHANGE</span> Change `external_id` to `external_id` in all the menu items.

    <span class="badge change">CHANGE</span> Change `menu_id` to `id` in the [Menu Model](#cmp--schemas-menu).

    <span class="badge change">CHANGE</span> Level up `value` and `tax_rate` (price section) in `Product` and `Modifier` model. Change `value` to `price`.

    <span class="badge change">CHANGE</span> Remove `tax_percentage` in the [Product Model](#cmp--schemas-product).
    ## FAQ

    For more information about this API or about the [Windelivery](https://windelivery.io) product, please contact the following email: [info@windelivery.io](mailto:info@windelivery.io).

  contact:
    email: info@windelivery.io
  license:
    name: Copyright © Homeria Open Solutions
    url: https://www.homeria.com/en/privacy-policy/
  version: 1.0.0

tags:
  - name: Authentication
    description: |-
      # Overview
    
      All Windelivery ESB endpoints are secured with the OAuth 2.0 protocol. For more information about this protocol, 
      you can visit <a href="https://www.oauth.com/oauth2-servers/access-tokens/" target="_blank">this website</a>.

      The first information needed to authenticate to the API are the `client_id` and `client_secret` keys. These keys can be
      provided by the Windelivery Admin portal or sent to you by the KAM assigned to your corporation. For more information
      on credentials, you can access <a href="#overview--api-credentials">this page of the documentation</a>.

      To get the `access_token` that should be sent in each request, you have to use the [endpoint for generate an OAuth2 Token](#post-/oauth/token).
      Each time a request is made to get the token, a new token will be generated with a 24-hour duration. A token cannot be revoked. A request example:  
      <br />
      ``` http
      GET https://esb.windelivery.io/v1/example_endpoint HTTP/1.1
      Host: es.windelivery.io
      Authorization: Bearer <ACCESS_TOKEN>
      ```

      When a request is made with an incorrect or expired token, the response will always be a `HTTP 401 Unauthorized`.  
      <br />
      ``` http
      HTTP/1.1 401 Unauthorized
      Date: Mon, 3 Jan 2022 08:23:20 GMT
      ```

      When a request is made with a token that does not have sufficient permissions to perform the action, the response will always be a `HTTP 403 Forbidden`.  
      <br />
      ``` http
      HTTP/1.1 403 Forbidden
      Date: Mon, 3 Jan 2022 08:23:20 GMT
      ```

    externalDocs:
      url: "https://windelivery.io"
  - name: Status
    description: >-
      # Overview

      The status of each Windelivery microservices can be consulted with the status service. The possible statuses are:


      | Status Name | Description |

      |:----------:| ------- |

      | `OK` | Description for `OK` | # TODO Complete description

      | `DISRUPTION` | Description for `DISRUPTION`  | # TODO Complete description

      | `OUTAGE` | Description for `OUTAGE`   | # TODO Complete description
      
    externalDocs:
      url: "https://windelivery.io"
  - name: Orders
    description:  >-
      # Overview
      
      Services related to the placement and modification of orders in Windelivery.

      ## Order Statuses

      
    externalDocs:
      url: "https://windelivery.io"
  - name: Stores
    description:   >-
      # Overview
      
      Services related to the creation and configuration of new stores in the Windelivery system.

      ## Store Services

      Store services are all the services (internal and external) that a shop has enabled. 
      These services can be paused (OFFLINE) or active (ONLINE). These services can be:

        - Order Types
          - `DELIVERY_MP`
          - `DELIVERY_CORE`
          - `PICKUP`
        - Order Channels
          - `OWNCHANNEL`
          - `OWNCHANNEL_EXT`
          - `AGG_JUSTEAT`
          - `AGG_DELIVEROO`
          - `AGG_UBEREATS`
          - `AGG_GLOVO`
          - `AGG_BOLT`
          - `AGG_TAKEAWAY`
        - Scheduled Orders
          - `SCH_DELIVERY_MP`
          - `SCH_DELIVERY_CORE`
          - `SCH_PICKUP`

    externalDocs:
      url: "https://windelivery.io"
  - name: Menu
    description:  >-
      # Overview
  - name: Webhooks
    description:   |-
      # Overview
      
      Services related to the creation and configuration of new stores in the Windelivery system.


      Windelivery offers the possibility to receive real-time notifications for different events. 
      These notifications work in both staging and production environments.
      In order to work with webhooks, you must expose as many web services as types of events you want to use. 
      Each web service must have a public URL that can be configured through the API or the administration 
      panel in Windelivery Admin.


      All HTTP requests that you will receive in the configured URLs will have the same structure:
      <br />
      <br />
      ``` json
      {
        "context": "<<context_name>>",
        "type": "<<notification_type>>"
        "data": {}
      }
      ```

      The value of `context` indicates the service which notifies of the event.  There are 4 contexts:

        - `order`: Notifications of **order** creation and order status update.
        - `store`: Notifications of **store** creation, data update and shop status update.
        - `menu`: Notifications of creation, update of the menu or any of its elements.
        - `user`: Notifications of creation, update and deletion of platform users (end customers).


      ## Security

      All HTTP requests sent to the endpoints you have registered have the following data in the headers:

      - **Header Name**: `X-Windelivery-API-key`
      - **Header Value**: Value generated by the platform - Accessible in [Windelivery Admin](#)

      For security reasons, the IPs from which HTTP requests are sent to the configured webhoooks are:

      ### Sandbox
      *TBD*

      ### Staging
      *TBD*

      ### Production
      *TBD*



      

    externalDocs:
      url: "https://windelivery.io"

servers:
  - url: https://{environment}.windelivery.io/{version}
    variables:
      environment:
        enum:
          - esb-sandbox #Sandbox Environment
          - esb-staging #Staging Environment
          - esb
        default: esb-sandbox
        description: API Environment
      version:
        enum:
          - v1
        default: v1
        description: Domain

paths:
#STATUS

  /health:
    get:
      summary: Get application status report
      operationId: health
      responses:
        "200":
          $ref: "#/components/responses/ResponseStatus"
      security: []
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Status

#AUTHORIZATION
  /oauth/token:
    post:
      summary: Generate Auth Token
      operationId: auth
      requestBody:
        $ref: "#/components/requestBodies/RequestAuth"
      responses:
        "200":
          $ref: "#/components/responses/ResponseAuth200"
        "401":
          $ref: "#/components/responses/ResponseAuth401"
      security: []
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Authentication

#ORDER
  /orders:
    # post:
    #   deprecated: true
    #   summary: Create an Order in Windelivery System
    #   operationId: createOrder
    #   requestBody:
    #     $ref: "#/components/requestBodies/RequestCreateOrder"
    #   responses:
    #     "200":
    #       $ref: "#/components/responses/EmptyResponse"
    #     "401":
    #       $ref: "#/components/responses/ResponseInvalidGrant"
    #   security:
    #     - ACCESS_TOKEN: [orders]
    #   x-amazon-apigateway-integration:
    #     $ref: "#/components/x-amazon-apigateway-integrations/test"
    #   tags:
    #     - Orders
    get:
      deprecated: false
      summary: Get all orders
      operationId: getOrders
      description: |-

        Returns all orders. Use the query parameters to filter the data. 
        If `store_id` param is not specified, all orders from your organization will be returned.

        Messages return with the most recent message first.
      parameters:
        - $ref: "#/components/parameters/offsetParam"
        - $ref: "#/components/parameters/limitParam"
        - $ref: "#/components/parameters/storeOrderParam"
        - $ref: "#/components/parameters/statusOrderParam"
      responses:
        200:
          $ref: "#/components/responses/ResponseGetOrders200"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [orders]
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Orders

  /orders/{order_id}:
    get:
      deprecated: false
      summary: Get order information
      operationId: getOrderbyId
      description: |-

        Return an order by `order_id`.
      
      parameters:
        - $ref: "#/components/parameters/orderIdParam"
      responses:
        "200":
          $ref: "#/components/responses/ResponseGetOrder200"
        "404":
          $ref: "#/components/responses/ResponseNotFoundOrder"
        "401":
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [orders]
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Orders

  /orders/{order_id}/status:
    put:
      deprecated: false
      summary: Update Order Status
      operationId: updateOrderStatus
      description: |-
        Update the order status.
      parameters:
        - $ref: "#/components/parameters/orderIdParam"
      requestBody:
        $ref: "#/components/requestBodies/RequestUpdateOrderStatus"
      responses:
        "204":
          $ref: "#/components/responses/ResponseUpdateOrderStatus"
        "404":
          $ref: "#/components/responses/ResponseNotFoundOrder"
        "401":
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [orders]
      tags:
        - Orders
      


#STORES
  /stores:
    get:
      operationId: getAllStores
      summary: Get all stores
      parameters:
        - $ref: "#/components/parameters/offsetParam"
        - $ref: "#/components/parameters/limitParam"
      responses:
        200:
          $ref: "#/components/responses/ResponseGetStores200"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [stores]
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Stores
    post:
      operationId: createStore
      summary: Create new store
      requestBody:
        $ref: "#/components/requestBodies/RequestCreateStore"
      responses:
        201:
          $ref: "#/components/responses/ResponseCreateStore201"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
        409:
          $ref: "#/components/responses/ResponseCreateStore409"
        422:
          $ref: "#/components/responses/ResponseCreateStore422"

      security:
        - ACCESS_TOKEN: [stores]
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Stores

  /stores/{store_id}:
    get:
      operationId: getStore
      summary: Get store information
      parameters:
        - $ref: "#/components/parameters/storeIdParam"
      responses:
        200:
          $ref: "#/components/responses/ResponseGetStore200"
        404:
          $ref: "#/components/responses/ResponseNotFoundStore"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [stores]
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Stores

  /stores/{store_id}/services:
    put:
      summary: Update Store Service
      operationId: UpdateStoreService
      description: |-

        If the query-string parameter `service_name` is empty, 
        the status will apply to all active services in the store.

      parameters:
        - $ref: "#/components/parameters/storeIdParam"
        - $ref: "#/components/parameters/serviceParam"
      requestBody:
        $ref: "#/components/requestBodies/RequestUpdateStoreService"
      responses:
        204:
          $ref: "#/components/responses/ResponseUpdateStoreService"
        404:
          $ref: "#/components/responses/ResponseNotFoundStore"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [stores]
      tags:
        - Stores

  /stores/{store_id}/integrations:
    get:
      deprecated: true
      operationId: getAllIntegrationsbyStore
      summary: Get all integrations for one store
      parameters:
        - $ref: "#/components/parameters/storeIdParam"
      responses:
        200:
          $ref: "#/components/responses/ResponseGetStore200"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [stores]
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Stores

    post:
      deprecated: true
      operationId: createNewIntegration
      summary: Create new integration for store
      parameters:
        - $ref: "#/components/parameters/storeIdParam"
      responses:
        200:
          $ref: "#/components/responses/EmptyResponse"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [stores]
      # x-amazon-apigateway-integration:
      #   $ref: "#/components/x-amazon-apigateway-integrations/test"
      tags:
        - Stores
  

  /stores/{store_id}/menus/{menu_id}:
    put:
      deprecated: false
      operationId: AssignMenutoStore
      summary: Assign Menu to Store
      parameters:
        - $ref: "#/components/parameters/storeIdParam"
        - $ref: "#/components/parameters/menuIdParam"
      requestBody:
        $ref: "#/components/requestBodies/RequestAssignMenuStore"
      responses:
        200:
          $ref: "#/components/responses/EmptyResponse"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [stores]
      tags:
        - Stores


  # /stores/{storeId}/pos_data:
  #   get:
  #     deprecated: true
  #     responses:
  #       "200":
  #         $ref: "#/components/responses/EmptyResponse"
  #     security:
  #       - ACCESS_TOKEN: [stores]
  #     x-amazon-apigateway-integration:
  #       $ref: "#/components/x-amazon-apigateway-integrations/test"
  #     tags:
  #       - Stores
  #   post:
  #     deprecated: true
  #     responses:
  #       "200":
  #         $ref: "#/components/responses/EmptyResponse"
  #     security:
  #       - ACCESS_TOKEN: [stores]
  #     x-amazon-apigateway-integration:
  #       $ref: "#/components/x-amazon-apigateway-integrations/test"
  #     tags:
  #       - Stores

#MENU
  /menus:
    get:
      operationId: getAllMenus
      summary: Get all menus
      responses:
        200:
          $ref: "#/components/responses/ResponseGetMenus200"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [menus]
      tags:
        - Menu

    post:
      operationId: createNewMenu
      summary: Create new menu
      requestBody:
        $ref: "#/components/requestBodies/RequestCreateMenu"
      responses:
        201:
          $ref: "#/components/responses/ResponsePostMenu201"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
        409:
          $ref: "#/components/responses/ResponsePostMenu409"
        422:
          $ref: "#/components/responses/ResponsePostMenu422"
      security:
        - ACCESS_TOKEN: [menus]
      tags:
        - Menu
  /menus/{menu_id}:
    get:
      operationId: GetMenuInformation
      summary: Get Menu Information
      parameters:
        - $ref: "#/components/parameters/menuIdParam"
      responses:
        200:
          $ref: "#/components/responses/ResponseGetMenu200"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
        404:
          $ref: "#/components/responses/ResponseGetMenu404"
      security:
        - ACCESS_TOKEN: [menus]
      tags:
        - Menu
    put:
      operationId: ModifyMenu
      summary: Modify Existing Menu
      parameters:
        - $ref: "#/components/parameters/menuIdParam"
      responses: 
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [menus]
      tags:
        - Menu
    patch:
      operationId: modifyProducts
      summary: Modify Menu Items
      requestBody:
        $ref: "#/components/requestBodies/RequestModifyProducts"

      responses: 
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [menus]
      tags:
        - Menu

    delete:
      operationId: DeleteMenu
      summary: Delete Existing Menu
      responses:
        202:
          $ref: "#/components/responses/ResponseDeleteMenu202"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      security:
        - ACCESS_TOKEN: [menus]
      tags:
        - Menu
  

#WEBHOOKS

  /subscription:
    get:
      operationId: getSubscription
      summary: Get Subscriptions
      responses:
        200:
          $ref: "#/components/responses/ResponseGetWebhook200"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      tags:
        - Webhooks

  /subscribe:
    post:
      operationId: subscribeOperation
      summary: Subscribe new webhook
      requestBody:
        $ref: "#/components/requestBodies/RequestSubscribe"
      responses:
        201:
          $ref: "#/components/responses/ResponseWebhook200"
        401:
          $ref: "#/components/responses/ResponseInvalidGrant"
      callbacks:
        orderStatusChanged:
          $ref: "#/components/callbacks/orderStatusChanged"
      tags:
        - Webhooks

  /unsubscribe:
    post:
      operationId: unsubscribeOperation
      summary: Unsubscribe existing webhook
      parameters:
        - name: subscriber_id
          in: query
          required: true
          schema:
            type: string
            example: ABC-123-ZYX-987
      responses:
        "200":
          $ref: "#/components/responses/EmptyResponse"
      tags:
        - Webhooks

components:
  schemas:
    ServiceStatus:
      type: object
      properties:
        status:
          type: string
          enum:
            - OK
            - DISRUPTION
            - OUTAGE
          example: OK
        lastUpdate:
          type: string
          format: date-time

    BaseWebhook:
      type: object
      properties:
        context:
          $ref: "#/components/schemas/WebhookEvents"
        type:
          $ref: "#/components/schemas/WebhookTypes"
        data:
          type: object

    OrderStatusWebhook:
      allOf:
        - $ref: "#/components/schemas/BaseWebhook"
        - properties:
            context:
              type: string
              enum:
                - order
                - store
                - menu
                - user
            data:
              type: object
              properties:
                order_id:
                  type: number
                status:
                  $ref: "#/components/schemas/OrderStatuses"
    
    ResponseWebhooks:
      type: array
      items:
        type: object
        properties:
          subscriber_id:
            type: string
            format: uuid
          webhooks:
              $ref: "#/components/schemas/WebhooksList"
        example:
          subscriber_id: 7189eb67-ddea-4eba-ba0a-12f1d2ddb604
          webhooks:
            order_status_url: "https://myfoodomain.com/webhook_orders"
               
    InputOrder:
      allOf:
        - $ref: "#components/schemas/Order"
        - properties:
            order_info:
              type: object
              properties:
                order_id:
                  nullable: true
                store_id:
                  nullable: true
                status:
                  nullable: true
                created_at:
                  nullable: true

    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        error_description:
          type: string

  # CLASSES

    Order:
      type: object
      properties:
        order_info:
          type: object
          properties:
            order_id:
              type: string
              format: uuid
              readOnly: true
            external_order_id:
              type: string
            store_id:
              type: string
              format: uuid
              readOnly: true
            external_store_id:
              type: string
            status:
              $ref: "#/components/schemas/OrderStatuses"
            type:
              $ref: "#/components/schemas/OrderTypes"
            channel:
              $ref: "#/components/schemas/OrderChannels"
            created_at:
              type: string
              format: date-time
              readOnly: true
            currency:
              $ref: "#/components/schemas/Currency"
            allergens:
              type: string
              nullable: true
            notes:
              type: string
              nullable: true

        customer:
          type: object
          properties:
            external_id:
              type: string
            name:
              type: string
            last_name:
              type: string
              nullable: true
            phone_number:
              type: string
            email:
              type: string
              format: email

        delivery_info:
          type: object
          nullable: true
          properties:
            address:
              type: object
              properties:
                street:
                  type: string
                number:
                  type: string
                country:
                  type: string
                city:
                  type: string
                region:
                  type: string
                postal_code:
                  type: string
            latitude:
              type: number
            longitude:
              type: number
            delivery_at:
              type: string
              format: date-time
            type:
              $ref: "#/components/schemas/DeliveryType"
            notes:
              type: string

        collector:
          type: object
          properties:
            name:
              type: string
            last_name:
              type: string
              nullable: true
            phone_number:
              type: string
              nullable: true
            pickup_code:
              type: string
            pickup_at:
              type: string
              format: date-time

        products:
          type: array
          items:
            $ref: "#/components/schemas/OrderProduct"

        package:
          type: object
          properties:
            cutlery:
              type: boolean
            size:
              type: string
              enum:
                - S
                - M
                - L
                - XL

        payment:
          type: object
          properties:
            payment_methods:
              type: array
              minItems: 1
              items:
                type: object
                properties:
                  method_key:
                    $ref: "#/components/schemas/PaymentMethods"
                  amount:
                    type: number
            charges:
              type: object
              properties:
                total:
                  type: number
                subtotal:
                  type: number
                total_fee:
                  type: number
                total_discount:
                  type: number
                total_tax:
                  type: number
                fees:
                  type: array
                  items:
                    type: string
                    properties:
                      type:
                        $ref: "#/components/schemas/OrderFees"
                      name:
                        type: string
                      amount:
                        type: number
            promotions:
              type: array
              items:
                $ref: "#/components/schemas/OrderPromotions"

        invoicing:
          type: object
          nullable: true
          properties:
            company_name:
              type: string
            company_address:
              type: string
            tax_id:
              type: string

    OrderProduct:
      type: object
      properties:
        external_id:
          type: string
        name:
          type: string
        quantity:
          type: number
        unit_price:
          type: number
        tax_rate: 
          type: number
          example: 21
        modifiers:
          type: array
          nullable: true
          items:
            $ref: "#/components/schemas/OrderProduct"

    OrderPromotions:
      type: object
      properties:
        promo_id:
          type: string
        promo_code:
          type: string
          nullable: true
        type:
          $ref: "#/components/schemas/OrderPromotionType"
        name:
          type: string
        payment:
          type: string
          enum:
            - MERCHANT
            - PARTNER
        amount:
          type: number

    WebhooksList:
      type: object
      properties:
        order_status_url:
          type: string
          format: uri
          example: "https://myfoodomain.com/webhook_orders"
          nullable: true
        store_status_url:
          type: string
          format: uri
          example: "https://myfoodomain.com/webhook_store"
          nullable: true

    Store:
      type: object
      properties:
        store_info:
          type: object
          properties:
            store_id:
              type: string
              format: uuid
              readOnly: true
            external_store_id:
              type: string
            brand_id:
              readOnly: true
              type: number
            name:
              type: string
              maxLength: 50
            currency:
              type: string
              description: ISO 4217 - https://es.wikipedia.org/wiki/ISO_4217
        services:
          type: object
          readOnly: true
          properties:
            sales_channels:
              type: array
              items:
                type: object
                properties:
                  service_name:
                      $ref: "#/components/schemas/OrderTypes"
                  status:
                    $ref: "#/components/schemas/StoreServiceStatus"
            input_channels:
              type: array
              items:
                type: object
                properties:
                  service_name:
                    $ref: "#/components/schemas/OrderChannels"
                  status:
                    $ref: "#/components/schemas/StoreServiceStatus"
            schedule_orders:
              type: array
              items:
                type: object
                properties:
                  service_name:
                      $ref: "#/components/schemas/OrderTypes"
                  status:
                    $ref: "#/components/schemas/StoreServiceStatus"

            last_mile:
              type: array
              items:
                type: object
                properties:
                  service_name:
                      type: string
                      enum:
                        - STUART
                        - MOX
                        - SHARGO
                  status:
                    $ref: "#/components/schemas/StoreServiceStatus"

        contact_info:
          type: object
          properties:
            phone:
              type: string
            email:
              type: string
              format: email
        location_info:
          type: object
          properties:
            address:
              type: string
              maxLength: 100
            address_2:
              type: string
              maxLength: 100
            city:
              type: string
              maxLength: 50
            country:
              type: string
              maxLength: 2
              description: ISO 3166-1 alpha-2 - https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
            postal_code:
              type: string
            state:
              type: string
            latitude:
              type: number
            longitude:
              type: number
        schedules:
          type: object
          properties:
            schedule_hd:
              $ref: "#/components/schemas/ChannelSchedule"
            schedule_ta:
              $ref: "#/components/schemas/ChannelSchedule"
            schedule_agg:
              $ref: "#/components/schemas/ChannelSchedule"
        menus:
          readOnly: true
          type: array
          items:
            type: object
            properties:
              channel:
                $ref: "#/components/schemas/OrderChannels"
              menu_id:
                type: string
                format: uuid
              minimum_order:
                type: number
                
    Menu:
      type: object
      properties:
        menu_id:
          type: string
          format: uuid
          readOnly: true
        external_menu_id:
          type: string
        name:
          type: string
        sections:
          type: array
          minItems: 0
          items:
            $ref: "#/components/schemas/Section"
        categories:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/Category"
        products:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/Product"
        modifier_groups:
          type: array
          minItems: 0
          items:
            $ref: "#/components/schemas/ModifierGroup"
        modifiers:
          type: array
          minItems: 0
          items:
            $ref: "#/components/schemas/Modifier"

    Section:
      type: object
      properties:
        id:
          type: string
          format: uuid
        external_id:
          type: string
        name:
          type: string
        image_url:
          type: string
          format: uri
        order:
          type: number
          format: int32
        description:
          type: string
        tags:
          type: array
          items:
            type: string
            minItems: 0
        available:
          type: boolean
          default: true
        categories:
          type: array
          items:
            type: string
            format: uuid
            description: ids of categories

    Category:
      type: object
      properties:
        id:
          type: string
          format: uuid
        external_id:
          type: string
        name:
          type: string
        image_url:
          type: string
          format: uri
        order:
          type: number
          format: int32
        description:
          type: string
        tags:
          type: array
          items:
            type: string
            minItems: 0
        available:
          type: boolean
          default: true
        products:
          type: array
          items:
            type: string
            format: uuid
            description: ids of products

    Product:
      type: object
      properties:
        id:
          type: string
          format: uuid
        external_id:
          type: string
        name:
          type: string
        description:
          type: string
        image_url:
          type: string
          format: uri
        order:
          type: number
          format: int32
        price:
          type: number
          description: Price value in cents. Tax included.
        tax_rate:
          type: number
          description: Tax percentage
        available:
          type: boolean
          default: true
        tags:
          type: array
          items:
            type: string
            minItems: 0
        modifier_groups:
          type: array
          items:
            type: string
            format: uuid
            description: ids of modifier groups
        nutritional_info:
          $ref: "#/components/schemas/NutritionalInfo"
        allergens:
          type: array
          items:
            type: string
          

    ModifierGroup:
      type: object
      properties:
        id:
          type: string
          format: uuid
        external_id:
          type: string
        name:
          type: string
        description:
          type: string
        image_url:
          type: string
          format: uri
        order:
          type: number
          format: int32
        min:
          type: number
          minimum: 0
        max:
          type: number
          minimum: 1
        max_free:
          type: number
          minimum: 0
        tags:
          type: array
          items:
            type: string
            minItems: 0
        display:
          type: string
          enum: [expanded, collapsed]
        modifiers:
          type: array
          items:
            type: string
            format: uuid
            description: ids of modifiers

    Modifier:
      type: object
      properties:
        id:
          type: string
          format: uuid
        external_id:
          type: string
        name:
          type: string
        order:
          type: number
          format: int32
        description:
          type: string
        price:
          type: number
          description: Price value in cents. Tax included.
        tax_rate:
          type: number
          description: Tax percentage
        available:
          type: boolean
          default: true
        image_url:
          type: string
          format: uri
        min:
          type: number
        max:
          type: number
        default_value:
          type: number
        tags:
          type: array
          items:
            type: string
            minItems: 0
        nutritional_info:
          $ref: "#/components/schemas/NutritionalInfo"
        allergens:
          type: array
          items:
            type: string

    NutritionalInfo:
      type: object
      properties:
        calories:
          type: number
          description: Unit (kcal)
        carbs:
          type: number
          description: Unit (g)
        fat:
          type: number
          description: Unit (g)
        protein:
          type: number
          description: Unit (g)
        salt:
          type: number
          description: Unit (g)

    ChannelSchedule:
      nullable: true
      type: object
      properties:
        weekly_schedule:
          $ref: "#/components/schemas/WeeklySchedule"
        special_hours:
          type: array
          nullable: true
          items:
            type: object
            properties:
                date:
                  type: string
                  format: date
                schedule:
                  $ref: "#/components/schemas/PeriodTime"

    WeeklySchedule:
      type: object
      properties:
        monday:
          $ref: "#/components/schemas/PeriodTime"
        tuesday:
          $ref: "#/components/schemas/PeriodTime"
        wednesday:
          $ref: "#/components/schemas/PeriodTime"
        thursday:
          $ref: "#/components/schemas/PeriodTime"
        friday:
          $ref: "#/components/schemas/PeriodTime"
        saturday:
          $ref: "#/components/schemas/PeriodTime"
        sunday:
          $ref: "#/components/schemas/PeriodTime"

    PeriodTime:
      type: object
      properties:
        start_time:
          type: string
        end_time:
          type: string
          
    OrderStatusRequest:
      type: object
      properties:
        status:
          $ref: "#/components/schemas/OrderStatuses"

    StoreServiceStatusRequest:
      type: object
      properties:
        status:
          type: string
          enum:
            - ONLINE
            - OFFLINE
        reason:
          type: string
          maxLength: 255
          example: High demand
        
    AssignMenuStoreRequest:
      type: object
      properties:
        service_name:
          type: string
          oneOf:
            - $ref: "#/components/schemas/OrderTypes"
            - $ref: "#/components/schemas/OrderChannels"
            - $ref: "#/components/schemas/OrderSchedule"
        schedules:
          $ref: "#/components/schemas/ChannelSchedule"

    ModifyProductRequest:
      type: array
      items:
        oneOf:
          - $ref: "#/components/schemas/OrderProduct"
          - $ref: "#/components/schemas/ModifierGroup"
          - $ref: "#/components/schemas/Modifier"
  
  # ENUMS

    OrderStatuses:
      type: string
      enum:
        - PENDING
        - DECLINED
        - ACCEPTED
        - AWAITING_POS_PAYMENT
        - AWAITING_POS_INTEGRATION
        - AWAITING_POS_CANCELLATION
        - AWAITING_POS_MODIFICATION
        - INTEGRATED
        - CANCELLED
        - REFUNDED
        - AWAITING_PICKUP
        - DELIVERING
        - DELIVERED
        - REJECTED
        - COMPLETED
      
    OrderTypes:
      type: string
      enum:
        - DELIVERY_MP
        - DELIVERY_CORE
        - PICKUP

    OrderChannels:
      type: string
      enum:
        - OWNCHANNEL
        - OWNCHANNEL_EXT
        - AGG_JUSTEAT
        - AGG_DELIVEROO
        - AGG_UBEREATS
        - AGG_GLOVO
        - AGG_BOLT
        - AGG_TAKEAWAY

    OrderSchedule:
      type: string
      enum:
        - SCH_DELIVERY_MP
        - SCH_DELIVERY_CORE
        - SCH_PICKUP       

    Currency:
      type: string
      description: ISO 4217
      enum:
        - EUR
        - GBP
        - USD
        - JPY
        - CHF
        - MXN

    DeliveryType:
      type: string
      enum:
        - LEAVE_AT_DOOR

    PaymentMethods:
      type: string
      enum:
        - CASH
        - MBWAY
        - CARD_AT_HOME

    OrderFees:
      type: string
      enum:
        - DELIVERY_FEE
        - SERVICE_FEE
        - EXTRA_FEE

    OrderTaxes:
      type: string
      enum:
        - PT-IVA-23
        - PT-IVA-13
        - PT-IVA-6
        - ES-IVA-21
        - ES-IVA-10
        - ES-IVA-4

    OrderPromotionType:
      type: string
      enum:
        - FREE_DELIVERY
        - FLAT_DISCOUNT"

    StoreServiceStatus:
      type: string
      enum:
        - ENABLED
        - DISABLED
        - PENDING

    WebhookEvents:
      type: string
      enum:
        - order"
        - store"

    WebhookTypes:
      type: string
      enum:
        - create
        - update
  
  parameters:
    offsetParam:
      in: query
      name: offset
      required: false
      schema:
        type: integer
        minimum: 0
        default: 0
      description: The number of items to skip before starting to collect the result set.

    limitParam:
      in: query
      name: limit
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 30
        default: 15
      description: The numbers of items to return.

    storeOrderParam:
      in: query
      name: store_id
      required: false
      description: Filter the orders by the store UUID.
      schema:
        type: string
        format: uuid
      example: f8161e1b-2314-4313-af2e-219022b5a6f2

    statusOrderParam:
      in: query
      name: status
      required: false
      description: Return the orders with the specified status. Only 1 is accepted.
      schema:
        $ref: "#/components/schemas/OrderStatuses"

    orderIdParam:
      in: path
      name: order_id
      required: true
      description: Order ID to search.
      schema:
        type: string
        format: uuid
      example: 373fd8d2-5cd9-4488-a7e3-9a7017c8c3c9

    storeIdParam:
      in: path
      name: store_id
      required: true
      description: Store ID to search.
      schema:
        type: string
        format: uuid
      example: 373fd8d2-5cd9-4488-a7e3-9a7017c8c3c9

    menuIdParam:
      in: path
      name: menu_id
      required: true
      description: Menu ID.
      schema:
        type: string
        format: uuid
      example: 373fd8d2-5cd9-4488-a7e3-9a7017c8c3c9      

    serviceParam:
      in: query
      name: service_name
      required: false
      description: Service to update
      schema:
        type: string
        oneOf:
          - $ref: "#/components/schemas/OrderTypes"
          - $ref: "#/components/schemas/OrderChannels"
          - $ref: "#/components/schemas/OrderSchedule"
        example: AGG_JUSTEAT


  requestBodies:
    RequestAuth:
      description: Request body for OAuth2 Authentication
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              client_id:
                type: string
              client_secret:
                type: string
              grant_type:
                type: string
                default: client_credentials
          examples:
            CorrectCredentials:
              $ref: "#/components/examples/RequestAuthExample"

    RequestCreateOrder:
      description: Example of incoming order
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Order"

    RequestUpdateOrderStatus:
      description: Request body for order status request
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/OrderStatusRequest"
  
    RequestUpdateStoreService:
      description: Request body for store service request
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/StoreServiceStatusRequest"

    RequestCreateMenu:
      description: Request body for menu creation
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Menu"

    RequestAssignMenuStore:
      description: Request body for menu assignment to a store.
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AssignMenuStoreRequest"

    RequestModifyProducts:
      description: Request body for menu items modification.
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ModifyProductRequest"
          examples:
            Example Request:
              $ref: "#/components/examples/RequestModifyProducts"


    RequestSubscribe:
      description: Request body for subscription
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/WebhooksList"              

    RequestCreateStore:
      description: Example of store
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Store"
  responses:
    EmptyResponse:
      description: Empty Response
      content:
        application/json:
          schema:
            type: string
            example: "OK"

    ResponseAuth200:
      description: Successful Authentication
      content:
        application/json:
          schema:
            type: object
            properties:
              expires_in:
                type: number
              access_token:
                type: string
                description: The account access token. Use this to make API requests
              token_type:
                type: string
          examples:
            1 hour valid token:
              $ref: "#/components/examples/ResponseAuth200Example"

    ResponseAuth401:
      description: Unauthorized Authentication
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
              error_description:
                type: string
          examples:
            Unsupported Grant Type:
              $ref: "#/components/examples/ResponseAuth400Example1"
            Invalid Client:
              $ref: "#/components/examples/ResponseAuth400Example2"

    ResponseInvalidGrant:
      description: Invalid Grant
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error: INVALID_GRANT
            error_description: The access token expired

    ResponseStatus:
      description: Status Response
      content:
        application/json:
          schema:
            type: object
            properties:
              global_status:
                $ref: "#/components/schemas/ServiceStatus"
              service_statuses:
                type: array
                items:
                  type: object
                  properties:
                      service_name:
                        type: string
                        example: order_service
                      service_status:
                        $ref: "#/components/schemas/ServiceStatus"
          examples:
            All Services OK:
              $ref: "#/components/examples/ResponseHealthOKExample"
            Any interrupted services:
              $ref: "#/components/examples/ResponseHealthDisruptionExample"
            General Outage:
              $ref: "#/components/examples/ResponseHealthOutageExample"

    ResponseWebhook200:
      description: Added
      content:
        application/json:
          schema:
            type: object
            properties:
              subscriber_id:
                type: string
                format: uuid
                example: 7189eb67-ddea-4eba-ba0a-12f1d2ddb604
                description: Subscription ID. It is used for unsubscribe an endpoint. 
      links:
        unsubscribeOp:
          operationId: unsubscribeOperation
          parameters:
            subscriber_id: "$response.body#/subscriber_id"

    ResponseGetOrders200:
      description: Correct Response.
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: "#/components/schemas/Order"
          examples:
            noOrdersFound:
              summary: No Orders Found
              value: []
            OK Response:
              $ref: "#/components/examples/ExampleOrders"
    
    ResponseGetOrder200:
      description: Order found.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Order"

    ResponseGetStores200:
      description: Correct Response
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: "#/components/schemas/Store"
          examples:
              noStoresFound:
                summary: No Stores Found
                value: []
              OK Response:
                $ref: "#/components/examples/ExampleStores"

    ResponseGetMenus200:
      description: Correct Response.
      content:
        application/json:
          schema:
            type: array
            description: IDs
            items:
              type: string
              format: uuid

    ResponseGetMenu200:
      description: Menu found.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Menu"
          examples:
            Empty Menu:
              $ref: "#/components/examples/EmptyMenu"
            Simple Menu:
              $ref: "#/components/examples/SimpleMenu"

    ResponseGetMenu404:
      description: Menu found.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error: MENU_NOT_FOUND
            error_description: Menu with id {menu_id} is not found.

    ResponsePutMenu200:
      description: Menu modified.

    ResponsePostMenu201:
      description: Menu created.
    
    ResponsePostMenu409:
      description: Store already exists.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error: MENU_ALREADY_EXISTS
            error_description: Menu with id {external_menu_id} already exists.
    
    ResponsePostMenu422:
      description: Error in menu data model.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error: MENU_INVALID
            error_description: Unable to save menu.

    ResponseDeleteMenu202:
      description: Menu deleted.

    ResponseGetStore200:
      description: Store found
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Store"

    ResponseUpdateStoreService:
      description: Store Service Updated

    ResponseCreateStore409:
      description: Store already exists.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error: STORE_ALREADY_EXISTS
            error_description: Store with id {external_store_id} already exists.
    
    ResponseCreateStore422:
      description: Error in store data model.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error: STORE_INVALID
            error_description: Unable to save store.

    ResponseNotFoundStore:
      description: Store with id not found
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error: STORE_NOT_FOUND
            error_description: Store with id {store_id} is not found.

    ResponseNotFoundOrder:
      description: Order with id not found
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error: ORDER_NOT_FOUND
            error_description: Order with id {order_id} is not found.

    ResponseUpdateOrderStatus:
      description: Order status changed
        
    ResponseCreateStore201:
      description: Store created
      content:
        application/json:
          schema:
            type: object
            properties:
              store_id:
                type: string
                format: uuid
                example: 17cb7eb9-77a0-4000-8501-a9ce1b5f6201        
  
    ResponseOrderWebhook:
      description: >- 
        Content of the webhook notification request send to `order_status_url`.
        To get the order information, you should use the [Get order information endpoint](#get-/orders/-orderId-).
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/OrderStatusWebhook"
          examples:
            order_created:
              summary: Order Creation Notification
              value:
                context: order
                type: create
                data:
                  order_id: f8161e1b-2314-4313-af2e-219022b5a6f2
                  status: PENDING

            order_in_kitchen:
              summary: Order Integrated in POS
              value:
                context: order
                type: update
                data:
                  order_id: f8161e1b-2314-4313-af2e-219022b5a6f2
                  status: INTEGRATED

    ResponseGetWebhook200:
      description: Existing webhooks response
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ResponseWebhooks"

  # header:

  examples:

    ExampleOrders:
      summary: Orders Found
      value:
          - order_info: {}
            customer: {}
            delivery_info: {}
            collector: {}
            products: {}
            package: {}
            payment: {}
            invoicing: {}
          - order_info: {}
            customer: {}
            delivery_info: {}
            collector: {}
            products: {}
            package: {}
            payment: {}
            invoicing: {}
          - order_info: {}
            customer: {}
            delivery_info: {}
            collector: {}
            products: {}
            package: {}
            payment: {}
            invoicing: {}
          - order_info: {}
            customer: {}
            delivery_info: {}
            collector: {}
            products: {}
            package: {}
            payment: {}
            invoicing: {}
          - order_info: {}
            customer: {}
            delivery_info: {}
            collector: {}
            products: {}
            package: {}
            payment: {}
            invoicing: {}
          - order_info: {}
            customer: {}
            delivery_info: {}
            collector: {}
            products: {}
            package: {}
            payment: {}
            invoicing: {}

          
    ExampleStores:
      summary: Stores Found


    ResponseHealthOKExample:
      value:
        global_status:
          status: OK
          lastUpdate: 2022-01-01T00:00:00.000Z
        services_statuses:
          - service_name: auth_service
            service_status: 
              status: OK
              lastUpdate: 2022-01-01T00:00:00.000Z   
          - service_name: user_service
            service_status: 
              status: OK
              lastUpdate: 2022-01-01T00:00:00.000Z                   
          - service_name: order_service
            service_status: 
              status: OK
              lastUpdate: 2022-01-01T00:00:00.000Z
          - service_name: store_service
            service_status: 
              status: OK
              lastUpdate: 2022-01-01T00:00:00.000Z

    ResponseHealthDisruptionExample:
      value:
        global_status:
          status: DISRUPTION
          lastUpdate: 2022-01-01T00:00:00.000Z
        services_statuses:
          - service_name: auth_service
            service_status: 
              status: DISRUPTION
              lastUpdate: 2022-01-01T00:00:00.000Z   
          - service_name: user_service
            service_status: 
              status: OUTAGE
              lastUpdate: 2022-01-01T00:00:00.000Z                   
          - service_name: order_service
            service_status: 
              status: OK
              lastUpdate: 2022-01-01T00:00:00.000Z
          - service_name: store_service
            service_status: 
              status: OK
              lastUpdate: 2022-01-01T00:00:00.000Z              

    ResponseHealthOutageExample:
      value:
        global_status:
          status: OUTAGE
          lastUpdate: 2022-01-01T00:00:00.000Z
        services_statuses:
          - service_name: auth_service
            service_status: 
              status: OUTAGE
              lastUpdate: 2022-01-01T00:00:00.000Z   
          - service_name: user_service
            service_status: 
              status: OUTAGE
              lastUpdate: 2022-01-01T00:00:00.000Z                   
          - service_name: order_service
            service_status: 
              status: OUTAGE
              lastUpdate: 2022-01-01T00:00:00.000Z
          - service_name: store_service
            service_status: 
              status: OUTAGE
              lastUpdate: 2022-01-01T00:00:00.000Z       
    
    RequestAuthExample:
      value:
        client_id: f2a1ed52710d4533bde25be6da03b6e3
        client_secret: azvbdNGNsTmQjbN5FYQvL2FmyqS5G2GQ
        grant_type: client_credentials

    ResponseAuth200Example:
      value:
        expires_in: 3600
        access_token: eyJraWQiOiJlRW9MdkRjZEVuVGQrUkd1NWliTjJ5eXgxSWJSMDdWZUNMK3oySTJTZDVVPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI3YzAyNHZoM2c3OTQz
        token_type: Bearer

    ResponseAuth400Example1:
      value:
        error: unsupported_grant_type
        error_description: The authorization grant type is not supported by the authorization server.

    ResponseAuth400Example2:
      value:
        error: invalid_client
        error_description: Client authentication failed

    RequestInputOrderExternal:
      value:
        order_info:
          order_id: null
          external_order_id: ORDER-1122
          store_id: null
          external_store_id: STORE-00001
          status: null
          type: DELIVERY_MP
          channel: OWNCHANNEL

    RequestModifyProducts:
      value:
        - external_id: "0100VEGETABLESANDWICH"
          available: False
        - external_id: "0200CAESARSALAD"
          price: 
            value: 850
    
    EmptyMenu:
      value:
        menu_id: e63146c7-8d3a-446d-bb4c-d5107731f1e7
        external_menu_id: MENUOCT2022
        sections: []
        categories: []
        products: []
        modifier_groups: []
        modifiers: []
    
    SimpleMenu:
      value:
        menu_id: a8290ff8-b71f-4886-a4db-aab6624980c2
        external_menu_id: MENUNOV2022
        sections: 
          - external_id: 0001STARTERS
            name: Starters
            image_url: https://resources.windelivery.io/images/e15bedaba8a5.png
            order: 1
            categories:
              - 0010SANDWICHES
        categories:
          - external_id: 0010SANDWICHES
            name: Sandwiches
            image_url: https://resources.windelivery.io/images/15b8dee40eeb.png
            order: 1
            products:
              - 0100VEGETABLESANDWICH
        products:
          - external_id: 0100VEGETABLESANDWICH
            name: Vegetable Sandwich
            image_url: https://resources.windelivery.io/images/cbd9e462c653.png
            order: 1
            modifier_groups:
              - 


  callbacks:
    orderStatusChanged:
      "{$request.body#/order_status_url}":
        post:
          requestBody:
            $ref: "#/components/responses/ResponseOrderWebhook"
          responses:
            200:
              $ref: "#/components/responses/EmptyResponse"

  securitySchemes:
    ACCESS_TOKEN:
      scheme: bearer
      type: http

  # x-amazon-apigateway-integrations:
  #   test:
  #     payloadFormatVersion: "2.0"
  #     type: "aws_proxy"
  #     httpMethod: "POST"
  #     uri: "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:936025244789:function:apilogger/invocations"
  #     connectionType: "INTERNET"

security:
  - ACCESS_TOKEN: []

# x-amazon-apigateway-importexport-version: "1.0"
