/**
  * Get a result set of bounces for a given campaign
  * @param string $accessToken - Constant Contact OAuth2 access token
  * @param string $campaign_id - Campaign id
  * @param array $params - query parameters to be appended to the request
  * @return ResultSet - Containing a results array of {@link BounceActivity}
  */
 public function getBounces($accessToken, $campaign_id, array $params = array())
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_bounces'), $campaign_id);
     $url = $this->buildUrl($baseUrl, $params);
     $response = parent::getRestClient()->get($url, parent::getHeaders($accessToken));
     $body = json_decode($response->body, true);
     $bounces = array();
     foreach ($body['results'] as $bounceActivity) {
         $bounces[] = BounceActivity::create($bounceActivity);
     }
     return new ResultSet($bounces, $body['meta']);
 }
 public function testGetBounces()
 {
     $response = self::$client->get('/')->json();
     $resultSet = new ResultSet($response['results'], $response['meta']);
     $bounceActivity = BounceActivity::create($resultSet->results[0]);
     $this->assertInstanceOf('Ctct\\Components\\ResultSet', $resultSet);
     $this->assertInstanceOf('Ctct\\Components\\Tracking\\BounceActivity', $bounceActivity);
     $this->assertEquals("bGltaXQ9MyZuZXh0PTEzNTQ4MTcyMTA0MzA", $resultSet->next);
     $this->assertEquals("EMAIL_BOUNCE", $bounceActivity->activity_type);
     $this->assertEquals(1100394165290, $bounceActivity->campaign_id);
     $this->assertEquals("2", $bounceActivity->contact_id);
     $this->assertEquals("*****@*****.**", $bounceActivity->email_address);
     $this->assertEquals("B", $bounceActivity->bounce_code);
     $this->assertEquals("Non-existent address", $bounceActivity->bounce_description);
     $this->assertEquals("", $bounceActivity->bounce_message);
     $this->assertEquals("2012-12-06T13:05:24.844Z", $bounceActivity->bounce_date);
 }
 /**
  * Get a result set of bounces 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 BounceActivity}
  * @throws CtctException
  */
 public function getBounces($accessToken, $campaignId, array $params = array())
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_bounces'), $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();
     $bounces = array();
     foreach ($body['results'] as $bounceActivity) {
         $bounces[] = BounceActivity::create($bounceActivity);
     }
     return new ResultSet($bounces, $body['meta']);
 }