API si Integrari

API Comenzi livrare

Documentație API pentru gestionarea comenzilor de livrare și ridicare

Obțineți toate comenzile de livrare

Endpoint: GET /v1/waiters/delivery/orders

Returnează lista comenzilor de livrare și ridicare asociate unui restaurant.

Exemplu cerere:

GET /v1/waiters/delivery/orders HTTP/1.1
Authorization: Bearer {token}

Exemplu răspuns:

{
  "orders": [
    {
      "_id": "680de6e42342ec985162129c",
      "type": "delivery",
      "code": 7174,
      "client": {
        "_id": "66e937b558cd647d5f6acce3",
        "name": "Anonymous#9460",
        "phoneNumber": "+40761111111"
      },
      "restaurant": "5f2c5a0eafd17b4d10ff8974",
      "status": "completed",
      "payment": {
        "_id": "680de6e42342ec985162129a",
        "status": "paid"
      },
      "delivery": {
        "status": "delivered",
        "address": {
          "location": {
            "type": "Point",
            "coordinates": [28.1654827, 47.0921875]
          },
          "address": {
            "formattedAddress": "R25 17, Vărzărești, Moldova",
            "country": "Moldova",
            "state": "Nisporeni District",
            "city": "Vărzărești",
            "street": "R25",
            "streetNumber": "17"
          },
          "place": {
            "placeId": "ChIJx-uBBu4atEAR-1tUiib9CW4",
            "mainText": "Mănăstirea Vărzărești",
            "secondaryText": "România"
          }
        },
        "estimate": "2025-04-27T08:43:55.493Z"
      },
      "note": "",
      "items": [
        {
          "item": "60a503641ee73009f45dbf00",
          "name": "SPAGHETTI CON CALAMARI",
          "price": 22,
          "quantity": 2,
          "options": [],
          "note": ""
        },
        {
          "item": "60a503641ee73009f45dbf09",
          "name": "TAGLIATELE DAVINCI",
          "price": 29,
          "quantity": 1,
          "options": [],
          "note": ""
        },
        {
          "item": "60a503651ee73009f45dbf0b",
          "name": "SPAGHETTI MARE E MONTI",
          "price": 28,
          "quantity": 1,
          "options": [],
          "note": ""
        },
        {
          "item": "60a503651ee73009f45dbf0d",
          "name": "SPAGETTI ALLA PUTTANESCA",
          "price": 25,
          "quantity": 1,
          "options": [],
          "note": ""
        }
      ],
      "fees": [],
      "currency": "RON",
      "total": 126,
      "createdAt": "2025-04-27T08:12:20.811Z",
      "updatedAt": "2025-04-27T08:14:01.344Z",
      "number": "233",
      "__v": 0
    }
  ]
}

Obțineți detalii despre o comandă specifică

Endpoint: GET /v1/waiters/delivery/orders/:id

Returnează detalii despre o comandă specifică.

Exemplu cerere:

GET /v1/waiters/delivery/orders/:id HTTP/1.1
Authorization: Bearer {token}

Exemplu răspuns:

{
  "order": {
    "_id": "680de6e42342ec985162129c",
    "type": "delivery",
    "code": 7174,
    "client": {
      "_id": "66e937b558cd647d5f6acce3",
      "name": "Anonymous#9460",
      "phoneNumber": "+40761111111"
    },
    "restaurant": "5f2c5a0eafd17b4d10ff8974",
    "status": "completed",
    "payment": "680de6e42342ec985162129a",
    "delivery": {
      "status": "delivered",
      "address": {
        "location": {
          "type": "Point",
          "coordinates": [28.1654827, 47.0921875]
        },
        "address": {
          "formattedAddress": "R25 17, Vărzărești, Moldova",
          "country": "Moldova",
          "state": "Nisporeni District",
          "city": "Vărzărești",
          "street": "R25",
          "streetNumber": "17"
        },
        "place": {
          "placeId": "ChIJx-uBBu4atEAR-1tUiib9CW4",
          "mainText": "Mănăstirea Vărzărești",
          "secondaryText": "România"
        }
      },
      "estimate": "2025-04-27T08:43:55.493Z"
    },
    "note": "",
    "items": [
      {
        "item": "60a503641ee73009f45dbf00",
        "name": "SPAGHETTI CON CALAMARI",
        "price": 22,
        "quantity": 2,
        "options": [],
        "note": ""
      },
      {
        "item": "60a503641ee73009f45dbf09",
        "name": "TAGLIATELE DAVINCI",
        "price": 29,
        "quantity": 1,
        "options": [],
        "note": ""
      },
      {
        "item": "60a503651ee73009f45dbf0b",
        "name": "SPAGHETTI MARE E MONTI",
        "price": 28,
        "quantity": 1,
        "options": [],
        "note": ""
      },
      {
        "item": "60a503651ee73009f45dbf0d",
        "name": "SPAGETTI ALLA PUTTANESCA",
        "price": 25,
        "quantity": 1,
        "options": [],
        "note": ""
      }
    ],
    "fees": [],
    "currency": "RON",
    "total": 126,
    "createdAt": "2025-04-27T08:12:20.811Z",
    "updatedAt": "2025-04-27T08:14:01.344Z",
    "number": "233",
    "__v": 0
  }
}

Confirmarea unei comenzi

Endpoint: PUT /v1/waiters/delivery/orders/:id/confirm

Confirmă o comandă și setează timpul estimat de livrare.

Exemplu cerere:

PUT /v1/waiters/delivery/orders/:id/confirm HTTP/1.1
Authorization: Bearer {token}
Content-Type: application/json

{
  "estimate": "2025-04-24T15:00:00.000Z"
}

Exemplu răspuns:

{
  "order": {
    "_id": "5f2c5d1aafd17b4d10ff8978",
    "status": "confirmed",
    "delivery": {
      "estimate": "2025-04-24T15:00:00.000Z"
    }
  }
}

Finalizarea unei comenzi

Endpoint: PUT /v1/waiters/delivery/orders/:id/complete

Finalizează o comandă și marchează livrarea ca efectuată.

Exemplu cerere:

PUT /v1/waiters/delivery/orders/:id/complete HTTP/1.1
Authorization: Bearer {token}

Exemplu răspuns:

{
  "order": {
    "_id": "5f2c5d1aafd17b4d10ff8978",
    "status": "completed",
    "delivery": {
      "status": "delivered"
    }
  }
}

Anularea unei comenzi

Endpoint: PUT /v1/waiters/delivery/orders/:id/cancel

Anulează o comandă de livrare.

Exemplu cerere:

PUT /v1/waiters/delivery/orders/:id/cancel HTTP/1.1
Authorization: Bearer {token}

Exemplu răspuns:

{
  "order": {
    "_id": "5f2c5d1aafd17b4d10ff8978",
    "status": "canceled"
  }
}