# GetVouchers 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 %}

{% hint style="info" %}
**The GetVouchers API can only be called up to 500 times in a 24-hour period.**
{% endhint %}

{% hint style="warning" %}
**Currently, we do not support adding multiple filters in a single GetVouchersAPI call**
{% 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.getVouchers",
	"tag": "plumProAPI",
	"variables": {
		"data":{
		    "limit": 10,
        	    "page": 2,
        	    "includeProducts": "",
        	    "excludeProducts": "",
              "exchangeRate": 1,
        	    "sort": {
        		    "field":"",
        		    "order":""
        	    },
        	    "filters":[
        		{
        			"key": "productName",
        			"value": ""
        		},
        		{
        			"key": "country",
        			"value": ""
        		},
        		{
        			"key": "price",
        			"value": ""
        		},
        		{
        			"key": "minPrice",
        			"value": ""
        		},
        		{
        			"key": "maxPrice",
        			"value": ""
        		},
            {
              "key": "deliveryType",
              "value": ""
            },
        		{
        			"key": "currencyCode",
        			"value": ""
        		}
    		]
               }
	}
}

```

{% endtab %}

{% tab title="Response" %}

#### `200 : Success`

`returns list of vouchers filtered by the applicable filters`

```bash
{
    "data": {
        "getVouchers": {
           "status": 1,
           "data": [{
              "productId": 15365,
              "name": "Amazon.in",
              "description": "",
              "orderQuantityLimit": 10,
              "termsAndConditionsInstructions": "",
              "expiryAndValidity": "",
              "redemptionInstructions": "",
              "categories": "eCommerce",
              "lastUpdateDate": "2020-01-06 10:23:24",
              "imageUrl": "",
              "currencyCode": "INR",
              "currencyName": "rupees",
              "countryName": "India",
              "countryCode": "IN",
              "countries": [
               {
                "code": "IN",
                "name": "India", 
               }
              ],
              "valueType": "fixed_denomination",
              "maxValue": 0,
              "minValue": 0,
              "valueDenominations": "20,30,500,1000,2500",
              "tatInDays": "0",
              "usageType": "",
              "deliveryType": "",
              "isCommon": "",
              "fee": 0,
              "discount": 0
              "usageType": "",
              "exchangeRate": "1"
         }]
       }
    }
}
```

#### `401 : Failure`

`Authorization error due to invalid or missing API key`

```bash
{ 
   code: 401, 
	   errorId: "PIPE10013",
	   errorInfo: "Plum Pro APIs: Invalid authorization header",
   error: "Eg: Unauthorized, Client is unauthorized for international orders"
}
```

#### `400 : Failure`

`Unable to get any vouchers`

```
{
	   code: 400,
	   errorId: "PLE10033",
	   errorInfo: "Failed to validate getVouchers request",
   error:"Eg: Bad request"
}
```

#### `404 : Failure`

`Failed to get product details`

```bash
{ 
	   code: 404,
	   errorId: "PLE10017",
	   errorInfo: "Failed to get product details",
   error: "ProductId Not Found"
}
```

#### `500 : Failure`

`Internal server error`

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

{% endtab %}
{% endtabs %}

## Parameters

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

#### `Body Parameters`

| `Property`            | `Type`    | **`Description`**                                                                            |
| --------------------- | --------- | -------------------------------------------------------------------------------------------- |
| `limit`**`*`**        | `Integer` | `Number of products desired per page`                                                        |
| `page`**`*`**         | `Integer` | `Offset with respect to the limit provided(starts from 1),`                                  |
| `includeProducts`     | `String`  | `Comma-separated product ids of products to be included`                                     |
| `excludeProducts`     | `String`  | `Comma-separated product ids of products to be excluded`                                     |
| `field`               | `String`  | `Fields to sort by, Eg: name, last update date`                                              |
| `order`               | `String`  | `fields to order by. Eg: ASC, DESC`                                                          |
| `filters`             | `Array`   | `An array of optional filter property objects having key and value as keys mentioned below:` |
| `filter.productName`  | `String`  | `Product names to be included`                                                               |
| `filter.country`      | `String`  | `Countries to be included`                                                                   |
| `filter.price`        | `String`  | `Price range filters to be included`                                                         |
| `filter.minPrice`     | `String`  | `The minimum price of the products looked for`                                               |
| `filter.maxPrice`     | `String`  | `Maximum price of the products looked for`                                                   |
| `filter.currencyCode` | `String`  | `Currency codes to be included`                                                              |
| `filter.deliveryType` | `String`  | `Delivery type to the voucher (realtime or delayed)`                                         |

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

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

{% tab title="Response" %}

#### **`Body Parameters`**

| **`Property`**               | **`Type`**    | **`Description`**                                                                                                 |
| ---------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------- |
| **`status`**                 | **`Integer`** | **`0 (Failure) / 1 (Successful)`**                                                                                |
| **`productId`**              | **`Integer`** | **`product Id of the product`**                                                                                   |
| **`name`**                   | **`String`**  | **`name of the product`**                                                                                         |
| **`description`**            | **`String`**  | **`description of the product`**                                                                                  |
| **`orderQuantityLimit`**     | **`Integer`** | **`Maximum order quantity allowed for the prpdouct`**                                                             |
| **`termsAndConditions`**     | **`String`**  | **`terms and conditions for the particular product`**                                                             |
| **`expiryAndValidity`**      | **`String`**  | **`expiry and validity of the product`**                                                                          |
| **`redemptionInstructions`** | **`String`**  | **`instructions to redeem the product`**                                                                          |
| **`categories`**             | **`String`**  | **`categories to which this product belongs to`**                                                                 |
| **`lastUpdateDate`**         | **`String`**  | **`last time and date when this product was updated`**                                                            |
| **`imageUrl`**               | **`String`**  | **`url of the image of the voucher if available`**                                                                |
| **`currencyCode`**           | **`String`**  | **`Currency code of the product`**                                                                                |
| **`currencyName`**           | **`String`**  | **`The currency name of the product`**                                                                            |
| **`countryName`**            | **`String`**  | **`The country in which this product can be redeemed`**                                                           |
| **`countryCode`**            | **`String`**  | **`Country code for the country in which this product can be redeemed`**                                          |
| **`countries`**              | **`Array`**   | **`List of countries with country code and country name where the products can be redeemed`**                     |
| **`valueType`**              | **`String`**  | <p><strong><code>Declared values or variable values eg open\_value or fixed\_denomination</code></strong><br></p> |
| **`maxValue`**               | **`Integer`** | **`Max value if given in request body`**                                                                          |
| **`minValue`**               | **`Integer`** | **`Min value if given in request body`**                                                                          |
| **`valueDenominations`**     | **`String`**  | **`Comma separated denomination`**                                                                                |
| **`tatInDays`**              | **`String`**  | **`Turn around time in days taken to process the order`**                                                         |
| **`usageType`**              | **`String`**  | **`Usage Type for eg: digital, offline,etc.`**                                                                    |
| **`deliveryType`**           | **`String`**  | **`Realtime or Delayed`**                                                                                         |
| **`fee`**                    | **`Float`**   | **`Any extra fees levied on this product`**                                                                       |
| **`discount`**               | **`FLoat`**   | **`discount amount`**                                                                                             |
| **`exchangeRate`**           | **`Integer`** | **`Exchange rate in comparison to client Base currency.`**                                                        |
| {% endtab %}                 |               |                                                                                                                   |
| {% endtabs %}                |               |                                                                                                                   |
