/** * Update information of the account. * @param string $accessToken - Constant Contact OAuth2 Access Token * @param AccountInfo $accountInfo - Updated AccountInfo * @return AccountInfo */ public function updateAccountInfo($accessToken, AccountInfo $accountInfo) { $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.account_info'); $url = $this->buildUrl($baseUrl); $response = parent::getRestClient()->put($url, parent::getHeaders($accessToken), $accountInfo->toJson()); return AccountInfo::create(json_decode($response->body, true)); }
/** * Get account info associated with an access token * @param string $accessToken - Constant Contact OAuth2 Access Token * @param array $params - array of query parameters/values to append to the request * @return AccountInfo */ public function getAccountInfo($accessToken, array $params) { $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.account_info')); $url = $this->buildUrl($baseUrl, $params); $response = parent::getRestClient()->get($url, parent::getHeaders($accessToken)); return AccountInfo::create(json_decode($response->body, true)); }
public function testGetAccountInfo() { $response = self::$client->get('/'); $result = AccountInfo::create($response->json()); $this->assertInstanceOf('Ctct\\Components\\Account\\AccountInfo', $result); $this->assertEquals("http://www.example.com", $result->website); $this->assertEquals("My Company", $result->organization_name); $this->assertEquals("http://www.example.com", $result->website); $this->assertEquals("My Company", $result->organization_name); $this->assertEquals("US/Eastern", $result->time_zone); $this->assertEquals("Mary Jane", $result->first_name); $this->assertEquals("Doe", $result->last_name); $this->assertEquals("*****@*****.**", $result->email); $this->assertEquals("5555555555", $result->phone); $this->assertEquals("https://ih.constantcontact.com/fs137/1100371573368/img/90.jpg", $result->company_logo); $this->assertEquals("US", $result->country_code); $this->assertEquals("MA", $result->state_code); }
/** * Update information of the account. * @param string $accessToken - Constant Contact OAuth2 Access Token * @param AccountInfo $accountInfo - Updated AccountInfo * @return AccountInfo * @throws CtctException */ public function updateAccountInfo($accessToken, AccountInfo $accountInfo) { $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.account_info'); $request = parent::createBaseRequest($accessToken, 'PUT', $baseUrl); $stream = Stream::factory(json_encode($accountInfo)); $request->setBody($stream); try { $response = parent::getClient()->send($request); } catch (ClientException $e) { throw parent::convertException($e); } return AccountInfo::create($response->json()); }