public function testGetUnsubscribes()
 {
     $response = self::$client->get('/')->json();
     $resultSet = new ResultSet($response['results'], $response['meta']);
     $unsubscribeActivity = UnsubscribeActivity::create($resultSet->results[0]);
     $this->assertInstanceOf('Ctct\\Components\\ResultSet', $resultSet);
     $this->assertInstanceOf('Ctct\\Components\\Tracking\\UnsubscribeActivity', $unsubscribeActivity);
     $this->assertEquals("bGltaXQ9MyZuZXh0PTEzNTQ4MTcyMTA0MzA", $resultSet->next);
     $this->assertEquals("EMAIL_UNSUBSCRIBE", $unsubscribeActivity->activity_type);
     $this->assertEquals(1100394165290, $unsubscribeActivity->campaign_id);
     $this->assertEquals("58", $unsubscribeActivity->contact_id);
     $this->assertEquals("*****@*****.**", $unsubscribeActivity->email_address);
     $this->assertEquals("2012-12-06T13:06:53.440Z", $unsubscribeActivity->unsubscribe_date);
     $this->assertEquals("ACTION_BY_CUSTOMER", $unsubscribeActivity->unsubscribe_source);
     $this->assertEquals("", $unsubscribeActivity->unsubscribe_reason);
 }
 /**
  * Get unsubscribes for a given campaign
  * @param string $accessToken - Constant Contact OAuth2 access token
  * @param string $campaignId - Campaign id
  * @param array $params - query params to be appended to request
  * @return ResultSet - Containing a results array of {@link UnsubscribeActivity}
  */
 public function getUnsubscribes($accessToken, $campaignId, array $params = array())
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_unsubscribes'), $campaignId);
     $url = $this->buildUrl($baseUrl, $params);
     $response = parent::getRestClient()->get($url, parent::getHeaders($accessToken));
     $body = json_decode($response->body, true);
     $optOuts = array();
     foreach ($body['results'] as $opt_out_activity) {
         $optOuts[] = UnsubscribeActivity::create($opt_out_activity);
     }
     return new ResultSet($optOuts, $body['meta']);
 }
 /**
  * Get unsubscribes for a given campaign
  * @param string $accessToken - Constant Contact OAuth2 access token
  * @param string $campaignId - Campaign id
  * @param array $params - associative array of query parameters and values to append to the request.
  *      Allowed parameters include:
  *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
  *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
  *      next - the next link returned from a previous paginated call. May only be used by itself.
  * @return ResultSet - Containing a results array of {@link UnsubscribeActivity}
  * @throws CtctException
  */
 public function getUnsubscribes($accessToken, $campaignId, array $params = array())
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_unsubscribes'), $campaignId);
     $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
     if ($params) {
         $query = $request->getQuery();
         foreach ($params as $name => $value) {
             $query->add($name, $value);
         }
     }
     try {
         $response = parent::getClient()->send($request);
     } catch (ClientException $e) {
         throw parent::convertException($e);
     }
     $body = $response->json();
     $optOuts = array();
     foreach ($body['results'] as $opt_out_activity) {
         $optOuts[] = UnsubscribeActivity::create($opt_out_activity);
     }
     return new ResultSet($optOuts, $body['meta']);
 }