constantcontact 1.0.2 → 1.1.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.
- 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
@@ -0,0 +1,127 @@
|
|
1
|
+
#
|
2
|
+
# campaign_tracking_service_spec.rb
|
3
|
+
# ConstantContact
|
4
|
+
#
|
5
|
+
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
|
+
|
7
|
+
require 'spec_helper'
|
8
|
+
|
9
|
+
describe ConstantContact::Services::CampaignTrackingService do
|
10
|
+
describe "#get_bounces" do
|
11
|
+
it "gets bounces for a given campaign" do
|
12
|
+
campaign_id = 1
|
13
|
+
params = {:limit => 5}
|
14
|
+
json = load_file('campaign_tracking_bounces_response.json')
|
15
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
16
|
+
|
17
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
18
|
+
RestClient.stub(:get).and_return(response)
|
19
|
+
|
20
|
+
set = ConstantContact::Services::CampaignTrackingService.get_bounces('token', campaign_id, params)
|
21
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
22
|
+
set.results.first.should be_kind_of(ConstantContact::Components::BounceActivity)
|
23
|
+
set.results.first.activity_type.should eq('EMAIL_BOUNCE')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#get_clicks" do
|
28
|
+
it "gets clicks for a given campaign" do
|
29
|
+
campaign_id = 1
|
30
|
+
params = {:limit => 5}
|
31
|
+
json = load_file('campaign_tracking_clicks_response.json')
|
32
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
33
|
+
|
34
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
35
|
+
RestClient.stub(:get).and_return(response)
|
36
|
+
|
37
|
+
set = ConstantContact::Services::CampaignTrackingService.get_clicks('token', campaign_id, params)
|
38
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
39
|
+
set.results.first.should be_kind_of(ConstantContact::Components::ClickActivity)
|
40
|
+
set.results.first.activity_type.should eq('EMAIL_CLICK')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#get_forwards" do
|
45
|
+
it "gets forwards for a given campaign" do
|
46
|
+
campaign_id = 1
|
47
|
+
params = {:limit => 5}
|
48
|
+
json = load_file('campaign_tracking_forwards_response.json')
|
49
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
50
|
+
|
51
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
52
|
+
RestClient.stub(:get).and_return(response)
|
53
|
+
|
54
|
+
set = ConstantContact::Services::CampaignTrackingService.get_forwards('token', campaign_id, params)
|
55
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
56
|
+
set.results.first.should be_kind_of(ConstantContact::Components::ForwardActivity)
|
57
|
+
set.results.first.activity_type.should eq('EMAIL_FORWARD')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#get_opens" do
|
62
|
+
it "gets opens for a given campaign" do
|
63
|
+
campaign_id = 1
|
64
|
+
params = {:limit => 5}
|
65
|
+
json = load_file('campaign_tracking_opens_response.json')
|
66
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
67
|
+
|
68
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
69
|
+
RestClient.stub(:get).and_return(response)
|
70
|
+
|
71
|
+
set = ConstantContact::Services::CampaignTrackingService.get_opens('token', campaign_id, params)
|
72
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
73
|
+
set.results.first.should be_kind_of(ConstantContact::Components::OpenActivity)
|
74
|
+
set.results.first.activity_type.should eq('EMAIL_OPEN')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#get_sends" do
|
79
|
+
it "gets sends for a given campaign" do
|
80
|
+
campaign_id = 1
|
81
|
+
params = {:limit => 5}
|
82
|
+
json = load_file('campaign_tracking_sends_response.json')
|
83
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
84
|
+
|
85
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
86
|
+
RestClient.stub(:get).and_return(response)
|
87
|
+
|
88
|
+
set = ConstantContact::Services::CampaignTrackingService.get_sends('token', campaign_id, params)
|
89
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
90
|
+
set.results.first.should be_kind_of(ConstantContact::Components::SendActivity)
|
91
|
+
set.results.first.activity_type.should eq('EMAIL_SEND')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#get_unsubscribes" do
|
96
|
+
it "gets unsubscribes for a given campaign" do
|
97
|
+
campaign_id = 1
|
98
|
+
params = {:limit => 5}
|
99
|
+
json = load_file('campaign_tracking_unsubscribes_response.json')
|
100
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
101
|
+
|
102
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
103
|
+
RestClient.stub(:get).and_return(response)
|
104
|
+
|
105
|
+
set = ConstantContact::Services::CampaignTrackingService.get_unsubscribes('token', campaign_id, params)
|
106
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
107
|
+
set.results.first.should be_kind_of(ConstantContact::Components::UnsubscribeActivity)
|
108
|
+
set.results.first.activity_type.should eq('EMAIL_UNSUBSCRIBE')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#get_summary" do
|
113
|
+
it "gets a summary of reporting data for a given campaign" do
|
114
|
+
campaign_id = 1
|
115
|
+
json = load_file('campaign_tracking_summary_response.json')
|
116
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
117
|
+
|
118
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
119
|
+
RestClient.stub(:get).and_return(response)
|
120
|
+
|
121
|
+
summary = ConstantContact::Services::CampaignTrackingService.get_summary('token', campaign_id)
|
122
|
+
summary.should be_kind_of(ConstantContact::Components::TrackingSummary)
|
123
|
+
summary.sends.should eq(15)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
@@ -9,7 +9,7 @@ require 'spec_helper'
|
|
9
9
|
describe ConstantContact::Services::ContactService do
|
10
10
|
describe "#get_contacts" do
|
11
11
|
it "returns an array of contacts" do
|
12
|
-
json =
|
12
|
+
json = load_file('contacts_response.json')
|
13
13
|
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
14
14
|
|
15
15
|
response = RestClient::Response.create(json, net_http_resp, {})
|
@@ -24,7 +24,7 @@ describe ConstantContact::Services::ContactService do
|
|
24
24
|
|
25
25
|
describe "#get_contact" do
|
26
26
|
it "returns a contact" do
|
27
|
-
json =
|
27
|
+
json = load_file('contact_response.json')
|
28
28
|
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
29
29
|
|
30
30
|
response = RestClient::Response.create(json, net_http_resp, {})
|
@@ -37,69 +37,71 @@ describe ConstantContact::Services::ContactService do
|
|
37
37
|
|
38
38
|
describe "#add_contact" do
|
39
39
|
it "adds a contact" do
|
40
|
-
json =
|
40
|
+
json = load_file('contact_response.json')
|
41
41
|
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
42
42
|
|
43
43
|
response = RestClient::Response.create(json, net_http_resp, {})
|
44
44
|
RestClient.stub(:post).and_return(response)
|
45
|
-
|
46
|
-
|
45
|
+
new_contact = ConstantContact::Components::Contact.create(JSON.parse(json))
|
46
|
+
contact = ConstantContact::Services::ContactService.add_contact('token', new_contact)
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
contact.should be_kind_of(ConstantContact::Components::Contact)
|
49
|
+
contact.status.should eq('ACTIVE')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "#delete_contact" do
|
54
54
|
it "deletes a contact" do
|
55
|
-
|
55
|
+
contact_id = 196
|
56
56
|
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
57
57
|
|
58
58
|
response = RestClient::Response.create('', net_http_resp, {})
|
59
59
|
RestClient.stub(:delete).and_return(response)
|
60
|
-
|
61
|
-
ConstantContact::Services::ContactService.delete_contact('token',
|
60
|
+
|
61
|
+
result = ConstantContact::Services::ContactService.delete_contact('token', contact_id)
|
62
|
+
result.should be_true
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
describe "#delete_contact_from_lists" do
|
66
67
|
it "deletes a contact" do
|
67
|
-
|
68
|
+
contact_id = 196
|
68
69
|
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
69
70
|
|
70
71
|
response = RestClient::Response.create('', net_http_resp, {})
|
71
72
|
RestClient.stub(:delete).and_return(response)
|
72
|
-
|
73
|
-
ConstantContact::Services::ContactService.delete_contact_from_lists('token',
|
73
|
+
|
74
|
+
result = ConstantContact::Services::ContactService.delete_contact_from_lists('token', contact_id)
|
75
|
+
result.should be_true
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
77
79
|
describe "#delete_contact_from_list" do
|
78
80
|
it "deletes a contact" do
|
79
|
-
|
80
|
-
|
81
|
+
contact_id = 196
|
82
|
+
list_id = 1
|
81
83
|
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
82
84
|
|
83
85
|
response = RestClient::Response.create('', net_http_resp, {})
|
84
86
|
RestClient.stub(:delete).and_return(response)
|
85
|
-
|
86
|
-
|
87
|
-
|
87
|
+
|
88
|
+
result = ConstantContact::Services::ContactService.delete_contact_from_list('token', contact_id, list_id)
|
89
|
+
result.should be_true
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
91
93
|
describe "#update_contact" do
|
92
94
|
it "updates a contact" do
|
93
|
-
json =
|
95
|
+
json = load_file('contact_response.json')
|
94
96
|
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
95
97
|
|
96
98
|
response = RestClient::Response.create(json, net_http_resp, {})
|
97
99
|
RestClient.stub(:put).and_return(response)
|
98
100
|
contact = ConstantContact::Components::Contact.create(JSON.parse(json))
|
99
|
-
|
101
|
+
result = ConstantContact::Services::ContactService.update_contact('token', contact)
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
+
result.should be_kind_of(ConstantContact::Components::Contact)
|
104
|
+
result.status.should eq('ACTIVE')
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
#
|
2
|
+
# contact_tracking_service_spec.rb
|
3
|
+
# ConstantContact
|
4
|
+
#
|
5
|
+
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
|
+
|
7
|
+
require 'spec_helper'
|
8
|
+
|
9
|
+
describe ConstantContact::Services::ContactTrackingService do
|
10
|
+
describe "#get_bounces" do
|
11
|
+
it "gets bounces for a given contact" do
|
12
|
+
contact_id = 1
|
13
|
+
params = {:limit => 5}
|
14
|
+
json = load_file('contact_tracking_bounces_response.json')
|
15
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
16
|
+
|
17
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
18
|
+
RestClient.stub(:get).and_return(response)
|
19
|
+
|
20
|
+
set = ConstantContact::Services::ContactTrackingService.get_bounces('token', contact_id, params)
|
21
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
22
|
+
set.results.first.should be_kind_of(ConstantContact::Components::BounceActivity)
|
23
|
+
set.results.first.activity_type.should eq('EMAIL_BOUNCE')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#get_clicks" do
|
28
|
+
it "gets clicks for a given contact" do
|
29
|
+
contact_id = 1
|
30
|
+
params = {:limit => 5}
|
31
|
+
json = load_file('contact_tracking_clicks_response.json')
|
32
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
33
|
+
|
34
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
35
|
+
RestClient.stub(:get).and_return(response)
|
36
|
+
|
37
|
+
set = ConstantContact::Services::ContactTrackingService.get_clicks('token', contact_id, params)
|
38
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
39
|
+
set.results.first.should be_kind_of(ConstantContact::Components::ClickActivity)
|
40
|
+
set.results.first.activity_type.should eq('EMAIL_CLICK')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#get_forwards" do
|
45
|
+
it "gets forwards for a given contact" do
|
46
|
+
contact_id = 1
|
47
|
+
params = {:limit => 5}
|
48
|
+
json = load_file('contact_tracking_forwards_response.json')
|
49
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
50
|
+
|
51
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
52
|
+
RestClient.stub(:get).and_return(response)
|
53
|
+
|
54
|
+
set = ConstantContact::Services::ContactTrackingService.get_forwards('token', contact_id, params)
|
55
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
56
|
+
set.results.first.should be_kind_of(ConstantContact::Components::ForwardActivity)
|
57
|
+
set.results.first.activity_type.should eq('EMAIL_FORWARD')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#get_opens" do
|
62
|
+
it "gets opens for a given contact" do
|
63
|
+
contact_id = 1
|
64
|
+
params = {:limit => 5}
|
65
|
+
json = load_file('contact_tracking_opens_response.json')
|
66
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
67
|
+
|
68
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
69
|
+
RestClient.stub(:get).and_return(response)
|
70
|
+
|
71
|
+
set = ConstantContact::Services::ContactTrackingService.get_opens('token', contact_id, params)
|
72
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
73
|
+
set.results.first.should be_kind_of(ConstantContact::Components::OpenActivity)
|
74
|
+
set.results.first.activity_type.should eq('EMAIL_OPEN')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#get_sends" do
|
79
|
+
it "gets sends for a given contact" do
|
80
|
+
contact_id = 1
|
81
|
+
params = {:limit => 5}
|
82
|
+
json = load_file('contact_tracking_sends_response.json')
|
83
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
84
|
+
|
85
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
86
|
+
RestClient.stub(:get).and_return(response)
|
87
|
+
|
88
|
+
set = ConstantContact::Services::ContactTrackingService.get_sends('token', contact_id, params)
|
89
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
90
|
+
set.results.first.should be_kind_of(ConstantContact::Components::SendActivity)
|
91
|
+
set.results.first.activity_type.should eq('EMAIL_SEND')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#get_unsubscribes" do
|
96
|
+
it "gets unsubscribes for a given contact" do
|
97
|
+
contact_id = 1
|
98
|
+
params = {:limit => 5}
|
99
|
+
json = load_file('contact_tracking_unsubscribes_response.json')
|
100
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
101
|
+
|
102
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
103
|
+
RestClient.stub(:get).and_return(response)
|
104
|
+
|
105
|
+
set = ConstantContact::Services::ContactTrackingService.get_unsubscribes('token', contact_id, params)
|
106
|
+
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
107
|
+
set.results.first.should be_kind_of(ConstantContact::Components::UnsubscribeActivity)
|
108
|
+
set.results.first.activity_type.should eq('EMAIL_UNSUBSCRIBE')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#get_summary" do
|
113
|
+
it "gets a summary of reporting data for a given contact" do
|
114
|
+
contact_id = 1
|
115
|
+
json = load_file('contact_tracking_summary_response.json')
|
116
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
117
|
+
|
118
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
119
|
+
RestClient.stub(:get).and_return(response)
|
120
|
+
|
121
|
+
summary = ConstantContact::Services::CampaignTrackingService.get_summary('token', contact_id)
|
122
|
+
summary.should be_kind_of(ConstantContact::Components::TrackingSummary)
|
123
|
+
summary.sends.should eq(15)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
@@ -7,70 +7,76 @@
|
|
7
7
|
require 'spec_helper'
|
8
8
|
|
9
9
|
describe ConstantContact::Services::EmailMarketingService do
|
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
|
-
|
10
|
+
describe "#get_campaigns" do
|
11
|
+
it "returns an array of campaigns" do
|
12
|
+
json_response = load_file('email_campaigns_response.json')
|
13
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
14
|
+
|
15
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
16
|
+
RestClient.stub(:get).and_return(response)
|
17
|
+
|
18
|
+
campaigns = ConstantContact::Services::EmailMarketingService.get_campaigns('token')
|
19
|
+
campaigns.should be_kind_of(ConstantContact::Components::ResultSet)
|
20
|
+
campaigns.results.first.should be_kind_of(ConstantContact::Components::Campaign)
|
21
|
+
campaigns.results.first.name.should eq('1357157252225')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#get_campaign" do
|
26
|
+
it "returns a campaign" do
|
27
|
+
json_response = load_file('email_campaign_response.json')
|
28
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
29
|
+
|
30
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
31
|
+
RestClient.stub(:get).and_return(response)
|
32
|
+
|
33
|
+
campaign = ConstantContact::Services::EmailMarketingService.get_campaign('token', 1)
|
34
|
+
campaign.should be_kind_of(ConstantContact::Components::Campaign)
|
35
|
+
campaign.name.should eq('Campaign Name')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#add_campaign" do
|
40
|
+
it "adds a campaign" do
|
41
|
+
json = load_file('email_campaign_response.json')
|
42
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
43
|
+
|
44
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
45
|
+
RestClient.stub(:post).and_return(response)
|
46
|
+
new_campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
47
|
+
|
48
|
+
campaign = ConstantContact::Services::EmailMarketingService.add_campaign('token', new_campaign)
|
49
|
+
campaign.should be_kind_of(ConstantContact::Components::Campaign)
|
50
|
+
campaign.name.should eq('Campaign Name')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#delete_campaign" do
|
55
|
+
it "deletes a campaign" do
|
56
|
+
json = load_file('email_campaign_response.json')
|
57
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
|
58
|
+
|
59
|
+
response = RestClient::Response.create('', net_http_resp, {})
|
60
|
+
RestClient.stub(:delete).and_return(response)
|
61
|
+
campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
62
|
+
|
63
|
+
result = ConstantContact::Services::EmailMarketingService.delete_campaign('token', campaign)
|
64
|
+
result.should be_true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#update_campaign" do
|
69
|
+
it "updates a campaign" do
|
70
|
+
json = load_file('email_campaign_response.json')
|
71
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
72
|
+
|
73
|
+
response = RestClient::Response.create(json, net_http_resp, {})
|
74
|
+
RestClient.stub(:put).and_return(response)
|
75
|
+
campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
76
|
+
|
77
|
+
result = ConstantContact::Services::EmailMarketingService.update_campaign('token', campaign)
|
78
|
+
result.should be_kind_of(ConstantContact::Components::Campaign)
|
79
|
+
result.name.should eq('Campaign Name')
|
80
|
+
end
|
81
|
+
end
|
76
82
|
end
|