Criar pedido - API Lojaz Delivery

POST

-

Criar pedido

Utilize esta rota para criar um pedido

PATH

{{BASE_URL}}/orders/:storeId

Headers

Authorization: Bearer Token

Body

{
  "referenceId": "Seu id de referencia (Será enviado nos webhooks)",
  "observation": "Observação",
  "items": [
    {
      "name": "Camisa",
      "referenceId": "Your product internal id",
      "quantity": 1,
      "price": "1.59",
      "imageUrl": "Optional Image URL",
      "width": "Optional Product Width",
      "height": "Optional Product Height",
      "weight": "100 //Weight in gram"
    }
  ],
  "address": {
    "customer": {
      "street": "Endereço do cliente",
      "number": "Numero da casa / ap",
      "postalCode": "CEP",
      "lat": "Latitude",
      "long": "Longitude"
    },
    "store": {
      "street": "Endereço da loja",
      "number": "Numero",
      "postalCode": "21320050",
      "lat": "Latitude",
      "long": "Longitude"
    }
  },
  "client": {
    "name": "Nome do cliente",
    "phoneNumber": "Telefone do cliente (Somente numeros)"
  }
}

Content-Type: application/json

Nota: você deve incluir latitude / longitude dos 2 endereços!

Exemplo em NodeJS:

const axios = require('axios'); const createOrder = async () => { try { const response = await axios.post( 'BASE_URL/orders/:storeId', { observation: "Nenhuma", address: { customer: { street: "Rua Teste", number: "24", postalCode: "21320050", lat: -23.000102247521262, long: -43.33050747765812 }, store: { street: "Rua Teste", number: "24", postalCode: "21320050", lat: -23.000102247521262, long: -43.33050747765812 } }, client: { name: "Weslley", phoneNumber: "21965442088" } }, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ACCESS_TOKEN` } } ); // handle response } catch (error) { // handle error } }; module.exports = createOrder;

Flow interno

Response - OK (200)

{
  "status": true,
  "message": "Pedido criado com sucesso",
  "data": {
    "trackCode": "LOJAZ28378905BR4435"
  }
}

Content-Type: application/json

Modelo de resposta de erro - OK (200)

{
  "status": false,
  "message": "Mensagem do erro"
}

Content-Type: application/json

Response - Unauthorized (401)

{
  "status": false,
  "message": "Unauthorized"
}

Content-Type: application/json