High level API provides objects for easy manipulation with common entities, like affiliates, commissions, etc. For every entity there are two main objects:

 

  • row object – (for example: Pap_Api_Affiliate) – it can retrieve one record, you can edit, or add new record using this object

     

  • grid object – (for example: Pap_Api_AfiliatesGrid) – it can retrieve grid of affiliates (list of affiliate records)

 

 

High level API classes have names start with Pap_Api_******

 

Row objects can be used to load one record by the given criteria. You can load record by it's ID, or by any combination of other fields.

Row object can handle only one record, so it returns exception if there are more records that match this criteria.

 

Example loading one affiliate:

// loading affiliate by his ID
$affiliate = new Pap_Api_Affiliate($session);
$affiliate->setUserid("11111111");
try {
  if(!$affiliate->load()) {
    echo 'Cannot load affiliate, error: '.$affiliate->getMessage();
  }
} catch (Exception $e) {
  echo 'Cannot load affiliate, error: '.$e->getMessage();
}

//loading affiliate by his first and last name
$affiliate = new Pap_Api_Affiliate($session);
$affiliate->setFirstname("John");
$affiliate->setLastname("Smith");

try {
  if(!$affiliate->load()) {
    echo 'Cannot load affiliate, error: '.$affiliate->getMessage();
  }
} catch (Exception $e) {
  echo 'Cannot load affiliate, error: '.$e->getMessage();
}

If you load affiliate by anything else than ID, it is possible that there will be multiple records that will match this criteria.

In case that load() method finds multiple records, or find zero records, it will throw an exception that you have to process.

×