geniusreferrals
v1.0.1
Published
The Genius Referrals API
Downloads
9
Maintainers
Readme
Getting started
How to Build
The generated SDK relies on Node Package Manager (NPM) being available to resolve dependencies. If you don't already have NPM installed, please go ahead and follow instructions to install NPM from here. The SDK also requires Node to be installed. If Node isn't already installed, please install it from here
NPM is installed by default when Node is installed
To check if node and npm have been successfully installed, write the following commands in command prompt:
node --version
npm -version
Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):
npm install
This will install all dependencies in the node_modules
folder.
Once dependencies are resolved, you will need to move the folder GeniusReferrals
in to your node_modules
folder.
How to Use
The following section explains how to use the library in a new project.
1. Open Project Folder
Open an IDE/Text Editor for JavaScript like Sublime Text. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
Click on File
and select Open Folder
Select the folder of your SDK and click on Select Folder
to open it up in Sublime Text. The folder will become visible in the bar on the left.
2. Creating a Test File
Now right click on the folder name and select the 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:
var lib = require('lib');
Save changes.
3. Running The Test File
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
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:
Method 1
(Run all tests)
- Navigate to the root directory of the SDK folder from command prompt.
- Type
mocha --recursive
to run all the tests.
Method 2
(Run all tests)
- Navigate to the
../test/Controllers/
directory from command prompt. - Type
mocha *
to run all the tests.
Method 3
(Run specific controller's tests)
- Navigate to the
../test/Controllers/
directory from command prompt. - 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 inConfiguration.js
.
NOTE: Changing default timeout is available for only Binary/File type endpoint tests
Initialization
Authentication
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:
// 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
List of Controllers
- RootsController
- AuthenticationsController
- AdvocatesController
- AccountsController
- ReportsController
- ReferralsController
- RedemptionRequestsController
- BonusesController
- CampaignsController
RootsController
Get singleton instance
The singleton instance of the RootsController
class can be accessed from the API Client.
var controller = lib.RootsController;
getRoot
The root of the API
function getRoot(callback)
Example Usage
controller.getRoot(function(error, response, context) {
});
AuthenticationsController
Get singleton instance
The singleton instance of the AuthenticationsController
class can be accessed from the API Client.
var controller = lib.AuthenticationsController;
getAuthentication
Allow clients to test authentication on Genius Referrals platform.
function getAuthentication(callback)
Example Usage
controller.getAuthentication(function(error, response, context) {
});
AdvocatesController
Get singleton instance
The singleton instance of the AdvocatesController
class can be accessed from the API Client.
var controller = lib.AdvocatesController;
deleteAdvocate
Delete an advocate
function deleteAdvocate(accountSlug, advocateToken, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| advocateToken | Required
| The advocate's token |
Example Usage
var accountSlug = account_slug;
var advocateToken = advocate_token;
controller.deleteAdvocate(accountSlug, advocateToken, function(error, response, context) {
});
putAdvocate
Update an advocate.
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
var accountSlug = account_slug;
var advocateToken = advocate_token;
var advocateForm = new AdvocateForm({"key":"value"});
controller.putAdvocate(accountSlug, advocateToken, advocateForm, function(error, response, context) {
});
postAdvocate
Create a new advocate.
function postAdvocate(accountSlug, advocateForm, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| advocateForm | Required
| The body of the request |
Example Usage
var accountSlug = account_slug;
var advocateForm = new AdvocateForm({"key":"value"});
controller.postAdvocate(accountSlug, advocateForm, function(error, response, context) {
});
getAdvocate
Get an advocate by a given token.
function getAdvocate(accountSlug, advocateToken, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| advocateToken | Required
| The advocate's token |
Example Usage
var accountSlug = account_slug;
var advocateToken = advocate_token;
controller.getAdvocate(accountSlug, advocateToken, function(error, response, context) {
});
deleteAdvocates
Delete all advocates
function deleteAdvocates(accountSlug, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
Example Usage
var accountSlug = account_slug;
controller.deleteAdvocates(accountSlug, function(error, response, context) {
});
getAdvocates
Get the list of advocates
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
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) {
});
patchAdvocate
Update partial elements of an advocate.
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
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) {
});
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.
function getShareLinks(accountSlug, advocateToken, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| advocateToken | Required
| The advocate's token |
Example Usage
var accountSlug = account_slug;
var advocateToken = advocate_token;
controller.getShareLinks(accountSlug, advocateToken, function(error, response, context) {
});
putPaymentMethod
Update a payment method.
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
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) {
});
getPaymentMethod
Get an advocate's payment method
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
var accountSlug = account_slug;
var advocateToken = advocate_token;
var advocatePaymentMethodId = 64;
controller.getPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodId, function(error, response, context) {
});
postPaymentMethod
Create a new payment method.
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
var accountSlug = account_slug;
var advocateToken = advocate_token;
var advocatePaymentMethodForm = new PaymentMethodForm({"key":"value"});
controller.postPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodForm, function(error, response, context) {
});
getBonusRedemptionMethod
Get bonuses redemption method.
function getBonusRedemptionMethod(bonusesRedemptionMethodSlug, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| bonusesRedemptionMethodSlug | Required
| The bonus redemption method's identifier |
Example Usage
var bonusesRedemptionMethodSlug = bonuses_redemption_method_slug;
controller.getBonusRedemptionMethod(bonusesRedemptionMethodSlug, function(error, response, context) {
});
getBonusRedemptionMethods
Get bonuses redemption methods.
function getBonusRedemptionMethods(callback)
Example Usage
controller.getBonusRedemptionMethods(function(error, response, context) {
});
getCurrencies
Get currencies.
function getCurrencies(callback)
Example Usage
controller.getCurrencies(function(error, response, context) {
});
getCurrency
Get a currency.
function getCurrency(code, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| code | Required
| The currency's code |
Example Usage
var code = "code";
controller.getCurrency(code, function(error, response, context) {
});
getPaymentMethods
Get the advocate's payment methods.
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
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) {
});
AccountsController
Get singleton instance
The singleton instance of the AccountsController
class can be accessed from the API Client.
var controller = lib.AccountsController;
getAccount
Get an account by a given slug.
function getAccount(accountSlug, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
Example Usage
var accountSlug = account_slug;
controller.getAccount(accountSlug, function(error, response, context) {
});
getAccounts
Get the list of accounts.
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
var page = 155;
var limit = 155;
var filter = "filter";
var sort = "sort";
controller.getAccounts(page, limit, filter, sort, function(error, response, context) {
});
ReportsController
Get singleton instance
The singleton instance of the ReportsController
class can be accessed from the API Client.
var controller = lib.ReportsController;
getReferralsSummaryPerOrigin
Get referrals summary per referral origin.
function getReferralsSummaryPerOrigin(advocateToken, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| advocateToken | Required
| The advocate's token |
Example Usage
var advocateToken = advocate_token;
controller.getReferralsSummaryPerOrigin(advocateToken, function(error, response, context) {
});
getBonusesSummaryPerOrigin
Get bonuses summary per referral origin.
function getBonusesSummaryPerOrigin(advocateToken, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| advocateToken | Required
| The advocate's token |
Example Usage
var advocateToken = advocate_token;
controller.getBonusesSummaryPerOrigin(advocateToken, function(error, response, context) {
});
getTopAdvocates
Get top 10 advocates.
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
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) {
});
getShareDailyParticipation
Get share daily participation.
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
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) {
});
getReferralDailyParticipation
Get referral daily participation.
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
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) {
});
getClickDailyParticipation
Get click daily participation.
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
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) {
});
getBonusesDailyGiven
Get bonuses daily given.
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
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) {
});
ReferralsController
Get singleton instance
The singleton instance of the ReferralsController
class can be accessed from the API Client.
var controller = lib.ReferralsController;
getReferralOrigin
Get a referral origin by a given slug.
function getReferralOrigin(referralOriginSlug, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| referralOriginSlug | Required
| The referral origin identifier |
Example Usage
var referralOriginSlug = referral_origin_slug;
controller.getReferralOrigin(referralOriginSlug, function(error, response, context) {
});
getReferralOrigins
Get referral origins. This is needed when creating (POST) a new referral, as referral_origin_slug refers to one of this origins.
function getReferralOrigins(callback)
Example Usage
controller.getReferralOrigins(function(error, response, context) {
});
getReferral
Get a referral by a given id.
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
var accountSlug = account_slug;
var advocateToken = advocate_token;
var referralId = referral_id;
controller.getReferral(accountSlug, advocateToken, referralId, function(error, response, context) {
});
deleteReferral
Delete a referral.
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
var accountSlug = account_slug;
var advocateToken = advocate_token;
var referralId = referral_id;
controller.deleteReferral(accountSlug, advocateToken, referralId, function(error, response, context) {
});
postReferral
Create a new referral.
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
var accountSlug = account_slug;
var advocateToken = advocate_token;
var referralForm = new ReferralForm({"key":"value"});
controller.postReferral(accountSlug, advocateToken, referralForm, function(error, response, context) {
});
putReferral
Update a referral.
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
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) {
});
getReferrals
Get the list of referrals for a given advocate.
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
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) {
});
RedemptionRequestsController
Get singleton instance
The singleton instance of the RedemptionRequestsController
class can be accessed from the API Client.
var controller = lib.RedemptionRequestsController;
getRedemptionRequestStatus
Get a redemption request status.
function getRedemptionRequestStatus(redemptionRequestStatusSlug, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| redemptionRequestStatusSlug | Required
| The redemption request status identifier |
Example Usage
var redemptionRequestStatusSlug = redemption_request_status_slug;
controller.getRedemptionRequestStatus(redemptionRequestStatusSlug, function(error, response, context) {
});
getRedemptionRequestStatuses
Get redemption request statuses.
function getRedemptionRequestStatuses(callback)
Example Usage
controller.getRedemptionRequestStatuses(function(error, response, context) {
});
getRedemptionRequestAction
Get a redemption request action.
function getRedemptionRequestAction(redemptionRequestActionSlug, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| redemptionRequestActionSlug | Required
| The redemption request action identifier |
Example Usage
var redemptionRequestActionSlug = redemption_request_action_slug;
controller.getRedemptionRequestAction(redemptionRequestActionSlug, function(error, response, context) {
});
getRedemptionRequestActions
Get redemption request actions.
function getRedemptionRequestActions(callback)
Example Usage
controller.getRedemptionRequestActions(function(error, response, context) {
});
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.
function patchRedemptionRequest(accountSlug, redemptionRequestId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| redemptionRequestId | Required
| The redemption request id |
Example Usage
var accountSlug = account_slug;
var redemptionRequestId = 247;
controller.patchRedemptionRequest(accountSlug, redemptionRequestId, function(error, response, context) {
});
postRedemptionRequest
Create a redemption request.
function postRedemptionRequest(accountSlug, redemptionRequestForm, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| redemptionRequestForm | Required
| The body of the request |
Example Usage
var accountSlug = account_slug;
var redemptionRequestForm = new RedemptionRequestForm({"key":"value"});
controller.postRedemptionRequest(accountSlug, redemptionRequestForm, function(error, response, context) {
});
getRedemptionRequest
Get a redemption request by a given id.
function getRedemptionRequest(accountSlug, redemptionRequestId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| redemptionRequestId | Required
| The redemption request identifier |
Example Usage
var accountSlug = account_slug;
var redemptionRequestId = redemption_request_id;
controller.getRedemptionRequest(accountSlug, redemptionRequestId, function(error, response, context) {
});
getRedemptionRequests
Get the list of redemption requests.
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
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) {
});
BonusesController
Get singleton instance
The singleton instance of the BonusesController
class can be accessed from the API Client.
var controller = lib.BonusesController;
getBonuses
Get the list of bonuses for a given account.
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
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) {
});
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.
function postBonus(accountSlug, bonusesForm, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| bonusesForm | Required
| The body of the request |
Example Usage
var accountSlug = account_slug;
var bonusesForm = new BonusesForm({"key":"value"});
controller.postBonus(accountSlug, bonusesForm, function(error, response, context) {
});
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.
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
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) {
});
});
postForceBonus
Force the system to give a bonus to an advocate. The system will not take into account the restriccions specified on the campaigns.
function postForceBonus(accountSlug, bonusForm, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| bonusForm | Required
| The body of the request |
Example Usage
var accountSlug = account_slug;
var bonusForm = new ForceBonusesForm({"key":"value"});
controller.postForceBonus(accountSlug, bonusForm, function(error, response, context) {
});
getBonusTrace
Get a bonus request trace.
function getBonusTrace(accountSlug, traceId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| traceId | Required
| The trace id |
Example Usage
var accountSlug = account_slug;
var traceId = 247;
controller.getBonusTrace(accountSlug, traceId, function(error, response, context) {
});
deleteBonus
Delete a bonus
function deleteBonus(accountSlug, bonusId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| bonusId | Required
| The bonus id |
Example Usage
var accountSlug = account_slug;
var bonusId = 247;
controller.deleteBonus(accountSlug, bonusId, function(error, response, context) {
});
getBonus
Get a bonus by a given id.
function getBonus(accountSlug, bonusId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| bonusId | Required
| The bonus id |
Example Usage
var accountSlug = account_slug;
var bonusId = 247;
controller.getBonus(accountSlug, bonusId, function(error, response, context) {
});
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.
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
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) {
});
CampaignsController
Get singleton instance
The singleton instance of the CampaignsController
class can be accessed from the API Client.
var controller = lib.CampaignsController;
getCampaign
Get a campaign by a given slug.
function getCampaign(accountSlug, campaignSlug, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| accountSlug | Required
| The account identifier |
| campaignSlug | Required
| The campaign identifier |
Example Usage
var accountSlug = account_slug;
var campaignSlug = campaign_slug;
controller.getCampaign(accountSlug, campaignSlug, function(error, response, context) {
});
getCampaigns
Get the list of campaings for a given account.
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
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) {
});