Following Advanced Attributes, this example demonstrates defining arbitrary data structure to be reused by various attribute descriptions.
Since a portion of the Coupon
data structure is shared between the Coupon
definition itself and the Create a Coupon
action, it was separated into a
Coupon Base
data structure in the Data Structures
API Blueprint Section.
Doing so enables us to reuse it as a base-type of other attribute definitions.
A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer.
Retrieves the coupon with the given ID.
Parameters | |||
---|---|---|---|
id |
string
|
The ID of the desired coupon. |
Headers | |
---|---|
Content-Type | application/json |
application/json
{
"percent_off": 25,
"redeem_by": 0,
"id": "250FF",
"created": 1415203908
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"percent_off": {
"type": "number",
"description": "A positive integer between 1 and 100 that represents the discount the\ncoupon will apply."
},
"redeem_by": {
"type": "number",
"description": "Date after which the coupon can no longer be redeemed"
},
"id": {
"type": "string"
},
"created": {
"type": "number",
"description": "Time stamp"
}
},
"required": [
"id"
]
}
Returns a list of your coupons.
Parameters | |||
---|---|---|---|
limit |
number
Default
10 |
A limit on the number of objects to be returned. Limit can range between 1 and 100 items. |
Headers | |
---|---|
Content-Type | application/json |
application/json
[
{
"percent_off": 25,
"redeem_by": 0,
"id": "250FF",
"created": 1415203908
}
]
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array"
}
Creates a new Coupon.
Headers | |
---|---|
Content-Type | application/json |
application/json
{
"percent_off": 25,
"redeem_by": 0
}
Headers | |
---|---|
Content-Type | application/json |
application/json
{
"percent_off": 25,
"redeem_by": 0,
"id": "250FF",
"created": 1415203908
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"percent_off": {
"type": "number",
"description": "A positive integer between 1 and 100 that represents the discount the\ncoupon will apply."
},
"redeem_by": {
"type": "number",
"description": "Date after which the coupon can no longer be redeemed"
},
"id": {
"type": "string"
},
"created": {
"type": "number",
"description": "Time stamp"
}
},
"required": [
"id"
]
}