Usage examples - 2Parale/2Performant-php GitHub Wiki
All classes are under the TPerformant\API
namespace, some even under nested namespaces.
Using structured classes
Remember to use
the class definitions you are going to actually use.
// As an advertiser
use TPerformant\API\HTTP\Advertiser;
...
$me = new Advertiser('[email protected]', 'password'); // fill in with your own credentials
$commissions = $me->getCommissions();
// or as an affiliate
use TPerformant\API\HTTP\Affiliate;
...
$me = new Affiliate('[email protected]', 'password'); // fill in with your own credentials
$commissions = $me->getCommissions();
You can overwrite the default connection settings used internally by Guzzle
by providing the http
property of the options
array in the Api::init()
method.
Api::init('https://api.2performant.com', [ 'http' => [ 'timeout' => 2.0 ] ]);
The line above sets the default timeout for requests to 2 seconds. You can check out all of Guzzle's request-specific options here.
Returned objects
The type of returned objects is constructed based on the existence of the following classes in the \TPerformant\API\Model
namespace
RoleResult
, whereRole
is the requesting user's role andResult
is an object type (e.g.AdvertiserCommission
for commissions requested by an advertiser)Result
if the former class wasn't found (e.g.Banner
, becauseAffiliateBanner
andAdvertiserBanner
don't exist)
All of these classes extend the GenericEntity
superclass.
In order to access actual properties, getter methods must be used (e.g. $commission->getAmount()
).
Other classes
For other classes, check out the class reference for the list of methods.