Data Structures API


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.

API Blueprint

Coupons
Coupon

A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer.

Retrieve a Coupon

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.

REQUEST

Parameters
id id

The ID of the desired coupon.

RESPONSE

Headers
Content-Type application/json
200 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"
    },
    "redeem_by": {
      "type": "number"
    },
    "id": {
      "type": "string"
    },
    "created": {
      "type": "number"
    }
  },
  "required": [
    "id"
  ]
}
                    
Coupons

List all Coupons

Returns a list of your coupons.

REQUEST

Parameters
limit limit

A limit on the number of objects to be returned. Limit can range between 1 and 100 items.

RESPONSE

Headers
Content-Type application/json
200 application/json
                      [
  {
    "percent_off": 25,
    "redeem_by": 0,
    "id": "250FF",
    "created": 1415203908
  }
]
                    
                      {
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "array"
}
                    

Create a Coupon

Creates a new Coupon.

REQUEST

Headers
Content-Type application/json
application/json
                        {
  "percent_off": 25,
  "redeem_by": 0
}
                      
                        
                      

RESPONSE

Headers
Content-Type application/json
200 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"
    },
    "redeem_by": {
      "type": "number"
    },
    "id": {
      "type": "string"
    },
    "created": {
      "type": "number"
    }
  },
  "required": [
    "id"
  ]
}