> For the complete documentation index, see [llms.txt](https://developers.myhubdelivery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.myhubdelivery.io/orders/orders/order.md).

# Order

{% hint style="success" %}
Utilizamos a especificação Open Delivery para o tratamento de pedidos.\
<https://abrasel-nacional.github.io/docs/#tag/ordersOverview>\
<https://abrasel-nacional.github.io/docs/#tag/ordersStatus>
{% endhint %}

## Consulta um pedido pelo identificador

<mark style="color:blue;">`GET`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}`

## Confirma um pedido

<mark style="color:green;">`POST`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}/confirm`

{% hint style="success" %}
**Exemplo do conteúdo da requisição**
{% endhint %}

```json
{
  "reason": "string",
  "createdAt": "2022-05-25T16:44:15.179Z",
  "orderExternalCode": "string"
}
```

## Atualiza o pedido para disponível para coleta.

<mark style="color:green;">`POST`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}/readyForPickup`

## Atualiza o pedido para depachado.

<mark style="color:green;">`POST`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}/dispatch`

Está operação é automática caso o operador logístico informe a posição do pedido em tempo real.

## Atualiza o pedido para entregue

<mark style="color:green;">`POST`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}/delivered`

Está operação é automática caso o operador logístico informe a posição do pedido em tempo real.

## Gera um pedido fake para fluxo de pedidos.

<mark style="color:green;">`POST`</mark> `https://sandbox.myhubdelivery.io/orders/api/v1/{merchantId}/fake`

#### Headers

| Name                                            | Type   | Description                   |
| ----------------------------------------------- | ------ | ----------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer <\<AuthorizatioToken>> |

#### Request Body

| Name                                        | Type   | Description                      |
| ------------------------------------------- | ------ | -------------------------------- |
| <\<Body>><mark style="color:red;">\*</mark> | String | Todos os campos são obrigatórios |

{% hint style="warning" %}
Para pedidos agendados (**scheduled**), é obrigatória o preenchimento do parâmetro **scheduledDateTime** com data em **UTC**.
{% endhint %}

{% hint style="success" %}
**Exemplo do conteúdo da requisição**
{% endhint %}

```json
{
  "saleChannelId": "JjVg9oBbxK",
  "sourceAppId": "0babcbcf2d5c4c69a9d1b6677cb4f593",
  "type": "DELIVERY|TAKEOUT|INDOOR",
  "scheduled": false,
  "scheduledDateTime": null,
  "extraInfo": "Pedido Teste",
  "items": [
    {
      "name": "X-Burger",
      "externalCode": "0101",
      "quantity": 1,
      "unitPrice": 10,
      "specialInstructions": "Remover mostarda",
      "options": [
        {
          "name": "Coca-Cola",
          "externalCode": "COC",
          "quantity": 1,
          "unitPrice": 0,
          "specialInstructions": ""
        }
      ]
    }
  ]
}
```

## Gera um pedido fake para fluxo de pedidos. (Com todos os dados do pedido)

<mark style="color:green;">`POST`</mark> `https://sandbox.myhubdelivery.io/orders/api/v1/{merchantId}/fake/complete`

#### Headers

| Name                                                 | Type   | Description                      |
| ---------------------------------------------------- | ------ | -------------------------------- |
| <\<Authorization>><mark style="color:red;">\*</mark> | String | Bearer <\<AuthorizatioToken>>    |
| <\<Body>><mark style="color:red;">\*</mark>          | String | Todos os campos são obrigatórios |

{% hint style="warning" %}
Para pedidos agendados (**scheduled**), é obrigatória o preenchimento do parâmetro **scheduledDateTime** com data em **UTC**.
{% endhint %}

{% hint style="success" %}
**Exemplo do conteúdo da requisição**
{% endhint %}

```json
{
 "saleChannelId": "JjVg9oBbxK",
  "sourceAppId": "0babcbcf2d5c4c69a9d1b6677cb4f593",
  "order": {
    "uniqueId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "id": "string",
    "type": "string",
    "displayId": "string",
    "createdAt": "2023-04-24T16:58:31.249Z",
    "orderTiming": "string",
    "merchant": {
      "id": "string",
      "name": "string"
    },
    "items": [
      {
        "id": "string",
        "index": 0,
        "name": "string",
        "externalCode": "string",
        "unit": "string",
        "quantity": 0,
        "specialInstructions": "string",
        "unitPrice": {
          "value": 0,
          "currency": "string"
        },
        "optionsPrice": {
          "value": 0,
          "currency": "string"
        },
        "totalPrice": {
          "value": 0,
          "currency": "string"
        },
        "options": [
          {
            "id": "string",
            "name": "string",
            "externalCode": "string",
            "unit": "string",
            "quantity": 0,
            "unitPrice": {
              "value": 0,
              "currency": "string"
            },
            "totalPrice": {
              "value": 0,
              "currency": "string"
            },
            "specialInstructions": "string"
          }
        ]
      }
    ],
    "otherFees": [
      {
        "name": "string",
        "type": "string",
        "receivedBy": "string",
        "receiverDocument": "string",
        "price": {
          "value": 0,
          "currency": "string"
        },
        "observation": "string"
      }
    ],
    "discounts": [
      {
        "amount": {
          "currency": "string",
          "value": 0
        },
        "target": "string",
        "targetId": "string",
        "sponsorShipValues": [
          {
            "name": "string",
            "amount": {
              "currency": "string",
              "value": 0
            }
          }
        ]
      }
    ],
    "total": {
      "itemsPrice": {
        "value": 0,
        "currency": "string"
      },
      "otherFees": {
        "value": 0,
        "currency": "string"
      },
      "discount": {
        "value": 0,
        "currency": "string"
      },
      "orderAmount": {
        "value": 0,
        "currency": "string"
      }
    },
    "payments": {
      "prepaid": 0,
      "pending": 0,
      "methods": [
        {
          "value": 0,
          "currency": "string",
          "method": "string",
          "methodInfo": "string",
          "type": "string",
          "changeFor": 0
        }
      ]
    },
    "customer": {
      "id": "string",
      "phone": {
        "number": "string",
        "extension": "string"
      },
      "documentNumber": "string",
      "name": "string",
      "ordersCountOnMerchant": 0
    },
    "delivery": {
      "deliveredBy": "string",
      "deliveryAddress": {
        "country": "string",
        "street": "string",
        "formattedAddress": "string",
        "number": "string",
        "city": "string",
        "postalCode": "string",
        "coordinates": {
          "latitude": 0,
          "longitude": 0
        },
        "district": "string",
        "state": "string",
        "complement": "string",
        "deliveryDateTime": "2023-04-24T16:58:31.250Z"
      },
      "estimatedDeliveryDateTime": "2023-04-24T16:58:31.250Z"
    },
    "takeout": {
      "mode": "string",
      "takeoutDateTime": "2023-04-24T16:58:31.250Z"
    },
    "schedule": {
      "scheduleDateTime": "2023-04-24T16:58:31.250Z"
    },
    "indoor": {
      "mode": "string",
      "indoorDeliveryDateTime": "2023-04-24T16:58:31.250Z",
      "table": "string"
    },
    "extraInfo": "string"
  }
}
```
