constantcontact 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +127 -136
- data/constantcontact.gemspec +4 -3
- data/lib/constantcontact.rb +63 -44
- data/lib/constantcontact/api.rb +932 -535
- data/lib/constantcontact/auth/oauth2.rb +86 -66
- data/lib/constantcontact/components/account/verified_email_address.rb +14 -14
- data/lib/constantcontact/components/activities/activity.rb +30 -30
- data/lib/constantcontact/components/activities/activity_error.rb +14 -14
- data/lib/constantcontact/components/activities/add_contacts.rb +1 -1
- data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -36
- data/lib/constantcontact/components/component.rb +25 -0
- data/lib/constantcontact/components/contacts/address.rb +12 -12
- data/lib/constantcontact/components/contacts/contact.rb +50 -44
- data/lib/constantcontact/components/contacts/contact_list.rb +12 -12
- data/lib/constantcontact/components/contacts/custom_field.rb +14 -14
- data/lib/constantcontact/components/contacts/email_address.rb +14 -14
- data/lib/constantcontact/components/contacts/note.rb +13 -13
- data/lib/constantcontact/components/email_marketing/campaign.rb +41 -41
- data/lib/constantcontact/components/email_marketing/click_through_details.rb +14 -14
- data/lib/constantcontact/components/email_marketing/message_footer.rb +14 -14
- data/lib/constantcontact/components/email_marketing/schedule.rb +14 -15
- data/lib/constantcontact/components/email_marketing/test_send.rb +21 -21
- data/lib/constantcontact/components/event_spot/contact.rb +27 -0
- data/lib/constantcontact/components/event_spot/event.rb +63 -0
- data/lib/constantcontact/components/event_spot/event_track.rb +28 -0
- data/lib/constantcontact/components/event_spot/fee.rb +27 -0
- data/lib/constantcontact/components/event_spot/guest.rb +31 -0
- data/lib/constantcontact/components/event_spot/notification_option.rb +27 -0
- data/lib/constantcontact/components/event_spot/promo_code.rb +26 -0
- data/lib/constantcontact/components/event_spot/registrant.rb +54 -0
- data/lib/constantcontact/components/event_spot/registrant_field.rb +27 -0
- data/lib/constantcontact/components/event_spot/registrant_section.rb +34 -0
- data/lib/constantcontact/components/event_spot/sale_item.rb +27 -0
- data/lib/constantcontact/components/library/file/library_file.rb +27 -0
- data/lib/constantcontact/components/library/folder/library_folder.rb +26 -0
- data/lib/constantcontact/components/library/info/library_summary.rb +26 -0
- data/lib/constantcontact/components/library/info/move_results.rb +26 -0
- data/lib/constantcontact/components/library/info/upload_status.rb +26 -0
- data/lib/constantcontact/components/tracking/bounce_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/click_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/forward_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/open_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/send_activity.rb +14 -14
- data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
- data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +14 -14
- data/lib/constantcontact/services/account_service.rb +4 -3
- data/lib/constantcontact/services/activity_service.rb +40 -3
- data/lib/constantcontact/services/base_service.rb +34 -6
- data/lib/constantcontact/services/campaign_tracking_service.rb +20 -20
- data/lib/constantcontact/services/contact_service.rb +10 -12
- data/lib/constantcontact/services/contact_tracking_service.rb +20 -20
- data/lib/constantcontact/services/email_marketing_service.rb +8 -10
- data/lib/constantcontact/services/event_spot_service.rb +254 -0
- data/lib/constantcontact/services/library_service.rb +297 -0
- data/lib/constantcontact/services/list_service.rb +6 -5
- data/lib/constantcontact/util/config.rb +135 -117
- data/lib/constantcontact/version.rb +1 -1
- data/spec/constantcontact/api_spec.rb +1223 -173
- data/spec/constantcontact/auth/oauth2_spec.rb +60 -47
- data/spec/constantcontact/components/contacts/address_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/contact_list_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/contact_spec.rb +1 -1
- data/spec/constantcontact/components/contacts/email_address_spec.rb +1 -1
- data/spec/constantcontact/services/activity_service_spec.rb +201 -0
- data/spec/constantcontact/services/base_service_spec.rb +27 -0
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +111 -0
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +127 -0
- data/spec/constantcontact/services/contact_service_spec.rb +24 -22
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +127 -0
- data/spec/constantcontact/services/email_marketing_spec.rb +72 -66
- data/spec/constantcontact/services/event_spot_spec.rb +217 -0
- data/spec/constantcontact/services/library_service_spec.rb +248 -0
- data/spec/constantcontact/services/list_service_spec.rb +33 -17
- data/spec/spec_helper.rb +3 -1
- metadata +63 -7
@@ -56,178 +56,1228 @@ describe ConstantContact::Api do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "test methods" do
|
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
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
59
|
+
before(:each) do
|
60
|
+
@api = ConstantContact::Api.new('api key')
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#get_verified_email_addresses" do
|
64
|
+
it "gets verified addresses for the account" do
|
65
|
+
json_response = load_file('verified_email_addresses_response.json')
|
66
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
67
|
+
|
68
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
69
|
+
RestClient.stub(:get).and_return(response)
|
70
|
+
|
71
|
+
email_addresses = @api.get_verified_email_addresses('token')
|
72
|
+
|
73
|
+
email_addresses.should be_kind_of(Array)
|
74
|
+
email_addresses.first.should be_kind_of(ConstantContact::Components::VerifiedEmailAddress)
|
75
|
+
email_addresses.first.email_address.should eq('abc@def.com')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#get_contacts" do
|
80
|
+
it "returns an array of contacts" do
|
81
|
+
json_response = load_file('contacts_response.json')
|
82
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
83
|
+
|
84
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
85
|
+
RestClient.stub(:get).and_return(response)
|
86
|
+
contacts = @api.get_contacts('token', {:limit => 60})
|
87
|
+
|
88
|
+
contacts.should be_kind_of(ConstantContact::Components::ResultSet)
|
89
|
+
contacts.results.first.should be_kind_of(ConstantContact::Components::Contact)
|
90
|
+
contacts.results.first.fax.should eq('318-978-7575')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#get_contact" do
|
95
|
+
it "returns a contact" do
|
96
|
+
json_response = load_file('contact_response.json')
|
97
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
98
|
+
|
99
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
100
|
+
RestClient.stub(:get).and_return(response)
|
101
|
+
contact = @api.get_contact('token', 1)
|
102
|
+
|
103
|
+
contact.should be_kind_of(ConstantContact::Components::Contact)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#get_contact_by_email" do
|
108
|
+
it "returns a contact" do
|
109
|
+
json_response = load_file('contacts_response.json')
|
110
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
111
|
+
|
112
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
113
|
+
RestClient.stub(:get).and_return(response)
|
114
|
+
contacts = @api.get_contact_by_email('token', 'rmartone@systems.com')
|
115
|
+
|
116
|
+
contacts.results.first.should be_kind_of(ConstantContact::Components::Contact)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "#add_contact" do
|
121
|
+
it "adds a contact" do
|
122
|
+
json_response = load_file('contact_response.json')
|
123
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
124
|
+
|
125
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
126
|
+
RestClient.stub(:post).and_return(response)
|
127
|
+
new_contact = ConstantContact::Components::Contact.create(JSON.parse(json_response))
|
128
|
+
|
129
|
+
contact = @api.add_contact('token', new_contact)
|
130
|
+
contact.should be_kind_of(ConstantContact::Components::Contact)
|
131
|
+
contact.status.should eq('ACTIVE')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "#delete_contact" do
|
136
|
+
it "deletes a contact" do
|
137
|
+
contact_id = 196
|
138
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
139
|
+
|
140
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
141
|
+
RestClient.stub(:delete).and_return(response)
|
142
|
+
|
143
|
+
result = @api.delete_contact('token', contact_id)
|
144
|
+
result.should be_true
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "#delete_contact_from_lists" do
|
149
|
+
it "deletes a contact" do
|
150
|
+
contact_id = 196
|
151
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
152
|
+
|
153
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
154
|
+
RestClient.stub(:delete).and_return(response)
|
155
|
+
|
156
|
+
result = @api.delete_contact_from_lists('token', contact_id)
|
157
|
+
result.should be_true
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "#delete_contact_from_list" do
|
162
|
+
it "deletes a contact" do
|
163
|
+
contact_id = 196
|
164
|
+
list_id = 1
|
165
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
166
|
+
|
167
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
168
|
+
RestClient.stub(:delete).and_return(response)
|
169
|
+
|
170
|
+
result = @api.delete_contact_from_list('token', contact_id, list_id)
|
171
|
+
result.should be_true
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe "#update_contact" do
|
176
|
+
it "updates a contact" do
|
177
|
+
json = load_file('contact_response.json')
|
178
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
179
|
+
|
180
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
181
|
+
RestClient.stub(:put).and_return(response)
|
182
|
+
contact = ConstantContact::Components::Contact.create(JSON.parse(json))
|
183
|
+
result = @api.update_contact('token', contact)
|
184
|
+
|
185
|
+
result.should be_kind_of(ConstantContact::Components::Contact)
|
186
|
+
result.status.should eq('ACTIVE')
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "#get_lists" do
|
191
|
+
it "returns an array of lists" do
|
192
|
+
json_response = load_file('lists_response.json')
|
193
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
194
|
+
|
195
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
196
|
+
RestClient.stub(:get).and_return(response)
|
197
|
+
lists = @api.get_lists('token')
|
198
|
+
|
199
|
+
lists.should be_kind_of(Array)
|
200
|
+
lists.first.should be_kind_of(ConstantContact::Components::ContactList)
|
201
|
+
lists.first.name.should eq('General Interest')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "#get_list" do
|
206
|
+
it "returns a list" do
|
207
|
+
json = load_file('list_response.json')
|
208
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
209
|
+
|
210
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
211
|
+
RestClient.stub(:get).and_return(response)
|
212
|
+
|
213
|
+
list = @api.get_list('token', 1)
|
214
|
+
list.should be_kind_of(ConstantContact::Components::ContactList)
|
215
|
+
list.name.should eq('Monthly Specials')
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "#add_list" do
|
220
|
+
it "adds a list" do
|
221
|
+
json = load_file('list_response.json')
|
222
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
223
|
+
|
224
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
225
|
+
RestClient.stub(:post).and_return(response)
|
226
|
+
new_list = ConstantContact::Components::ContactList.create(JSON.parse(json))
|
227
|
+
|
228
|
+
list = @api.add_list('token', new_list)
|
229
|
+
list.should be_kind_of(ConstantContact::Components::ContactList)
|
230
|
+
list.status.should eq('ACTIVE')
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
describe "#update_list" do
|
235
|
+
it "updates a list" do
|
236
|
+
json = load_file('list_response.json')
|
237
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
238
|
+
|
239
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
240
|
+
RestClient.stub(:put).and_return(response)
|
241
|
+
list = ConstantContact::Components::ContactList.create(JSON.parse(json))
|
242
|
+
|
243
|
+
result = @api.update_list('token', list)
|
244
|
+
result.should be_kind_of(ConstantContact::Components::ContactList)
|
245
|
+
result.status.should eq('ACTIVE')
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe "#get_contacts_from_list" do
|
250
|
+
it "returns an array of contacts" do
|
251
|
+
json_list = load_file('list_response.json')
|
252
|
+
json_contacts = load_file('contacts_response.json')
|
253
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
254
|
+
|
255
|
+
response = RestClient::Response.create(json_contacts, net_http_resp, {})
|
256
|
+
RestClient.stub(:get).and_return(response)
|
257
|
+
list = ConstantContact::Components::ContactList.create(JSON.parse(json_list))
|
258
|
+
|
259
|
+
contacts = @api.get_contacts_from_list('token', list, "?limit=4&next=true")
|
260
|
+
contacts.should be_kind_of(ConstantContact::Components::ResultSet)
|
261
|
+
contacts.results.first.should be_kind_of(ConstantContact::Components::Contact)
|
262
|
+
contacts.results.first.fax.should eq('318-978-7575')
|
263
|
+
|
264
|
+
contacts = @api.get_contacts_from_list('token', list, 4)
|
265
|
+
contacts.should be_kind_of(ConstantContact::Components::ResultSet)
|
266
|
+
contacts.results.first.should be_kind_of(ConstantContact::Components::Contact)
|
267
|
+
contacts.results.first.fax.should eq('318-978-7575')
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe "#get_events" do
|
272
|
+
it "returns an array of events" do
|
273
|
+
json = load_file('events.json')
|
274
|
+
|
275
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
276
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
277
|
+
RestClient.stub(:get).and_return(response)
|
278
|
+
|
279
|
+
events = @api.get_events('token')
|
280
|
+
events.should be_kind_of(ConstantContact::Components::ResultSet)
|
281
|
+
events.results.collect{|e| e.should be_kind_of(ConstantContact::Components::Event) }
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
describe "#get_event" do
|
286
|
+
it "returns an event" do
|
287
|
+
json = load_file('event.json')
|
288
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
289
|
+
|
290
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
291
|
+
RestClient.stub(:get).and_return(response)
|
292
|
+
event = @api.get_event('token', 1)
|
293
|
+
|
294
|
+
event.should be_kind_of(ConstantContact::Components::Event)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
describe "#add_event" do
|
299
|
+
it "adds an event" do
|
300
|
+
json = load_file('event.json')
|
301
|
+
|
302
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
303
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
304
|
+
RestClient.stub(:post).and_return(response)
|
305
|
+
|
306
|
+
event = ConstantContact::Components::Event.create(JSON.parse(json))
|
307
|
+
added = @api.add_event('token', event)
|
308
|
+
|
309
|
+
added.should respond_to(:id)
|
310
|
+
added.id.should_not be_empty
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
describe "#delete_event" do
|
315
|
+
it "deletes an event" do
|
316
|
+
json = load_file('event.json')
|
317
|
+
|
318
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
319
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
320
|
+
RestClient.stub(:delete).and_return(response)
|
321
|
+
|
322
|
+
event = ConstantContact::Components::Event.create(JSON.parse(json))
|
323
|
+
@api.delete_event('token', event).should be_true
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
describe "#publish_event" do
|
328
|
+
it "updates an event with status of ACTIVE" do
|
329
|
+
json = load_file('event.json')
|
330
|
+
hash = JSON.parse json
|
331
|
+
hash["status"] = "ACTIVE"
|
332
|
+
|
333
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
334
|
+
response = RestClient::Response.create(hash.to_json, net_http_resp, {})
|
335
|
+
RestClient.stub(:patch).and_return(response)
|
336
|
+
|
337
|
+
event = ConstantContact::Components::Event.create(JSON.parse(json))
|
338
|
+
updated = @api.publish_event('token', event)
|
339
|
+
updated.should be_kind_of(ConstantContact::Components::Event)
|
340
|
+
updated.should respond_to(:status)
|
341
|
+
updated.status.should eq("ACTIVE")
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
describe "#cancel_event" do
|
346
|
+
it "updates an event's status to CANCELLED" do
|
347
|
+
json = load_file('event.json')
|
348
|
+
hash = JSON.parse json
|
349
|
+
hash["status"] = "CANCELLED"
|
350
|
+
|
351
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
352
|
+
response = RestClient::Response.create(hash.to_json, net_http_resp, {})
|
353
|
+
RestClient.stub(:patch).and_return(response)
|
354
|
+
|
355
|
+
event = ConstantContact::Components::Event.create(JSON.parse(json))
|
356
|
+
updated = @api.cancel_event('token', event)
|
357
|
+
updated.should be_kind_of(ConstantContact::Components::Event)
|
358
|
+
updated.should respond_to(:status)
|
359
|
+
updated.status.should eq("CANCELLED")
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
describe "#get_fees" do
|
364
|
+
it "returns an array of fees for an event" do
|
365
|
+
event_json = load_file('event.json')
|
366
|
+
fees_json = load_file('fees.json')
|
367
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
368
|
+
|
369
|
+
response = RestClient::Response.create(fees_json, net_http_resp, {})
|
370
|
+
RestClient.stub(:get).and_return(response)
|
371
|
+
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
372
|
+
fees = @api.get_event_fees('token', event)
|
373
|
+
#fees.should be_kind_of(ConstantContact::Components::ResultSet)
|
374
|
+
#fees.results.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
|
375
|
+
|
376
|
+
fees.should be_kind_of(Array) # inconsistent with oether APIs.
|
377
|
+
fees.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
describe "#get_fee" do
|
382
|
+
it "return an event fee" do
|
383
|
+
event_json = load_file('event.json')
|
384
|
+
fee_json = load_file('fees.json')
|
385
|
+
|
386
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
387
|
+
response = RestClient::Response.create(fee_json, net_http_resp, {})
|
388
|
+
RestClient.stub(:get).and_return(response)
|
389
|
+
|
390
|
+
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
391
|
+
fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
|
392
|
+
retrieved = @api.get_event_fee('token', event, fee)
|
393
|
+
retrieved.should be_kind_of(ConstantContact::Components::Fee)
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
describe "#add_fee" do
|
398
|
+
it "adds an event fee" do
|
399
|
+
event_json = load_file('event.json')
|
400
|
+
fee_json = load_file('fee.json')
|
401
|
+
|
402
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 201, 'Created')
|
403
|
+
response = RestClient::Response.create(fee_json, net_http_resp, {})
|
404
|
+
RestClient.stub(:post).and_return(response)
|
405
|
+
|
406
|
+
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
407
|
+
fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
|
408
|
+
added = @api.add_event_fee('token', event, fee)
|
409
|
+
added.should be_kind_of(ConstantContact::Components::Fee)
|
410
|
+
added.id.should_not be_empty
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
describe "#update_fee" do
|
415
|
+
it "updates an event fee" do
|
416
|
+
event_json = load_file('event.json')
|
417
|
+
fee_json = load_file('fee.json')
|
418
|
+
hash = JSON.parse fee_json
|
419
|
+
hash['fee'] += 1
|
420
|
+
|
421
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 201, 'Created')
|
422
|
+
response = RestClient::Response.create(hash.to_json, net_http_resp, {})
|
423
|
+
RestClient.stub(:put).and_return(response)
|
424
|
+
|
425
|
+
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
426
|
+
fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
|
427
|
+
updated = @api.update_event_fee('token', event, fee)
|
428
|
+
updated.should be_kind_of(ConstantContact::Components::Fee)
|
429
|
+
updated.fee.should_not eq(fee.fee)
|
430
|
+
updated.fee.should eq(fee.fee + 1)
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
describe "#delete_fee" do
|
435
|
+
it "deletes an event fee" do
|
436
|
+
event_json = load_file('event.json')
|
437
|
+
fee_json = load_file('fees.json')
|
438
|
+
|
439
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
440
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
441
|
+
RestClient.stub(:delete).and_return(response)
|
442
|
+
|
443
|
+
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
444
|
+
fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
|
445
|
+
@api.delete_event_fee('token', event, fee).should be_true
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
describe "#get_registrants" do
|
450
|
+
it "returns an array of event registrants" do
|
451
|
+
event_json = load_file('event.json')
|
452
|
+
registrants_json = load_file('registrants.json')
|
453
|
+
|
454
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 201, 'Created')
|
455
|
+
response = RestClient::Response.create(registrants_json, net_http_resp, {})
|
456
|
+
RestClient.stub(:get).and_return(response)
|
457
|
+
|
458
|
+
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
459
|
+
registrants = @api.get_event_registrants('token', event)
|
460
|
+
registrants.should be_kind_of(ConstantContact::Components::ResultSet)
|
461
|
+
registrants.results.collect{|r| r .should be_kind_of(ConstantContact::Components::Registrant) }
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
describe "#get_registrant" do
|
466
|
+
it "returns an event registrant" do
|
467
|
+
event_json = load_file('event.json')
|
468
|
+
registrant_json = load_file('registrant.json')
|
469
|
+
|
470
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 201, 'Created')
|
471
|
+
response = RestClient::Response.create(registrant_json, net_http_resp, {})
|
472
|
+
RestClient.stub(:get).and_return(response)
|
473
|
+
|
474
|
+
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
475
|
+
registrant = ConstantContact::Components::Registrant.create(JSON.parse(registrant_json))
|
476
|
+
retrieved = @api.get_event_registrant('token', event, registrant)
|
477
|
+
retrieved.should be_kind_of(ConstantContact::Components::Registrant)
|
478
|
+
retrieved.id.should_not be_empty
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
describe "#get_email_campaigns" do
|
483
|
+
it "gets a set of campaigns" do
|
484
|
+
json_response = load_file('email_campaigns_response.json')
|
485
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
486
|
+
|
487
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
488
|
+
RestClient.stub(:get).and_return(response)
|
489
|
+
|
490
|
+
campaigns = @api.get_email_campaigns('token', {:limit => 2})
|
491
|
+
campaigns.should be_kind_of(ConstantContact::Components::ResultSet)
|
492
|
+
campaigns.results.first.should be_kind_of(ConstantContact::Components::Campaign)
|
493
|
+
campaigns.results.first.name.should eq('1357157252225')
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
describe "#get_email_campaign" do
|
498
|
+
it "gets an individual campaign" do
|
499
|
+
json_response = load_file('email_campaign_response.json')
|
500
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
501
|
+
|
502
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
503
|
+
RestClient.stub(:get).and_return(response)
|
504
|
+
|
505
|
+
campaign = @api.get_email_campaign('token', 1)
|
506
|
+
campaign.should be_kind_of(ConstantContact::Components::Campaign)
|
507
|
+
campaign.name.should eq('Campaign Name')
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
describe "#add_email_campaign" do
|
512
|
+
it "creates a new campaign" do
|
513
|
+
json = load_file('email_campaign_response.json')
|
514
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
515
|
+
|
516
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
517
|
+
RestClient.stub(:post).and_return(response)
|
518
|
+
new_campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
519
|
+
|
520
|
+
campaign = @api.add_email_campaign('token', new_campaign)
|
521
|
+
campaign.should be_kind_of(ConstantContact::Components::Campaign)
|
522
|
+
campaign.name.should eq('Campaign Name')
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
describe "#delete_email_campaign" do
|
527
|
+
it "deletes an individual campaign" do
|
528
|
+
json = load_file('email_campaign_response.json')
|
529
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
530
|
+
|
531
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
532
|
+
RestClient.stub(:delete).and_return(response)
|
533
|
+
campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
534
|
+
|
535
|
+
result = @api.delete_email_campaign('token', campaign)
|
536
|
+
result.should be_true
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
describe "#update_email_campaign" do
|
541
|
+
it "updates a specific campaign" do
|
542
|
+
json = load_file('email_campaign_response.json')
|
543
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
544
|
+
|
545
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
546
|
+
RestClient.stub(:put).and_return(response)
|
547
|
+
campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
548
|
+
|
549
|
+
result = @api.update_email_campaign('token', campaign)
|
550
|
+
result.should be_kind_of(ConstantContact::Components::Campaign)
|
551
|
+
result.name.should eq('Campaign Name')
|
552
|
+
end
|
553
|
+
end
|
554
|
+
|
555
|
+
describe "#add_email_campaign_schedule" do
|
556
|
+
it "schedules a campaign to be sent" do
|
557
|
+
campaign_id = 1
|
558
|
+
json = load_file('schedule_response.json')
|
559
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
560
|
+
|
561
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
562
|
+
RestClient.stub(:post).and_return(response)
|
563
|
+
new_schedule = ConstantContact::Components::Schedule.create(JSON.parse(json))
|
564
|
+
|
565
|
+
schedule = @api.add_email_campaign_schedule('token', campaign_id, new_schedule)
|
566
|
+
schedule.should be_kind_of(ConstantContact::Components::Schedule)
|
567
|
+
schedule.scheduled_date.should eq('2013-05-10T11:07:43.626Z')
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
describe "#get_email_campaign_schedules" do
|
572
|
+
it "gets an array of schedules associated with a given campaign" do
|
573
|
+
campaign_id = 1
|
574
|
+
json = load_file('schedules_response.json')
|
575
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
576
|
+
|
577
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
578
|
+
RestClient.stub(:get).and_return(response)
|
579
|
+
|
580
|
+
schedules = @api.get_email_campaign_schedules('token', campaign_id)
|
581
|
+
schedules.first.should be_kind_of(ConstantContact::Components::Schedule)
|
582
|
+
schedules.first.scheduled_date.should eq('2012-12-16T11:07:43.626Z')
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
describe "#get_email_campaign_schedule" do
|
587
|
+
it "gets a specific schedule associated with a given campaign" do
|
588
|
+
campaign_id = 1
|
589
|
+
schedule_id = 1
|
590
|
+
|
591
|
+
json = load_file('schedule_response.json')
|
592
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
593
|
+
|
594
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
595
|
+
RestClient.stub(:get).and_return(response)
|
596
|
+
|
597
|
+
schedule = @api.get_email_campaign_schedule('token', campaign_id, schedule_id)
|
598
|
+
schedule.should be_kind_of(ConstantContact::Components::Schedule)
|
599
|
+
schedule.scheduled_date.should eq('2013-05-10T11:07:43.626Z')
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
describe "#delete_email_campaign_schedule" do
|
604
|
+
it "deletes a specific schedule associated with a given campaign" do
|
605
|
+
campaign_id = 1
|
606
|
+
schedule_id = 1
|
607
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
608
|
+
|
609
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
610
|
+
RestClient.stub(:delete).and_return(response)
|
611
|
+
|
612
|
+
result = @api.delete_email_campaign_schedule('token', campaign_id, schedule_id)
|
613
|
+
result.should be_true
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
describe "#update_email_campaign_schedule" do
|
618
|
+
it "updates a specific schedule associated with a given campaign" do
|
619
|
+
campaign_id = 1
|
620
|
+
json = load_file('schedule_response.json')
|
621
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
622
|
+
|
623
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
624
|
+
RestClient.stub(:put).and_return(response)
|
625
|
+
schedule = ConstantContact::Components::Schedule.create(JSON.parse(json))
|
626
|
+
|
627
|
+
result = @api.update_email_campaign_schedule('token', campaign_id, schedule)
|
628
|
+
result.should be_kind_of(ConstantContact::Components::Schedule)
|
629
|
+
result.scheduled_date.should eq('2013-05-10T11:07:43.626Z')
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
633
|
+
describe "#send_email_campaign_test" do
|
634
|
+
it "sends a test send of a campaign" do
|
635
|
+
campaign_id = 1
|
636
|
+
json_request = load_file('test_send_request.json')
|
637
|
+
json_response = load_file('test_send_response.json')
|
638
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
639
|
+
|
640
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
641
|
+
RestClient.stub(:post).and_return(response)
|
642
|
+
test_send = ConstantContact::Components::TestSend.create(JSON.parse(json_request))
|
643
|
+
|
644
|
+
result = @api.send_email_campaign_test('token', campaign_id, test_send)
|
645
|
+
result.should be_kind_of(ConstantContact::Components::TestSend)
|
646
|
+
result.personal_message.should eq('This is a test send of the email campaign message.')
|
647
|
+
end
|
648
|
+
end
|
649
|
+
|
650
|
+
describe "#get_email_campaign_bounces" do
|
651
|
+
it "gets bounces for a campaign" do
|
652
|
+
campaign_id = 1
|
653
|
+
params = {:limit => 5}
|
654
|
+
json = load_file('campaign_tracking_bounces_response.json')
|
655
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
656
|
+
|
657
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
658
|
+
RestClient.stub(:get).and_return(response)
|
659
|
+
|
660
|
+
set = @api.get_email_campaign_bounces('token', campaign_id, params)
|
661
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
662
|
+
set.results.first.should be_kind_of(ConstantContact::Components::BounceActivity)
|
663
|
+
set.results.first.activity_type.should eq('EMAIL_BOUNCE')
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
667
|
+
describe "#get_email_campaign_clicks" do
|
668
|
+
it "gets clicks for a campaign" do
|
669
|
+
campaign_id = 1
|
670
|
+
params = {:limit => 5}
|
671
|
+
json = load_file('campaign_tracking_clicks_response.json')
|
672
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
673
|
+
|
674
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
675
|
+
RestClient.stub(:get).and_return(response)
|
676
|
+
|
677
|
+
set = @api.get_email_campaign_clicks('token', campaign_id, params)
|
678
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
679
|
+
set.results.first.should be_kind_of(ConstantContact::Components::ClickActivity)
|
680
|
+
set.results.first.activity_type.should eq('EMAIL_CLICK')
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
684
|
+
describe "#get_email_campaign_forwards" do
|
685
|
+
it "gets forwards for a campaign" do
|
686
|
+
campaign_id = 1
|
687
|
+
params = {:limit => 5}
|
688
|
+
json = load_file('campaign_tracking_forwards_response.json')
|
689
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
690
|
+
|
691
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
692
|
+
RestClient.stub(:get).and_return(response)
|
693
|
+
|
694
|
+
set = @api.get_email_campaign_forwards('token', campaign_id, params)
|
695
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
696
|
+
set.results.first.should be_kind_of(ConstantContact::Components::ForwardActivity)
|
697
|
+
set.results.first.activity_type.should eq('EMAIL_FORWARD')
|
698
|
+
end
|
699
|
+
end
|
700
|
+
|
701
|
+
describe "#get_email_campaign_opens" do
|
702
|
+
it "gets opens for a campaign" do
|
703
|
+
campaign_id = 1
|
704
|
+
params = {:limit => 5}
|
705
|
+
json = load_file('campaign_tracking_opens_response.json')
|
706
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
707
|
+
|
708
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
709
|
+
RestClient.stub(:get).and_return(response)
|
710
|
+
|
711
|
+
set = @api.get_email_campaign_opens('token', campaign_id, params)
|
712
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
713
|
+
set.results.first.should be_kind_of(ConstantContact::Components::OpenActivity)
|
714
|
+
set.results.first.activity_type.should eq('EMAIL_OPEN')
|
715
|
+
end
|
716
|
+
end
|
717
|
+
|
718
|
+
describe "#get_email_campaign_sends" do
|
719
|
+
it "gets sends for a given campaign" do
|
720
|
+
campaign_id = 1
|
721
|
+
params = {:limit => 5}
|
722
|
+
json = load_file('campaign_tracking_sends_response.json')
|
723
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
724
|
+
|
725
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
726
|
+
RestClient.stub(:get).and_return(response)
|
727
|
+
|
728
|
+
set = @api.get_email_campaign_sends('token', campaign_id, params)
|
729
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
730
|
+
set.results.first.should be_kind_of(ConstantContact::Components::SendActivity)
|
731
|
+
set.results.first.activity_type.should eq('EMAIL_SEND')
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
describe "#get_email_campaign_unsubscribes" do
|
736
|
+
it "gets unsubscribes for a campaign" do
|
737
|
+
campaign_id = 1
|
738
|
+
params = {:limit => 5}
|
739
|
+
json = load_file('campaign_tracking_unsubscribes_response.json')
|
740
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
741
|
+
|
742
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
743
|
+
RestClient.stub(:get).and_return(response)
|
744
|
+
|
745
|
+
set = @api.get_email_campaign_unsubscribes('token', campaign_id, params)
|
746
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
747
|
+
set.results.first.should be_kind_of(ConstantContact::Components::UnsubscribeActivity)
|
748
|
+
set.results.first.activity_type.should eq('EMAIL_UNSUBSCRIBE')
|
749
|
+
end
|
750
|
+
end
|
751
|
+
|
752
|
+
describe "#get_email_campaign_summary_report" do
|
753
|
+
it "gets a reporting summary for a campaign" do
|
754
|
+
campaign_id = 1
|
755
|
+
json = load_file('campaign_tracking_summary_response.json')
|
756
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
757
|
+
|
758
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
759
|
+
RestClient.stub(:get).and_return(response)
|
760
|
+
|
761
|
+
summary = @api.get_email_campaign_summary_report('token', campaign_id)
|
762
|
+
summary.should be_kind_of(ConstantContact::Components::TrackingSummary)
|
763
|
+
summary.sends.should eq(15)
|
764
|
+
end
|
765
|
+
end
|
766
|
+
|
767
|
+
describe "#get_contact_bounces" do
|
768
|
+
it "gets bounces for a contact" do
|
769
|
+
contact_id = 1
|
770
|
+
params = {:limit => 5}
|
771
|
+
json = load_file('contact_tracking_bounces_response.json')
|
772
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
773
|
+
|
774
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
775
|
+
RestClient.stub(:get).and_return(response)
|
776
|
+
|
777
|
+
set = @api.get_contact_bounces('token', contact_id, params)
|
778
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
779
|
+
set.results.first.should be_kind_of(ConstantContact::Components::BounceActivity)
|
780
|
+
set.results.first.activity_type.should eq('EMAIL_BOUNCE')
|
781
|
+
end
|
782
|
+
end
|
783
|
+
|
784
|
+
describe "#get_contact_clicks" do
|
785
|
+
it "gets clicks for a contact" do
|
786
|
+
contact_id = 1
|
787
|
+
params = {:limit => 5}
|
788
|
+
json = load_file('contact_tracking_clicks_response.json')
|
789
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
790
|
+
|
791
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
792
|
+
RestClient.stub(:get).and_return(response)
|
793
|
+
|
794
|
+
set = @api.get_contact_clicks('token', contact_id, params)
|
795
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
796
|
+
set.results.first.should be_kind_of(ConstantContact::Components::ClickActivity)
|
797
|
+
set.results.first.activity_type.should eq('EMAIL_CLICK')
|
798
|
+
end
|
799
|
+
end
|
800
|
+
|
801
|
+
describe "#get_contact_forwards" do
|
802
|
+
it "gets forwards for a contact" do
|
803
|
+
contact_id = 1
|
804
|
+
params = {:limit => 5}
|
805
|
+
json = load_file('contact_tracking_forwards_response.json')
|
806
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
807
|
+
|
808
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
809
|
+
RestClient.stub(:get).and_return(response)
|
810
|
+
|
811
|
+
set = @api.get_contact_forwards('token', contact_id, params)
|
812
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
813
|
+
set.results.first.should be_kind_of(ConstantContact::Components::ForwardActivity)
|
814
|
+
set.results.first.activity_type.should eq('EMAIL_FORWARD')
|
815
|
+
end
|
816
|
+
end
|
817
|
+
|
818
|
+
describe "#get_contact_opens" do
|
819
|
+
it "gets opens for a given contact" do
|
820
|
+
contact_id = 1
|
821
|
+
params = {:limit => 5}
|
822
|
+
json = load_file('contact_tracking_opens_response.json')
|
823
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
824
|
+
|
825
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
826
|
+
RestClient.stub(:get).and_return(response)
|
827
|
+
|
828
|
+
set = @api.get_contact_opens('token', contact_id, params)
|
829
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
830
|
+
set.results.first.should be_kind_of(ConstantContact::Components::OpenActivity)
|
831
|
+
set.results.first.activity_type.should eq('EMAIL_OPEN')
|
832
|
+
end
|
833
|
+
end
|
834
|
+
|
835
|
+
describe "#get_contact_sends" do
|
836
|
+
it "gets sends for a contact" do
|
837
|
+
contact_id = 1
|
838
|
+
params = {:limit => 5}
|
839
|
+
json = load_file('contact_tracking_sends_response.json')
|
840
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
841
|
+
|
842
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
843
|
+
RestClient.stub(:get).and_return(response)
|
844
|
+
|
845
|
+
set = @api.get_contact_sends('token', contact_id, params)
|
846
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
847
|
+
set.results.first.should be_kind_of(ConstantContact::Components::SendActivity)
|
848
|
+
set.results.first.activity_type.should eq('EMAIL_SEND')
|
849
|
+
end
|
850
|
+
end
|
851
|
+
|
852
|
+
describe "#get_contact_unsubscribes" do
|
853
|
+
it "gets unsubscribes for a given contact" do
|
854
|
+
contact_id = 1
|
855
|
+
params = {:limit => 5}
|
856
|
+
json = load_file('contact_tracking_unsubscribes_response.json')
|
857
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
858
|
+
|
859
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
860
|
+
RestClient.stub(:get).and_return(response)
|
861
|
+
|
862
|
+
set = @api.get_contact_unsubscribes('token', contact_id, params)
|
863
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
864
|
+
set.results.first.should be_kind_of(ConstantContact::Components::UnsubscribeActivity)
|
865
|
+
set.results.first.activity_type.should eq('EMAIL_UNSUBSCRIBE')
|
866
|
+
end
|
867
|
+
end
|
868
|
+
|
869
|
+
describe "#get_contact_summary_report" do
|
870
|
+
it "gets a reporting summary for a Contact" do
|
871
|
+
contact_id = 1
|
872
|
+
json = load_file('contact_tracking_summary_response.json')
|
873
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
874
|
+
|
875
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
876
|
+
RestClient.stub(:get).and_return(response)
|
877
|
+
|
878
|
+
summary = @api.get_contact_summary_report('token', contact_id)
|
879
|
+
summary.should be_kind_of(ConstantContact::Components::TrackingSummary)
|
880
|
+
summary.sends.should eq(15)
|
881
|
+
end
|
882
|
+
end
|
883
|
+
|
884
|
+
describe "#get_activities" do
|
885
|
+
it "gets an array of activities" do
|
886
|
+
json_response = load_file('activities_response.json')
|
887
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
888
|
+
|
889
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
890
|
+
RestClient.stub(:get).and_return(response)
|
891
|
+
|
892
|
+
activities = @api.get_activities('token')
|
893
|
+
activities.first.should be_kind_of(ConstantContact::Components::Activity)
|
894
|
+
activities.first.type.should eq('REMOVE_CONTACTS_FROM_LISTS')
|
895
|
+
end
|
896
|
+
end
|
897
|
+
|
898
|
+
describe "#update_email_campaign" do
|
899
|
+
it "updates a specific campaign" do
|
900
|
+
json_response = load_file('activity_response.json')
|
901
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
902
|
+
|
903
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
904
|
+
RestClient.stub(:get).and_return(response)
|
905
|
+
|
906
|
+
activity = @api.get_activity('token', 'a07e1ilbm7shdg6ikeo')
|
907
|
+
activity.should be_kind_of(ConstantContact::Components::Activity)
|
908
|
+
activity.type.should eq('REMOVE_CONTACTS_FROM_LISTS')
|
909
|
+
end
|
910
|
+
end
|
911
|
+
|
912
|
+
describe "#add_create_contacts_activity" do
|
913
|
+
it "adds an AddContacts activity to add contacts in bulk" do
|
914
|
+
json_add_contacts = load_file('add_contacts_response.json')
|
915
|
+
json_lists = load_file('lists_response.json')
|
916
|
+
json_contacts = load_file('contacts_response.json')
|
917
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
918
|
+
|
919
|
+
response = RestClient::Response.create(json_add_contacts, net_http_resp, {})
|
920
|
+
RestClient.stub(:post).and_return(response)
|
921
|
+
|
922
|
+
import = ConstantContact::Components::AddContactsImportData.new
|
923
|
+
address = ConstantContact::Components::Address.create(
|
924
|
+
:line1 => "1601 Trapelo Rd",
|
925
|
+
:city => "Waltham",
|
926
|
+
:state => "MA"
|
927
|
+
)
|
928
|
+
import.add_address(address)
|
929
|
+
|
930
|
+
custom_field = ConstantContact::Components::CustomField.create(
|
931
|
+
:name => "custom_field_1",
|
932
|
+
:value => "my custom value"
|
933
|
+
)
|
934
|
+
import.add_custom_field(custom_field)
|
935
|
+
import.add_email("abc@def.com")
|
936
|
+
|
937
|
+
contacts = []
|
938
|
+
contacts << import
|
939
|
+
contacts_objects = JSON.parse(json_contacts)
|
940
|
+
contacts_objects['results'].each do |contact|
|
941
|
+
contacts << ConstantContact::Components::Contact.create(contact)
|
942
|
+
end
|
943
|
+
|
944
|
+
lists = []
|
945
|
+
lists_objects = JSON.parse(json_lists)
|
946
|
+
lists_objects.each do |list|
|
947
|
+
lists << ConstantContact::Components::ContactList.create(list)
|
948
|
+
end
|
949
|
+
|
950
|
+
add_contact = ConstantContact::Components::AddContacts.new(contacts, lists)
|
951
|
+
|
952
|
+
activity = @api.add_create_contacts_activity('token', add_contact)
|
953
|
+
activity.should be_kind_of(ConstantContact::Components::Activity)
|
954
|
+
activity.type.should eq('ADD_CONTACTS')
|
955
|
+
end
|
956
|
+
end
|
957
|
+
|
958
|
+
describe "#add_create_contacts_activity_from_file" do
|
959
|
+
it "creates an Add Contacts Activity from a file. Valid file types are txt, csv, xls, xlsx" do
|
960
|
+
content = load_file('add_contacts_request.csv')
|
961
|
+
json = load_file('add_contacts_response.json')
|
962
|
+
lists = 'list1, list2'
|
963
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
964
|
+
|
965
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
966
|
+
RestClient.stub(:post).and_return(response)
|
967
|
+
|
968
|
+
activity = @api.add_create_contacts_activity_from_file('token', 'contacts.txt', content, lists)
|
969
|
+
activity.should be_kind_of(ConstantContact::Components::Activity)
|
970
|
+
activity.type.should eq('ADD_CONTACTS')
|
971
|
+
end
|
972
|
+
end
|
973
|
+
|
974
|
+
describe "#add_clear_lists_activity" do
|
975
|
+
it "adds a ClearLists Activity to remove all contacts from the provided lists" do
|
976
|
+
json_clear_lists = load_file('clear_lists_response.json')
|
977
|
+
json_list = load_file('list_response.json')
|
978
|
+
|
979
|
+
lists = []
|
980
|
+
lists << ConstantContact::Components::ContactList.create(JSON.parse(json_list))
|
981
|
+
|
982
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
983
|
+
|
984
|
+
response = RestClient::Response.create(json_clear_lists, net_http_resp, {})
|
985
|
+
RestClient.stub(:post).and_return(response)
|
986
|
+
|
987
|
+
activity = @api.add_clear_lists_activity('token', lists)
|
988
|
+
activity.should be_kind_of(ConstantContact::Components::Activity)
|
989
|
+
activity.type.should eq('CLEAR_CONTACTS_FROM_LISTS')
|
990
|
+
end
|
991
|
+
end
|
992
|
+
|
993
|
+
describe "#add_remove_contacts_from_lists_activity" do
|
994
|
+
it "adds a Remove Contacts From Lists Activity" do
|
995
|
+
json = load_file('remove_contacts_response.json')
|
996
|
+
lists = 'list1, list2'
|
997
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
998
|
+
|
999
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1000
|
+
RestClient.stub(:post).and_return(response)
|
1001
|
+
email_addresses = ["djellesma@constantcontact.com"]
|
1002
|
+
|
1003
|
+
activity = @api.add_remove_contacts_from_lists_activity(
|
1004
|
+
'token', email_addresses, lists)
|
1005
|
+
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1006
|
+
activity.type.should eq('REMOVE_CONTACTS_FROM_LISTS')
|
1007
|
+
end
|
1008
|
+
end
|
1009
|
+
|
1010
|
+
describe "#add_remove_contacts_from_lists_activity_from_file" do
|
1011
|
+
it "adds a Remove Contacts From Lists Activity from a file. Valid file types are txt, csv, xls, xlsx" do
|
1012
|
+
content = load_file('remove_contacts_request.txt')
|
1013
|
+
json = load_file('remove_contacts_response.json')
|
1014
|
+
lists = 'list1, list2'
|
1015
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1016
|
+
|
1017
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1018
|
+
RestClient.stub(:post).and_return(response)
|
1019
|
+
|
1020
|
+
activity = @api.add_remove_contacts_from_lists_activity_from_file(
|
1021
|
+
'token', 'contacts.txt', content, lists)
|
1022
|
+
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1023
|
+
activity.type.should eq('REMOVE_CONTACTS_FROM_LISTS')
|
1024
|
+
end
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
describe "#add_export_contacts_activity" do
|
1028
|
+
it "creates an Export Contacts Activity" do
|
1029
|
+
json_request = load_file('export_contacts_request.json')
|
1030
|
+
json_response = load_file('export_contacts_response.json')
|
1031
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1032
|
+
|
1033
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1034
|
+
RestClient.stub(:post).and_return(response)
|
1035
|
+
export_contacts = ConstantContact::Components::ExportContacts.new(JSON.parse(json_request))
|
1036
|
+
|
1037
|
+
activity = @api.add_export_contacts_activity(
|
1038
|
+
'token', export_contacts)
|
1039
|
+
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1040
|
+
activity.type.should eq('EXPORT_CONTACTS')
|
1041
|
+
end
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
describe "#get_library_info" do
|
1045
|
+
it "retrieves a MyLibrary usage information" do
|
1046
|
+
json_response = load_file('library_info_response.json')
|
1047
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1048
|
+
|
1049
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1050
|
+
RestClient.stub(:get).and_return(response)
|
1051
|
+
|
1052
|
+
info = @api.get_library_info('token')
|
1053
|
+
info.should be_kind_of(ConstantContact::Components::LibrarySummary)
|
1054
|
+
info.usage_summary['folder_count'].should eq(6)
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
describe "#get_library_folders" do
|
1059
|
+
it "retrieves a list of MyLibrary folders" do
|
1060
|
+
json_response = load_file('library_folders_response.json')
|
1061
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1062
|
+
|
1063
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1064
|
+
RestClient.stub(:get).and_return(response)
|
1065
|
+
|
1066
|
+
folders = @api.get_library_folders('token', {:limit => 2})
|
1067
|
+
folders.should be_kind_of(ConstantContact::Components::ResultSet)
|
1068
|
+
folders.results.first.should be_kind_of(ConstantContact::Components::LibraryFolder)
|
1069
|
+
folders.results.first.name.should eq('backgrounds')
|
1070
|
+
end
|
1071
|
+
end
|
1072
|
+
|
1073
|
+
describe "#add_library_folder" do
|
1074
|
+
it "creates a new MyLibrary folder" do
|
1075
|
+
json = load_file('library_folder_response.json')
|
1076
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1077
|
+
|
1078
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1079
|
+
RestClient.stub(:post).and_return(response)
|
1080
|
+
new_folder = ConstantContact::Components::LibraryFolder.create(JSON.parse(json))
|
1081
|
+
|
1082
|
+
folder = @api.add_library_folder('token', new_folder)
|
1083
|
+
folder.should be_kind_of(ConstantContact::Components::LibraryFolder)
|
1084
|
+
folder.name.should eq('wildflowers')
|
1085
|
+
end
|
1086
|
+
end
|
1087
|
+
|
1088
|
+
describe "#get_library_folder" do
|
1089
|
+
it "retrieves a specific MyLibrary folder using the folder_id path parameter" do
|
1090
|
+
json = load_file('library_folder_response.json')
|
1091
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1092
|
+
|
1093
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1094
|
+
RestClient.stub(:get).and_return(response)
|
1095
|
+
|
1096
|
+
folder = @api.get_library_folder('token', 6)
|
1097
|
+
folder.should be_kind_of(ConstantContact::Components::LibraryFolder)
|
1098
|
+
folder.name.should eq('wildflowers')
|
1099
|
+
end
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
describe "#update_library_folder" do
|
1103
|
+
it "retrieves a specific MyLibrary folder using the folder_id path parameter" do
|
1104
|
+
json = load_file('library_folder_response.json')
|
1105
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1106
|
+
|
1107
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1108
|
+
RestClient.stub(:put).and_return(response)
|
1109
|
+
folder = ConstantContact::Components::LibraryFolder.create(JSON.parse(json))
|
1110
|
+
|
1111
|
+
response = @api.update_library_folder('token', folder)
|
1112
|
+
response.should be_kind_of(ConstantContact::Components::LibraryFolder)
|
1113
|
+
response.name.should eq('wildflowers')
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
describe "#delete_library_folder" do
|
1118
|
+
it "deletes a MyLibrary folder" do
|
1119
|
+
folder_id = 6
|
1120
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
1121
|
+
|
1122
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
1123
|
+
RestClient.stub(:delete).and_return(response)
|
1124
|
+
|
1125
|
+
result = @api.delete_library_folder('token', folder_id)
|
1126
|
+
result.should be_true
|
1127
|
+
end
|
1128
|
+
end
|
1129
|
+
|
1130
|
+
describe "#get_library_trash" do
|
1131
|
+
it "retrieve all files in the Trash folder" do
|
1132
|
+
json = load_file('library_trash_response.json')
|
1133
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1134
|
+
|
1135
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1136
|
+
RestClient.stub(:get).and_return(response)
|
1137
|
+
|
1138
|
+
files = @api.get_library_trash('token', {:sort_by => 'SIZE_DESC'})
|
1139
|
+
files.should be_kind_of(ConstantContact::Components::ResultSet)
|
1140
|
+
files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1141
|
+
files.results.first.name.should eq('menu_form.pdf')
|
1142
|
+
end
|
1143
|
+
end
|
1144
|
+
|
1145
|
+
describe "#delete_library_trash" do
|
1146
|
+
it "permanently deletes all files in the Trash folder" do
|
1147
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
1148
|
+
|
1149
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
1150
|
+
RestClient.stub(:delete).and_return(response)
|
1151
|
+
|
1152
|
+
result = @api.delete_library_trash('token')
|
1153
|
+
result.should be_true
|
1154
|
+
end
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
describe "#get_library_files" do
|
1158
|
+
it "retrieves a collection of MyLibrary files in the Constant Contact account" do
|
1159
|
+
json_response = load_file('library_files_response.json')
|
1160
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1161
|
+
|
1162
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1163
|
+
RestClient.stub(:get).and_return(response)
|
1164
|
+
|
1165
|
+
files = @api.get_library_files('token', {:type => 'ALL'})
|
1166
|
+
files.should be_kind_of(ConstantContact::Components::ResultSet)
|
1167
|
+
files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1168
|
+
files.results.first.name.should eq('IMG_0341.JPG')
|
1169
|
+
end
|
1170
|
+
end
|
1171
|
+
|
1172
|
+
describe "#get_library_files_by_folder" do
|
1173
|
+
it "retrieves a collection of MyLibrary files in the Constant Contact account" do
|
1174
|
+
folder_id = -1
|
1175
|
+
json_response = load_file('library_files_by_folder_response.json')
|
1176
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1177
|
+
|
1178
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1179
|
+
RestClient.stub(:get).and_return(response)
|
1180
|
+
|
1181
|
+
files = @api.get_library_files_by_folder('token', folder_id, {:limit => 10})
|
1182
|
+
files.should be_kind_of(ConstantContact::Components::ResultSet)
|
1183
|
+
files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1184
|
+
files.results.first.name.should eq('IMG_0341.JPG')
|
1185
|
+
end
|
1186
|
+
end
|
1187
|
+
|
1188
|
+
describe "#get_library_file" do
|
1189
|
+
it "retrieve a MyLibrary file using the file_id path parameter" do
|
1190
|
+
json = load_file('library_file_response.json')
|
1191
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1192
|
+
|
1193
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1194
|
+
RestClient.stub(:get).and_return(response)
|
1195
|
+
|
1196
|
+
file = @api.get_library_file('token', 6)
|
1197
|
+
file.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1198
|
+
file.name.should eq('IMG_0261.JPG')
|
1199
|
+
end
|
1200
|
+
end
|
1201
|
+
|
1202
|
+
describe "#add_library_file" do
|
1203
|
+
it "adds a new MyLibrary file using the multipart content-type" do
|
1204
|
+
file_name = 'logo.jpg'
|
1205
|
+
folder_id = 1
|
1206
|
+
description = 'Logo'
|
1207
|
+
source = 'MyComputer'
|
1208
|
+
file_type = 'JPG'
|
1209
|
+
contents = load_file('logo.jpg')
|
1210
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1211
|
+
net_http_resp.add_field('Location', '"https://api.d1.constantcontact.com/v2/library/files/123456789')
|
1212
|
+
|
1213
|
+
response = RestClient::Response.create("", net_http_resp, {})
|
1214
|
+
RestClient.stub(:post).and_return(response)
|
1215
|
+
|
1216
|
+
response = @api.add_library_file('token', file_name, folder_id, description, source, file_type, contents)
|
1217
|
+
response.should be_kind_of(String)
|
1218
|
+
response.should eq('123456789')
|
1219
|
+
end
|
1220
|
+
end
|
1221
|
+
|
1222
|
+
describe "#update_library_file" do
|
1223
|
+
it "updates information for a specific MyLibrary file" do
|
1224
|
+
json = load_file('library_file_response.json')
|
1225
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1226
|
+
|
1227
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1228
|
+
RestClient.stub(:put).and_return(response)
|
1229
|
+
file = ConstantContact::Components::LibraryFile.create(JSON.parse(json))
|
1230
|
+
|
1231
|
+
response = @api.update_library_file('token', file)
|
1232
|
+
response.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1233
|
+
response.name.should eq('IMG_0261.JPG')
|
1234
|
+
end
|
1235
|
+
end
|
1236
|
+
|
1237
|
+
describe "#delete_library_file" do
|
1238
|
+
it "deletes one or more MyLibrary files specified by the fileId path parameter" do
|
1239
|
+
file_id = '6, 7'
|
1240
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
1241
|
+
|
1242
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
1243
|
+
RestClient.stub(:delete).and_return(response)
|
1244
|
+
|
1245
|
+
result = @api.delete_library_file('token', file_id)
|
1246
|
+
result.should be_true
|
1247
|
+
end
|
1248
|
+
end
|
1249
|
+
|
1250
|
+
describe "#get_library_files_upload_status" do
|
1251
|
+
it "retrieves the upload status for one or more MyLibrary files using the file_id path parameter" do
|
1252
|
+
file_id = '6, 7'
|
1253
|
+
json = load_file('library_files_upload_status_response.json')
|
1254
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1255
|
+
|
1256
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1257
|
+
RestClient.stub(:get).and_return(response)
|
1258
|
+
|
1259
|
+
statuses = @api.get_library_files_upload_status('token', file_id)
|
1260
|
+
statuses.should be_kind_of(Array)
|
1261
|
+
statuses.first.should be_kind_of(ConstantContact::Components::UploadStatus)
|
1262
|
+
statuses.first.status.should eq('Active')
|
1263
|
+
end
|
1264
|
+
end
|
1265
|
+
|
1266
|
+
describe "#move_library_files" do
|
1267
|
+
it "moves one or more MyLibrary files to a different folder in the user's account" do
|
1268
|
+
folder_id = 1
|
1269
|
+
file_id = '8, 9'
|
1270
|
+
json = load_file('library_files_move_results_response.json')
|
1271
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
1272
|
+
|
1273
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
1274
|
+
RestClient.stub(:put).and_return(response)
|
1275
|
+
|
1276
|
+
results = @api.move_library_files('token', folder_id, file_id)
|
1277
|
+
results.should be_kind_of(Array)
|
1278
|
+
results.first.should be_kind_of(ConstantContact::Components::MoveResults)
|
1279
|
+
results.first.uri.should eq('https://api.d1.constantcontact.com/v2/library/files/9')
|
1280
|
+
end
|
1281
|
+
end
|
232
1282
|
end
|
233
1283
|
end
|