/** * Update an account * * @param Account $account * @return Account|false */ public function update(Account $account) { $params = $account->toApiParams(); // Make sure all the required fields are present $requireFields = array('username', 'companyname', 'phone'); foreach ($requireFields as $requiredField) { if (empty($params[$requiredField])) { throw new RuntimeException("Unable to update an account without a '{$requiredField}' field"); } } $response = $this->getApiClient()->post('/accounts', $params); if ($response && $response->isOk()) { // add the resulting API key to the account instance $account->setApiKey($response->data->apikey); return $account; } return false; }