BookstoreDiscountCode
The BookstoreDiscountCode object
The BookstoreDiscountCode object looks like this in JSON:
{
"object": "discount_code",
"id": 1,
"code": "SUPERSALE!",
"type": "bookstore",
"amount": 0,
"percent": 30,
"applies_to": "all",
"available_to": "all",
"min_total": null,
"max_uses": null,
"can_combine": false,
"pos_only": false,
"starts": null,
"expires": null,
"added_at": null,
"added_by_id": null,
"sandbox": true
}
| Attribute | Required | Data Type |
|---|---|---|
| id | Yes | int |
| code | No | text (100) |
| type | No | enum (bookstore, application, form) |
| amount | No | decimal |
| percent | No | int |
| applies_to | No | enum (all, selected, shipping) |
| available_to | No | enum (all, roles) |
| min_total | No | decimal |
| max_uses | No | int |
| can_combine | Yes | bool |
| pos_only | Yes | bool |
| starts | No | datetime |
| expires | No | datetime |
| added_at | No | datetime |
| added_by_id | No | int |
| sandbox | No | bool |
index
Example code to call this method:
curl "https://yourschool.populiweb.com/api2/discountcodes" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_POPULI_API_KEY" \
-X GET
-d '{
"filter": {"0":{"logic":"ALL","fields":[{"name":"active","value":"YES","positive":1}]}}
}' \
require 'httparty'
response = HTTParty.get(
'https://yourschool.populiweb.com/api2/discountcodes',
headers: {
'Authorization' => 'Bearer YOUR_POPULI_API_KEY'
},
)
puts response.body
import requests
response = requests.get(
'https://yourschool.populiweb.com/api2/discountcodes',
headers={
'Authorization': 'Bearer YOUR_POPULI_API_KEY'
},
)
print(response.json())
using Newtonsoft.Json;
using RestSharp;
var client = new RestClient();
var request = new RestRequest(new Uri("https://yourschool.populiweb.com/api2/discountcodes"), Method.Get);
request.AddHeader("Authorization", "Bearer YOUR_POPULI_API_KEY");
var response = client.Execute(request);
var response_object = JsonConvert.DeserializeObject(response.Content);
Console.Write(response_object);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://yourschool.populiweb.com/api2/discountcodes');
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_POPULI_API_KEY']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
$response = curl_exec($curl);
$response_decoded = json_decode($response);
var_dump($response_decoded);
Example response:
{
"object": "list",
"count": 1,
"results": 1,
"results_per_page": 200,
"pages": 1,
"page": 1,
"offset": 0,
"has_more": false,
"data": [
{
"object": "discount_code",
"id": 1,
"code": "SUPERSALE!",
"type": "bookstore",
"amount": 0,
"percent": 30,
"applies_to": "all",
"available_to": "all",
"min_total": null,
"max_uses": null,
"can_combine": false,
"pos_only": false,
"starts": null,
"expires": null,
"added_at": null,
"added_by_id": null,
"report_data": {
"num_uses": 0
}
}
],
"sandbox": true
}
Retrieves all BookstoreDiscountCode objects that match given filter conditions.
HTTP Request
GET /discountcodes
Parameters
| Name | Required | Data Type | Description |
|---|---|---|---|
| filter | No | mixed | See available filter conditions |
| page | No | int | The page of results to return if more than 200 records are found. |
Filter Condition Parameters
These conditions can be used to narrow the results returned.
| Name | Type |
|---|---|
| active | bool |
| amount_off | decimal |
| applies_to | choice |
| available_to | choice |
| can_combine | bool |
| expires | datetime |
| max_uses | integer |
| minimum_order | decimal |
| percent_off | integer |
| uses | integer |
| valid_starting | datetime |
Permissions
One of the following roles is required to call this method:
- Campus Store Admin
- Financial Admin
show
Example code to call this method:
curl "https://yourschool.populiweb.com/api2/discountcodes/(bookstorediscountcode)" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_POPULI_API_KEY" \
-X GET
require 'httparty'
response = HTTParty.get(
'https://yourschool.populiweb.com/api2/discountcodes/(bookstorediscountcode)',
headers: {
'Authorization' => 'Bearer YOUR_POPULI_API_KEY'
},
)
puts response.body
import requests
response = requests.get(
'https://yourschool.populiweb.com/api2/discountcodes/(bookstorediscountcode)',
headers={
'Authorization': 'Bearer YOUR_POPULI_API_KEY'
},
)
print(response.json())
using Newtonsoft.Json;
using RestSharp;
var client = new RestClient();
var request = new RestRequest(new Uri("https://yourschool.populiweb.com/api2/discountcodes/(bookstorediscountcode)"), Method.Get);
request.AddHeader("Authorization", "Bearer YOUR_POPULI_API_KEY");
var response = client.Execute(request);
var response_object = JsonConvert.DeserializeObject(response.Content);
Console.Write(response_object);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://yourschool.populiweb.com/api2/discountcodes/(bookstorediscountcode)');
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_POPULI_API_KEY']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
$response = curl_exec($curl);
$response_decoded = json_decode($response);
var_dump($response_decoded);
Example response:
{
"object": "discount_code",
"id": 1,
"code": "SUPERSALE!",
"type": "bookstore",
"amount": 0,
"percent": 30,
"applies_to": "all",
"available_to": "all",
"min_total": null,
"max_uses": null,
"can_combine": false,
"pos_only": false,
"starts": null,
"expires": null,
"added_at": null,
"added_by_id": null,
"sandbox": true
}
Retrieves a specific BookstoreDiscountCode object.
HTTP Request
GET /discountcodes/(bookstorediscountcode)
Parameters
No additional parameters are needed beyond the ID of the object being requested that appears in the URL.
Permissions
One of the following roles is required to call this method:
- Campus Store Admin
- Financial Admin