geniusreferrals/geniusreferrals

This client allows you to implement referral programs using the Genius Referrals RESTful API.

v1.2 2020-06-17 04:55 UTC

This package is not auto-updated.

Last update: 2024-12-12 02:32:33 UTC


README

How to Build

The generated code has dependencies over external libraries like UniRest. These dependencies are defined in the composer.json file that comes with the SDK. To resolve these dependencies, we use the Composer package manager which requires PHP greater than 5.3.2 installed in your system. Visit https://getcomposer.org/download/ to download the installer file for Composer and run it in your system. Open command prompt and type composer --version. This should display the current version of the Composer installed if the installation was successful.

  • Using command line, navigate to the directory containing the generated files (including composer.json) for the SDK.
  • Run the command composer install. This should install all the required dependencies and create the vendor directory in your project directory.

Building SDK - Step 1

[For Windows Users Only] Configuring CURL Certificate Path in php.ini

CURL used to include a list of accepted CAs, but no longer bundles ANY CA certs. So by default it will reject all SSL certificates as unverifiable. You will have to get your CA's cert and point curl at it. The steps are as follows:

  1. Download the certificate bundle (.pem file) from https://curl.haxx.se/docs/caextract.html on to your system.
  2. Add curl.cainfo = "PATH_TO/cacert.pem" to your php.ini file located in your php installation. “PATH_TO” must be an absolute path containing the .pem file.
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =

How to Intall on your Project via Composer

composer install geniusreferrals/geniusreferrals

How to Use

The following section explains how to use the GeniusReferrals library in a new project.

1. Open Project in an IDE

Open an IDE for PHP like PhpStorm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.

Open project in PHPStorm - Step 1

Click on Open in PhpStorm to browse to your generated SDK directory and then click OK.

Open project in PHPStorm - Step 2

2. Add a new Test Project

Create a new directory by right clicking on the solution name as shown below:

Add a new project in PHPStorm - Step 1

Name the directory as "test"

Add a new project in PHPStorm - Step 2

Add a PHP file to this project

Add a new project in PHPStorm - Step 3

Name it "testSDK"

Add a new project in PHPStorm - Step 4

Depending on your project setup, you might need to include composer's autoloader in your PHP code to enable auto loading of classes.

require_once "../vendor/autoload.php";

It is important that the path inside require_once correctly points to the file autoload.php inside the vendor directory created during dependency installations.

Add a new project in PHPStorm - Step 4

After this you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.

3. Run the Test Project

To run your project you must set the Interpreter for your project. Interpreter is the PHP engine installed on your computer.

Open Settings from File menu.

Run Test Project - Step 1

Select PHP from within Languages & Frameworks

Run Test Project - Step 2

Browse for Interpreters near the Interpreter option and choose your interpreter.

Run Test Project - Step 3

Once the interpreter is selected, click OK

Run Test Project - Step 4

To run your project, right click on your PHP file inside your Test project and click on Run

Run Test Project - Step 5

How to Test

Unit tests in this SDK can be run using PHPUnit.

  1. First install the dependencies using composer including the require-dev dependencies.
  2. Run vendor\bin\phpunit --verbose from commandline to execute tests. If you have installed PHPUnit globally, run tests using phpunit --verbose instead.

You can change the PHPUnit test configuration in the phpunit.xml file.

Initialization

Authentication

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

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

$client = new GeniusReferralsLib\GeniusReferralsClient($contentType, $xAuthToken);

Class Reference

List of Controllers

Class: RootsController

Get singleton instance

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

$roots = $client->getRoots();

Method: getRoot

The root of the API

function getRoot()

Example Usage

$result = $roots->getRoot();

Back to List of Controllers

Class: AuthenticationsController

Get singleton instance

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

$authentications = $client->getAuthentications();

Method: getAuthentication

Allow clients to test authentication on Genius Referrals platform.

function getAuthentication()

Example Usage

$result = $authentications->getAuthentication();

Back to List of Controllers

Class: AdvocatesController

Get singleton instance

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

$advocates = $client->getAdvocates();

Method: deleteAdvocate

Delete an advocate

function deleteAdvocate(
        $accountSlug,
        $advocateToken)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';

$advocates->deleteAdvocate($accountSlug, $advocateToken);

Method: putAdvocate

Update an advocate.

function putAdvocate(
        $accountSlug,
        $advocateToken,
        $advocateForm)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$advocateForm = new AdvocateForm();

$advocates->putAdvocate($accountSlug, $advocateToken, $advocateForm);

Method: postAdvocate

Create a new advocate.

function postAdvocate(
        $accountSlug,
        $advocateForm)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateForm = new AdvocateForm();

$result = $advocates->postAdvocate($accountSlug, $advocateForm);

Method: getAdvocate

Get an advocate by a given token.

function getAdvocate(
        $accountSlug,
        $advocateToken)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';

$result = $advocates->getAdvocate($accountSlug, $advocateToken);

Method: deleteAdvocates

Delete all advocates

function deleteAdvocates($accountSlug)

Parameters

Example Usage

$accountSlug = 'account_slug';

$advocates->deleteAdvocates($accountSlug);

Method: getAdvocates

Get the list of advocates

function getAdvocates(
        $accountSlug,
        $page = 1,
        $limit = 10,
        $filter = null,
        $sort = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$page = 1;
$limit = 10;
$filter = 'filter';
$sort = 'sort';

$result = $advocates->getAdvocates($accountSlug, $page, $limit, $filter, $sort);

Method: patchAdvocate

Update partial elements of an advocate.

function patchAdvocate(
        $accountSlug,
        $advocateToken,
        $advocatePatchForm)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$advocatePatchForm = new AdvocatePatchForm();

$result = $advocates->patchAdvocate($accountSlug, $advocateToken, $advocatePatchForm);

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)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';

$result = $advocates->getShareLinks($accountSlug, $advocateToken);

Method: putPaymentMethod

Update a payment method.

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

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$advocatePaymentMethodId = 147;
$advocatePaymentMethodForm = new PaymentMethodForm();

$advocates->putPaymentMethod($accountSlug, $advocateToken, $advocatePaymentMethodId, $advocatePaymentMethodForm);

Method: getPaymentMethod

Get an advocate's payment method

function getPaymentMethod(
        $accountSlug,
        $advocateToken,
        $advocatePaymentMethodId)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$advocatePaymentMethodId = 147;

$result = $advocates->getPaymentMethod($accountSlug, $advocateToken, $advocatePaymentMethodId);

Method: postPaymentMethod

Create a new payment method.

function postPaymentMethod(
        $accountSlug,
        $advocateToken,
        $advocatePaymentMethodForm)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$advocatePaymentMethodForm = new PaymentMethodForm();

$result = $advocates->postPaymentMethod($accountSlug, $advocateToken, $advocatePaymentMethodForm);

Method: getBonusRedemptionMethod

Get bonuses redemption method.

function getBonusRedemptionMethod($bonusesRedemptionMethodSlug)

Parameters

Example Usage

$bonusesRedemptionMethodSlug = 'bonuses_redemption_method_slug';

$result = $advocates->getBonusRedemptionMethod($bonusesRedemptionMethodSlug);

Method: getBonusRedemptionMethods

Get bonuses redemption methods.

function getBonusRedemptionMethods()

Example Usage

$result = $advocates->getBonusRedemptionMethods();

Method: getCurrencies

Get currencies.

function getCurrencies()

Example Usage

$result = $advocates->getCurrencies();

Method: getCurrency

Get a currency.

function getCurrency($code)

Parameters

Example Usage

$code = 'code';

$result = $advocates->getCurrency($code);

Method: getPaymentMethods

Get the advocate's payment methods.

function getPaymentMethods(
        $accountSlug,
        $advocateToken,
        $page = 1,
        $limit = 10,
        $filter = null,
        $sort = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$page = 1;
$limit = 10;
$filter = 'filter';
$sort = 'sort';

$result = $advocates->getPaymentMethods($accountSlug, $advocateToken, $page, $limit, $filter, $sort);

Back to List of Controllers

Class: AccountsController

Get singleton instance

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

$accounts = $client->getAccounts();

Method: getAccount

Get an account by a given slug.

function getAccount($accountSlug)

Parameters

Example Usage

$accountSlug = 'account_slug';

$result = $accounts->getAccount($accountSlug);

Method: getAccounts

Get the list of accounts.

function getAccounts(
        $page = 1,
        $limit = 10,
        $filter = null,
        $sort = null)

Parameters

Example Usage

$page = 1;
$limit = 10;
$filter = 'filter';
$sort = 'sort';

$result = $accounts->getAccounts($page, $limit, $filter, $sort);

Back to List of Controllers

Class: ReportsController

Get singleton instance

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

$reports = $client->getReports();

Method: getReferralsSummaryPerOrigin

Get referrals summary per referral origin.

function getReferralsSummaryPerOrigin($advocateToken)

Parameters

Example Usage

$advocateToken = 'advocate_token';

$result = $reports->getReferralsSummaryPerOrigin($advocateToken);

Method: getBonusesSummaryPerOrigin

Get bonuses summary per referral origin.

function getBonusesSummaryPerOrigin($advocateToken)

Parameters

Example Usage

$advocateToken = 'advocate_token';

$result = $reports->getBonusesSummaryPerOrigin($advocateToken);

Method: getTopAdvocates

Get top 10 advocates.

function getTopAdvocates(
        $accountSlug = null,
        $campaignSlug = null,
        $limit = 10,
        $from = null,
        $to = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$campaignSlug = 'campaign_slug';
$limit = 10;
$from = date("D M d, Y G:i");
$to = date("D M d, Y G:i");

$result = $reports->getTopAdvocates($accountSlug, $campaignSlug, $limit, $from, $to);

Method: getShareDailyParticipation

Get share daily participation.

function getShareDailyParticipation(
        $accountSlug = null,
        $campaignSlug = null,
        $advocateToken = null,
        $from = null,
        $to = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$campaignSlug = 'campaign_slug';
$advocateToken = 'advocate_token';
$from = date("D M d, Y G:i");
$to = date("D M d, Y G:i");

$result = $reports->getShareDailyParticipation($accountSlug, $campaignSlug, $advocateToken, $from, $to);

Method: getReferralDailyParticipation

Get referral daily participation.

function getReferralDailyParticipation(
        $accountSlug = null,
        $campaignSlug = null,
        $advocateToken = null,
        $from = null,
        $to = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$campaignSlug = 'campaign_slug';
$advocateToken = 'advocate_token';
$from = date("D M d, Y G:i");
$to = date("D M d, Y G:i");

$result = $reports->getReferralDailyParticipation($accountSlug, $campaignSlug, $advocateToken, $from, $to);

Method: getClickDailyParticipation

Get click daily participation.

function getClickDailyParticipation(
        $accountSlug = null,
        $campaignSlug = null,
        $advocateToken = null,
        $from = null,
        $to = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$campaignSlug = 'campaign_slug';
$advocateToken = 'advocate_token';
$from = date("D M d, Y G:i");
$to = date("D M d, Y G:i");

$result = $reports->getClickDailyParticipation($accountSlug, $campaignSlug, $advocateToken, $from, $to);

Method: getBonusesDailyGiven

Get bonuses daily given.

function getBonusesDailyGiven(
        $accountSlug = null,
        $campaignSlug = null,
        $advocateToken = null,
        $from = null,
        $to = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$campaignSlug = 'campaign_slug';
$advocateToken = 'advocate_token';
$from = date("D M d, Y G:i");
$to = date("D M d, Y G:i");

$result = $reports->getBonusesDailyGiven($accountSlug, $campaignSlug, $advocateToken, $from, $to);

Back to List of Controllers

Class: ReferralsController

Get singleton instance

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

$referrals = $client->getReferrals();

Method: getReferralOrigin

Get a referral origin by a given slug.

function getReferralOrigin($referralOriginSlug)

Parameters

Example Usage

$referralOriginSlug = 'referral_origin_slug';

$result = $referrals->getReferralOrigin($referralOriginSlug);

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

Example Usage

$result = $referrals->getReferralOrigins();

Method: getReferral

Get a referral by a given id.

function getReferral(
        $accountSlug,
        $advocateToken,
        $referralId)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$referralId = 'referral_id';

$result = $referrals->getReferral($accountSlug, $advocateToken, $referralId);

Method: deleteReferral

Delete a referral.

function deleteReferral(
        $accountSlug,
        $advocateToken,
        $referralId)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$referralId = 'referral_id';

$referrals->deleteReferral($accountSlug, $advocateToken, $referralId);

Method: postReferral

Create a new referral.

function postReferral(
        $accountSlug,
        $advocateToken,
        $referralForm)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$referralForm = new ReferralForm();

$result = $referrals->postReferral($accountSlug, $advocateToken, $referralForm);

Method: putReferral

Update a referral.

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

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$referralId = 'referral_id';
$referralForm = new ReferralForm();

$referrals->putReferral($accountSlug, $advocateToken, $referralId, $referralForm);

Method: getReferrals

Get the list of referrals for a given advocate.

function getReferrals(
        $accountSlug,
        $advocateToken,
        $page = 1,
        $limit = 10,
        $filter = null,
        $sort = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$page = 1;
$limit = 10;
$filter = 'filter';
$sort = 'sort';

$result = $referrals->getReferrals($accountSlug, $advocateToken, $page, $limit, $filter, $sort);

Back to List of Controllers

Class: RedemptionRequestsController

Get singleton instance

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

$redemptionRequests = $client->getRedemptionRequests();

Method: getRedemptionRequestStatus

Get a redemption request status.

function getRedemptionRequestStatus($redemptionRequestStatusSlug)

Parameters

Example Usage

$redemptionRequestStatusSlug = 'redemption_request_status_slug';

$result = $redemptionRequests->getRedemptionRequestStatus($redemptionRequestStatusSlug);

Method: getRedemptionRequestStatuses

Get redemption request statuses.

function getRedemptionRequestStatuses()

Example Usage

$result = $redemptionRequests->getRedemptionRequestStatuses();

Method: getRedemptionRequestAction

Get a redemption request action.

function getRedemptionRequestAction($redemptionRequestActionSlug)

Parameters

Example Usage

$redemptionRequestActionSlug = 'redemption_request_action_slug';

$result = $redemptionRequests->getRedemptionRequestAction($redemptionRequestActionSlug);

Method: getRedemptionRequestActions

Get redemption request actions.

function getRedemptionRequestActions()

Example Usage

$result = $redemptionRequests->getRedemptionRequestActions();

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)

Parameters

Example Usage

$accountSlug = 'account_slug';
$redemptionRequestId = 147;

$redemptionRequests->patchRedemptionRequest($accountSlug, $redemptionRequestId);

Method: postRedemptionRequest

Create a redemption request.

function postRedemptionRequest(
        $accountSlug,
        $redemptionRequestForm)

Parameters

Example Usage

$accountSlug = 'account_slug';
$redemptionRequestForm = new RedemptionRequestForm();

$result = $redemptionRequests->postRedemptionRequest($accountSlug, $redemptionRequestForm);

Method: getRedemptionRequest

Get a redemption request by a given id.

function getRedemptionRequest(
        $accountSlug,
        $redemptionRequestId)

Parameters

Example Usage

$accountSlug = 'account_slug';
$redemptionRequestId = 'redemption_request_id';

$result = $redemptionRequests->getRedemptionRequest($accountSlug, $redemptionRequestId);

Method: getRedemptionRequests

Get the list of redemption requests.

function getRedemptionRequests(
        $accountSlug,
        $page = 1,
        $limit = 10,
        $filter = null,
        $sort = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$page = 1;
$limit = 10;
$filter = 'filter';
$sort = 'sort';

$result = $redemptionRequests->getRedemptionRequests($accountSlug, $page, $limit, $filter, $sort);

Back to List of Controllers

Class: BonusesController

Get singleton instance

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

$bonuses = $client->getBonuses();

Method: getBonuses

Get the list of bonuses for a given account.

function getBonuses(
        $accountSlug,
        $page = 1,
        $limit = 10,
        $filter = null,
        $sort = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$page = 1;
$limit = 10;
$filter = 'filter';
$sort = 'sort';

$result = $bonuses->getBonuses($accountSlug, $page, $limit, $filter, $sort);

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)

Parameters

Example Usage

$accountSlug = 'account_slug';
$bonusesForm = new BonusesForm();

$result = $bonuses->postBonus($accountSlug, $bonusesForm);

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)

Parameters

Example Usage

$accountSlug = 'account_slug';
$advocateToken = 'advocate_token';
$reference = 'reference';
$paymentAmount = 105.64688331012;

$result = $bonuses->getBonusCheckup($accountSlug, $advocateToken, $reference, $paymentAmount);

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)

Parameters

Example Usage

$accountSlug = 'account_slug';
$bonusForm = new ForceBonusesForm();

$result = $bonuses->postForceBonus($accountSlug, $bonusForm);

Method: getBonusTrace

Get a bonus request trace.

function getBonusTrace(
        $accountSlug,
        $traceId)

Parameters

Example Usage

$accountSlug = 'account_slug';
$traceId = 105;

$result = $bonuses->getBonusTrace($accountSlug, $traceId);

Method: deleteBonus

Delete a bonus

function deleteBonus(
        $accountSlug,
        $bonusId)

Parameters

Example Usage

$accountSlug = 'account_slug';
$bonusId = 105;

$bonuses->deleteBonus($accountSlug, $bonusId);

Method: getBonus

Get a bonus by a given id.

function getBonus(
        $accountSlug,
        $bonusId)

Parameters

Example Usage

$accountSlug = 'account_slug';
$bonusId = 105;

$result = $bonuses->getBonus($accountSlug, $bonusId);

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 = 1,
        $limit = 10,
        $filter = null,
        $sort = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$page = 1;
$limit = 10;
$filter = 'filter';
$sort = 'sort';

$result = $bonuses->getBonusTraces($accountSlug, $page, $limit, $filter, $sort);

Back to List of Controllers

Class: CampaignsController

Get singleton instance

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

$campaigns = $client->getCampaigns();

Method: getCampaign

Get a campaign by a given slug.

function getCampaign(
        $accountSlug,
        $campaignSlug)

Parameters

Example Usage

$accountSlug = 'account_slug';
$campaignSlug = 'campaign_slug';

$result = $campaigns->getCampaign($accountSlug, $campaignSlug);

Method: getCampaigns

Get the list of campaings for a given account.

function getCampaigns(
        $accountSlug,
        $page = 1,
        $limit = 10,
        $filter = null,
        $sort = null)

Parameters

Example Usage

$accountSlug = 'account_slug';
$page = 1;
$limit = 10;
$filter = 'filter';
$sort = 'sort';

$result = $campaigns->getCampaigns($accountSlug, $page, $limit, $filter, $sort);

Back to List of Controllers