# Delivery Order Object

## Attributes

### orderId  
`Integer`  
Unique identifier for this order

### orderNumber  
`String`  
Order reference of customer platform

### companyId  
`Integer`  
Identifier of the company to which this order belong

### areaId  
`Integer`  
Identifier of the operational area when the company is operating their delivery

### customer  
`Object`  
Customer associated with the order

#### Child attributes  
- **name** `String`  
  Name of the customer  
- **address** `String`  
  Address of the customer  
- **phoneNumber** `String`  
  Phone number of the customer  
- **emailAddress** `String`  
  Email address of the customer  
- **latitude** `Double`  
  Customer location latitude value  
- **longitude** `Double`  
  Customer location longitude value

### restaurant  
`Object`  
Restaurant associated with the order

#### Child attributes  
- **id** `Integer`  
  Unique Identifier specifying the restaurant  
- **name** `String`  
  Name of the restaurant  
- **address** `String`  
  Address of the restaurant  
- **phoneNumber** `String`  
  Phone number of the restaurant  
- **latitude** `Double`  
  Restaurant location latitude value  
- **longitude** `Double`  
  Restaurant location longitude value

### assignedCarrier  
`Object`  
Assigned Carrier information for the order ( `null` if not assigned yet)

#### Child attributes  
- **id** `Integer`  
  Unique Identifier specifying the carrier  
- **personalId** `Integer`  
  Provided id from the user ( `null` if not available )  
- **name** `String`  
  Name of the carrier  
- **codeName** `String`  
  Provided code name for the carrier  
- **phoneNumber** `String`  
  Phone number of the carrier  
- **companyId** `Integer`  
  Unique identifier specifying the company  
- **areaId** `Integer`  
  Unique identifier specifying the area  
- **isOnShift** `Boolean`  
  Indication for the carrier if he/she is on shift  
- **email** `String`  
  Email Address of the carrier  
- **carrierPhoto** `String`  
  Carrier photo link  
- **isActive** `Boolean`  
  Indication for the carrier if he/she is active

### distance  
`Double`  
Calculated distance between pickup and delivery address

### activityLog  
`Object`  
Order related events log

#### Child attributes  
- **placementTime** `String`  
  Order placement time (must be in UTC format)  
- **expectedPickupTime** `String`  
  Expected order pickup time (hh:mm format)  
- **expectedDeliveryDate** `String`  
  Expected order delivery date (yyyy-mm-dd)  
- **expectedDeliveryTime** `String`  
  Expected order delivery time (hh:mm format)  
- **assignedTime** `String`  
  Order assignment time (must be in UTC format)  
- **startTime** `String`  
  Order start time (must be in UTC format)  
- **pickedUpTime** `String`  
  Order picked up time from restaurant (must be in UTC format)  
- **arrivedTime** `String`  
  Arrival time to the customer (must be in UTC format)  
- **deliveryTime** `String`  
  Order delivery time (must be in UTC format)

### costing  
`Object`  
Order costing details

#### Child attributes  
- **totalCost** `Double`  
  Total cost of the order items  
- **deliveryFee** `Double`  
  Delivery fee of the order  
- **tip** `Double`  
  Tip amount for the order  
- **discountAmount** `Double`  
  Discount amount for the order  
- **tax** `Double`  
  Tax amount for the ordered items  
- **cashTip** `Double`  
  Cash tip for the order

### paymentMethod  
`String`  
Payment method for the order

### orderItems  
`Array`  
Array of Order item objects

#### Ordered Item object child attributes  
- **name** `String`  
  Name of the order item  
- **quantity** `Integer`  
  Quantity of the order item  
- **unitPrice** `Double`  
  Price of the order item per unit

### assignedCarrierId  
`Integer`  
Assigned carrier's ID

### orderStatus  
`Object`  
Order status info

#### Child attributes  
- **incomplete** `Boolean`  
  Boolean value to indicate if the order is incomplete  
- **accepted** `Boolean`  
  Boolean value to indicate if the order is accepted  
- **orderState** `String`  
  Order's current state

### trackingLink  
`String`  
Customer tracking url link

### feedback  
`String`  
Feedback of the customer

### schedule  
`Boolean`  
Indication for the order if it is a scheduled order or not

### parentId  
`Integer`  
Parent ID for the order

### etaTime  
`String`  
Estimated time of arrival for the order

### pickupInstruction  
`String`  
Pickup related instruction for the order

### deliveryInstruction  
`String`  
Delivery Instruction for the order

### proofOfDelivery  
`Object`  
Proof of delivery details

#### Child attributes  
- **signaturePath** `String`  
  URL of the signature or POD image  
- **latitude** `Double`  
  Latitude value where driver completed the delivery  
- **longitude** `Double`  
  Longitude value where driver completed the delivery  
- **imageUrls** `Array`  
  Array of proof of delivery image URL strings

| Supported orderState Enum values |
| --- |
| ACTIVE |
| NOT_ASSIGNED |
| NOT_ACCEPTED |
| NOT_STARTED_YET |
| STARTED |
| PICKED_UP |
| READY_TO_DELIVER |
| ALREADY_DELIVERED |
| FAILED_DELIVERY |
| INCOMPLETE |

## Example JSON Output

```json
{
    "orderId": 20625,
    "orderNumber": "7568",
    "companyId": 409,
    "areaId": 406,
    "customer": {
      "name": "William Jacob",
      "address": "CVV4+C7 Palo Alto, California, United States",
      "phoneNumber": "+16504135349",
      "emailAddress": "jacob.william@gmail.com",
      "latitude": 32.7875632,
      "longitude": -170.3874568
    },
    "restaurant": {
      "id":36726661,
      "name": "Garden fresh Palo Alto",
      "address": "460 Ramona St, Palo Alto, CA 94301, United States",
      "phoneNumber": "+16504632332",
      "latitude": 32.8069245,
      "longitude": -170.368697
    },
    "assignedCarrier": {
      "id": 30309,
      "personalId": null,
      "name": "John Doe",
      "codeName": null,
      "phoneNumber": "+12342342330",
      "companyId": null,
      "areaId": null,
      "isOnShift": null,
      "email": null,
      "carrierPhoto": "https://s3-us-west-2.amazonaws.com/qt.com.dashboard.profile.driver/somelinktothecarrierphoto.jpg",
      "isActive": null
    },
    "distance": 1.78772,
    "activityLog": {
      "placementTime": "2019-11-29T11:43:59",
      "expectedPickupTime": "12:12",
      "expectedDeliveryDate": "2019-11-29",
      "expectedDeliveryTime": "12:42",
      "assignedTime": "2019-11-30T13:40:07",
      "startTime": "2019-11-30T13:41:07",
      "pickedUpTime": "2019-12-01T05:43:15",
      "arrivedTime": "2019-12-01T05:43:15",
      "deliveryTime": "2019-12-01T05:43:15"
    },
    "costing": {
      "totalCost": 30.45,
      "deliveryFee": 0,
      "tip": 0,
      "discountAmount": 0,
      "tax": 1.45,
      "cashTip": 0
    },
    "paymentMethod": "CASH",
    "orderItems": [
      {
        "name": "Grilled Salmon Fillet",
        "quantity": 2,
        "unitPrice": 14.50
      }
    ],
    "assignedCarrierId": -1,
    "orderStatus": {
      "incomplete": false,
      "accepted": true,
      "orderState": "ALREADY_DELIVERED"
    },
    "trackingLink": null,
    "feedback": 5,
    "schedule": false,
    "parentId": 0,
    "etaTime": "",
   "pickupInstruction": "Will be ready in 15 minutes",
    "deliveryInstruction": "Please, Knock at the door",
    "proofOfDelivery": {
        "signaturePath": "https://s3-us-west-2.amazonaws.com/qt.com.dashboard.order.signature/a7dc65d0e8d44ef397e705512beb913d.jpg",
        "latitude": 23.8,
        "longitude": 90.36,
       "imageUrls": ["https://s3-us-west-2.amazonaws.com/qt.com.dashboard.order.signature/a7dc65d0e8d44ef397e705512beb913d.jpg"]
      }
}
```
