Пример #1
0
 /**
  * get's the creditor info by its code
  *
  * @param  int $creditorCode
  * @throws Exception
  * @return WeFact_Creditor
  */
 public static function getByCode($creditorCode)
 {
     $api = new WeFact_Api();
     if ($creditorCode == '') {
         throw new \InvalidArgumentException(sprintf('CreditorCode must be defined!'));
     }
     $parameters = array('CreditorCode' => $creditorCode);
     $response = $api->sendRequest('creditor', 'show', $parameters);
     if (!isset($response['status']) || $response['status'] == 'error') {
         return null;
     }
     $creditor = new self();
     if (isset($response['creditor'])) {
         foreach ($response['creditor'] as $field => $value) {
             $creditor->{$field} = $value;
         }
     }
     return $creditor;
 }
Пример #2
0
 /**
  * get the Object info by Code
  *
  * @param  int $objectCode
  * @return WeFact_Model
  */
 public static function getByCode($objectCode)
 {
     $api = new WeFact_Api();
     if ($objectCode == '') {
         throw new \InvalidArgumentException(sprintf('ObjectCode must be defined!'));
     }
     $parameters = array(self::getModelCodeName() => $objectCode);
     $response = $api->sendRequest(self::getModelName(), 'show', $parameters);
     if (!isset($response['status']) || $response['status'] == 'error') {
         return null;
     }
     return self::responseToObject($response);
 }
Пример #3
0
 /**
  * @param string $domain
  * @param string $tld
  * @return WeFact_Domain
  */
 public static function getByDomainTld($domain, $tld)
 {
     $api = new WeFact_Api();
     $parameters = array('Domain' => $domain, 'Tld' => $tld);
     $response = $api->sendRequest('domain', 'show', $parameters);
     $result = array();
     if (isset($response['domains'])) {
         foreach ($response['domains'] as $domainArray) {
             $domain = new self();
             foreach ($domainArray as $field => $value) {
                 $domain->{$field} = $value;
             }
             $result[] = $domain;
         }
     }
     return $result;
 }
Пример #4
0
 /**
  * Check login credentials and get a Debtor on success
  *
  * @param string $username DebtorCode
  * @param string $password
  * @throws Exception on fail
  * @return WeFact_Debtor
  */
 public static function checkLogin($username, $password)
 {
     $api = new WeFact_Api();
     if ($username == '') {
         throw new \InvalidArgumentException(sprintf('Username must be defined!'));
     }
     if ($password == '') {
         throw new \InvalidArgumentException(sprintf('Password must be defined!'));
     }
     $parameters = array('Username' => $username, 'Password' => $password);
     $response = $api->sendRequest('debtor', 'checklogin', $parameters);
     if (!isset($response['status']) || $response['status'] == 'error') {
         return null;
     }
     $debtor = new self();
     if (isset($response['debtor'])) {
         foreach ($response['debtor'] as $field => $value) {
             $debtor->{$field} = $value;
         }
     }
     return $debtor;
 }
Пример #5
0
 /**
  * Search all by string
  * NOTE: information returned by this ApiCall is just a fraction of the object information
  *
  * @param int $groupId
  * @throws Exception
  * @return WeFact_Product[]
  */
 public static function getByGroupId($groupId)
 {
     $api = new WeFact_Api();
     $parameters = array('group' => $groupId);
     $response = $api->sendRequest(self::getModelName(), 'list', $parameters);
     $result = array();
     $modelNames = self::getModelName() . 's';
     if (isset($response[$modelNames])) {
         foreach ($response[$modelNames] as $objectArray) {
             $calledClass = get_called_class();
             $object = new $calledClass();
             foreach ($objectArray as $field => $value) {
                 $object->{$field} = $value;
             }
             $result[] = $object;
         }
     }
     return $result;
 }
Пример #6
0
 /**
  * get all the invoices by DebtorCode
  * NOTE: information returned by this ApiCall is just a fraction of the object information
  *
  * @param $debtorCode
  * @return WeFact_Invoice[]
  */
 public static function getByDebtorCode($debtorCode)
 {
     $api = new WeFact_Api();
     $parameters = array('searchat' => 'DebtorCode', 'searchfor' => $debtorCode);
     $response = $api->sendRequest('invoice', 'list', $parameters);
     $result = array();
     if (isset($response['invoices'])) {
         foreach ($response['invoices'] as $invoiceArray) {
             $invoice = new self();
             foreach ($invoiceArray as $field => $value) {
                 $invoice->{$field} = $value;
             }
             $result[] = $invoice;
         }
     }
     return $result;
 }