1.0.1 • Published 7 years ago

geniusreferrals v1.0.1

Weekly downloads
34
License
-
Repository
-
Last release
7 years ago

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 Version Check

Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):

  • npm install Resolve Dependencies Resolve Dependencies

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 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. Open Project

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.

Create new file Save new file

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 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:

Method 1

(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.

Method 2

(Run all tests)
  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha * to run all the tests.

Method 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

Authentication

In order to setup authentication and initialization of the API client, you need the following information.

ParameterDescription
contentTypeThe content type
xAuthTokenYour 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

Class: RootsController

Get singleton instance

The singleton instance of the RootsController class can be accessed from the API Client.

var controller = lib.RootsController;

Method: getRoot

The root of the API

function getRoot(callback)

Example Usage

    controller.getRoot(function(error, response, context) {

    
	});

Back to List of Controllers

Class: AuthenticationsController

Get singleton instance

The singleton instance of the AuthenticationsController class can be accessed from the API Client.

var controller = lib.AuthenticationsController;

Method: getAuthentication

Allow clients to test authentication on Genius Referrals platform.

function getAuthentication(callback)

Example Usage

    controller.getAuthentication(function(error, response, context) {

    
	});

Back to List of Controllers

Class: AdvocatesController

Get singleton instance

The singleton instance of the AdvocatesController class can be accessed from the API Client.

var controller = lib.AdvocatesController;

Method: deleteAdvocate

Delete an advocate

function deleteAdvocate(accountSlug, advocateToken, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token

Example Usage

    var accountSlug = account_slug;
    var advocateToken = advocate_token;

    controller.deleteAdvocate(accountSlug, advocateToken, function(error, response, context) {

    
	});

Method: putAdvocate

Update an advocate.

function putAdvocate(accountSlug, advocateToken, advocateForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
advocateFormRequiredThe 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) {

    
	});

Method: postAdvocate

Create a new advocate.

function postAdvocate(accountSlug, advocateForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateFormRequiredThe body of the request

Example Usage

    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.

function getAdvocate(accountSlug, advocateToken, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token

Example Usage

    var accountSlug = account_slug;
    var advocateToken = advocate_token;

    controller.getAdvocate(accountSlug, advocateToken, function(error, response, context) {

    
	});

Method: deleteAdvocates

Delete all advocates

function deleteAdvocates(accountSlug, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier

Example Usage

    var accountSlug = account_slug;

    controller.deleteAdvocates(accountSlug, function(error, response, context) {

    
	});

Method: getAdvocates

Get the list of advocates

function getAdvocates(accountSlug, page, limit, filter, sort, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
pageOptional DefaultValuePage number, e.g. 1 would start at the first result, and 10 would start at the tenth result.
limitOptional DefaultValueMaximum number of results to return in the response. Default (10), threshold (100)
filterOptionalAllowed 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'
sortOptionalAllowed 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) {

    
	});

Method: patchAdvocate

Update partial elements of an advocate.

function patchAdvocate(accountSlug, advocateToken, advocatePatchForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
advocatePatchFormRequired CollectionThe 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) {

    
	});

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.

function getShareLinks(accountSlug, advocateToken, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token

Example Usage

    var accountSlug = account_slug;
    var advocateToken = advocate_token;

    controller.getShareLinks(accountSlug, advocateToken, function(error, response, context) {

    
	});

Method: putPaymentMethod

Update a payment method.

function putPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodId, advocatePaymentMethodForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe advocate's token
advocateTokenRequiredThe advocate's token
advocatePaymentMethodIdRequiredThe payment method's identifier
advocatePaymentMethodFormRequiredThe 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) {

    
	});

Method: getPaymentMethod

Get an advocate's payment method

function getPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodId, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
advocatePaymentMethodIdRequiredThe 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) {

    
	});

Method: postPaymentMethod

Create a new payment method.

function postPaymentMethod(accountSlug, advocateToken, advocatePaymentMethodForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
advocatePaymentMethodFormRequiredThe 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) {

    
	});

Method: getBonusRedemptionMethod

Get bonuses redemption method.

function getBonusRedemptionMethod(bonusesRedemptionMethodSlug, callback)

Parameters

ParameterTagsDescription
bonusesRedemptionMethodSlugRequiredThe bonus redemption method's identifier

Example Usage

    var bonusesRedemptionMethodSlug = bonuses_redemption_method_slug;

    controller.getBonusRedemptionMethod(bonusesRedemptionMethodSlug, function(error, response, context) {

    
	});

Method: getBonusRedemptionMethods

Get bonuses redemption methods.

function getBonusRedemptionMethods(callback)

Example Usage

    controller.getBonusRedemptionMethods(function(error, response, context) {

    
	});

Method: getCurrencies

Get currencies.

function getCurrencies(callback)

Example Usage

    controller.getCurrencies(function(error, response, context) {

    
	});

Method: getCurrency

Get a currency.

function getCurrency(code, callback)

Parameters

ParameterTagsDescription
codeRequiredThe currency's code

Example Usage

    var code = "code";

    controller.getCurrency(code, function(error, response, context) {

    
	});

Method: getPaymentMethods

Get the advocate's payment methods.

function getPaymentMethods(accountSlug, advocateToken, page, limit, filter, sort, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
pageOptional DefaultValuePage number, e.g. 1 would start at the first result, and 10 would start at the tenth result.
limitOptional DefaultValueMaximum number of results to return in the response. Default (10), threshold (100)
filterOptionalAllowed 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'
sortOptionalAllowed 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) {

    
	});

Back to List of Controllers

Class: AccountsController

Get singleton instance

The singleton instance of the AccountsController class can be accessed from the API Client.

var controller = lib.AccountsController;

Method: getAccount

Get an account by a given slug.

function getAccount(accountSlug, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier

Example Usage

    var accountSlug = account_slug;

    controller.getAccount(accountSlug, function(error, response, context) {

    
	});

Method: getAccounts

Get the list of accounts.

function getAccounts(page, limit, filter, sort, callback)

Parameters

ParameterTagsDescription
pageOptional DefaultValuePage number, e.g. 1 would start at the first result, and 10 would start at the tenth result.
limitOptional DefaultValueMaximum number of results to return in the response. Default (10), threshold (100)
filterOptionalAllowed 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'
sortOptionalAllowed 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) {

    
	});

Back to List of Controllers

Class: ReportsController

Get singleton instance

The singleton instance of the ReportsController class can be accessed from the API Client.

var controller = lib.ReportsController;

Method: getReferralsSummaryPerOrigin

Get referrals summary per referral origin.

function getReferralsSummaryPerOrigin(advocateToken, callback)

Parameters

ParameterTagsDescription
advocateTokenRequiredThe advocate's token

Example Usage

    var advocateToken = advocate_token;

    controller.getReferralsSummaryPerOrigin(advocateToken, function(error, response, context) {

    
	});

Method: getBonusesSummaryPerOrigin

Get bonuses summary per referral origin.

function getBonusesSummaryPerOrigin(advocateToken, callback)

Parameters

ParameterTagsDescription
advocateTokenRequiredThe advocate's token

Example Usage

    var advocateToken = advocate_token;

    controller.getBonusesSummaryPerOrigin(advocateToken, function(error, response, context) {

    
	});

Method: getTopAdvocates

Get top 10 advocates.

function getTopAdvocates(accountSlug, campaignSlug, limit, from, to, callback)

Parameters

ParameterTagsDescription
accountSlugOptionalThe account identifier
campaignSlugOptionalThe campaign identifier
limitOptional DefaultValueMaximum number of results to return in the response. Default (10)
fromOptionalThe datetime were the range of the search starts
toOptionalThe 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) {

    
	});

Method: getShareDailyParticipation

Get share daily participation.

function getShareDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, callback)

Parameters

ParameterTagsDescription
accountSlugOptionalThe account identifier
campaignSlugOptionalThe campaign identifier
advocateTokenOptionalThe advocate's token
fromOptionalThe datetime were the range of the search starts
toOptionalThe 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) {

    
	});

Method: getReferralDailyParticipation

Get referral daily participation.

function getReferralDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, callback)

Parameters

ParameterTagsDescription
accountSlugOptionalThe account identifier
campaignSlugOptionalThe campaign identifier
advocateTokenOptionalThe advocate's token
fromOptionalThe datetime were the range of the search starts
toOptionalThe 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) {

    
	});

Method: getClickDailyParticipation

Get click daily participation.

function getClickDailyParticipation(accountSlug, campaignSlug, advocateToken, from, to, callback)

Parameters

ParameterTagsDescription
accountSlugOptionalThe account identifier
campaignSlugOptionalThe campaign identifier
advocateTokenOptionalThe advocate's token
fromOptionalThe datetime were the range of the search starts
toOptionalThe 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) {

    
	});

Method: getBonusesDailyGiven

Get bonuses daily given.

function getBonusesDailyGiven(accountSlug, campaignSlug, advocateToken, from, to, callback)

Parameters

ParameterTagsDescription
accountSlugOptionalThe account identifier
campaignSlugOptionalThe campaign identifier
advocateTokenOptionalThe advocate identifier
fromOptionalThe datetime were the range of the search starts
toOptionalThe 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) {

    
	});

Back to List of Controllers

Class: ReferralsController

Get singleton instance

The singleton instance of the ReferralsController class can be accessed from the API Client.

var controller = lib.ReferralsController;

Method: getReferralOrigin

Get a referral origin by a given slug.

function getReferralOrigin(referralOriginSlug, callback)

Parameters

ParameterTagsDescription
referralOriginSlugRequiredThe referral origin identifier

Example Usage

    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.

function getReferralOrigins(callback)

Example Usage

    controller.getReferralOrigins(function(error, response, context) {

    
	});

Method: getReferral

Get a referral by a given id.

function getReferral(accountSlug, advocateToken, referralId, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
referralIdRequiredThe 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) {

    
	});

Method: deleteReferral

Delete a referral.

function deleteReferral(accountSlug, advocateToken, referralId, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
referralIdRequiredThe 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) {

    
	});

Method: postReferral

Create a new referral.

function postReferral(accountSlug, advocateToken, referralForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
referralFormRequiredThe 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) {

    
	});

Method: putReferral

Update a referral.

function putReferral(accountSlug, advocateToken, referralId, referralForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
referralIdRequiredThe referral id
referralFormRequiredThe 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) {

    
	});

Method: getReferrals

Get the list of referrals for a given advocate.

function getReferrals(accountSlug, advocateToken, page, limit, filter, sort, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe advocate's token
pageOptional DefaultValuePage number, e.g. 1 would start at the first result, and 10 would start at the tenth result.
limitOptional DefaultValueMaximum number of results to return in the response. Default (10), threshold (100)
filterOptionalAllowed 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'
sortOptionalAllowed 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) {

    
	});

Back to List of Controllers

Class: RedemptionRequestsController

Get singleton instance

The singleton instance of the RedemptionRequestsController class can be accessed from the API Client.

var controller = lib.RedemptionRequestsController;

Method: getRedemptionRequestStatus

Get a redemption request status.

function getRedemptionRequestStatus(redemptionRequestStatusSlug, callback)

Parameters

ParameterTagsDescription
redemptionRequestStatusSlugRequiredThe redemption request status identifier

Example Usage

    var redemptionRequestStatusSlug = redemption_request_status_slug;

    controller.getRedemptionRequestStatus(redemptionRequestStatusSlug, function(error, response, context) {

    
	});

Method: getRedemptionRequestStatuses

Get redemption request statuses.

function getRedemptionRequestStatuses(callback)

Example Usage

    controller.getRedemptionRequestStatuses(function(error, response, context) {

    
	});

Method: getRedemptionRequestAction

Get a redemption request action.

function getRedemptionRequestAction(redemptionRequestActionSlug, callback)

Parameters

ParameterTagsDescription
redemptionRequestActionSlugRequiredThe redemption request action identifier

Example Usage

    var redemptionRequestActionSlug = redemption_request_action_slug;

    controller.getRedemptionRequestAction(redemptionRequestActionSlug, function(error, response, context) {

    
	});

Method: getRedemptionRequestActions

Get redemption request actions.

function getRedemptionRequestActions(callback)

Example Usage

    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.

function patchRedemptionRequest(accountSlug, redemptionRequestId, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
redemptionRequestIdRequiredThe redemption request id

Example Usage

    var accountSlug = account_slug;
    var redemptionRequestId = 247;

    controller.patchRedemptionRequest(accountSlug, redemptionRequestId, function(error, response, context) {

    
	});

Method: postRedemptionRequest

Create a redemption request.

function postRedemptionRequest(accountSlug, redemptionRequestForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
redemptionRequestFormRequiredThe body of the request

Example Usage

    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.

function getRedemptionRequest(accountSlug, redemptionRequestId, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
redemptionRequestIdRequiredThe redemption request identifier

Example Usage

    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.

function getRedemptionRequests(accountSlug, page, limit, filter, sort, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
pageOptional DefaultValuePage number, e.g. 1 would start at the first result, and 10 would start at the tenth result.
limitOptional DefaultValueMaximum number of results to return in the response. Default (10), threshold (100)
filterOptionalAllowed 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'
sortOptionalAllowed 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) {

    
	});

Back to List of Controllers

Class: BonusesController

Get singleton instance

The singleton instance of the BonusesController class can be accessed from the API Client.

var controller = lib.BonusesController;

Method: getBonuses

Get the list of bonuses for a given account.

function getBonuses(accountSlug, page, limit, filter, sort, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
pageOptional DefaultValuePage number, e.g. 1 would start at the first result, and 10 would start at the tenth result.
limitOptional DefaultValueMaximum number of results to return in the response. Default (10), threshold (100)
filterOptionalAllowed 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'
sortOptionalAllowed 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) {

    
	});

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.

function postBonus(accountSlug, bonusesForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
bonusesFormRequiredThe body of the request

Example Usage

    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.

function getBonusCheckup(accountSlug, advocateToken, reference, paymentAmount, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
advocateTokenRequiredThe referral's token. Usually the one that completed the purchase, or trigger an event.
referenceRequiredThe reference number for this request. Usually the order_id, payment_id, or timestamp.
paymentAmountRequiredThe 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) {

        });
	});

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.

function postForceBonus(accountSlug, bonusForm, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
bonusFormRequiredThe body of the request

Example Usage

    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.

function getBonusTrace(accountSlug, traceId, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
traceIdRequiredThe trace id

Example Usage

    var accountSlug = account_slug;
    var traceId = 247;

    controller.getBonusTrace(accountSlug, traceId, function(error, response, context) {

    
	});

Method: deleteBonus

Delete a bonus

function deleteBonus(accountSlug, bonusId, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
bonusIdRequiredThe bonus id

Example Usage

    var accountSlug = account_slug;
    var bonusId = 247;

    controller.deleteBonus(accountSlug, bonusId, function(error, response, context) {

    
	});

Method: getBonus

Get a bonus by a given id.

function getBonus(accountSlug, bonusId, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
bonusIdRequiredThe bonus id

Example Usage

    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.

function getBonusTraces(accountSlug, page, limit, filter, sort, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
pageOptional DefaultValuePage number, e.g. 1 would start at the first result, and 10 would start at the tenth result.
limitOptional DefaultValueMaximum number of results to return in the response. Default (10), threshold (100)
filterOptionalAllowed 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'
sortOptionalAllowed 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) {

    
	});

Back to List of Controllers

Class: CampaignsController

Get singleton instance

The singleton instance of the CampaignsController class can be accessed from the API Client.

var controller = lib.CampaignsController;

Method: getCampaign

Get a campaign by a given slug.

function getCampaign(accountSlug, campaignSlug, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
campaignSlugRequiredThe campaign identifier

Example Usage

    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.

function getCampaigns(accountSlug, page, limit, filter, sort, callback)

Parameters

ParameterTagsDescription
accountSlugRequiredThe account identifier
pageOptional DefaultValuePage number, e.g. 1 would start at the first result, and 10 would start at the tenth result.
limitOptional DefaultValueMaximum number of results to return in the response. Default (10), threshold (100)
filterOptionalAllowed 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'
sortOptionalAllowed 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) {

    
	});

Back to List of Controllers