public function testGetSummary()
 {
     $response = self::$client->get('/');
     $summary = TrackingSummary::create($response->json());
     $this->assertInstanceOf('Ctct\\Components\\Tracking\\TrackingSummary', $summary);
     $this->assertEquals(15, $summary->sends);
     $this->assertEquals(10, $summary->opens);
     $this->assertEquals(10, $summary->clicks);
     $this->assertEquals(3, $summary->forwards);
     $this->assertEquals(2, $summary->unsubscribes);
     $this->assertEquals(18, $summary->bounces);
 }
 /**
  * Get a summary of reporting data for a given campaign
  * @param string $accessToken - Constant Contact OAuth2 access token
  * @param int $campaign_id - Campaign id
  * @return TrackingSummary
  */
 public function getSummary($accessToken, $campaign_id)
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_summary'), $campaign_id);
     $url = $this->buildUrl($baseUrl);
     $response = parent::getRestClient()->get($url, parent::getHeaders($accessToken));
     return TrackingSummary::create(json_decode($response->body, true));
 }
 /**
  * Factory method to create a Campaign object from an array
  * @param array $props - associative array of initial properties to set
  * @return Campaign
  */
 public static function create(array $props)
 {
     $campaign = new Campaign();
     $campaign->id = parent::getValue($props, "id");
     $campaign->name = parent::getValue($props, "name");
     $campaign->subject = parent::getValue($props, "subject");
     $campaign->from_name = parent::getValue($props, "from_name");
     $campaign->from_email = parent::getValue($props, "from_email");
     $campaign->reply_to_email = parent::getValue($props, "reply_to_email");
     $campaign->template_type = parent::getValue($props, "template_type");
     $campaign->created_date = parent::getValue($props, "created_date");
     $campaign->modified_date = parent::getValue($props, "modified_date");
     $campaign->last_run_date = parent::getValue($props, "last_run_date");
     $campaign->next_run_date = parent::getValue($props, "next_run_date");
     $campaign->status = parent::getValue($props, "status");
     $campaign->is_permission_reminder_enabled = parent::getValue($props, "is_permission_reminder_enabled");
     $campaign->permission_reminder_text = parent::getValue($props, "permission_reminder_text");
     $campaign->is_view_as_webpage_enabled = parent::getValue($props, "is_view_as_webpage_enabled");
     $campaign->view_as_web_page_text = parent::getValue($props, "view_as_web_page_text");
     $campaign->view_as_web_page_link_text = parent::getValue($props, "view_as_web_page_link_text");
     $campaign->greeting_salutations = parent::getValue($props, "greeting_salutations");
     $campaign->greeting_name = parent::getValue($props, "greeting_name");
     $campaign->greeting_string = parent::getValue($props, "greeting_string");
     if (array_key_exists("message_footer", $props)) {
         $campaign->message_footer = MessageFooter::create($props['message_footer']);
     }
     if (array_key_exists("tracking_summary", $props)) {
         $campaign->tracking_summary = TrackingSummary::create($props['tracking_summary']);
     }
     $campaign->email_content = parent::getValue($props, "email_content");
     $campaign->email_content_format = parent::getValue($props, "email_content_format");
     $campaign->style_sheet = parent::getValue($props, "style_sheet");
     $campaign->text_content = parent::getValue($props, "text_content");
     if (array_key_exists('sent_to_contact_lists', $props)) {
         foreach ($props['sent_to_contact_lists'] as $sent_to_contact_list) {
             $campaign->sent_to_contact_lists[] = ContactList::create($sent_to_contact_list);
         }
     }
     if (array_key_exists('click_through_details', $props)) {
         foreach ($props['click_through_details'] as $click_through_details) {
             $campaign->click_through_details[] = ClickThroughDetails::create($click_through_details);
         }
     }
     return $campaign;
 }
 /**
  * Get a summary of reporting data for a given campaign
  * @param string $accessToken - Constant Contact OAuth2 access token
  * @param int $campaignId - Campaign id
  * @return TrackingSummary
  * @throws CtctException
  */
 public function getSummary($accessToken, $campaignId)
 {
     $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_tracking_summary'), $campaignId);
     $request = parent::createBaseRequest($accessToken, 'GET', $baseUrl);
     try {
         $response = parent::getClient()->send($request);
     } catch (ClientException $e) {
         throw parent::convertException($e);
     }
     return TrackingSummary::create($response->json());
 }