# GetOrderHistory API

#### **Base URL :**

{% hint style="info" %}

> **`Staging :`** [**https://stagingaccount.xoxoday.com/chef**](https://stagingaccount.xoxoday.com/chef)
>
> **`Production :`** [**https://accounts.xoxoday.com/chef**](https://accounts.xoxoday.com/chef)
> {% endhint %}

{% tabs %}
{% tab title="Request" %}

```bash
curl -X POST {OAUTH_URL}/v1/oauth/api 
-H 'Authorization: Bearer eyJ0b2tlbkNvbnRlbnQiOnsiaXNzdWVkRm9yIjoiRnJlc2h3b3JrcyIsInNjb3BlIjoiIiwiaXNzdWVkQXQiOjE1NTk4MDQ1Nzg1ODIsImV4cGlyZXNBdCI6IjIwMTktMDYtMjFUMDc6MDI6NTguNTgyWiIsInRva2VuX3R5cGUiOiJVU0VSIn0sImFfdCI6ImV5SmxibU1pT2lKQk1USTRRMEpETFVoVE1qVTJJaXdpWVd4bklqb2lSVU5FU0MxRlV5SXNJbXRwWkNJNkltVnVZeUlzSW1Wd2F5STZleUpyZEhraU9pSkZReUlzSW1OeWRpSTZJbEF0TWpVMklpd2llQ0k2SWpoMmJVTkVRMUZQZW1wQlNHWndabXQ0TVhjNVluZHphM1JhZWtRek0ySXRZamx0VVhSclEyRnhNV3NpTENKNUlqb2lZMGR0V2kxdWIySjBWbUptTVdGdVNraDBUMmxoWW5VMFZHUlVhRzVVYmpCYWRuWnJabGMwYzBWb2N5SjlmUS4uU1h3TlNUSWhFUXNlN0htaXpPUmFIQS5NRzBVUy1lek1IOEFsbWFLc2ZTY3Nwa2FlYzBIcW9FcUV1YXRoNHRSTTRpeVg2dFByX1ZjTnlsdnk5YjlGLTZHR01DbjY1TjYwYnpIUUJtRVZvZGRYVWlvQS1kTkpuaE9KdThHczRfeW9pM042VGFOdWhjRENCUGtwWk1CeTlDRjJBaEh4UGotQkd0SzdEamhNbjBBQXpTM1VhTE11eUdrTmNwSGxQSUxNcFlVM' 
--header 'Content-Type: application/json'
  -d '{
	"query": "plumProAPI.mutation.getOrderHistory",
	"tag": "plumProAPI",
	"variables": {
		"data":{
			"startDate": "2012-07-25",
        	        "endDate": "2012-07-28",
        	        "limit": 10,
        	        "page": 1
		}
	}
}

```

{% endtab %}

{% tab title="Response" %}

#### `200 : Success`

`returns the list of all order within a specific time range`

```bash
{
    "data": {
        "getOrderHistory": {
            "status": 1,
            "data": [
              {
                "orderId": 1316578,
                "orderDate": "2019-12-27 16:41:33",
                "email": "admin@pointsreport.com",
                "deliveryStatus": "Pending",
                "tag": "somethingToTagThisOrder",
                "poNumber": "",
                "products": [
                  {
                    "productName": "Brand Vouchers - Product Test 3456",
                    "receiverMobileNumber": "",
                    "price": 221,
                    "quantity": 1,
                    "orderProductStatus": "pending"
                  }
                ]
              }
            ]
          }
    }
}



```

#### `400 : Failure`

`Validation error in order history`

```
{
	   code: 400,
	   errorId: "PLE10032"
	   errorInfo: "Failed to validate OrderHistory Request"
   error:"Eg: Bad request"// More details about error
}
```

#### `401 : Failure`

`Invalid authorization header`

```
{
	   code: 401,
	   errorId: "PIPE10013"
	   errorInfo: "Plum Pro APIs: Invalid authorization header"
   error:"Eg: invalid authorization header!"
}
```

#### `404 : Failure`&#x20;

`Order history not found`

```
{
	   code: 404,
   	   errorId: "PLE10027"
	   errorInfo: "Failed to find order history"
   error: "Order History Not Found"
}
```

#### `502 : Failure`&#x20;

`Failed to process resend vouchers`

```
{
            code: 502,
            errorId: "PLE10034",
            errorInfo: "Failed to process resendVoucher",
            error: "Invalid Order status id."
}
```

#### `500: Failure`

`Internal server error`

```
{ 
   code: 500, 
   error: "Eg: Internal server error"
}
```

{% endtab %}
{% endtabs %}

## Parameters

{% tabs %}
{% tab title="Request " %}

#### `Body Parameters`

| `Property`         | `Type`    | **`Description`**                                                 |
| ------------------ | --------- | ----------------------------------------------------------------- |
| `startDate`**`*`** | `String`  | `Date from which order history needs to be retrieved`             |
| `endDate`**`*`**   | `String`  | `Date till which order history needs to be retrieved`             |
| `limit`**`*`**     | `Integer` | `Limit for number of orders per page`                             |
| `page`**`*`**      | `Integer` | `Page number with respect to the limit specified (starts with 1)` |

{% hint style="info" %}
**"\*" means the parameter is mandatory**
{% endhint %}
{% endtab %}

{% tab title="Response" %}

#### `Body Parameters`

| `Property`                        | `Type`    | `Description`                                                                                              |
| --------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------- |
| `status`                          | `Integer` | <p><code>0 (Failure) / 1 (Successful)</code><br></p>                                                       |
| `data`                            | `Array`   | <p><code>The array of the orders matching the request filters</code><br></p>                               |
| `data.orderId`                    | `Integer` | `orderId of the order`                                                                                     |
| `data.orderDate`                  | `String`  | `This gives date and time when order is placed and`` `**`the format for Order date time stamp is in IST`** |
| `data.email`                      | `String`  | <p> <code>The email that the order was placed with</code><br></p>                                          |
| `data.deliveryStatus`             | `String`  | <p><code>delivery status of the order</code><br></p>                                                       |
| `data.poNumber`                   | `String`  | `poNumber associated with the order if any`                                                                |
| `data.tag`                        | `String`  | <p><code>Order’s tag</code><br></p>                                                                        |
| `data.products`                   | `Array`   | <p><code>An array of products ordered in that specific order</code><br></p>                                |
| `data.product.productName`        | `String`  | `name of the product`                                                                                      |
| `product.receiverMobileNumber`    | `String`  | `Receiver’s mobile number if any`                                                                          |
| `data.product.price`              | `Float`   | `price of the product`                                                                                     |
| `data.product.quantity`           | `Integer` | `quantity of the product ordered`                                                                          |
| `data.product.orderProductStatus` | `String`  | `delivery status of this particular product in the order`                                                  |

{% hint style="info" %}
**`data.xyz= data property objects`**
{% endhint %}
{% endtab %}
{% endtabs %}
