/** * Update data on Quickbooks * * @return object */ public function update() { // In order to update an entity, we need to have the complete data. Otherwise, unprovided data will be removed. $existing = $this->client->load($this->getId()); // add existing data foreach ($existing as $key => $value) { if (!isset($this->data[$key])) { $this->data[$key] = $value; } } return $this->client->update($this); }
/** * Constructor * @return void */ public function __construct($options = []) { parent::__construct($options); if (isset($options['callback_url'])) { $this->callback_url = $options['callback_url']; } }
/** * Get data from Quickbooks * * @return array */ public function get() { $data = $this->client->get('query?query=' . rawurlencode($this)); // If Query syntax is incorrect, it will return a 200 with Fault. // Lets make that an Exception instead. if (property_exists($data, 'Fault')) { throw new \Exception('[' . $data->Fault->Error[0]->code . ' ' . $data->Fault->Error[0]->Message . '] ' . $data->Fault->Error[0]->Detail); } $data = $data->QueryResponse; if (!property_exists($data, $this->entity)) { $return = new \stdClass(); $return->{$this->entity} = []; $return->maxResults = 0; $return->totalCount = 0; return $return; } return $data; }
/** * Update an entity. * * @param array $data Item information. * @return void */ public function update($data) { return parent::post($this->getResourceName() . '?operation=update', $data)->{$this->getEntityName()}; }