Coupon Class
This is a Simplify domain object. In order to get access to a domain object, a client needs to be created. The client is then used to invoke the different methods e.g.
var client = Simplify.getClient({
publicKey: 'YOUR_PUBLIC_API_KEY',
privateKey: 'YOUR_PRIVATE_API_KEY'
});
client.coupon.METHOD_NAME(params, function(error, data){
if(error){
// handle the error
}
// Awesome...no error, handle the data
});
Constructor
Coupon
-
appKeys
Parameters:
-
appKeys
ObjectObject containing the public & private API keys
Methods
create
-
params
-
callback
Function to create a Coupon object.
Parameters:
-
params
ObjectA map of parameters in which to create the Coupon from.
Valid parameters include:- amountOff : Amount off of the price of the product in the smallest units of the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00 [min value: 1]
- couponCode : Code that identifies the coupon to be used. [max length: 25, min length: 3] (REQUIRED)
- description : A brief section that describes the coupon. [max length: 1024]
- durationInMonths : DEPRECATED - Duration in months that the coupon will be applied after it has first been selected. [min value: 1, max value: 9999]
- endDate : Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
- maxRedemptions : Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1, max value: 10000]
- numTimesApplied : The number of times a coupon will be applied on a customer's subscription. [min value: 1, max value: 9999]
- percentOff : Percentage off of the price of the product. While this field is optional, you must provide either amountOff or percentOff for a coupon. The percent off is a whole number. [min value: 1, max value: 100]
- startDate : First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone. (REQUIRED)
NOTE: Any parameters with a sub-parameter (e.g. param.subParam) need to be nested when passed as an argument in e.g.{ param: { subParam1: 'value', subParam2: 'value' } }
-
callback
FunctionA function to handle success/error responses from the API.
The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.
delete
-
A
-
callback
Function to delete a Coupon object.
Parameters:
-
A
Objectstring ID of the Coupon to delete.
-
callback
FunctionA function to handle success/error responses from the API.
The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.
find
-
id
-
callback
Function to retrieve a Coupon object from the API.
Parameters:
-
id
StringThe ID of the Coupon to retrieve
-
callback
FunctionA function to handle success/error responses from the API.
The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.
list
-
params
-
callback
Function to retrieve a list Coupon objects.
Parameters:
-
params
ObjectA map of parameters in which to define the Coupon list from.
Valid parameters include:- filter :
filter.id Filter by the coupon Id filter.text Filter by the coupon code filter.dateCreatedMin Filter by the minimum created date you are searching for - Date in UTC millis filter.dateCreatedMax Filter by the maximum created date you are searching for - Date in UTC millis filter.startDateMin Filter by the minimum coupon start date you are searching for - Date in UTC millis filter.startDateMax Filter by the maximum coupon start date you are searching for - Date in UTC millis filter.endDateMin Filter by the minimum coupon end date you are searching for - Date in UTC millis filter.endDateMax Filter by the maximum coupon end date you are searching for - Date in UTC millis
*Use dateCreatedMin with dateCreatedMax in the same filter if you want to search between two created dates - max : Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
- offset : Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
- sorting : Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either 'asc' for ascending or 'desc' for descending).
Sortable properties are:- dateCreated
- maxRedemptions
- timesRedeemed
- id
- startDate
- endDate
- percentOff
- couponCode
- durationInMonths
- numTimesApplied
- amountOff
NOTE: Any parameters with a sub-parameter (e.g. param.subParam) need to be nested when passed as an argument in e.g.{ param: { subParam1: 'value', subParam2: 'value' } }
- filter :
-
callback
FunctionA function to handle success/error responses from the API.
The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.
update
-
params
-
callback
Function to update a Coupon object.
Parameters:
-
params
ObjectA map of parameters on which to update the Coupon object.
Valid parameters include:- id : A string ID of the Coupon object to update
- endDate : The ending date in UTC millis for the coupon. This must be after the starting date of the coupon.
- maxRedemptions : Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
NOTE: Any parameters with a sub-parameter (e.g. param.subParam) need to be nested when passed as an argument in e.g.{ param: { subParam1: 'value', subParam2: 'value' } }
-
callback
FunctionA function to handle success/error responses from the API.
The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.