/**
  * Get all verified email addresses associated with an account
  * @param string $accessToken - Constant Contact OAuth2 Access Token
  * @param array $params - array of query parameters/values to append to the request
  * @return array of VerifiedEmailAddress
  */
 public function getVerifiedEmailAddresses($accessToken, array $params)
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.account_verified_addresses'));
     $url = $this->buildUrl($baseUrl, $params);
     $response = parent::getRestClient()->get($url, parent::getHeaders($accessToken));
     $verifiedAddresses = array();
     foreach (json_decode($response->body, true) as $verifiedAddress) {
         $verifiedAddresses[] = VerifiedEmailAddress::create($verifiedAddress);
     }
     return $verifiedAddresses;
 }
Ejemplo n.º 2
0
 /**
  * Create a new verified email address. This will also prompt the account to send
  * a verification email to the address.
  * @param string $accessToken - Constant Contact OAuth2 Access Token
  * @param string $emailAddress - email address to create
  * @return array - array of VerifiedEmailAddress created
  */
 public function createVerifiedEmailAddress($accessToken, $emailAddress)
 {
     $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.account_verified_addresses');
     $request = array(array("email_address" => $emailAddress));
     $url = $this->buildUrl($baseUrl);
     $response = parent::getRestClient()->post($url, parent::getHeaders($accessToken), json_encode($request));
     $verifiedAddresses = array();
     foreach (json_decode($response->body, true) as $verifiedAddress) {
         $verifiedAddresses[] = VerifiedEmailAddress::create($verifiedAddress);
     }
     return $verifiedAddresses;
 }
 public function testGetVerifiedAddresses()
 {
     $response = self::$client->get('/');
     $verifiedAddresses = array();
     foreach ($response->json() as $verifiedAddress) {
         $verifiedAddresses[] = VerifiedEmailAddress::create($verifiedAddress);
     }
     foreach ($verifiedAddresses as $verifiedAddress) {
         $this->assertInstanceOf('Ctct\\Components\\Account\\VerifiedEmailAddress', $verifiedAddress);
         $this->assertEquals("*****@*****.**", $verifiedAddress->email_address);
         $this->assertEquals("CONFIRMED", $verifiedAddress->status);
     }
 }
 /**
  * Create a new verified email address. This will also prompt the account to send
  * a verification email to the address.
  * @param string $accessToken - Constant Contact OAuth2 Access Token
  * @param string $emailAddress - email address to create
  * @return array - array of VerifiedEmailAddress created
  * @throws CtctException
  */
 public function createVerifiedEmailAddress($accessToken, $emailAddress)
 {
     $baseUrl = Config::get('endpoints.base_url') . Config::get('endpoints.account_verified_addresses');
     $request = parent::createBaseRequest($accessToken, 'POST', $baseUrl);
     $stream = Stream::factory(json_encode(array(array("email_address" => $emailAddress))));
     $request->setBody($stream);
     try {
         $response = parent::getClient()->send($request);
     } catch (ClientException $e) {
         throw parent::convertException($e);
     }
     $verifiedAddresses = array();
     foreach ($response->json() as $verifiedAddress) {
         $verifiedAddresses[] = VerifiedEmailAddress::create($verifiedAddress);
     }
     return $verifiedAddresses;
 }