The Genius Referrals API
npm install geniusreferralsnode --version
npm -version
npm install
node_modules folder.
GeniusReferrals in to your node_modules folder.
File and select Open Folder
Select Folder to open it up in Sublime Text. The folder will become visible in the bar on the left.
New File option to create a new test file. Save it as index.js Now import the generated NodeJS library using the following lines of code:
JavaScript
var lib = require('lib');
`
Save changes.
!Create new file
!Save new file
$3
To run the index.js file, open up the command prompt and navigate to the Path where the SDK folder resides. Type the following command to run the file:
node index.js
!Run file
How to Test
These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run.
Tests can be run in a number of ways:
$3
###### (Run all tests)
1. Navigate to the root directory of the SDK folder from command prompt.
2. Type mocha --recursive to run all the tests.
$3
###### (Run all tests)
1. Navigate to the ../test/Controllers/ directory from command prompt.
2. Type mocha * to run all the tests.
$3
###### (Run specific controller's tests)
1. Navigate to the ../test/Controllers/ directory from command prompt.
2. Type mocha Genius ReferralsController to run all the tests in that controller file.
> To increase mocha's default timeout, you can change the TESTTIMEOUT parameter's value in Configuration.js.
> NOTE: Changing default timeout is available for only Binary/File type endpoint tests
!Run Tests
Initialization
$3
In order to setup authentication and initialization of the API client, you need the following information.
| Parameter | Description |
|-----------|-------------|
| contentType | The content type |
| xAuthToken | Your API Token, you can get your token here https://www.geniusreferrals.com/en/settings/api-access |
API client can be initialized as following:
`JavaScript
// Configuration parameters and credentials
$contentType = "application/json"; // The content type
$xAuthToken = "3b9d11374b602fb47b987dff90f1c5940a1f377f"; // Your API Token, you can get your token here https://www.geniusreferrals.com/en/settings/api-access
var lib = require('lib');
`
Class Reference
$3
* RootsController
* AuthenticationsController
* AdvocatesController
* AccountsController
* ReportsController
* ReferralsController
* RedemptionRequestsController
* BonusesController
* CampaignsController
$3
#### Get singleton instance
The singleton instance of the ` RootsController ` class can be accessed from the API Client.
`javascript
var controller = lib.RootsController;
`
#### !Method: getRoot
> The root of the API
`javascript
function getRoot(callback)
`
#### Example Usage
`javascript
controller.getRoot(function(error, response, context) {
});
`
Back to List of Controllers
$3
#### Get singleton instance
The singleton instance of the ` AuthenticationsController ` class can be accessed from the API Client.
`javascript
var controller = lib.AuthenticationsController;
`
#### !Method: getAuthentication
> Allow clients to test authentication on Genius Referrals platform.
`javascript
function getAuthentication(callback)
`
#### Example Usage
`javascript
controller.getAuthentication(function(error, response, context) {
});
`
Back to List of Controllers
$3
#### Get singleton instance
The singleton instance of the ` AdvocatesController ` class can be accessed from the API Client.
`javascript
var controller = lib.AdvocatesController;
`
#### !Method: deleteAdvocate
> Delete an advocate
`javascript
function deleteAdvocate(accountSlug, advocateToken, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
controller.deleteAdvocate(accountSlug, advocateToken, function(error, response, context) {
});
`
#### !Method: putAdvocate
> Update an advocate.
`javascript
function putAdvocate(accountSlug, advocateToken, advocateForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| advocateForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var advocateForm = new AdvocateForm({"key":"value"});
controller.putAdvocate(accountSlug, advocateToken, advocateForm, function(error, response, context) {
});
`
#### !Method: postAdvocate
> Create a new advocate.
`javascript
function postAdvocate(accountSlug, advocateForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateForm = new AdvocateForm({"key":"value"});
controller.postAdvocate(accountSlug, advocateForm, function(error, response, context) {
});
`
#### !Method: getAdvocate
> Get an advocate by a given token.
`javascript
function getAdvocate(accountSlug, advocateToken, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
controller.getAdvocate(accountSlug, advocateToken, function(error, response, context) {
});
`
#### !Method: deleteAdvocates
> Delete all advocates
`javascript
function deleteAdvocates(accountSlug, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
#### Example Usage
`javascript
var accountSlug = account_slug;
controller.deleteAdvocates(accountSlug, function(error, response, context) {
});
`
#### !Method: getAdvocates
> Get the list of advocates
`javascript
function getAdvocates(accountSlug, page, limit, filter, sort, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| page | ` Optional ` ` DefaultValue ` | Page number, e.g. 1 would start at the first result, and 10 would start at the tenth result. |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10), threshold (100) |
| filter | ` Optional ` | Allowed fields: name, lastname, email, advocate_token, bonus_exchange_method_slug, campaign_slug, can_refer, is_referral, from, to, created. Use the following delimiters to build your filters params. The vertical bar ('\|') to separate individual filter phrases and a double colon ('::') to separate the names and values. The delimiter of the double colon (':') separates the property name from the comparison value, enabling the comparison value to contain spaces. Example: www.example.com/users?filter='name::todd\|city::denver\|title::grand poobah' |
| sort | ` Optional ` | Allowed fields: name, lastname, email, created. Use sort query-string parameter that contains a delimited set of property names. For each property name, sort in ascending order, and for each property prefixed with a dash ('-') sort in descending order. Separate each property name with a vertical bar ('\|'), which is consistent with the separation of the name\|value pairs in filtering, above. For example, if we want to retrieve users in order of their last name (ascending), first name (ascending) and hire date (descending), the request might look like this www.example.com/users?sort='last_name\|first_name\|-hire_date' |
#### Example Usage
`javascript
var accountSlug = account_slug;
var page = 64;
var limit = 64;
var filter = "filter";
var sort = "sort";
controller.getAdvocates(accountSlug, page, limit, filter, sort, function(error, response, context) {
});
`
#### !Method: patchAdvocate
> Update partial elements of an advocate.
`javascript
function patchAdvocate(accountSlug, advocateToken, advocatePatchForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| advocatePatchForm | ` Required ` ` Collection ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var advocatePatchForm = [{"key":"value"}].map(function(elem) {
return new Advocate Patch Form(elem);
});
controller.patchAdvocate(accountSlug, advocateToken, advocatePatchForm, function(error, response, context) {
});
`
#### !Method: getShareLinks
> Get the advocates share links. These are the links that advocates use to share your services online. Share links are wrapped per campaign and widget package.
`javascript
function getShareLinks(accountSlug, advocateToken, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
controller.getShareLinks(accountSlug, advocateToken, function(error, response, context) {
});
`
#### !Method: putPaymentMethod
> Update a payment method.
`javascript
function putPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodId, advocatePaymentMethodForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The advocate's token |
| advocateToken | ` Required ` | The advocate's token |
| advocatePaymentMethodId | ` Required ` | The payment method's identifier |
| advocatePaymentMethodForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var advocatePaymentMethodId = 64;
var advocatePaymentMethodForm = new PaymentMethodForm({"key":"value"});
controller.putPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodId, advocatePaymentMethodForm, function(error, response, context) {
});
`
#### !Method: getPaymentMethod
> Get an advocate's payment method
`javascript
function getPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodId, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| advocatePaymentMethodId | ` Required ` | The payment method's identifier |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var advocatePaymentMethodId = 64;
controller.getPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodId, function(error, response, context) {
});
`
#### !Method: postPaymentMethod
> Create a new payment method.
`javascript
function postPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| advocatePaymentMethodForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var advocatePaymentMethodForm = new PaymentMethodForm({"key":"value"});
controller.postPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodForm, function(error, response, context) {
});
`
#### !Method: getBonusRedemptionMethod
> Get bonuses redemption method.
`javascript
function getBonusRedemptionMethod(bonusesRedemptionMethodSlug, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| bonusesRedemptionMethodSlug | ` Required ` | The bonus redemption method's identifier |
#### Example Usage
`javascript
var bonusesRedemptionMethodSlug = bonuses_redemption_method_slug;
controller.getBonusRedemptionMethod(bonusesRedemptionMethodSlug, function(error, response, context) {
});
`
#### !Method: getBonusRedemptionMethods
> Get bonuses redemption methods.
`javascript
function getBonusRedemptionMethods(callback)
`
#### Example Usage
`javascript
controller.getBonusRedemptionMethods(function(error, response, context) {
});
`
#### !Method: getCurrencies
> Get currencies.
`javascript
function getCurrencies(callback)
`
#### Example Usage
`javascript
controller.getCurrencies(function(error, response, context) {
});
`
#### !Method: getCurrency
> Get a currency.
`javascript
function getCurrency(code, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| code | ` Required ` | The currency's code |
#### Example Usage
`javascript
var code = "code";
controller.getCurrency(code, function(error, response, context) {
});
`
#### !Method: getPaymentMethods
> Get the advocate's payment methods.
`javascript
function getPaymentMethods(accountSlug, advocateToken, page, limit, filter, sort, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| page | ` Optional ` ` DefaultValue ` | Page number, e.g. 1 would start at the first result, and 10 would start at the tenth result. |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10), threshold (100) |
| filter | ` Optional ` | Allowed fields: username, is_active. Use the following delimiters to build your filters params. The vertical bar ('\|') to separate individual filter phrases and a double colon ('::') to separate the names and values. The delimiter of the double colon (':') separates the property name from the comparison value, enabling the comparison value to contain spaces. Example: www.example.com/users?filter='name::todd\|city::denver\|title::grand poobah' |
| sort | ` Optional ` | Allowed fields: username, created. Use sort query-string parameter that contains a delimited set of property names. For each property name, sort in ascending order, and for each property prefixed with a dash ('-') sort in descending order. Separate each property name with a vertical bar ('\|'), which is consistent with the separation of the name\|value pairs in filtering, above. For example, if we want to retrieve users in order of their last name (ascending), first name (ascending) and hire date (descending), the request might look like this www.example.com/users?sort=last_name\|first_name\|-hire_date |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var page = 155;
var limit = 155;
var filter = "filter";
var sort = "sort";
controller.getPaymentMethods(accountSlug, advocateToken, page, limit, filter, sort, function(error, response, context) {
});
`
Back to List of Controllers
$3
#### Get singleton instance
The singleton instance of the ` AccountsController ` class can be accessed from the API Client.
`javascript
var controller = lib.AccountsController;
`
#### !Method: getAccount
> Get an account by a given slug.
`javascript
function getAccount(accountSlug, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
#### Example Usage
`javascript
var accountSlug = account_slug;
controller.getAccount(accountSlug, function(error, response, context) {
});
`
#### !Method: getAccounts
> Get the list of accounts.
`javascript
function getAccounts(page, limit, filter, sort, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| page | ` Optional ` ` DefaultValue ` | Page number, e.g. 1 would start at the first result, and 10 would start at the tenth result. |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10), threshold (100) |
| filter | ` Optional ` | Allowed fields: name. Use the following delimiters to build your filters params. The vertical bar ('\|') to separate individual filter phrases and a double colon ('::') to separate the names and values. The delimiter of the double colon (':') separates the property name from the comparison value, enabling the comparison value to contain spaces. Example: www.example.com/users?filter='name::todd\|city::denver\|title::grand poobah' |
| sort | ` Optional ` | Allowed fields: name, created. Use sort query-string parameter that contains a delimited set of property names. For each property name, sort in ascending order, and for each property prefixed with a dash ('-') sort in descending order. Separate each property name with a vertical bar ('\|'), which is consistent with the separation of the name\|value pairs in filtering, above. For example, if we want to retrieve users in order of their last name (ascending), first name (ascending) and hire date (descending), the request might look like this www.example.com/users?sort=last_name\|first_name\|-hire_date |
#### Example Usage
`javascript
var page = 155;
var limit = 155;
var filter = "filter";
var sort = "sort";
controller.getAccounts(page, limit, filter, sort, function(error, response, context) {
});
`
Back to List of Controllers
$3
#### Get singleton instance
The singleton instance of the ` ReportsController ` class can be accessed from the API Client.
`javascript
var controller = lib.ReportsController;
`
#### !Method: getReferralsSummaryPerOrigin
> Get referrals summary per referral origin.
`javascript
function getReferralsSummaryPerOrigin(advocateToken, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| advocateToken | ` Required ` | The advocate's token |
#### Example Usage
`javascript
var advocateToken = advocate_token;
controller.getReferralsSummaryPerOrigin(advocateToken, function(error, response, context) {
});
`
#### !Method: getBonusesSummaryPerOrigin
> Get bonuses summary per referral origin.
`javascript
function getBonusesSummaryPerOrigin(advocateToken, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| advocateToken | ` Required ` | The advocate's token |
#### Example Usage
`javascript
var advocateToken = advocate_token;
controller.getBonusesSummaryPerOrigin(advocateToken, function(error, response, context) {
});
`
#### !Method: getTopAdvocates
> Get top 10 advocates.
`javascript
function getTopAdvocates(accountSlug, campaignSlug, limit, from, to, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Optional ` | The account identifier |
| campaignSlug | ` Optional ` | The campaign identifier |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10) |
| from | ` Optional ` | The datetime were the range of the search starts |
| to | ` Optional ` | The datetime were the range of the search stops |
#### Example Usage
`javascript
var accountSlug = account_slug;
var campaignSlug = campaign_slug;
var limit = 155;
var from = date("D M d, Y G:i");
var to = date("D M d, Y G:i");
controller.getTopAdvocates(accountSlug, campaignSlug, limit, from, to, function(error, response, context) {
});
`
#### !Method: getShareDailyParticipation
> Get share daily participation.
`javascript
function getShareDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Optional ` | The account identifier |
| campaignSlug | ` Optional ` | The campaign identifier |
| advocateToken | ` Optional ` | The advocate's token |
| from | ` Optional ` | The datetime were the range of the search starts |
| to | ` Optional ` | The datetime were the range of the search stops |
#### Example Usage
`javascript
var accountSlug = account_slug;
var campaignSlug = campaign_slug;
var advocateToken = advocate_token;
var from = date("D M d, Y G:i");
var to = date("D M d, Y G:i");
controller.getShareDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, function(error, response, context) {
});
`
#### !Method: getReferralDailyParticipation
> Get referral daily participation.
`javascript
function getReferralDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Optional ` | The account identifier |
| campaignSlug | ` Optional ` | The campaign identifier |
| advocateToken | ` Optional ` | The advocate's token |
| from | ` Optional ` | The datetime were the range of the search starts |
| to | ` Optional ` | The datetime were the range of the search stops |
#### Example Usage
`javascript
var accountSlug = account_slug;
var campaignSlug = campaign_slug;
var advocateToken = advocate_token;
var from = date("D M d, Y G:i");
var to = date("D M d, Y G:i");
controller.getReferralDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, function(error, response, context) {
});
`
#### !Method: getClickDailyParticipation
> Get click daily participation.
`javascript
function getClickDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Optional ` | The account identifier |
| campaignSlug | ` Optional ` | The campaign identifier |
| advocateToken | ` Optional ` | The advocate's token |
| from | ` Optional ` | The datetime were the range of the search starts |
| to | ` Optional ` | The datetime were the range of the search stops |
#### Example Usage
`javascript
var accountSlug = account_slug;
var campaignSlug = campaign_slug;
var advocateToken = advocate_token;
var from = date("D M d, Y G:i");
var to = date("D M d, Y G:i");
controller.getClickDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, function(error, response, context) {
});
`
#### !Method: getBonusesDailyGiven
> Get bonuses daily given.
`javascript
function getBonusesDailyGiven(accountSlug, campaignSlug, advocateToken, from, to, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Optional ` | The account identifier |
| campaignSlug | ` Optional ` | The campaign identifier |
| advocateToken | ` Optional ` | The advocate identifier |
| from | ` Optional ` | The datetime were the range of the search starts |
| to | ` Optional ` | The datetime were the range of the search stops |
#### Example Usage
`javascript
var accountSlug = account_slug;
var campaignSlug = campaign_slug;
var advocateToken = advocate_token;
var from = date("D M d, Y G:i");
var to = date("D M d, Y G:i");
controller.getBonusesDailyGiven(accountSlug, campaignSlug, advocateToken, from, to, function(error, response, context) {
});
`
Back to List of Controllers
$3
#### Get singleton instance
The singleton instance of the ` ReferralsController ` class can be accessed from the API Client.
`javascript
var controller = lib.ReferralsController;
`
#### !Method: getReferralOrigin
> Get a referral origin by a given slug.
`javascript
function getReferralOrigin(referralOriginSlug, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| referralOriginSlug | ` Required ` | The referral origin identifier |
#### Example Usage
`javascript
var referralOriginSlug = referral_origin_slug;
controller.getReferralOrigin(referralOriginSlug, function(error, response, context) {
});
`
#### !Method: getReferralOrigins
> Get referral origins. This is needed when creating (POST) a new referral, as referral_origin_slug refers to one of this origins.
`javascript
function getReferralOrigins(callback)
`
#### Example Usage
`javascript
controller.getReferralOrigins(function(error, response, context) {
});
`
#### !Method: getReferral
> Get a referral by a given id.
`javascript
function getReferral(accountSlug, advocateToken, referralId, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| referralId | ` Required ` | The referral id |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var referralId = referral_id;
controller.getReferral(accountSlug, advocateToken, referralId, function(error, response, context) {
});
`
#### !Method: deleteReferral
> Delete a referral.
`javascript
function deleteReferral(accountSlug, advocateToken, referralId, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| referralId | ` Required ` | The referral identifier |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var referralId = referral_id;
controller.deleteReferral(accountSlug, advocateToken, referralId, function(error, response, context) {
});
`
#### !Method: postReferral
> Create a new referral.
`javascript
function postReferral(accountSlug, advocateToken, referralForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| referralForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var referralForm = new ReferralForm({"key":"value"});
controller.postReferral(accountSlug, advocateToken, referralForm, function(error, response, context) {
});
`
#### !Method: putReferral
> Update a referral.
`javascript
function putReferral(accountSlug, advocateToken, referralId, referralForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| referralId | ` Required ` | The referral id |
| referralForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var referralId = referral_id;
var referralForm = new ReferralForm({"key":"value"});
controller.putReferral(accountSlug, advocateToken, referralId, referralForm, function(error, response, context) {
});
`
#### !Method: getReferrals
> Get the list of referrals for a given advocate.
`javascript
function getReferrals(accountSlug, advocateToken, page, limit, filter, sort, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The advocate's token |
| page | ` Optional ` ` DefaultValue ` | Page number, e.g. 1 would start at the first result, and 10 would start at the tenth result. |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10), threshold (100) |
| filter | ` Optional ` | Allowed fields: url, referral_origin_slug, created. Use the following delimiters to build your filters params. Use the following delimiters to build your filters params. The vertical bar ('\|') to separate individual filter phrases and a double colon ('::') to separate the names and values. The delimiter of the double colon (':') separates the property name from the comparison value, enabling the comparison value to contain spaces. Example: www.example.com/users?filter='name::todd\|city::denver\|title::grand poobah' |
| sort | ` Optional ` | Allowed fields: created. Use sort query-string parameter that contains a delimited set of property names. For each property name, sort in ascending order, and for each property prefixed with a dash ('-') sort in descending order. Separate each property name with a vertical bar ('\|'), which is consistent with the separation of the name\|value pairs in filtering, above. For example, if we want to retrieve users in order of their last name (ascending), first name (ascending) and hire date (descending), the request might look like this www.example.com/users?sort='last_name\|first_name\|-hire_date' |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var page = 155;
var limit = 155;
var filter = "filter";
var sort = "sort";
controller.getReferrals(accountSlug, advocateToken, page, limit, filter, sort, function(error, response, context) {
});
`
Back to List of Controllers
$3
#### Get singleton instance
The singleton instance of the ` RedemptionRequestsController ` class can be accessed from the API Client.
`javascript
var controller = lib.RedemptionRequestsController;
`
#### !Method: getRedemptionRequestStatus
> Get a redemption request status.
`javascript
function getRedemptionRequestStatus(redemptionRequestStatusSlug, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| redemptionRequestStatusSlug | ` Required ` | The redemption request status identifier |
#### Example Usage
`javascript
var redemptionRequestStatusSlug = redemption_request_status_slug;
controller.getRedemptionRequestStatus(redemptionRequestStatusSlug, function(error, response, context) {
});
`
#### !Method: getRedemptionRequestStatuses
> Get redemption request statuses.
`javascript
function getRedemptionRequestStatuses(callback)
`
#### Example Usage
`javascript
controller.getRedemptionRequestStatuses(function(error, response, context) {
});
`
#### !Method: getRedemptionRequestAction
> Get a redemption request action.
`javascript
function getRedemptionRequestAction(redemptionRequestActionSlug, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| redemptionRequestActionSlug | ` Required ` | The redemption request action identifier |
#### Example Usage
`javascript
var redemptionRequestActionSlug = redemption_request_action_slug;
controller.getRedemptionRequestAction(redemptionRequestActionSlug, function(error, response, context) {
});
`
#### !Method: getRedemptionRequestActions
> Get redemption request actions.
`javascript
function getRedemptionRequestActions(callback)
`
#### Example Usage
`javascript
controller.getRedemptionRequestActions(function(error, response, context) {
});
`
#### !Method: patchRedemptionRequest
> Redeem a redemption request. After the redemption request is created it needs to be redeemed. This will deduct the amount of the advocate unclaimed balance and move the request to the completed state.
`javascript
function patchRedemptionRequest(accountSlug, redemptionRequestId, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| redemptionRequestId | ` Required ` | The redemption request id |
#### Example Usage
`javascript
var accountSlug = account_slug;
var redemptionRequestId = 247;
controller.patchRedemptionRequest(accountSlug, redemptionRequestId, function(error, response, context) {
});
`
#### !Method: postRedemptionRequest
> Create a redemption request.
`javascript
function postRedemptionRequest(accountSlug, redemptionRequestForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| redemptionRequestForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var redemptionRequestForm = new RedemptionRequestForm({"key":"value"});
controller.postRedemptionRequest(accountSlug, redemptionRequestForm, function(error, response, context) {
});
`
#### !Method: getRedemptionRequest
> Get a redemption request by a given id.
`javascript
function getRedemptionRequest(accountSlug, redemptionRequestId, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| redemptionRequestId | ` Required ` | The redemption request identifier |
#### Example Usage
`javascript
var accountSlug = account_slug;
var redemptionRequestId = redemption_request_id;
controller.getRedemptionRequest(accountSlug, redemptionRequestId, function(error, response, context) {
});
`
#### !Method: getRedemptionRequests
> Get the list of redemption requests.
`javascript
function getRedemptionRequests(accountSlug, page, limit, filter, sort, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| page | ` Optional ` ` DefaultValue ` | Page number, e.g. 1 would start at the first result, and 10 would start at the tenth result. |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10), threshold (100) |
| filter | ` Optional ` | Allowed fields: redemption_request_id, name, lastname, email, request_status_slug, request_action_slug, from, to, created. Use the following delimiters to build your filters params. The vertical bar ('\|') to separate individual filter phrases and a double colon ('::') to separate the names and values. The delimiter of the double colon (':') separates the property name from the comparison value, enabling the comparison value to contain spaces. Example: www.example.com/users?filter='name::todd\|city::denver\|title::grand poobah' |
| sort | ` Optional ` | Allowed fields: name, lastname, email, created. Use sort query-string parameter that contains a delimited set of property names. For each property name, sort in ascending order, and for each property prefixed with a dash ('-') sort in descending order. Separate each property name with a vertical bar ('\|'), which is consistent with the separation of the name\|value pairs in filtering, above. For example, if we want to retrieve users in order of their last name (ascending), first name (ascending) and hire date (descending), the request might look like this www.example.com/users?sort='last_name\|first_name\|-hire_date' |
#### Example Usage
`javascript
var accountSlug = account_slug;
var page = 247;
var limit = 247;
var filter = "filter";
var sort = "sort";
controller.getRedemptionRequests(accountSlug, page, limit, filter, sort, function(error, response, context) {
});
`
Back to List of Controllers
$3
#### Get singleton instance
The singleton instance of the ` BonusesController ` class can be accessed from the API Client.
`javascript
var controller = lib.BonusesController;
`
#### !Method: getBonuses
> Get the list of bonuses for a given account.
`javascript
function getBonuses(accountSlug, page, limit, filter, sort, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| page | ` Optional ` ` DefaultValue ` | Page number, e.g. 1 would start at the first result, and 10 would start at the tenth result. |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10), threshold (100) |
| filter | ` Optional ` | Allowed fields: name, lastname, email, campaign_slug, from, to, created. Use the following delimiters to build your filters params. The vertical bar ('\|') to separate individual filter phrases and a double colon ('::') to separate the names and values. The delimiter of the double colon (':') separates the property name from the comparison value, enabling the comparison value to contain spaces. Example: www.example.com/users?filter='name::todd\|city::denver\|title::grand poobah' |
| sort | ` Optional ` | Allowed fields: name, lastname, email, created. Use sort query-string parameter that contains a delimited set of property names. For each property name, sort in ascending order, and for each property prefixed with a dash ('-') sort in descending order. Separate each property name with a vertical bar ('\|'), which is consistent with the separation of the name\|value pairs in filtering, above. For example, if we want to retrieve users in order of their last name (ascending), first name (ascending) and hire date (descending), the request might look like this www.example.com/users?sort='last_name\|first_name\|-hire_date' |
#### Example Usage
`javascript
var accountSlug = account_slug;
var page = 247;
var limit = 247;
var filter = "filter";
var sort = "sort";
controller.getBonuses(accountSlug, page, limit, filter, sort, function(error, response, context) {
});
`
#### !Method: postBonus
> Make an attempt to give a bonus for to the advocate's referrer. The system processes the given advocate (referral) and creates a bonus for the advocate's referrer if is needed. All restrictions set on the campaigns for this account will be check out before giving the bonus to the advocate's referrer.
`javascript
function postBonus(accountSlug, bonusesForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| bonusesForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var bonusesForm = new BonusesForm({"key":"value"});
controller.postBonus(accountSlug, bonusesForm, function(error, response, context) {
});
`
#### !Method: getBonusCheckup
> Check if there is a bonus to be given to the advocate. Allows the clients to check if there is a bonus to be given, it simulates the behaivor of a POST request to /accounts/{account_slug}/bonuses resource. This resource is idempotent.
`javascript
function getBonusCheckup(accountSlug, advocateToken, reference, paymentAmount, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| advocateToken | ` Required ` | The referral's token. Usually the one that completed the purchase, or trigger an event. |
| reference | ` Required ` | The reference number for this request. Usually the order_id, payment_id, or timestamp. |
| paymentAmount | ` Required ` | The payment amount the referrals has made. Required for a percentage based campaign. |
#### Example Usage
`javascript
var accountSlug = account_slug;
var advocateToken = advocate_token;
var reference = "reference";
var paymentAmount = 247.051445675106;
TestHelper.getFileContents("url", function(data) {
controller.getBonusCheckup(accountSlug, advocateToken, reference, paymentAmount, function(error, response, context) {
});
});
`
#### !Method: postForceBonus
> Force the system to give a bonus to an advocate. The system will not take into account the restriccions specified on the campaigns.
`javascript
function postForceBonus(accountSlug, bonusForm, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| bonusForm | ` Required ` | The body of the request |
#### Example Usage
`javascript
var accountSlug = account_slug;
var bonusForm = new ForceBonusesForm({"key":"value"});
controller.postForceBonus(accountSlug, bonusForm, function(error, response, context) {
});
`
#### !Method: getBonusTrace
> Get a bonus request trace.
`javascript
function getBonusTrace(accountSlug, traceId, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| traceId | ` Required ` | The trace id |
#### Example Usage
`javascript
var accountSlug = account_slug;
var traceId = 247;
controller.getBonusTrace(accountSlug, traceId, function(error, response, context) {
});
`
#### !Method: deleteBonus
> Delete a bonus
`javascript
function deleteBonus(accountSlug, bonusId, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| bonusId | ` Required ` | The bonus id |
#### Example Usage
`javascript
var accountSlug = account_slug;
var bonusId = 247;
controller.deleteBonus(accountSlug, bonusId, function(error, response, context) {
});
`
#### !Method: getBonus
> Get a bonus by a given id.
`javascript
function getBonus(accountSlug, bonusId, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| bonusId | ` Required ` | The bonus id |
#### Example Usage
`javascript
var accountSlug = account_slug;
var bonusId = 247;
controller.getBonus(accountSlug, bonusId, function(error, response, context) {
});
`
#### !Method: getBonusTraces
> Get the list of bonuses traces (audit trail). Every time the system tries to give a bonus the an advocate a new trace is created.
`javascript
function getBonusTraces(accountSlug, page, limit, filter, sort, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| page | ` Optional ` ` DefaultValue ` | Page number, e.g. 1 would start at the first result, and 10 would start at the tenth result. |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10), threshold (100) |
| filter | ` Optional ` | Allowed fields: reference, result, bonus_amount, advocate_token, advocate_referrer_token, campaign_slug, from, to, created. Use the following delimiters to build your filters params. The vertical bar ('\|') to separate individual filter phrases and a double colon ('::') to separate the names and values. The delimiter of the double colon (':') separates the property name from the comparison value, enabling the comparison value to contain spaces. Example: www.example.com/users?filter='name::todd\|city::denver\|title::grand poobah' |
| sort | ` Optional ` | Allowed fields: created. Use sort query-string parameter that contains a delimited set of property names. For each property name, sort in ascending order, and for each property prefixed with a dash ('-') sort in descending order. Separate each property name with a vertical bar ('\|'), which is consistent with the separation of the name\|value pairs in filtering, above. For example, if we want to retrieve users in order of their last name (ascending), first name (ascending) and hire date (descending), the request might look like this www.example.com/users?sort='last_name\|first_name\|-hire_date' |
#### Example Usage
`javascript
var accountSlug = account_slug;
var page = 247;
var limit = 247;
var filter = "filter";
var sort = "sort";
controller.getBonusTraces(accountSlug, page, limit, filter, sort, function(error, response, context) {
});
`
Back to List of Controllers
$3
#### Get singleton instance
The singleton instance of the ` CampaignsController ` class can be accessed from the API Client.
`javascript
var controller = lib.CampaignsController;
`
#### !Method: getCampaign
> Get a campaign by a given slug.
`javascript
function getCampaign(accountSlug, campaignSlug, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| campaignSlug | ` Required ` | The campaign identifier |
#### Example Usage
`javascript
var accountSlug = account_slug;
var campaignSlug = campaign_slug;
controller.getCampaign(accountSlug, campaignSlug, function(error, response, context) {
});
`
#### !Method: getCampaigns
> Get the list of campaings for a given account.
`javascript
function getCampaigns(accountSlug, page, limit, filter, sort, callback)
`
#### Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | ` Required ` | The account identifier |
| page | ` Optional ` ` DefaultValue ` | Page number, e.g. 1 would start at the first result, and 10 would start at the tenth result. |
| limit | ` Optional ` ` DefaultValue ` | Maximum number of results to return in the response. Default (10), threshold (100) |
| filter | ` Optional ` | Allowed fields: name, description, start_date, end_date, is_active (true\|false), created. Use the following delimiters to build your filters params. The vertical bar ('\|') to separate individual filter phrases and a double colon ('::') to separate the names and values. The delimiter of the double colon (':') separates the property name from the comparison value, enabling the comparison value to contain spaces. Example: www.example.com/users?filter='name::todd\|city::denver\|title::grand poobah' |
| sort | ` Optional ` | Allowed fields: campaign_slug, created, start_date, end_date, is_active. Use sort query-string parameter that contains a delimited set of property names. For each property name, sort in ascending order, and for each property prefixed with a dash ('-') sort in descending order. Separate each property name with a vertical bar ('\|'), which is consistent with the separation of the name\|value pairs in filtering, above. For example, if we want to retrieve users in order of their last name (ascending), first name (ascending) and hire date (descending), the request might look like this www.example.com/users?sort='last_name\|first_name\|-hire_date' |
#### Example Usage
`javascript
var accountSlug = account_slug;
var page = 247;
var limit = 247;
var filter = "filter";
var sort = "sort";
controller.getCampaigns(accountSlug, page, limit, filter, sort, function(error, response, context) {
});
``