示例#1
0
 /**
  * Update an existing client
  *
  * @param  string $id     The id of the client.
  * @param  Client $client The information of the client.
  * @return bool
  */
 public function clientsUpdate($id, Client $client)
 {
     $parameters['client'] = $client->toArray(true);
     $rawData = $this->doCall('clients/' . (string) $id . '.json', $parameters, 'PUT', true);
     return $rawData['http_code'] == 204;
 }
示例#2
0
 /**
  * @param \SumoCoders\Factr\Client\Client $client
  */
 public function setClient(Client $client)
 {
     $this->client = $client;
     $this->setClientId($client->getId());
 }
示例#3
0
 /**
  * Initialize the object with raw data
  *
  * @param $data
  * @return Client
  */
 public static function initializeWithRawData($data)
 {
     $item = new Client();
     if (isset($data['id'])) {
         $item->setId($data['id']);
     }
     if (isset($data['cid'])) {
         $item->setCid($data['cid']);
     }
     if (isset($data['first_name'])) {
         $item->setFirstName($data['first_name']);
     }
     if (isset($data['last_name'])) {
         $item->setLastName($data['last_name']);
     }
     if (isset($data['company'])) {
         $item->setCompany($data['company']);
     }
     if (isset($data['vat'])) {
         $item->setVat($data['vat']);
     }
     if (isset($data['company_address'])) {
         $address = Address::initializeWithRawData($data['company_address']);
         $item->setCompanyAddress($address);
     }
     if (isset($data['billing_address'])) {
         $address = Address::initializeWithRawData($data['billing_address']);
         $item->setBillingAddress($address);
     }
     if (isset($data['email'])) {
         $item->setEmail($data['email']);
     }
     if (isset($data['fax'])) {
         $item->setFax($data['fax']);
     }
     if (isset($data['phone'])) {
         $item->setPhone($data['phone']);
     }
     if (isset($data['cell'])) {
         $item->setCell($data['cell']);
     }
     if (isset($data['cellphone'])) {
         $item->setCell($data['cellphone']);
     }
     // @remark: kinda stupid the API expects cell, but returns cellphone
     if (isset($data['website'])) {
         $item->setWebsite($data['website']);
     }
     if (isset($data['invoiceable_by_email'])) {
         $item->setInvoiceableByEmail($data['invoiceable_by_email']);
     }
     if (isset($data['invoiceable_by_snailmail'])) {
         $item->setInvoiceableBySnailMail($data['invoiceable_by_snailmail']);
     }
     if (isset($data['invoiceable_by_factr'])) {
         $item->setInvoiceableByFactr($data['invoiceable_by_factr']);
     }
     if (isset($data['payment_days'])) {
         $item->setPaymentDays($data['payment_days']);
     }
     if (isset($data['remarks'])) {
         $item->setRemarks($data['remarks']);
     }
     if (isset($data['replaced_by_id'])) {
         $item->setReplacedById($data['replaced_by_id']);
     }
     return $item;
 }