Backend API
Coupon generations track the instances for which coupon codes are generated for a particular coupon. Each batch of generations is tied to an entry and is stored on the coupon model.
Fields
Unique identifier for the coupon codes generated.
An array of coupon codes to be generated.
Specifies the number of codes to be generated and limit for generations is 10,000. For example, count=100 would generate 100 coupon codes.
Date the coupon code is generated.
Date the coupon code was last updated.
Expandable link to the parent coupon.
Unique identifier of the parent coupon.
Specifies the code pattern for generated coupons.
Determines the pattern type for the codes generated, which can be either default or custom. Specify the pattern when using custom.
Possible enum values:
The coupon generation model
{
"complete": true,
"count": 1000,
"date_created": "2015-09-02T20:57:03.441Z",
"date_updated": "2015-09-02T20:57:20.033Z",
"parent_id": "559c5799bcb1de1d1c4821da",
"pattern": "TABATHA-{0000000}",
"pattern_type": "custom",
"id": "55e7629f5c0dfa1e3c2dd4c1"
},Create a new coupon generation.
Arguments
ID of the coupon generation.
The number of coupon codes generated in the generation. Minimum of 0 and maximum of 1000.
ID of the parent coupon.
Expandable link to the coupon code.
Indicates that the coupon code generation is complete.
Date and time the coupon generation was created.
Date and time the coupon generation was last updated.
Indicates if there was an error with the coupon code generation.
Expandable link to the parent coupon.
Specifies the code pattern for generated coupons.
Determines the pattern type for the codes generated, which can be either default or custom. Specify the pattern when using custom.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.post('/coupons:generations', {
pattern_type: default
count: 10
});The coupon generation model
{
"complete": true,
"count": 1000,
"date_created": "2015-09-02T20:57:03.441Z",
"date_updated": "2015-09-02T20:57:20.033Z",
"parent_id": "559c5799bcb1de1d1c4821da",
"pattern": "TABATHA-{0000000}",
"pattern_type": "custom",
"id": "55e7629f5c0dfa1e3c2dd4c1"
},Retrieve an existing coupon generation using the ID that was returned when created.
Arguments
The ID of the coupon generation to retrieve.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.get('/coupons:generations/{id}', {
id: '611e890866ceea71e6704d0e'
});The coupon generation model
{
"complete": true,
"count": 1000,
"date_created": "2015-09-02T20:57:03.441Z",
"date_updated": "2015-09-02T20:57:20.033Z",
"parent_id": "559c5799bcb1de1d1c4821da",
"pattern": "TABATHA-{0000000}",
"pattern_type": "custom",
"id": "55e7629f5c0dfa1e3c2dd4c1"
},Update an existing coupon generation using the ID that was returned when created.
Arguments
Unique identifier for the coupon generation.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.put('/coupons:generations/{id}', {
id: '611e890866ceea71e6704d0e',
count: 10
});The coupon generation model
{
"complete": true,
"count": 1000,
"date_created": "2015-09-02T20:57:03.441Z",
"date_updated": "2015-09-02T20:57:20.033Z",
"parent_id": "559c5799bcb1de1d1c4821da",
"pattern": "TABATHA-{0000000}",
"pattern_type": "custom",
"id": "55e7629f5c0dfa1e3c2dd4c1"
},Return a list of coupon generations.
Arguments
Expand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Returns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
Include one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.
The page number of results to return given the specified or default limit.
A text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
Expression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
An object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.get('/coupons:generations', {
});The coupon generation model
{
"complete": true,
"count": 1000,
"date_created": "2015-09-02T20:57:03.441Z",
"date_updated": "2015-09-02T20:57:20.033Z",
"parent_id": "559c5799bcb1de1d1c4821da",
"pattern": "TABATHA-{0000000}",
"pattern_type": "custom",
"id": "55e7629f5c0dfa1e3c2dd4c1"
},Delete a coupon generation permanently.
Arguments
The ID of the coupon generation to delete.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.delete('/coupons:generations/{id}', {
id: '611e890866ceea71e6704d0e'
});The coupon generation model
{
"complete": true,
"count": 1000,
"date_created": "2015-09-02T20:57:03.441Z",
"date_updated": "2015-09-02T20:57:20.033Z",
"parent_id": "559c5799bcb1de1d1c4821da",
"pattern": "TABATHA-{0000000}",
"pattern_type": "custom",
"id": "55e7629f5c0dfa1e3c2dd4c1"
},