/**
  * Get clicks 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 ClickActivity}
  */
 public function getClicks($accessToken, $campaignId, array $params = array())
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_clicks'), $campaignId);
     $url = $this->buildUrl($baseUrl, $params);
     $response = parent::getRestClient()->get($url, parent::getHeaders($accessToken));
     $body = json_decode($response->body, true);
     $clicks = array();
     foreach ($body['results'] as $click_activity) {
         $clicks[] = ClickActivity::create($click_activity);
     }
     return new ResultSet($clicks, $body['meta']);
 }
 public function testGetClicks()
 {
     $response = self::$client->get('/')->json();
     $resultSet = new ResultSet($response['results'], $response['meta']);
     $clickActivity = ClickActivity::create($resultSet->results[0]);
     $this->assertInstanceOf('Ctct\\Components\\ResultSet', $resultSet);
     $this->assertInstanceOf('Ctct\\Components\\Tracking\\ClickActivity', $clickActivity);
     $this->assertEquals("bGltaXQ9MyZuZXh0PTEzNTQ4MTcyMTA0MzA", $resultSet->next);
     $this->assertEquals("EMAIL_CLICK", $clickActivity->activity_type);
     $this->assertEquals(1100394165290, $clickActivity->campaign_id);
     $this->assertEquals("69", $clickActivity->contact_id);
     $this->assertEquals("*****@*****.**", $clickActivity->email_address);
     $this->assertEquals(0, $clickActivity->link_id);
     $this->assertEquals("2012-12-06T13:07:01.701Z", $clickActivity->click_date);
 }
 /**
  * Get clicks 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 ClickActivity}
  * @throws CtctException
  */
 public function getClicks($accessToken, $campaignId, array $params = array())
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_clicks'), $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();
     $clicks = array();
     foreach ($body['results'] as $click_activity) {
         $clicks[] = ClickActivity::create($click_activity);
     }
     return new ResultSet($clicks, $body['meta']);
 }