Пример #1
0
 public function account()
 {
     $apiObj = new NylasAPIObject();
     $nsObj = new Models\Account();
     $accountData = $this->getResource('', $nsObj, '', array());
     $account = $apiObj->_createObject($accountData->klass, NULL, $accountData->data);
     return $account;
 }
Пример #2
0
 /**
  * @param string|null $namespace
  * @param NylasAPIObject $klass
  * @param string $id
  * @param mixed $data
  * @return mixed
  */
 public function _updateResource($namespace, $klass, $id, $data)
 {
     $prefix = $namespace ? '/' . $klass->apiRoot . '/' . $namespace : '';
     $url = $this->apiServer . $prefix . '/' . $klass->collectionName . '/' . $id;
     if ($klass->collectionName == 'files') {
         $payload['headers']['Content-Type'] = 'multipart/form-data';
         $payload['multipart'] = $data;
     } else {
         $payload = $this->createHeaders();
         $payload['json'] = $data;
         $responseJson = $this->apiClient->put($url, $payload)->getBody()->getContents();
         $response = json_decode($responseJson, true);
         return $klass->_createObject($this, $namespace, $response);
     }
 }