constantcontact 1.0.0 → 1.0.1
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.
- checksums.yaml +7 -7
- data/README.md +7 -0
- data/constantcontact.gemspec +1 -1
- data/lib/constantcontact.rb +54 -54
- data/lib/constantcontact/api.rb +5 -3
- data/lib/constantcontact/auth/oauth2.rb +7 -4
- data/lib/constantcontact/auth/session_data_store.rb +52 -52
- data/lib/constantcontact/components/account/verified_email_address.rb +17 -17
- data/lib/constantcontact/components/activities/activity.rb +34 -34
- data/lib/constantcontact/components/activities/activity_error.rb +17 -17
- data/lib/constantcontact/components/activities/add_contacts.rb +109 -109
- data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -37
- data/lib/constantcontact/components/activities/export_contacts.rb +19 -19
- data/lib/constantcontact/components/component.rb +13 -13
- data/lib/constantcontact/components/contacts/address.rb +18 -18
- data/lib/constantcontact/components/contacts/contact.rb +69 -69
- data/lib/constantcontact/components/contacts/contact_list.rb +17 -17
- data/lib/constantcontact/components/contacts/custom_field.rb +17 -17
- data/lib/constantcontact/components/contacts/email_address.rb +23 -23
- data/lib/constantcontact/components/contacts/note.rb +16 -16
- data/lib/constantcontact/components/email_marketing/campaign.rb +67 -67
- data/lib/constantcontact/components/email_marketing/click_through_details.rb +17 -17
- data/lib/constantcontact/components/email_marketing/message_footer.rb +20 -20
- data/lib/constantcontact/components/email_marketing/schedule.rb +18 -18
- data/lib/constantcontact/components/email_marketing/test_send.rb +32 -32
- data/lib/constantcontact/components/result_set.rb +15 -15
- data/lib/constantcontact/components/tracking/bounce_activity.rb +18 -18
- data/lib/constantcontact/components/tracking/click_activity.rb +17 -17
- data/lib/constantcontact/components/tracking/forward_activity.rb +17 -17
- data/lib/constantcontact/components/tracking/open_activity.rb +17 -17
- data/lib/constantcontact/components/tracking/send_activity.rb +17 -17
- data/lib/constantcontact/components/tracking/tracking_activity.rb +15 -15
- data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
- data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +18 -18
- data/lib/constantcontact/exceptions/ctct_exception.rb +15 -15
- data/lib/constantcontact/exceptions/illegal_argument_exception.rb +3 -3
- data/lib/constantcontact/exceptions/oauth2_exception.rb +3 -3
- data/lib/constantcontact/services/account_service.rb +19 -19
- data/lib/constantcontact/services/activity_service.rb +99 -99
- data/lib/constantcontact/services/base_service.rb +24 -24
- data/lib/constantcontact/services/campaign_schedule_service.rb +85 -85
- data/lib/constantcontact/services/campaign_tracking_service.rb +151 -151
- data/lib/constantcontact/services/contact_service.rb +106 -106
- data/lib/constantcontact/services/contact_tracking_service.rb +151 -151
- data/lib/constantcontact/services/email_marketing_service.rb +66 -66
- data/lib/constantcontact/services/list_service.rb +67 -67
- data/lib/constantcontact/util/config.rb +102 -96
- data/lib/constantcontact/util/helpers.rb +18 -18
- data/lib/constantcontact/version.rb +4 -4
- data/spec/constantcontact/api_spec.rb +223 -173
- data/spec/constantcontact/auth/oauth2_spec.rb +68 -4
- data/spec/constantcontact/components/contacts/address_spec.rb +7 -7
- data/spec/constantcontact/components/contacts/contact_list_spec.rb +7 -7
- data/spec/constantcontact/components/contacts/contact_spec.rb +7 -7
- data/spec/constantcontact/components/contacts/custom_field_spec.rb +7 -7
- data/spec/constantcontact/components/contacts/email_address_spec.rb +7 -7
- data/spec/constantcontact/services/contact_service_spec.rb +95 -95
- data/spec/constantcontact/services/list_service_spec.rb +48 -48
- data/spec/spec_helper.rb +1 -1
- metadata +55 -44
@@ -5,155 +5,155 @@
|
|
5
5
|
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
6
|
|
7
7
|
module ConstantContact
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
8
|
+
module Services
|
9
|
+
class ContactTrackingService < BaseService
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# Get a result set of bounces for a given contact
|
13
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
|
+
# @param [String] contact_id - Contact id
|
15
|
+
# @param [Hash] param - query parameters to be appended to request
|
16
|
+
# @return [ResultSet<BounceActivity>] - Containing a results array of BounceActivity
|
17
|
+
def get_bounces(access_token, contact_id, param = nil)
|
18
|
+
url = Util::Config.get('endpoints.base_url') +
|
19
|
+
sprintf(Util::Config.get('endpoints.contact_tracking_bounces'), contact_id)
|
20
|
+
url = build_url(url, param)
|
21
|
+
|
22
|
+
response = RestClient.get(url, get_headers(access_token))
|
23
|
+
body = JSON.parse(response.body)
|
24
|
+
|
25
|
+
bounces = []
|
26
|
+
body['results'].each do |bounce_activity|
|
27
|
+
bounces << Components::BounceActivity.create(bounce_activity)
|
28
|
+
end
|
29
|
+
|
30
|
+
Components::ResultSet.new(bounces, body['meta'])
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# Get clicks for a given contact
|
35
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
36
|
+
# @param [String] contact_id - Contact id
|
37
|
+
# @param [Hash] param - query parameters to be appended to request
|
38
|
+
# @return [ResultSet<ClickActivity>] - Containing a results array of ClickActivity
|
39
|
+
def get_clicks(access_token, contact_id, param = nil)
|
40
|
+
url = Util::Config.get('endpoints.base_url') +
|
41
|
+
sprintf(Util::Config.get('endpoints.contact_tracking_clicks'), contact_id)
|
42
|
+
url = build_url(url, param)
|
43
|
+
|
44
|
+
response = RestClient.get(url, get_headers(access_token))
|
45
|
+
body = JSON.parse(response.body)
|
46
|
+
|
47
|
+
clicks = []
|
48
|
+
body['results'].each do |click_activity|
|
49
|
+
clicks << Components::ClickActivity.create(click_activity)
|
50
|
+
end
|
51
|
+
|
52
|
+
Components::ResultSet.new(clicks, body['meta'])
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
# Get forwards for a given contact
|
57
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
58
|
+
# @param [String] contact_id - Contact id
|
59
|
+
# @param [Hash] param - query parameters to be appended to request
|
60
|
+
# @return [ResultSet<ForwardActivity>] - Containing a results array of ForwardActivity
|
61
|
+
def get_forwards(access_token, contact_id, param = nil)
|
62
|
+
url = Util::Config.get('endpoints.base_url') +
|
63
|
+
sprintf(Util::Config.get('endpoints.contact_tracking_forwards'), contact_id)
|
64
|
+
url = build_url(url, param)
|
65
|
+
|
66
|
+
response = RestClient.get(url, get_headers(access_token))
|
67
|
+
body = JSON.parse(response.body)
|
68
|
+
|
69
|
+
forwards = []
|
70
|
+
body['results'].each do |forward_activity|
|
71
|
+
forwards << Components::ForwardActivity.create(forward_activity)
|
72
|
+
end
|
73
|
+
|
74
|
+
Components::ResultSet.new(forwards, body['meta'])
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# Get opens for a given contact
|
79
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
80
|
+
# @param [String] contact_id - Contact id
|
81
|
+
# @param [Hash] param - query parameters to be appended to request
|
82
|
+
# @return [ResultSet<OpenActivity>] - Containing a results array of OpenActivity
|
83
|
+
def get_opens(access_token, contact_id, param = nil)
|
84
|
+
url = Util::Config.get('endpoints.base_url') +
|
85
|
+
sprintf(Util::Config.get('endpoints.contact_tracking_opens'), contact_id)
|
86
|
+
url = build_url(url, param)
|
87
|
+
|
88
|
+
response = RestClient.get(url, get_headers(access_token))
|
89
|
+
body = JSON.parse(response.body)
|
90
|
+
|
91
|
+
opens = []
|
92
|
+
body['results'].each do |open_activity|
|
93
|
+
opens << Components::OpenActivity.create(open_activity)
|
94
|
+
end
|
95
|
+
|
96
|
+
Components::ResultSet.new(opens, body['meta'])
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
# Get sends for a given contact
|
101
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
102
|
+
# @param [String] contact_id - Contact id
|
103
|
+
# @param [Hash] param - query parameters to be appended to request
|
104
|
+
# @return [ResultSet<SendActivity>] - Containing a results array of SendActivity
|
105
|
+
def get_sends(access_token, contact_id, param = nil)
|
106
|
+
url = Util::Config.get('endpoints.base_url') +
|
107
|
+
sprintf(Util::Config.get('endpoints.contact_tracking_sends'), contact_id)
|
108
|
+
url = build_url(url, param)
|
109
|
+
|
110
|
+
response = RestClient.get(url, get_headers(access_token))
|
111
|
+
body = JSON.parse(response.body)
|
112
|
+
|
113
|
+
sends = []
|
114
|
+
body['results'].each do |send_activity|
|
115
|
+
sends << Components::SendActivity.create(send_activity)
|
116
|
+
end
|
117
|
+
|
118
|
+
Components::ResultSet.new(sends, body['meta'])
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
# Get unsubscribes for a given contact
|
123
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
124
|
+
# @param [String] contact_id - Contact id
|
125
|
+
# @param [Hash] param - query parameters to be appended to request
|
126
|
+
# @return [ResultSet<UnsubscribeActivity>] - Containing a results array of UnsubscribeActivity
|
127
|
+
def get_unsubscribes(access_token, contact_id, param = nil)
|
128
|
+
url = Util::Config.get('endpoints.base_url') +
|
129
|
+
sprintf(Util::Config.get('endpoints.contact_tracking_unsubscribes'), contact_id)
|
130
|
+
url = build_url(url, param)
|
131
|
+
|
132
|
+
response = RestClient.get(url, get_headers(access_token))
|
133
|
+
body = JSON.parse(response.body)
|
134
|
+
|
135
|
+
unsubscribes = []
|
136
|
+
body['results'].each do |unsubscribe_activity|
|
137
|
+
unsubscribes[] = Components::UnsubscribeActivity.create(unsubscribe_activity)
|
138
|
+
end
|
139
|
+
|
140
|
+
Components::ResultSet.new(unsubscribes, body['meta'])
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
# Get a summary of reporting data for a given contact
|
145
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
146
|
+
# @param [String] contact_id - Contact id
|
147
|
+
# @return [TrackingSummary]
|
148
|
+
def get_summary(access_token, contact_id)
|
149
|
+
url = Util::Config.get('endpoints.base_url') +
|
150
|
+
sprintf(Util::Config.get('endpoints.contact_tracking_summary'), contact_id)
|
151
|
+
url = build_url(url)
|
152
|
+
response = RestClient.get(url, get_headers(access_token))
|
153
|
+
Components::TrackingSummary.create(JSON.parse(response.body))
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
159
|
end
|
@@ -5,83 +5,83 @@
|
|
5
5
|
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
6
|
|
7
7
|
module ConstantContact
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Services
|
9
|
+
class EmailMarketingService < BaseService
|
10
|
+
class << self
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
# Create a new campaign
|
13
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
|
+
# @param [Campaign] campaign - Campaign to be created
|
15
|
+
# @return [Campaign]
|
16
|
+
def add_campaign(access_token, campaign)
|
17
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')
|
18
|
+
url = build_url(url)
|
19
|
+
payload = campaign.to_json
|
20
|
+
response = RestClient.post(url, payload, get_headers(access_token))
|
21
|
+
Components::Campaign.create(JSON.parse(response.body))
|
22
|
+
end
|
23
23
|
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
# Get a set of campaigns
|
26
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
27
|
+
# @param [Hash] param - query parameters to be appended to the request
|
28
|
+
# @return [ResultSet<Campaign>]
|
29
|
+
def get_campaigns(access_token, param = nil)
|
30
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')
|
31
|
+
url = build_url(url, param)
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
response = RestClient.get(url, get_headers(access_token))
|
34
|
+
body = JSON.parse(response.body)
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
campaigns = []
|
37
|
+
body['results'].each do |campaign|
|
38
|
+
campaigns << Components::Campaign.create_summary(campaign)
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
Components::ResultSet.new(campaigns, body['meta'])
|
42
|
+
end
|
43
43
|
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
45
|
+
# Get campaign details for a specific campaign
|
46
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
47
|
+
# @param [Integer] campaign_id - Valid campaign id
|
48
|
+
# @return [Campaign]
|
49
|
+
def get_campaign(access_token, campaign_id)
|
50
|
+
url = Util::Config.get('endpoints.base_url') +
|
51
|
+
sprintf(Util::Config.get('endpoints.campaign'), campaign_id)
|
52
|
+
url = build_url(url)
|
53
|
+
response = RestClient.get(url, get_headers(access_token))
|
54
|
+
Components::Campaign.create(JSON.parse(response.body))
|
55
|
+
end
|
56
56
|
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
58
|
+
# Delete an email campaign
|
59
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
60
|
+
# @param [Integer] campaign_id - Valid campaign id
|
61
|
+
# @return [Boolean]
|
62
|
+
def delete_campaign(access_token, campaign_id)
|
63
|
+
url = Util::Config.get('endpoints.base_url') +
|
64
|
+
sprintf(Util::Config.get('endpoints.campaign'), campaign_id)
|
65
|
+
url = build_url(url)
|
66
|
+
response = RestClient.delete(url, get_headers(access_token))
|
67
|
+
response.code == 204
|
68
|
+
end
|
69
69
|
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
71
|
+
# Update a specific email campaign
|
72
|
+
# @param [String] access_token - Constant Contact OAuth2 access token
|
73
|
+
# @param [Campaign] campaign - Campaign to be updated
|
74
|
+
# @return [Campaign]
|
75
|
+
def update_campaign(access_token, campaign)
|
76
|
+
url = Util::Config.get('endpoints.base_url') +
|
77
|
+
sprintf(Util::Config.get('endpoints.campaign'), campaign.id)
|
78
|
+
url = build_url(url)
|
79
|
+
payload = campaign.to_json
|
80
|
+
response = RestClient.put(url, payload, get_headers(access_token))
|
81
|
+
Components::Campaign.create(JSON.parse(response.body))
|
82
|
+
end
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
87
|
end
|