---
# System prepended metadata

title: eHealth Order Service API Design

---

# eHealth Order Service API Design

```shell
/*
    Author: Osman Goni Nahid
    Email: os@evaly.com.bd
------------------------------------
    Sub-Author: Amirul Islam Al Mamun
    Email: amirul.islam@evaly.com.bd
*/
```

API Service path: `/{service-name}`
API Version path: `/api/v1`
<u>Modules:</u> Order, OrderItems, OrderHistory, Notes



## 1. Module Name: **Order** 


### **<u>API Consumer: Back office Administrations</u>**

API Permission: Employees with the appropriate role(s) `eHealthAdmin` `eHealthManager` `eHealthOrderAdmin` `eHealthOrderManager` `superuser`

#### 1. **<u>Order List for Admin</u>**
- Method : `GET`
- API Path:  `/admin/orders`
- Filter options: `?invoice_no=&order_status=&delivery_status=&payment_status=&contact_number=&limit=10&page=2&shop_slug=&elogistic_delivery_hero_id=&elogistics_delivery_status=&payment_method=&delivery_method=&order_origin=` etc  
- Required Action Permission (v1): `view.order.list`
- Sample Headers: `Authoriztion` : `Bearer {access_token}`
- Sample Request Body: `N/A`
- Sample Response
```json
{
  "success": true,
  "message": "Status OK",
  "meta_info": {
    "count": 1,
    "page_size": 10,
    "next": 2,
    "previous": null
  },
  "data": [
    {
      "id": 152,
      "invoice_no": "EVH351339954",
      "customer_info": {
        "first_name": "Osman Goni Nahid",
        "email": null,
        "profile_pic_url": ""
      },
      "customer_username": "01685026771",
      "shop_info": {
        "shop": {
          "status": "active",
          "max_allowed_total": 1000000,
          "min_allowed_total": 500,
          "max_order_quantity": 0,
          "max_order_amount": 0,
          "min_order_quantity": 0,
          "min_order_amount": 0,
          "is_delivery_hero_allowed": false,
          "is_cod_allowed": false,
          "is_mother_shop": false,
          "approved": false,
          "shop_type": "Regular",
          "_id": "606eacd78f076100499b9a0f",
          "name": "Milk vita",
          "merchant_id": "606be7fcb28114002020874d",
          "address": "merchant address",
          "mother_shop_id": "606c5ed490800a010808663e",
          "longitude": 0,
          "latitude": 0,
          "slug": "milk-vita-10e29c52",
          "createdAt": "2021-04-08T07:12:24.029Z",
          "updatedAt": "2021-04-08T07:12:24.029Z",
          "__v": 0
        }
      },
      "shop_slug": "evaly-express-aks-pharmacy-dmch-dhaka",
      "contact_number": "01521400404",
      "customer_address": "Banani",
      "date": "2021-04-29 04:25:17.272120",
      "subtotal": 16270.0,
      "total": 16270.0,
      "paid_amount": 0.0,
      "delivery_status": null,
      "service_charge": 0.0,
      "delivery_fee": 0.0,
      "order_status": "pending",
      "payment_status": "unpaid",
      "payment_method": "",
      "delivery_option": {},
      "attachments": [
        "https://dev.azure.com/Evaly/eHealth/_git/ehealth-order"
      ],
      "status": "active",
      "delivery_lat": 300.0,
      "delivery_lon": 290.0,
      "order_origin": "web",
      "last_update": null,
      "delivered_at": null,
      "shipped_at": null,
      "is_delivery_hero_allowed": false,
      "is_cod_allowed": false,
      "elgoistics_delivery_id": null,
      "elgoistics_delivery_hero_id": null,
      "elogistics_delivery_status": null
    }
}
```

#### 2. <u>**Order Details:**</u>
Order details for admin, here order will be fetched by `invoice_no` where the API will return the full details or order as much as possible

- Method: `GET`
- API Path: `/admin/orders/{invoice_no}`
- Required Action Permission (v1): `view.order.details`
- Sample Headers: `Authoriztion` : `Bearer {access_token}`
- Sample Request Body: `N/A`
- Sample Response
```json
{
  "success": true,
  "message": "Status OK",
  "data": {
    "order": {
      "id": 165,
      "invoice_no": "EVH597464770",
      "customer_info": {
        "first_name": "Osman Goni Nahid",
        "email": null,
        "profile_pic_url": ""
      },
      "customer_username": "01685026771",
      "shop_info": {
        "shop": {
          "status": "active",
          "max_allowed_total": 1000000,
          "min_allowed_total": 500,
          "max_order_quantity": 0,
          "max_order_amount": 0,
          "min_order_quantity": 0,
          "min_order_amount": 0,
          "is_delivery_hero_allowed": false,
          "is_cod_allowed": false,
          "is_mother_shop": false,
          "approved": false,
          "shop_type": "Regular",
          "_id": "606eacd78f076100499b9a0f",
          "name": "Milk vita",
          "merchant_id": "606be7fcb28114002020874d",
          "address": "merchant address",
          "mother_shop_id": "606c5ed490800a010808663e",
          "longitude": 0,
          "latitude": 0,
          "slug": "milk-vita-10e29c52",
          "createdAt": "2021-04-08T07:12:24.029Z",
          "updatedAt": "2021-04-08T07:12:24.029Z",
          "__v": 0
        }
      },
      "shop_slug": "milk-vita-10e29c52",
      "contact_number": "01521400404",
      "customer_address": "Banani",
      "date": "2021-04-30 10:12:16.631448",
      "subtotal": 740.0,
      "total": 740.0,
      "paid_amount": 0.0,
      "delivery_status": null,
      "service_charge": 0.0,
      "delivery_fee": 0.0,
      "order_status": "pending",
      "payment_status": "unpaid",
      "payment_method": "",
      "delivery_option": {},
      "attachments": [
        "https://dev.azure.com/Evaly/eHealth/_git/ehealth-order"
      ],
      "status": "active",
      "delivery_lat": 300.0,
      "delivery_lon": 290.0,
      "order_origin": "web",
      "last_update": null,
      "delivered_at": null,
      "shipped_at": null,
      "is_delivery_hero_allowed": false,
      "is_cod_allowed": false,
      "elgoistics_delivery_id": null,
      "elgoistics_delivery_hero_id": null,
      "elogistics_delivery_status": null
    },
    "order_items": [
      {
        "id": 279,
        "invoice_code": "EVH597464770T2I2",
        "order": 165,
        "shop_item_id": "608a97552e51e42d315174cc",
        "shop_item_details": {
          "shop_item_id": "608a97552e51e42d315174cc",
          "item_name": "Dexoride Fluid - 500ml",
          "product_slug": "dexoride-fluid-500ml-cf9d90ac2",
          "prescription_required": false,
          "item_price": 80,
          "in_stock": 100,
          "discount": 10,
          "discounted_price": 70,
          "discount_type": "flat",
          "price_type": "fixed",
          "max_price": 0,
          "min_price": 0,
          "min_discounted_price": 0,
          "wholesale_price": 65,
          "minimum_wholesale_quantity": 10,
          "shop_name": "Milk vita",
          "shop_slug": "milk-vita-10e29c52",
          "shop_owner_name": ""
        },
        "quantity": 8,
        "order_time_price": 70.0,
        "order_time_status": 70.0,
        "status": "active",
        "note": null,
        "updated_at": null,
        "created_at": "2021-04-30 22:12:16.655083",
        "deleted_at": null
      },
      {
        "id": 278,
        "invoice_code": "EVH597464770T2I1",
        "order": 165,
        "shop_item_id": "608a973b2e51e42d315174cb",
        "shop_item_details": {
          "shop_item_id": "608a973b2e51e42d315174cb",
          "item_name": "Koloride Fluid - 500ml",
          "product_slug": "koloride-fluid-500ml-eb5a914df",
          "prescription_required": false,
          "item_price": 70,
          "in_stock": 100,
          "discount": 10,
          "discounted_price": 60,
          "discount_type": "flat",
          "price_type": "fixed",
          "max_price": 0,
          "min_price": 0,
          "min_discounted_price": 0,
          "wholesale_price": 65,
          "minimum_wholesale_quantity": 10,
          "shop_name": "Milk vita",
          "shop_slug": "milk-vita-10e29c52",
          "shop_owner_name": ""
        },
        "quantity": 3,
        "order_time_price": 60.0,
        "order_time_status": 60.0,
        "status": "active",
        "note": null,
        "updated_at": null,
        "created_at": "2021-04-30 22:12:16.642937",
        "deleted_at": null
      }
    ]
  }
}
```

#### 3. <u>**Order Update:**</u>
Update order information by admin those fields we allowed to update from back-office by an employee

- Method: `PUT`
- API Path: `/admin/orders/{invoice_no}`
- Required Action Permission (v1): `update.order.details`
- Sample Headers: `Authoriztion` : `Bearer {access_token}`
- Sample Request Body
```json
{
    "customer_address":"20/7, Banani",
    "contact_number":"01521400405",
    "delivery_lat": 120.01,
    "delivery_lon": 90.23
}
```
- Sample Response
```json
{
  "success": true,
  "message": "Status OK",
  "data": {
    "id": 31,
    "invoice_no": "EVH060830646",
    "customer_info": {
      "first_name": "Ishak Ahammed",
      "email": null,
      "profile_pic_url": "https://s3-ap-southeast-1.amazonaws.com/media.evaly.com.bd/media/images/1573e2c486ec-newfile.jpeg"
    },
    "customer_username": "ishak",
    "shop_info": {
      "shop": {
        "status": "active",
        "is_delivery_hero_allowed": false,
        "is_cod_allowed": false,
        "is_mother_shop": false,
        "approved": false,
        "shop_type": "Regular",
        "_id": "606e928f98ae9100594691fe",
        "name": "shop aagg",
        "merchant_id": "606be7fcb28114002020874d",
        "address": "merchant address",
        "mother_shop_id": "606c5ed490800a010808663e",
        "longitude": 0,
        "latitude": 0,
        "slug": "shop-aagg-1973a9cb",
        "createdAt": "2021-04-08T05:20:15.660Z",
        "updatedAt": "2021-04-08T05:20:15.660Z",
        "__v": 0
      }
    },
    "shop_slug": "evaly-express-aks-pharmacy-dmch-dhaka",
    "contact_number": "01521400405",
    "customer_address": "20/7, Banani",
    "date": "2021-04-25 07:28:37.106090",
    "subtotal": 14000.0,
    "total": 14000.0,
    "paid_amount": 14000.0,
    "delivery_status": null,
    "service_charge": 0.0,
    "delivery_fee": 0.0,
    "order_status": "cancelled",
    "payment_status": "refunded",
    "payment_method": "nagad",
    "delivery_option": {},
    "attachments": null,
    "status": "active",
    "delivery_lat": 120.01,
    "delivery_lon": 90.23,
    "order_origin": "web",
    "last_update": "2021-04-30 22:18:22.255621",
    "delivered_at": "2021-04-08 05:20:15.660000",
    "shipped_at": "2021-04-08 05:20:15.660000",
    "is_delivery_hero_allowed": false,
    "is_cod_allowed": false,
    "elgoistics_delivery_id": "default",
    "elgoistics_delivery_hero_id": "default",
    "elogistics_delivery_status": "default"
  }
}
```



### **<u>API Consumer: Public facing web/app</u>**
API Permission: `Customer` or end-user

#### 1. **<u>Order List for Customer:</u>**
will be able to the filer and search with appropriate fields
- Method : `GET`
- API Path:  `/orders`
- Filter options: `??order_status=&limit=10 &page=2` etc  
- Required Action Permission (v1): `customer`
- Sample Headers: `Authoriztion` : `Bearer {access_token}`
- Sample Request Body: `N/A`
- Sample Response
```json
{
  "success": true,
  "message": "Status OK",
  "meta_info": {
    "count": 1,
    "page_size": 10,
    "next": 2,
    "previous": null
  },
  "data": [
    {
      "id": 55,
      "invoice_no": "EVH057279997",
      "customer_info": {
        "first_name": "Osman Goni Nahid",
        "email": null,
        "profile_pic_url": ""
      },
      "customer_username": "01685026771",
      "shop_info": {
        "shop": {
          "status": "active",
          "is_delivery_hero_allowed": false,
          "is_cod_allowed": false,
          "is_mother_shop": false,
          "approved": false,
          "shop_type": "Regular",
          "_id": "606eacd78f076100499b9a0f",
          "name": "Milk vita",
          "merchant_id": "606be7fcb28114002020874d",
          "address": "merchant address",
          "mother_shop_id": "606c5ed490800a010808663e",
          "longitude": 0,
          "latitude": 0,
          "slug": "milk-vita-10e29c52",
          "createdAt": "2021-04-08T07:12:24.029Z",
          "updatedAt": "2021-04-08T07:12:24.029Z",
          "__v": 0
        }
      },
      "shop_slug": "evaly-express-aks-pharmacy-dmch-dhaka",
      "contact_number": "01521400404",
      "customer_address": "Banani",
      "date": "2021-04-26 03:39:38.558027",
      "subtotal": 22000.0,
      "total": 22000.0,
      "paid_amount": 100.0,
      "delivery_status": null,
      "service_charge": 0.0,
      "delivery_fee": 0.0,
      "order_status": "pending",
      "payment_status": "unpaid",
      "payment_method": "",
      "delivery_option": {},
      "attachments": [
        "https://dev.azure.com/Evaly/eHealth/_git/ehealth-order"
      ],
      "status": "active",
      "delivery_lat": 300.0,
      "delivery_lon": 290.0,
      "order_origin": "web",
      "last_update": null,
      "delivered_at": null,
      "shipped_at": null,
      "is_delivery_hero_allowed": false,
      "is_cod_allowed": false,
      "elgoistics_delivery_id": null,
      "elgoistics_delivery_hero_id": null,
      "elogistics_delivery_status": null
    }
}
```