constantcontact 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -2
  3. data/README.md +56 -1
  4. data/constantcontact.gemspec +1 -1
  5. data/lib/constantcontact/api.rb +111 -97
  6. data/lib/constantcontact/services/account_service.rb +20 -22
  7. data/lib/constantcontact/services/activity_service.rb +98 -100
  8. data/lib/constantcontact/services/base_service.rb +46 -44
  9. data/lib/constantcontact/services/campaign_schedule_service.rb +72 -74
  10. data/lib/constantcontact/services/campaign_tracking_service.rb +103 -105
  11. data/lib/constantcontact/services/contact_service.rb +73 -75
  12. data/lib/constantcontact/services/contact_tracking_service.rb +103 -105
  13. data/lib/constantcontact/services/email_marketing_service.rb +64 -66
  14. data/lib/constantcontact/services/event_spot_service.rb +356 -358
  15. data/lib/constantcontact/services/library_service.rb +228 -230
  16. data/lib/constantcontact/services/list_service.rb +55 -57
  17. data/lib/constantcontact/version.rb +1 -1
  18. data/spec/constantcontact/api_spec.rb +2 -4
  19. data/spec/constantcontact/services/account_service_spec.rb +3 -2
  20. data/spec/constantcontact/services/activity_service_spec.rb +10 -9
  21. data/spec/constantcontact/services/base_service_spec.rb +7 -5
  22. data/spec/constantcontact/services/campaign_schedule_service_spec.rb +7 -6
  23. data/spec/constantcontact/services/campaign_tracking_service_spec.rb +8 -7
  24. data/spec/constantcontact/services/contact_service_spec.rb +8 -7
  25. data/spec/constantcontact/services/contact_tracking_service_spec.rb +8 -7
  26. data/spec/constantcontact/services/email_marketing_spec.rb +7 -6
  27. data/spec/constantcontact/services/event_spot_spec.rb +28 -27
  28. data/spec/constantcontact/services/library_service_spec.rb +17 -16
  29. data/spec/constantcontact/services/list_service_spec.rb +6 -5
  30. metadata +20 -20
@@ -7,146 +7,144 @@
7
7
  module ConstantContact
8
8
  module Services
9
9
  class CampaignTrackingService < BaseService
10
- class << self
11
-
12
- # Get bounces for a given campaign
13
- # @param [String] campaign_id - Campaign id
14
- # @param [Hash] params - query parameters to be appended to request
15
- # @return [ResultSet<BounceActivity>] - Containing a results array of BounceActivity
16
- def get_bounces(campaign_id, params = {})
17
- url = Util::Config.get('endpoints.base_url') +
18
- sprintf(Util::Config.get('endpoints.campaign_tracking_bounces'), campaign_id)
19
- url = build_url(url, params)
20
-
21
- response = RestClient.get(url, get_headers())
22
- body = JSON.parse(response.body)
23
-
24
- bounces = []
25
- body['results'].each do |bounce_activity|
26
- bounces << Components::BounceActivity.create(bounce_activity)
27
- end
28
-
29
- Components::ResultSet.new(bounces, body['meta'])
10
+
11
+ # Get bounces for a given campaign
12
+ # @param [String] campaign_id - Campaign id
13
+ # @param [Hash] params - query parameters to be appended to request
14
+ # @return [ResultSet<BounceActivity>] - Containing a results array of BounceActivity
15
+ def get_bounces(campaign_id, params = {})
16
+ url = Util::Config.get('endpoints.base_url') +
17
+ sprintf(Util::Config.get('endpoints.campaign_tracking_bounces'), campaign_id)
18
+ url = build_url(url, params)
19
+
20
+ response = RestClient.get(url, get_headers())
21
+ body = JSON.parse(response.body)
22
+
23
+ bounces = []
24
+ body['results'].each do |bounce_activity|
25
+ bounces << Components::BounceActivity.create(bounce_activity)
30
26
  end
31
27
 
28
+ Components::ResultSet.new(bounces, body['meta'])
29
+ end
32
30
 
33
- # Get clicks for a given campaign
34
- # @param [String] campaign_id - Campaign id
35
- # @param [Hash] params - query parameters to be appended to request
36
- # @return [ResultSet<ClickActivity>] - Containing a results array of ClickActivity
37
- def get_clicks(campaign_id, params = {})
38
- url = Util::Config.get('endpoints.base_url') +
39
- sprintf(Util::Config.get('endpoints.campaign_tracking_clicks'), campaign_id)
40
- url = build_url(url, params)
41
31
 
42
- response = RestClient.get(url, get_headers())
43
- body = JSON.parse(response.body)
32
+ # Get clicks for a given campaign
33
+ # @param [String] campaign_id - Campaign id
34
+ # @param [Hash] params - query parameters to be appended to request
35
+ # @return [ResultSet<ClickActivity>] - Containing a results array of ClickActivity
36
+ def get_clicks(campaign_id, params = {})
37
+ url = Util::Config.get('endpoints.base_url') +
38
+ sprintf(Util::Config.get('endpoints.campaign_tracking_clicks'), campaign_id)
39
+ url = build_url(url, params)
44
40
 
45
- clicks = []
46
- body['results'].each do |click_activity|
47
- clicks << Components::ClickActivity.create(click_activity)
48
- end
41
+ response = RestClient.get(url, get_headers())
42
+ body = JSON.parse(response.body)
49
43
 
50
- Components::ResultSet.new(clicks, body['meta'])
44
+ clicks = []
45
+ body['results'].each do |click_activity|
46
+ clicks << Components::ClickActivity.create(click_activity)
51
47
  end
52
48
 
49
+ Components::ResultSet.new(clicks, body['meta'])
50
+ end
53
51
 
54
- # Get forwards for a given campaign
55
- # @param [String] campaign_id - Campaign id
56
- # @param [Hash] params - query parameters to be appended to request
57
- # @return [ResultSet<ForwardActivity>] - Containing a results array of ForwardActivity
58
- def get_forwards(campaign_id, params = {})
59
- url = Util::Config.get('endpoints.base_url') +
60
- sprintf(Util::Config.get('endpoints.campaign_tracking_forwards'), campaign_id)
61
- url = build_url(url, params)
62
52
 
63
- response = RestClient.get(url, get_headers())
64
- body = JSON.parse(response.body)
53
+ # Get forwards for a given campaign
54
+ # @param [String] campaign_id - Campaign id
55
+ # @param [Hash] params - query parameters to be appended to request
56
+ # @return [ResultSet<ForwardActivity>] - Containing a results array of ForwardActivity
57
+ def get_forwards(campaign_id, params = {})
58
+ url = Util::Config.get('endpoints.base_url') +
59
+ sprintf(Util::Config.get('endpoints.campaign_tracking_forwards'), campaign_id)
60
+ url = build_url(url, params)
65
61
 
66
- forwards = []
67
- body['results'].each do |forward_activity|
68
- forwards << Components::ForwardActivity.create(forward_activity)
69
- end
62
+ response = RestClient.get(url, get_headers())
63
+ body = JSON.parse(response.body)
70
64
 
71
- Components::ResultSet.new(forwards, body['meta'])
65
+ forwards = []
66
+ body['results'].each do |forward_activity|
67
+ forwards << Components::ForwardActivity.create(forward_activity)
72
68
  end
73
69
 
70
+ Components::ResultSet.new(forwards, body['meta'])
71
+ end
74
72
 
75
- # Get opens for a given campaign
76
- # @param [String] campaign_id - Campaign id
77
- # @param [Hash] params - query parameters to be appended to request
78
- # @return [ResultSet<OpenActivity>] - Containing a results array of OpenActivity
79
- def get_opens(campaign_id, params = {})
80
- url = Util::Config.get('endpoints.base_url') +
81
- sprintf(Util::Config.get('endpoints.campaign_tracking_opens'), campaign_id)
82
- url = build_url(url, params)
83
73
 
84
- response = RestClient.get(url, get_headers())
85
- body = JSON.parse(response.body)
74
+ # Get opens for a given campaign
75
+ # @param [String] campaign_id - Campaign id
76
+ # @param [Hash] params - query parameters to be appended to request
77
+ # @return [ResultSet<OpenActivity>] - Containing a results array of OpenActivity
78
+ def get_opens(campaign_id, params = {})
79
+ url = Util::Config.get('endpoints.base_url') +
80
+ sprintf(Util::Config.get('endpoints.campaign_tracking_opens'), campaign_id)
81
+ url = build_url(url, params)
86
82
 
87
- opens = []
88
- body['results'].each do |open_activity|
89
- opens << Components::OpenActivity.create(open_activity)
90
- end
83
+ response = RestClient.get(url, get_headers())
84
+ body = JSON.parse(response.body)
91
85
 
92
- Components::ResultSet.new(opens, body['meta'])
86
+ opens = []
87
+ body['results'].each do |open_activity|
88
+ opens << Components::OpenActivity.create(open_activity)
93
89
  end
94
90
 
91
+ Components::ResultSet.new(opens, body['meta'])
92
+ end
95
93
 
96
- # Get sends for a given campaign
97
- # @param [String] campaign_id - Campaign id
98
- # @param [Hash] params - query parameters to be appended to request
99
- # @return [ResultSet<SendActivity>] - Containing a results array of SendActivity
100
- def get_sends(campaign_id, params = {})
101
- url = Util::Config.get('endpoints.base_url') +
102
- sprintf(Util::Config.get('endpoints.campaign_tracking_sends'), campaign_id)
103
- url = build_url(url, params)
104
94
 
105
- response = RestClient.get(url, get_headers())
106
- body = JSON.parse(response.body)
95
+ # Get sends for a given campaign
96
+ # @param [String] campaign_id - Campaign id
97
+ # @param [Hash] params - query parameters to be appended to request
98
+ # @return [ResultSet<SendActivity>] - Containing a results array of SendActivity
99
+ def get_sends(campaign_id, params = {})
100
+ url = Util::Config.get('endpoints.base_url') +
101
+ sprintf(Util::Config.get('endpoints.campaign_tracking_sends'), campaign_id)
102
+ url = build_url(url, params)
107
103
 
108
- sends = []
109
- body['results'].each do |send_activity|
110
- sends << Components::SendActivity.create(send_activity)
111
- end
104
+ response = RestClient.get(url, get_headers())
105
+ body = JSON.parse(response.body)
112
106
 
113
- Components::ResultSet.new(sends, body['meta'])
107
+ sends = []
108
+ body['results'].each do |send_activity|
109
+ sends << Components::SendActivity.create(send_activity)
114
110
  end
115
111
 
112
+ Components::ResultSet.new(sends, body['meta'])
113
+ end
116
114
 
117
- # Get unsubscribes for a given campaign
118
- # @param [String] campaign_id - Campaign id
119
- # @param [Hash] params - query params to be appended to request
120
- # @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
121
- def get_unsubscribes(campaign_id, params = {})
122
- url = Util::Config.get('endpoints.base_url') +
123
- sprintf(Util::Config.get('endpoints.campaign_tracking_unsubscribes'), campaign_id)
124
- url = build_url(url, params)
125
115
 
126
- response = RestClient.get(url, get_headers())
127
- body = JSON.parse(response.body)
116
+ # Get unsubscribes for a given campaign
117
+ # @param [String] campaign_id - Campaign id
118
+ # @param [Hash] params - query params to be appended to request
119
+ # @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
120
+ def get_unsubscribes(campaign_id, params = {})
121
+ url = Util::Config.get('endpoints.base_url') +
122
+ sprintf(Util::Config.get('endpoints.campaign_tracking_unsubscribes'), campaign_id)
123
+ url = build_url(url, params)
128
124
 
129
- unsubscribes = []
130
- body['results'].each do |unsubscribe_activity|
131
- unsubscribes << Components::UnsubscribeActivity.create(unsubscribe_activity)
132
- end
125
+ response = RestClient.get(url, get_headers())
126
+ body = JSON.parse(response.body)
133
127
 
134
- Components::ResultSet.new(unsubscribes, body['meta'])
128
+ unsubscribes = []
129
+ body['results'].each do |unsubscribe_activity|
130
+ unsubscribes << Components::UnsubscribeActivity.create(unsubscribe_activity)
135
131
  end
136
132
 
133
+ Components::ResultSet.new(unsubscribes, body['meta'])
134
+ end
137
135
 
138
- # Get a summary of reporting data for a given campaign
139
- # @param [Integer] campaign_id - Campaign id
140
- # @return [TrackingSummary]
141
- def get_summary(campaign_id)
142
- url = Util::Config.get('endpoints.base_url') +
143
- sprintf(Util::Config.get('endpoints.campaign_tracking_summary'), campaign_id)
144
- url = build_url(url)
145
- response = RestClient.get(url, get_headers())
146
- Components::TrackingSummary.create(JSON.parse(response.body))
147
- end
148
136
 
137
+ # Get a summary of reporting data for a given campaign
138
+ # @param [Integer] campaign_id - Campaign id
139
+ # @return [TrackingSummary]
140
+ def get_summary(campaign_id)
141
+ url = Util::Config.get('endpoints.base_url') +
142
+ sprintf(Util::Config.get('endpoints.campaign_tracking_summary'), campaign_id)
143
+ url = build_url(url)
144
+ response = RestClient.get(url, get_headers())
145
+ Components::TrackingSummary.create(JSON.parse(response.body))
149
146
  end
147
+
150
148
  end
151
149
  end
152
150
  end
@@ -7,99 +7,97 @@
7
7
  module ConstantContact
8
8
  module Services
9
9
  class ContactService < BaseService
10
- class << self
11
10
 
12
- # Get an array of contacts
13
- # @param [Hash] params - query parameters to be appended to the request
14
- # @return [ResultSet<Contact>]
15
- def get_contacts(params = {})
16
- url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.contacts')
17
- url = build_url(url, params)
11
+ # Get an array of contacts
12
+ # @param [Hash] params - query parameters to be appended to the request
13
+ # @return [ResultSet<Contact>]
14
+ def get_contacts(params = {})
15
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.contacts')
16
+ url = build_url(url, params)
18
17
 
19
- response = RestClient.get(url, get_headers())
20
- body = JSON.parse(response.body)
18
+ response = RestClient.get(url, get_headers())
19
+ body = JSON.parse(response.body)
21
20
 
22
- contacts = []
23
- body['results'].each do |contact|
24
- contacts << Components::Contact.create(contact)
25
- end
26
-
27
- Components::ResultSet.new(contacts, body['meta'])
21
+ contacts = []
22
+ body['results'].each do |contact|
23
+ contacts << Components::Contact.create(contact)
28
24
  end
29
25
 
26
+ Components::ResultSet.new(contacts, body['meta'])
27
+ end
30
28
 
31
- # Get contact details for a specific contact
32
- # @param [Integer] contact_id - Unique contact id
33
- # @return [Contact]
34
- def get_contact(contact_id)
35
- url = Util::Config.get('endpoints.base_url') +
36
- sprintf(Util::Config.get('endpoints.contact'), contact_id)
37
- url = build_url(url)
38
- response = RestClient.get(url, get_headers())
39
- Components::Contact.create(JSON.parse(response.body))
40
- end
41
29
 
30
+ # Get contact details for a specific contact
31
+ # @param [Integer] contact_id - Unique contact id
32
+ # @return [Contact]
33
+ def get_contact(contact_id)
34
+ url = Util::Config.get('endpoints.base_url') +
35
+ sprintf(Util::Config.get('endpoints.contact'), contact_id)
36
+ url = build_url(url)
37
+ response = RestClient.get(url, get_headers())
38
+ Components::Contact.create(JSON.parse(response.body))
39
+ end
42
40
 
43
- # Add a new contact to the Constant Contact account
44
- # @param [Contact] contact - Contact to add
45
- # @param [Boolean] params - query params to be appended to the request
46
- # @return [Contact]
47
- def add_contact(contact, params = {})
48
- url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.contacts')
49
- url = build_url(url, params)
50
- payload = contact.to_json
51
- response = RestClient.post(url, payload, get_headers())
52
- Components::Contact.create(JSON.parse(response.body))
53
- end
54
41
 
42
+ # Add a new contact to the Constant Contact account
43
+ # @param [Contact] contact - Contact to add
44
+ # @param [Boolean] params - query params to be appended to the request
45
+ # @return [Contact]
46
+ def add_contact(contact, params = {})
47
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.contacts')
48
+ url = build_url(url, params)
49
+ payload = contact.to_json
50
+ response = RestClient.post(url, payload, get_headers())
51
+ Components::Contact.create(JSON.parse(response.body))
52
+ end
55
53
 
56
- # Delete contact details for a specific contact
57
- # @param [Integer] contact_id - Unique contact id
58
- # @return [Boolean]
59
- def delete_contact(contact_id)
60
- url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact'), contact_id)
61
- url = build_url(url)
62
- response = RestClient.delete(url, get_headers())
63
- response.code == 204
64
- end
65
54
 
55
+ # Delete contact details for a specific contact
56
+ # @param [Integer] contact_id - Unique contact id
57
+ # @return [Boolean]
58
+ def delete_contact(contact_id)
59
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact'), contact_id)
60
+ url = build_url(url)
61
+ response = RestClient.delete(url, get_headers())
62
+ response.code == 204
63
+ end
66
64
 
67
- # Delete a contact from all contact lists
68
- # @param [Integer] contact_id - Contact id to be removed from lists
69
- # @return [Boolean]
70
- def delete_contact_from_lists(contact_id)
71
- url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact_lists'), contact_id)
72
- url = build_url(url)
73
- response = RestClient.delete(url, get_headers())
74
- response.code == 204
75
- end
76
65
 
66
+ # Delete a contact from all contact lists
67
+ # @param [Integer] contact_id - Contact id to be removed from lists
68
+ # @return [Boolean]
69
+ def delete_contact_from_lists(contact_id)
70
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact_lists'), contact_id)
71
+ url = build_url(url)
72
+ response = RestClient.delete(url, get_headers())
73
+ response.code == 204
74
+ end
77
75
 
78
- # Delete a contact from a specific contact list
79
- # @param [Integer] contact_id - Contact id to be removed
80
- # @param [Integer] list_id - ContactList id to remove the contact from
81
- # @return [Boolean]
82
- def delete_contact_from_list(contact_id, list_id)
83
- url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact_list'), contact_id, list_id)
84
- url = build_url(url)
85
- response = RestClient.delete(url, get_headers())
86
- response.code == 204
87
- end
88
76
 
77
+ # Delete a contact from a specific contact list
78
+ # @param [Integer] contact_id - Contact id to be removed
79
+ # @param [Integer] list_id - ContactList id to remove the contact from
80
+ # @return [Boolean]
81
+ def delete_contact_from_list(contact_id, list_id)
82
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact_list'), contact_id, list_id)
83
+ url = build_url(url)
84
+ response = RestClient.delete(url, get_headers())
85
+ response.code == 204
86
+ end
89
87
 
90
- # Update contact details for a specific contact
91
- # @param [Contact] contact - Contact to be updated
92
- # @param [Hash] params - query params to be appended to the request
93
- # @return [Contact]
94
- def update_contact(contact, params = {})
95
- url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact'), contact.id)
96
- url = build_url(url, params)
97
- payload = contact.to_json
98
- response = RestClient.put(url, payload, get_headers())
99
- Components::Contact.create(JSON.parse(response.body))
100
- end
101
88
 
89
+ # Update contact details for a specific contact
90
+ # @param [Contact] contact - Contact to be updated
91
+ # @param [Hash] params - query params to be appended to the request
92
+ # @return [Contact]
93
+ def update_contact(contact, params = {})
94
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.contact'), contact.id)
95
+ url = build_url(url, params)
96
+ payload = contact.to_json
97
+ response = RestClient.put(url, payload, get_headers())
98
+ Components::Contact.create(JSON.parse(response.body))
102
99
  end
100
+
103
101
  end
104
102
  end
105
103
  end
@@ -7,146 +7,144 @@
7
7
  module ConstantContact
8
8
  module Services
9
9
  class ContactTrackingService < BaseService
10
- class << self
11
-
12
- # Get bounces for a given contact
13
- # @param [String] contact_id - Contact id
14
- # @param [Hash] params - query parameters to be appended to request
15
- # @return [ResultSet<BounceActivity>] - Containing a results array of BounceActivity
16
- def get_bounces(contact_id, params = {})
17
- url = Util::Config.get('endpoints.base_url') +
18
- sprintf(Util::Config.get('endpoints.contact_tracking_bounces'), contact_id)
19
- url = build_url(url, params)
20
-
21
- response = RestClient.get(url, get_headers())
22
- body = JSON.parse(response.body)
23
-
24
- bounces = []
25
- body['results'].each do |bounce_activity|
26
- bounces << Components::BounceActivity.create(bounce_activity)
27
- end
28
-
29
- Components::ResultSet.new(bounces, body['meta'])
10
+
11
+ # Get bounces for a given contact
12
+ # @param [String] contact_id - Contact id
13
+ # @param [Hash] params - query parameters to be appended to request
14
+ # @return [ResultSet<BounceActivity>] - Containing a results array of BounceActivity
15
+ def get_bounces(contact_id, params = {})
16
+ url = Util::Config.get('endpoints.base_url') +
17
+ sprintf(Util::Config.get('endpoints.contact_tracking_bounces'), contact_id)
18
+ url = build_url(url, params)
19
+
20
+ response = RestClient.get(url, get_headers())
21
+ body = JSON.parse(response.body)
22
+
23
+ bounces = []
24
+ body['results'].each do |bounce_activity|
25
+ bounces << Components::BounceActivity.create(bounce_activity)
30
26
  end
31
27
 
28
+ Components::ResultSet.new(bounces, body['meta'])
29
+ end
32
30
 
33
- # Get clicks for a given contact
34
- # @param [String] contact_id - Contact id
35
- # @param [Hash] params - query parameters to be appended to request
36
- # @return [ResultSet<ClickActivity>] - Containing a results array of ClickActivity
37
- def get_clicks(contact_id, params = {})
38
- url = Util::Config.get('endpoints.base_url') +
39
- sprintf(Util::Config.get('endpoints.contact_tracking_clicks'), contact_id)
40
- url = build_url(url, params)
41
31
 
42
- response = RestClient.get(url, get_headers())
43
- body = JSON.parse(response.body)
32
+ # Get clicks for a given contact
33
+ # @param [String] contact_id - Contact id
34
+ # @param [Hash] params - query parameters to be appended to request
35
+ # @return [ResultSet<ClickActivity>] - Containing a results array of ClickActivity
36
+ def get_clicks(contact_id, params = {})
37
+ url = Util::Config.get('endpoints.base_url') +
38
+ sprintf(Util::Config.get('endpoints.contact_tracking_clicks'), contact_id)
39
+ url = build_url(url, params)
44
40
 
45
- clicks = []
46
- body['results'].each do |click_activity|
47
- clicks << Components::ClickActivity.create(click_activity)
48
- end
41
+ response = RestClient.get(url, get_headers())
42
+ body = JSON.parse(response.body)
49
43
 
50
- Components::ResultSet.new(clicks, body['meta'])
44
+ clicks = []
45
+ body['results'].each do |click_activity|
46
+ clicks << Components::ClickActivity.create(click_activity)
51
47
  end
52
48
 
49
+ Components::ResultSet.new(clicks, body['meta'])
50
+ end
53
51
 
54
- # Get forwards for a given contact
55
- # @param [String] contact_id - Contact id
56
- # @param [Hash] params - query parameters to be appended to request
57
- # @return [ResultSet<ForwardActivity>] - Containing a results array of ForwardActivity
58
- def get_forwards(contact_id, params = {})
59
- url = Util::Config.get('endpoints.base_url') +
60
- sprintf(Util::Config.get('endpoints.contact_tracking_forwards'), contact_id)
61
- url = build_url(url, params)
62
52
 
63
- response = RestClient.get(url, get_headers())
64
- body = JSON.parse(response.body)
53
+ # Get forwards for a given contact
54
+ # @param [String] contact_id - Contact id
55
+ # @param [Hash] params - query parameters to be appended to request
56
+ # @return [ResultSet<ForwardActivity>] - Containing a results array of ForwardActivity
57
+ def get_forwards(contact_id, params = {})
58
+ url = Util::Config.get('endpoints.base_url') +
59
+ sprintf(Util::Config.get('endpoints.contact_tracking_forwards'), contact_id)
60
+ url = build_url(url, params)
65
61
 
66
- forwards = []
67
- body['results'].each do |forward_activity|
68
- forwards << Components::ForwardActivity.create(forward_activity)
69
- end
62
+ response = RestClient.get(url, get_headers())
63
+ body = JSON.parse(response.body)
70
64
 
71
- Components::ResultSet.new(forwards, body['meta'])
65
+ forwards = []
66
+ body['results'].each do |forward_activity|
67
+ forwards << Components::ForwardActivity.create(forward_activity)
72
68
  end
73
69
 
70
+ Components::ResultSet.new(forwards, body['meta'])
71
+ end
74
72
 
75
- # Get opens for a given contact
76
- # @param [String] contact_id - Contact id
77
- # @param [Hash] params - query parameters to be appended to request
78
- # @return [ResultSet<OpenActivity>] - Containing a results array of OpenActivity
79
- def get_opens(contact_id, params = {})
80
- url = Util::Config.get('endpoints.base_url') +
81
- sprintf(Util::Config.get('endpoints.contact_tracking_opens'), contact_id)
82
- url = build_url(url, params)
83
73
 
84
- response = RestClient.get(url, get_headers())
85
- body = JSON.parse(response.body)
74
+ # Get opens for a given contact
75
+ # @param [String] contact_id - Contact id
76
+ # @param [Hash] params - query parameters to be appended to request
77
+ # @return [ResultSet<OpenActivity>] - Containing a results array of OpenActivity
78
+ def get_opens(contact_id, params = {})
79
+ url = Util::Config.get('endpoints.base_url') +
80
+ sprintf(Util::Config.get('endpoints.contact_tracking_opens'), contact_id)
81
+ url = build_url(url, params)
86
82
 
87
- opens = []
88
- body['results'].each do |open_activity|
89
- opens << Components::OpenActivity.create(open_activity)
90
- end
83
+ response = RestClient.get(url, get_headers())
84
+ body = JSON.parse(response.body)
91
85
 
92
- Components::ResultSet.new(opens, body['meta'])
86
+ opens = []
87
+ body['results'].each do |open_activity|
88
+ opens << Components::OpenActivity.create(open_activity)
93
89
  end
94
90
 
91
+ Components::ResultSet.new(opens, body['meta'])
92
+ end
95
93
 
96
- # Get sends for a given contact
97
- # @param [String] contact_id - Contact id
98
- # @param [Hash] params - query parameters to be appended to request
99
- # @return [ResultSet<SendActivity>] - Containing a results array of SendActivity
100
- def get_sends(contact_id, params = {})
101
- url = Util::Config.get('endpoints.base_url') +
102
- sprintf(Util::Config.get('endpoints.contact_tracking_sends'), contact_id)
103
- url = build_url(url, params)
104
94
 
105
- response = RestClient.get(url, get_headers())
106
- body = JSON.parse(response.body)
95
+ # Get sends for a given contact
96
+ # @param [String] contact_id - Contact id
97
+ # @param [Hash] params - query parameters to be appended to request
98
+ # @return [ResultSet<SendActivity>] - Containing a results array of SendActivity
99
+ def get_sends(contact_id, params = {})
100
+ url = Util::Config.get('endpoints.base_url') +
101
+ sprintf(Util::Config.get('endpoints.contact_tracking_sends'), contact_id)
102
+ url = build_url(url, params)
107
103
 
108
- sends = []
109
- body['results'].each do |send_activity|
110
- sends << Components::SendActivity.create(send_activity)
111
- end
104
+ response = RestClient.get(url, get_headers())
105
+ body = JSON.parse(response.body)
112
106
 
113
- Components::ResultSet.new(sends, body['meta'])
107
+ sends = []
108
+ body['results'].each do |send_activity|
109
+ sends << Components::SendActivity.create(send_activity)
114
110
  end
115
111
 
112
+ Components::ResultSet.new(sends, body['meta'])
113
+ end
116
114
 
117
- # Get unsubscribes for a given contact
118
- # @param [String] contact_id - Contact id
119
- # @param [Hash] params - query parameters to be appended to request
120
- # @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
121
- def get_unsubscribes(contact_id, params = {})
122
- url = Util::Config.get('endpoints.base_url') +
123
- sprintf(Util::Config.get('endpoints.contact_tracking_unsubscribes'), contact_id)
124
- url = build_url(url, params)
125
115
 
126
- response = RestClient.get(url, get_headers())
127
- body = JSON.parse(response.body)
116
+ # Get unsubscribes for a given contact
117
+ # @param [String] contact_id - Contact id
118
+ # @param [Hash] params - query parameters to be appended to request
119
+ # @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
120
+ def get_unsubscribes(contact_id, params = {})
121
+ url = Util::Config.get('endpoints.base_url') +
122
+ sprintf(Util::Config.get('endpoints.contact_tracking_unsubscribes'), contact_id)
123
+ url = build_url(url, params)
128
124
 
129
- unsubscribes = []
130
- body['results'].each do |unsubscribe_activity|
131
- unsubscribes << Components::UnsubscribeActivity.create(unsubscribe_activity)
132
- end
125
+ response = RestClient.get(url, get_headers())
126
+ body = JSON.parse(response.body)
133
127
 
134
- Components::ResultSet.new(unsubscribes, body['meta'])
128
+ unsubscribes = []
129
+ body['results'].each do |unsubscribe_activity|
130
+ unsubscribes << Components::UnsubscribeActivity.create(unsubscribe_activity)
135
131
  end
136
132
 
133
+ Components::ResultSet.new(unsubscribes, body['meta'])
134
+ end
137
135
 
138
- # Get a summary of reporting data for a given contact
139
- # @param [String] contact_id - Contact id
140
- # @return [TrackingSummary]
141
- def get_summary(contact_id)
142
- url = Util::Config.get('endpoints.base_url') +
143
- sprintf(Util::Config.get('endpoints.contact_tracking_summary'), contact_id)
144
- url = build_url(url)
145
- response = RestClient.get(url, get_headers())
146
- Components::TrackingSummary.create(JSON.parse(response.body))
147
- end
148
136
 
137
+ # Get a summary of reporting data for a given contact
138
+ # @param [String] contact_id - Contact id
139
+ # @return [TrackingSummary]
140
+ def get_summary(contact_id)
141
+ url = Util::Config.get('endpoints.base_url') +
142
+ sprintf(Util::Config.get('endpoints.contact_tracking_summary'), contact_id)
143
+ url = build_url(url)
144
+ response = RestClient.get(url, get_headers())
145
+ Components::TrackingSummary.create(JSON.parse(response.body))
149
146
  end
147
+
150
148
  end
151
149
  end
152
150
  end