geniusreferrals / geniusreferrals
This client allows you to implement referral programs using the Genius Referrals RESTful API.
Installs: 7 774
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- apimatic/jsonmapper: ~1.0.0
- mashape/unirest-php: ~3.0.1
This package is not auto-updated.
Last update: 2024-11-14 02:14:17 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 thevendor
directory in your project directory.
[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:
- Download the certificate bundle (.pem file) from https://curl.haxx.se/docs/caextract.html on to your system.
- 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.
Click on Open
in PhpStorm to browse to your generated SDK directory and then click OK
.
2. Add a new Test Project
Create a new directory by right clicking on the solution name as shown below:
Name the directory as "test"
Add a PHP file to this project
Name it "testSDK"
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.
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.
Select PHP
from within Languages & Frameworks
Browse for Interpreters near the Interpreter
option and choose your interpreter.
Once the interpreter is selected, click OK
To run your project, right click on your PHP file inside your Test project and click on Run
How to Test
Unit tests in this SDK can be run using PHPUnit.
- First install the dependencies using composer including the
require-dev
dependencies. - Run
vendor\bin\phpunit --verbose
from commandline to execute tests. If you have installed PHPUnit globally, run tests usingphpunit --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
- 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.
$roots = $client->getRoots();
getRoot
The root of the API
function getRoot()
Example Usage
$result = $roots->getRoot();
AuthenticationsController
Get singleton instance
The singleton instance of the AuthenticationsController
class can be accessed from the API Client.
$authentications = $client->getAuthentications();
getAuthentication
Allow clients to test authentication on Genius Referrals platform.
function getAuthentication()
Example Usage
$result = $authentications->getAuthentication();
AdvocatesController
Get singleton instance
The singleton instance of the AdvocatesController
class can be accessed from the API Client.
$advocates = $client->getAdvocates();
deleteAdvocate
Delete an advocate
function deleteAdvocate( $accountSlug, $advocateToken)
Parameters
Example Usage
$accountSlug = 'account_slug'; $advocateToken = 'advocate_token'; $advocates->deleteAdvocate($accountSlug, $advocateToken);
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);
postAdvocate
Create a new advocate.
function postAdvocate( $accountSlug, $advocateForm)
Parameters
Example Usage
$accountSlug = 'account_slug'; $advocateForm = new AdvocateForm(); $result = $advocates->postAdvocate($accountSlug, $advocateForm);
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);
deleteAdvocates
Delete all advocates
function deleteAdvocates($accountSlug)
Parameters
Example Usage
$accountSlug = 'account_slug'; $advocates->deleteAdvocates($accountSlug);
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);
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);
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);
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);
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);
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);
getBonusRedemptionMethod
Get bonuses redemption method.
function getBonusRedemptionMethod($bonusesRedemptionMethodSlug)
Parameters
Example Usage
$bonusesRedemptionMethodSlug = 'bonuses_redemption_method_slug'; $result = $advocates->getBonusRedemptionMethod($bonusesRedemptionMethodSlug);
getBonusRedemptionMethods
Get bonuses redemption methods.
function getBonusRedemptionMethods()
Example Usage
$result = $advocates->getBonusRedemptionMethods();
getCurrencies
Get currencies.
function getCurrencies()
Example Usage
$result = $advocates->getCurrencies();
getCurrency
Get a currency.
function getCurrency($code)
Parameters
Example Usage
$code = 'code'; $result = $advocates->getCurrency($code);
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);
AccountsController
Get singleton instance
The singleton instance of the AccountsController
class can be accessed from the API Client.
$accounts = $client->getAccounts();
getAccount
Get an account by a given slug.
function getAccount($accountSlug)
Parameters
Example Usage
$accountSlug = 'account_slug'; $result = $accounts->getAccount($accountSlug);
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);
ReportsController
Get singleton instance
The singleton instance of the ReportsController
class can be accessed from the API Client.
$reports = $client->getReports();
getReferralsSummaryPerOrigin
Get referrals summary per referral origin.
function getReferralsSummaryPerOrigin($advocateToken)
Parameters
Example Usage
$advocateToken = 'advocate_token'; $result = $reports->getReferralsSummaryPerOrigin($advocateToken);
getBonusesSummaryPerOrigin
Get bonuses summary per referral origin.
function getBonusesSummaryPerOrigin($advocateToken)
Parameters
Example Usage
$advocateToken = 'advocate_token'; $result = $reports->getBonusesSummaryPerOrigin($advocateToken);
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);
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);
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);
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);
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);
ReferralsController
Get singleton instance
The singleton instance of the ReferralsController
class can be accessed from the API Client.
$referrals = $client->getReferrals();
getReferralOrigin
Get a referral origin by a given slug.
function getReferralOrigin($referralOriginSlug)
Parameters
Example Usage
$referralOriginSlug = 'referral_origin_slug'; $result = $referrals->getReferralOrigin($referralOriginSlug);
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();
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);
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);
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);
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);
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);
RedemptionRequestsController
Get singleton instance
The singleton instance of the RedemptionRequestsController
class can be accessed from the API Client.
$redemptionRequests = $client->getRedemptionRequests();
getRedemptionRequestStatus
Get a redemption request status.
function getRedemptionRequestStatus($redemptionRequestStatusSlug)
Parameters
Example Usage
$redemptionRequestStatusSlug = 'redemption_request_status_slug'; $result = $redemptionRequests->getRedemptionRequestStatus($redemptionRequestStatusSlug);
getRedemptionRequestStatuses
Get redemption request statuses.
function getRedemptionRequestStatuses()
Example Usage
$result = $redemptionRequests->getRedemptionRequestStatuses();
getRedemptionRequestAction
Get a redemption request action.
function getRedemptionRequestAction($redemptionRequestActionSlug)
Parameters
Example Usage
$redemptionRequestActionSlug = 'redemption_request_action_slug'; $result = $redemptionRequests->getRedemptionRequestAction($redemptionRequestActionSlug);
getRedemptionRequestActions
Get redemption request actions.
function getRedemptionRequestActions()
Example Usage
$result = $redemptionRequests->getRedemptionRequestActions();
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);
postRedemptionRequest
Create a redemption request.
function postRedemptionRequest( $accountSlug, $redemptionRequestForm)
Parameters
Example Usage
$accountSlug = 'account_slug'; $redemptionRequestForm = new RedemptionRequestForm(); $result = $redemptionRequests->postRedemptionRequest($accountSlug, $redemptionRequestForm);
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);
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);
BonusesController
Get singleton instance
The singleton instance of the BonusesController
class can be accessed from the API Client.
$bonuses = $client->getBonuses();
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);
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);
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);
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);
getBonusTrace
Get a bonus request trace.
function getBonusTrace( $accountSlug, $traceId)
Parameters
Example Usage
$accountSlug = 'account_slug'; $traceId = 105; $result = $bonuses->getBonusTrace($accountSlug, $traceId);
deleteBonus
Delete a bonus
function deleteBonus( $accountSlug, $bonusId)
Parameters
Example Usage
$accountSlug = 'account_slug'; $bonusId = 105; $bonuses->deleteBonus($accountSlug, $bonusId);
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);
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);
CampaignsController
Get singleton instance
The singleton instance of the CampaignsController
class can be accessed from the API Client.
$campaigns = $client->getCampaigns();
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);
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);