constantcontact 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -2
  3. data/README.md +56 -1
  4. data/constantcontact.gemspec +1 -1
  5. data/lib/constantcontact/api.rb +111 -97
  6. data/lib/constantcontact/services/account_service.rb +20 -22
  7. data/lib/constantcontact/services/activity_service.rb +98 -100
  8. data/lib/constantcontact/services/base_service.rb +46 -44
  9. data/lib/constantcontact/services/campaign_schedule_service.rb +72 -74
  10. data/lib/constantcontact/services/campaign_tracking_service.rb +103 -105
  11. data/lib/constantcontact/services/contact_service.rb +73 -75
  12. data/lib/constantcontact/services/contact_tracking_service.rb +103 -105
  13. data/lib/constantcontact/services/email_marketing_service.rb +64 -66
  14. data/lib/constantcontact/services/event_spot_service.rb +356 -358
  15. data/lib/constantcontact/services/library_service.rb +228 -230
  16. data/lib/constantcontact/services/list_service.rb +55 -57
  17. data/lib/constantcontact/version.rb +1 -1
  18. data/spec/constantcontact/api_spec.rb +2 -4
  19. data/spec/constantcontact/services/account_service_spec.rb +3 -2
  20. data/spec/constantcontact/services/activity_service_spec.rb +10 -9
  21. data/spec/constantcontact/services/base_service_spec.rb +7 -5
  22. data/spec/constantcontact/services/campaign_schedule_service_spec.rb +7 -6
  23. data/spec/constantcontact/services/campaign_tracking_service_spec.rb +8 -7
  24. data/spec/constantcontact/services/contact_service_spec.rb +8 -7
  25. data/spec/constantcontact/services/contact_tracking_service_spec.rb +8 -7
  26. data/spec/constantcontact/services/email_marketing_spec.rb +7 -6
  27. data/spec/constantcontact/services/event_spot_spec.rb +28 -27
  28. data/spec/constantcontact/services/library_service_spec.rb +17 -16
  29. data/spec/constantcontact/services/list_service_spec.rb +6 -5
  30. metadata +20 -20
@@ -9,6 +9,7 @@ require 'spec_helper'
9
9
  describe ConstantContact::Services::ContactService do
10
10
  before(:each) do
11
11
  @request = double('http request', :user => nil, :password => nil, :url => 'http://example.com', :redirection_history => nil)
12
+ @client = ConstantContact::Api.new('explicit_api_key', "access_token")
12
13
  end
13
14
 
14
15
  describe "#get_contacts" do
@@ -18,7 +19,7 @@ describe ConstantContact::Services::ContactService do
18
19
 
19
20
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
20
21
  RestClient.stub(:get).and_return(response)
21
- contacts = ConstantContact::Services::ContactService.get_contacts()
22
+ contacts = ConstantContact::Services::ContactService.new(@client).get_contacts()
22
23
  contact = contacts.results[0]
23
24
 
24
25
  contacts.should be_kind_of(ConstantContact::Components::ResultSet)
@@ -33,7 +34,7 @@ describe ConstantContact::Services::ContactService do
33
34
 
34
35
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
35
36
  RestClient.stub(:get).and_return(response)
36
- contact = ConstantContact::Services::ContactService.get_contact(1)
37
+ contact = ConstantContact::Services::ContactService.new(@client).get_contact(1)
37
38
 
38
39
  contact.should be_kind_of(ConstantContact::Components::Contact)
39
40
  end
@@ -47,7 +48,7 @@ describe ConstantContact::Services::ContactService do
47
48
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
48
49
  RestClient.stub(:post).and_return(response)
49
50
  new_contact = ConstantContact::Components::Contact.create(JSON.parse(json))
50
- contact = ConstantContact::Services::ContactService.add_contact(new_contact)
51
+ contact = ConstantContact::Services::ContactService.new(@client).add_contact(new_contact)
51
52
 
52
53
  contact.should be_kind_of(ConstantContact::Components::Contact)
53
54
  contact.status.should eq('ACTIVE')
@@ -62,7 +63,7 @@ describe ConstantContact::Services::ContactService do
62
63
  response = RestClient::Response.create('', net_http_resp, {}, @request)
63
64
  RestClient.stub(:delete).and_return(response)
64
65
 
65
- result = ConstantContact::Services::ContactService.delete_contact(contact_id)
66
+ result = ConstantContact::Services::ContactService.new(@client).delete_contact(contact_id)
66
67
  result.should be_true
67
68
  end
68
69
  end
@@ -75,7 +76,7 @@ describe ConstantContact::Services::ContactService do
75
76
  response = RestClient::Response.create('', net_http_resp, {}, @request)
76
77
  RestClient.stub(:delete).and_return(response)
77
78
 
78
- result = ConstantContact::Services::ContactService.delete_contact_from_lists(contact_id)
79
+ result = ConstantContact::Services::ContactService.new(@client).delete_contact_from_lists(contact_id)
79
80
  result.should be_true
80
81
  end
81
82
  end
@@ -89,7 +90,7 @@ describe ConstantContact::Services::ContactService do
89
90
  response = RestClient::Response.create('', net_http_resp, {}, @request)
90
91
  RestClient.stub(:delete).and_return(response)
91
92
 
92
- result = ConstantContact::Services::ContactService.delete_contact_from_list(contact_id, list_id)
93
+ result = ConstantContact::Services::ContactService.new(@client).delete_contact_from_list(contact_id, list_id)
93
94
  result.should be_true
94
95
  end
95
96
  end
@@ -102,7 +103,7 @@ describe ConstantContact::Services::ContactService do
102
103
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
103
104
  RestClient.stub(:put).and_return(response)
104
105
  contact = ConstantContact::Components::Contact.create(JSON.parse(json))
105
- result = ConstantContact::Services::ContactService.update_contact(contact)
106
+ result = ConstantContact::Services::ContactService.new(@client).update_contact(contact)
106
107
 
107
108
  result.should be_kind_of(ConstantContact::Components::Contact)
108
109
  result.status.should eq('ACTIVE')
@@ -9,6 +9,7 @@ require 'spec_helper'
9
9
  describe ConstantContact::Services::ContactTrackingService do
10
10
  before(:each) do
11
11
  @request = double('http request', :user => nil, :password => nil, :url => 'http://example.com', :redirection_history => nil)
12
+ @client = ConstantContact::Api.new('explicit_api_key', "access_token")
12
13
  end
13
14
 
14
15
  describe "#get_bounces" do
@@ -21,7 +22,7 @@ describe ConstantContact::Services::ContactTrackingService do
21
22
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
22
23
  RestClient.stub(:get).and_return(response)
23
24
 
24
- set = ConstantContact::Services::ContactTrackingService.get_bounces(contact_id, params)
25
+ set = ConstantContact::Services::ContactTrackingService.new(@client).get_bounces(contact_id, params)
25
26
  set.should be_kind_of(ConstantContact::Components::ResultSet)
26
27
  set.results.first.should be_kind_of(ConstantContact::Components::BounceActivity)
27
28
  set.results.first.activity_type.should eq('EMAIL_BOUNCE')
@@ -38,7 +39,7 @@ describe ConstantContact::Services::ContactTrackingService do
38
39
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
39
40
  RestClient.stub(:get).and_return(response)
40
41
 
41
- set = ConstantContact::Services::ContactTrackingService.get_clicks(contact_id, params)
42
+ set = ConstantContact::Services::ContactTrackingService.new(@client).get_clicks(contact_id, params)
42
43
  set.should be_kind_of(ConstantContact::Components::ResultSet)
43
44
  set.results.first.should be_kind_of(ConstantContact::Components::ClickActivity)
44
45
  set.results.first.activity_type.should eq('EMAIL_CLICK')
@@ -55,7 +56,7 @@ describe ConstantContact::Services::ContactTrackingService do
55
56
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
56
57
  RestClient.stub(:get).and_return(response)
57
58
 
58
- set = ConstantContact::Services::ContactTrackingService.get_forwards(contact_id, params)
59
+ set = ConstantContact::Services::ContactTrackingService.new(@client).get_forwards(contact_id, params)
59
60
  set.should be_kind_of(ConstantContact::Components::ResultSet)
60
61
  set.results.first.should be_kind_of(ConstantContact::Components::ForwardActivity)
61
62
  set.results.first.activity_type.should eq('EMAIL_FORWARD')
@@ -72,7 +73,7 @@ describe ConstantContact::Services::ContactTrackingService do
72
73
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
73
74
  RestClient.stub(:get).and_return(response)
74
75
 
75
- set = ConstantContact::Services::ContactTrackingService.get_opens(contact_id, params)
76
+ set = ConstantContact::Services::ContactTrackingService.new(@client).get_opens(contact_id, params)
76
77
  set.should be_kind_of(ConstantContact::Components::ResultSet)
77
78
  set.results.first.should be_kind_of(ConstantContact::Components::OpenActivity)
78
79
  set.results.first.activity_type.should eq('EMAIL_OPEN')
@@ -89,7 +90,7 @@ describe ConstantContact::Services::ContactTrackingService do
89
90
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
90
91
  RestClient.stub(:get).and_return(response)
91
92
 
92
- set = ConstantContact::Services::ContactTrackingService.get_sends(contact_id, params)
93
+ set = ConstantContact::Services::ContactTrackingService.new(@client).get_sends(contact_id, params)
93
94
  set.should be_kind_of(ConstantContact::Components::ResultSet)
94
95
  set.results.first.should be_kind_of(ConstantContact::Components::SendActivity)
95
96
  set.results.first.activity_type.should eq('EMAIL_SEND')
@@ -106,7 +107,7 @@ describe ConstantContact::Services::ContactTrackingService do
106
107
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
107
108
  RestClient.stub(:get).and_return(response)
108
109
 
109
- set = ConstantContact::Services::ContactTrackingService.get_unsubscribes(contact_id, params)
110
+ set = ConstantContact::Services::ContactTrackingService.new(@client).get_unsubscribes(contact_id, params)
110
111
  set.should be_kind_of(ConstantContact::Components::ResultSet)
111
112
  set.results.first.should be_kind_of(ConstantContact::Components::UnsubscribeActivity)
112
113
  set.results.first.activity_type.should eq('EMAIL_UNSUBSCRIBE')
@@ -122,7 +123,7 @@ describe ConstantContact::Services::ContactTrackingService do
122
123
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
123
124
  RestClient.stub(:get).and_return(response)
124
125
 
125
- summary = ConstantContact::Services::CampaignTrackingService.get_summary(contact_id)
126
+ summary = ConstantContact::Services::CampaignTrackingService.new(@client).get_summary(contact_id)
126
127
  summary.should be_kind_of(ConstantContact::Components::TrackingSummary)
127
128
  summary.sends.should eq(15)
128
129
  end
@@ -9,6 +9,7 @@ require 'spec_helper'
9
9
  describe ConstantContact::Services::EmailMarketingService do
10
10
  before(:each) do
11
11
  @request = double('http request', :user => nil, :password => nil, :url => 'http://example.com', :redirection_history => nil)
12
+ @client = ConstantContact::Api.new('explicit_api_key', "access_token")
12
13
  end
13
14
 
14
15
  describe "#get_campaigns" do
@@ -19,7 +20,7 @@ describe ConstantContact::Services::EmailMarketingService do
19
20
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
20
21
  RestClient.stub(:get).and_return(response)
21
22
 
22
- campaigns = ConstantContact::Services::EmailMarketingService.get_campaigns()
23
+ campaigns = ConstantContact::Services::EmailMarketingService.new(@client).get_campaigns()
23
24
  campaigns.should be_kind_of(ConstantContact::Components::ResultSet)
24
25
  campaigns.results.first.should be_kind_of(ConstantContact::Components::Campaign)
25
26
  campaigns.results.first.name.should eq('1357157252225')
@@ -34,7 +35,7 @@ describe ConstantContact::Services::EmailMarketingService do
34
35
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
35
36
  RestClient.stub(:get).and_return(response)
36
37
 
37
- campaign = ConstantContact::Services::EmailMarketingService.get_campaign(1)
38
+ campaign = ConstantContact::Services::EmailMarketingService.new(@client).get_campaign(1)
38
39
  campaign.should be_kind_of(ConstantContact::Components::Campaign)
39
40
  campaign.name.should eq('Campaign Name')
40
41
  end
@@ -48,7 +49,7 @@ describe ConstantContact::Services::EmailMarketingService do
48
49
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
49
50
  RestClient.stub(:get).and_return(response)
50
51
 
51
- campaign_preview = ConstantContact::Services::EmailMarketingService.get_campaign_preview(1)
52
+ campaign_preview = ConstantContact::Services::EmailMarketingService.new(@client).get_campaign_preview(1)
52
53
  campaign_preview.should be_kind_of(ConstantContact::Components::CampaignPreview)
53
54
  campaign_preview.subject.should eq('Subject Test')
54
55
  end
@@ -63,7 +64,7 @@ describe ConstantContact::Services::EmailMarketingService do
63
64
  RestClient.stub(:post).and_return(response)
64
65
  new_campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
65
66
 
66
- campaign = ConstantContact::Services::EmailMarketingService.add_campaign(new_campaign)
67
+ campaign = ConstantContact::Services::EmailMarketingService.new(@client).add_campaign(new_campaign)
67
68
  campaign.should be_kind_of(ConstantContact::Components::Campaign)
68
69
  campaign.name.should eq('Campaign Name')
69
70
  end
@@ -78,7 +79,7 @@ describe ConstantContact::Services::EmailMarketingService do
78
79
  RestClient.stub(:delete).and_return(response)
79
80
  campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
80
81
 
81
- result = ConstantContact::Services::EmailMarketingService.delete_campaign(campaign)
82
+ result = ConstantContact::Services::EmailMarketingService.new(@client).delete_campaign(campaign)
82
83
  result.should be_true
83
84
  end
84
85
  end
@@ -92,7 +93,7 @@ describe ConstantContact::Services::EmailMarketingService do
92
93
  RestClient.stub(:put).and_return(response)
93
94
  campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
94
95
 
95
- result = ConstantContact::Services::EmailMarketingService.update_campaign(campaign)
96
+ result = ConstantContact::Services::EmailMarketingService.new(@client).update_campaign(campaign)
96
97
  result.should be_kind_of(ConstantContact::Components::Campaign)
97
98
  result.name.should eq('Campaign Name')
98
99
  end
@@ -9,6 +9,7 @@ require 'spec_helper'
9
9
  describe ConstantContact::Services::EventSpotService do
10
10
  before(:each) do
11
11
  @request = double('http request', :user => nil, :password => nil, :url => 'http://example.com', :redirection_history => nil)
12
+ @client = ConstantContact::Api.new('explicit_api_key', "access_token")
12
13
  end
13
14
 
14
15
  describe "#get_events" do
@@ -18,7 +19,7 @@ describe ConstantContact::Services::EventSpotService do
18
19
 
19
20
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
20
21
  RestClient.stub(:get).and_return(response)
21
- events = ConstantContact::Services::EventSpotService.get_events()
22
+ events = ConstantContact::Services::EventSpotService.new(@client).get_events()
22
23
  events.should be_kind_of(ConstantContact::Components::ResultSet)
23
24
  events.results.collect{|e| e.should be_kind_of(ConstantContact::Components::Event) }
24
25
  end
@@ -31,7 +32,7 @@ describe ConstantContact::Services::EventSpotService do
31
32
 
32
33
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
33
34
  RestClient.stub(:get).and_return(response)
34
- event = ConstantContact::Services::EventSpotService.get_event(1)
35
+ event = ConstantContact::Services::EventSpotService.new(@client).get_event(1)
35
36
 
36
37
  event.should be_kind_of(ConstantContact::Components::Event)
37
38
  end
@@ -45,7 +46,7 @@ describe ConstantContact::Services::EventSpotService do
45
46
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
46
47
  RestClient.stub(:post).and_return(response)
47
48
  event = ConstantContact::Components::Event.create(JSON.parse(json))
48
- added = ConstantContact::Services::EventSpotService.add_event(event)
49
+ added = ConstantContact::Services::EventSpotService.new(@client).add_event(event)
49
50
 
50
51
  added.should respond_to(:id)
51
52
  added.id.should_not be_empty
@@ -63,7 +64,7 @@ describe ConstantContact::Services::EventSpotService do
63
64
  RestClient.stub(:patch).and_return(response)
64
65
 
65
66
  event = ConstantContact::Components::Event.create(JSON.parse(json))
66
- updated = ConstantContact::Services::EventSpotService.publish_event(event)
67
+ updated = ConstantContact::Services::EventSpotService.new(@client).publish_event(event)
67
68
  updated.should be_kind_of(ConstantContact::Components::Event)
68
69
  updated.should respond_to(:status)
69
70
  updated.status.should eq("ACTIVE")
@@ -81,7 +82,7 @@ describe ConstantContact::Services::EventSpotService do
81
82
  RestClient.stub(:patch).and_return(response)
82
83
 
83
84
  event = ConstantContact::Components::Event.create(JSON.parse(json))
84
- updated = ConstantContact::Services::EventSpotService.cancel_event(event)
85
+ updated = ConstantContact::Services::EventSpotService.new(@client).cancel_event(event)
85
86
  updated.should be_kind_of(ConstantContact::Components::Event)
86
87
  updated.should respond_to(:status)
87
88
  updated.status.should eq("CANCELLED")
@@ -97,7 +98,7 @@ describe ConstantContact::Services::EventSpotService do
97
98
  response = RestClient::Response.create(fees_json, net_http_resp, {}, @request)
98
99
  RestClient.stub(:get).and_return(response)
99
100
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
100
- fees = ConstantContact::Services::EventSpotService.get_fees(event)
101
+ fees = ConstantContact::Services::EventSpotService.new(@client).get_fees(event)
101
102
  #fees.should be_kind_of(ConstantContact::Components::ResultSet)
102
103
  #fees.results.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
103
104
 
@@ -117,7 +118,7 @@ describe ConstantContact::Services::EventSpotService do
117
118
 
118
119
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
119
120
  fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
120
- retrieved = ConstantContact::Services::EventSpotService.get_fee(event, fee)
121
+ retrieved = ConstantContact::Services::EventSpotService.new(@client).get_fee(event, fee)
121
122
  retrieved.should be_kind_of(ConstantContact::Components::EventFee)
122
123
  end
123
124
  end
@@ -133,7 +134,7 @@ describe ConstantContact::Services::EventSpotService do
133
134
 
134
135
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
135
136
  fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
136
- added = ConstantContact::Services::EventSpotService.add_fee(event, fee)
137
+ added = ConstantContact::Services::EventSpotService.new(@client).add_fee(event, fee)
137
138
  added.should be_kind_of(ConstantContact::Components::EventFee)
138
139
  added.id.should_not be_empty
139
140
  end
@@ -152,7 +153,7 @@ describe ConstantContact::Services::EventSpotService do
152
153
 
153
154
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
154
155
  fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
155
- updated = ConstantContact::Services::EventSpotService.update_fee(event, fee)
156
+ updated = ConstantContact::Services::EventSpotService.new(@client).update_fee(event, fee)
156
157
  updated.should be_kind_of(ConstantContact::Components::EventFee)
157
158
  updated.fee.should_not eq(fee.fee)
158
159
  updated.fee.should eq(fee.fee + 1)
@@ -170,7 +171,7 @@ describe ConstantContact::Services::EventSpotService do
170
171
 
171
172
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
172
173
  fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
173
- ConstantContact::Services::EventSpotService.delete_fee(event, fee).should be_true
174
+ ConstantContact::Services::EventSpotService.new(@client).delete_fee(event, fee).should be_true
174
175
  end
175
176
  end
176
177
 
@@ -184,7 +185,7 @@ describe ConstantContact::Services::EventSpotService do
184
185
  RestClient.stub(:get).and_return(response)
185
186
 
186
187
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
187
- registrants = ConstantContact::Services::EventSpotService.get_registrants(event)
188
+ registrants = ConstantContact::Services::EventSpotService.new(@client).get_registrants(event)
188
189
  registrants.should be_kind_of(ConstantContact::Components::ResultSet)
189
190
  registrants.results.collect{|r| r .should be_kind_of(ConstantContact::Components::Registrant) }
190
191
  end
@@ -201,7 +202,7 @@ describe ConstantContact::Services::EventSpotService do
201
202
 
202
203
  event = ConstantContact::Components::Event.create(JSON.parse(event_json))
203
204
  registrant = ConstantContact::Components::Registrant.create(JSON.parse(registrant_json))
204
- retrieved = ConstantContact::Services::EventSpotService.get_registrant(event, registrant)
205
+ retrieved = ConstantContact::Services::EventSpotService.new(@client).get_registrant(event, registrant)
205
206
  retrieved.should be_kind_of(ConstantContact::Components::Registrant)
206
207
  retrieved.id.should_not be_empty
207
208
  end
@@ -215,7 +216,7 @@ describe ConstantContact::Services::EventSpotService do
215
216
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
216
217
  RestClient.stub(:get).and_return(response)
217
218
 
218
- results = ConstantContact::Services::EventSpotService.get_event_items(1)
219
+ results = ConstantContact::Services::EventSpotService.new(@client).get_event_items(1)
219
220
  results.should be_kind_of(Array)
220
221
  results.first.should be_kind_of(ConstantContact::Components::EventItem)
221
222
  results.first.name.should eq('Running Belt')
@@ -230,7 +231,7 @@ describe ConstantContact::Services::EventSpotService do
230
231
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
231
232
  RestClient.stub(:get).and_return(response)
232
233
 
233
- result = ConstantContact::Services::EventSpotService.get_event_item(1, 1)
234
+ result = ConstantContact::Services::EventSpotService.new(@client).get_event_item(1, 1)
234
235
  result.should be_kind_of(ConstantContact::Components::EventItem)
235
236
  result.name.should eq('Running Belt')
236
237
  end
@@ -245,7 +246,7 @@ describe ConstantContact::Services::EventSpotService do
245
246
  RestClient.stub(:post).and_return(response)
246
247
  event_item = ConstantContact::Components::EventItem.create(JSON.parse(json))
247
248
 
248
- result = ConstantContact::Services::EventSpotService.add_event_item(1, event_item)
249
+ result = ConstantContact::Services::EventSpotService.new(@client).add_event_item(1, event_item)
249
250
  result.should be_kind_of(ConstantContact::Components::EventItem)
250
251
  result.name.should eq('Running Belt')
251
252
  end
@@ -258,7 +259,7 @@ describe ConstantContact::Services::EventSpotService do
258
259
  response = RestClient::Response.create('', net_http_resp, {}, @request)
259
260
  RestClient.stub(:delete).and_return(response)
260
261
 
261
- result = ConstantContact::Services::EventSpotService.delete_event_item(1, 1)
262
+ result = ConstantContact::Services::EventSpotService.new(@client).delete_event_item(1, 1)
262
263
  result.should be_true
263
264
  end
264
265
  end
@@ -272,7 +273,7 @@ describe ConstantContact::Services::EventSpotService do
272
273
  RestClient.stub(:put).and_return(response)
273
274
  event_item = ConstantContact::Components::EventItem.create(JSON.parse(json))
274
275
 
275
- result = ConstantContact::Services::EventSpotService.update_event_item(1, event_item)
276
+ result = ConstantContact::Services::EventSpotService.new(@client).update_event_item(1, event_item)
276
277
  result.should be_kind_of(ConstantContact::Components::EventItem)
277
278
  result.name.should eq('Running Belt')
278
279
  end
@@ -286,7 +287,7 @@ describe ConstantContact::Services::EventSpotService do
286
287
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
287
288
  RestClient.stub(:get).and_return(response)
288
289
 
289
- results = ConstantContact::Services::EventSpotService.get_event_item_attributes(1, 1)
290
+ results = ConstantContact::Services::EventSpotService.new(@client).get_event_item_attributes(1, 1)
290
291
  results.should be_kind_of(Array)
291
292
  results.first.should be_kind_of(ConstantContact::Components::EventItemAttribute)
292
293
  results.first.name.should eq('Royal Blue')
@@ -301,7 +302,7 @@ describe ConstantContact::Services::EventSpotService do
301
302
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
302
303
  RestClient.stub(:get).and_return(response)
303
304
 
304
- result = ConstantContact::Services::EventSpotService.get_event_item_attribute(1, 1, 1)
305
+ result = ConstantContact::Services::EventSpotService.new(@client).get_event_item_attribute(1, 1, 1)
305
306
  result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
306
307
  result.name.should eq('Hi-Vis Green')
307
308
  end
@@ -316,7 +317,7 @@ describe ConstantContact::Services::EventSpotService do
316
317
  RestClient.stub(:post).and_return(response)
317
318
  event_item_attribute = ConstantContact::Components::EventItemAttribute.create(JSON.parse(json))
318
319
 
319
- result = ConstantContact::Services::EventSpotService.add_event_item_attribute(1, 1, event_item_attribute)
320
+ result = ConstantContact::Services::EventSpotService.new(@client).add_event_item_attribute(1, 1, event_item_attribute)
320
321
  result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
321
322
  result.name.should eq('Hi-Vis Green')
322
323
  end
@@ -329,7 +330,7 @@ describe ConstantContact::Services::EventSpotService do
329
330
  response = RestClient::Response.create('', net_http_resp, {}, @request)
330
331
  RestClient.stub(:delete).and_return(response)
331
332
 
332
- result = ConstantContact::Services::EventSpotService.delete_event_item_attribute(1, 1, 1)
333
+ result = ConstantContact::Services::EventSpotService.new(@client).delete_event_item_attribute(1, 1, 1)
333
334
  result.should be_true
334
335
  end
335
336
  end
@@ -343,7 +344,7 @@ describe ConstantContact::Services::EventSpotService do
343
344
  RestClient.stub(:put).and_return(response)
344
345
  event_item_attribute = ConstantContact::Components::EventItemAttribute.create(JSON.parse(json))
345
346
 
346
- result = ConstantContact::Services::EventSpotService.update_event_item_attribute(1, 1, event_item_attribute)
347
+ result = ConstantContact::Services::EventSpotService.new(@client).update_event_item_attribute(1, 1, event_item_attribute)
347
348
  result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
348
349
  result.name.should eq('Hi-Vis Green')
349
350
  end
@@ -357,7 +358,7 @@ describe ConstantContact::Services::EventSpotService do
357
358
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
358
359
  RestClient.stub(:get).and_return(response)
359
360
 
360
- results = ConstantContact::Services::EventSpotService.get_promocodes(1)
361
+ results = ConstantContact::Services::EventSpotService.new(@client).get_promocodes(1)
361
362
  results.should be_kind_of(Array)
362
363
  results.first.should be_kind_of(ConstantContact::Components::Promocode)
363
364
  results.first.code_name.should eq('REDUCED_FEE')
@@ -372,7 +373,7 @@ describe ConstantContact::Services::EventSpotService do
372
373
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
373
374
  RestClient.stub(:get).and_return(response)
374
375
 
375
- result = ConstantContact::Services::EventSpotService.get_promocode(1, 1)
376
+ result = ConstantContact::Services::EventSpotService.new(@client).get_promocode(1, 1)
376
377
  result.should be_kind_of(ConstantContact::Components::Promocode)
377
378
  result.code_name.should eq('TOTAL_FEE')
378
379
  end
@@ -387,7 +388,7 @@ describe ConstantContact::Services::EventSpotService do
387
388
  RestClient.stub(:post).and_return(response)
388
389
  promocode = ConstantContact::Components::Promocode.create(JSON.parse(json))
389
390
 
390
- result = ConstantContact::Services::EventSpotService.add_promocode(1, promocode)
391
+ result = ConstantContact::Services::EventSpotService.new(@client).add_promocode(1, promocode)
391
392
  result.should be_kind_of(ConstantContact::Components::Promocode)
392
393
  result.code_name.should eq('TOTAL_FEE')
393
394
  end
@@ -400,7 +401,7 @@ describe ConstantContact::Services::EventSpotService do
400
401
  response = RestClient::Response.create('', net_http_resp, {}, @request)
401
402
  RestClient.stub(:delete).and_return(response)
402
403
 
403
- result = ConstantContact::Services::EventSpotService.delete_promocode(1, 1)
404
+ result = ConstantContact::Services::EventSpotService.new(@client).delete_promocode(1, 1)
404
405
  result.should be_true
405
406
  end
406
407
  end
@@ -414,7 +415,7 @@ describe ConstantContact::Services::EventSpotService do
414
415
  RestClient.stub(:put).and_return(response)
415
416
  promocode = ConstantContact::Components::Promocode.create(JSON.parse(json))
416
417
 
417
- result = ConstantContact::Services::EventSpotService.update_promocode(1, promocode)
418
+ result = ConstantContact::Services::EventSpotService.new(@client).update_promocode(1, promocode)
418
419
  result.should be_kind_of(ConstantContact::Components::Promocode)
419
420
  result.code_name.should eq('TOTAL_FEE')
420
421
  end
@@ -9,6 +9,7 @@ require 'spec_helper'
9
9
  describe ConstantContact::Services::LibraryService do
10
10
  before(:each) do
11
11
  @request = double('http request', :user => nil, :password => nil, :url => 'http://example.com', :redirection_history => nil)
12
+ @client = ConstantContact::Api.new('explicit_api_key', "access_token")
12
13
  end
13
14
 
14
15
  describe "#get_library_info" do
@@ -19,7 +20,7 @@ describe ConstantContact::Services::LibraryService do
19
20
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
20
21
  RestClient.stub(:get).and_return(response)
21
22
 
22
- info = ConstantContact::Services::LibraryService.get_library_info()
23
+ info = ConstantContact::Services::LibraryService.new(@client).get_library_info()
23
24
  info.should be_kind_of(ConstantContact::Components::LibrarySummary)
24
25
  info.usage_summary['folder_count'].should eq(6)
25
26
  end
@@ -33,7 +34,7 @@ describe ConstantContact::Services::LibraryService do
33
34
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
34
35
  RestClient.stub(:get).and_return(response)
35
36
 
36
- folders = ConstantContact::Services::LibraryService.get_library_folders({:limit => 2})
37
+ folders = ConstantContact::Services::LibraryService.new(@client).get_library_folders({:limit => 2})
37
38
  folders.should be_kind_of(ConstantContact::Components::ResultSet)
38
39
  folders.results.first.should be_kind_of(ConstantContact::Components::LibraryFolder)
39
40
  folders.results.first.name.should eq('backgrounds')
@@ -49,7 +50,7 @@ describe ConstantContact::Services::LibraryService do
49
50
  RestClient.stub(:post).and_return(response)
50
51
  new_folder = ConstantContact::Components::LibraryFolder.create(JSON.parse(json))
51
52
 
52
- folder = ConstantContact::Services::LibraryService.add_library_folder(new_folder)
53
+ folder = ConstantContact::Services::LibraryService.new(@client).add_library_folder(new_folder)
53
54
  folder.should be_kind_of(ConstantContact::Components::LibraryFolder)
54
55
  folder.name.should eq('wildflowers')
55
56
  end
@@ -63,7 +64,7 @@ describe ConstantContact::Services::LibraryService do
63
64
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
64
65
  RestClient.stub(:get).and_return(response)
65
66
 
66
- folder = ConstantContact::Services::LibraryService.get_library_folder(6)
67
+ folder = ConstantContact::Services::LibraryService.new(@client).get_library_folder(6)
67
68
  folder.should be_kind_of(ConstantContact::Components::LibraryFolder)
68
69
  folder.name.should eq('wildflowers')
69
70
  end
@@ -78,7 +79,7 @@ describe ConstantContact::Services::LibraryService do
78
79
  RestClient.stub(:put).and_return(response)
79
80
  folder = ConstantContact::Components::LibraryFolder.create(JSON.parse(json))
80
81
 
81
- response = ConstantContact::Services::LibraryService.update_library_folder(folder)
82
+ response = ConstantContact::Services::LibraryService.new(@client).update_library_folder(folder)
82
83
  response.should be_kind_of(ConstantContact::Components::LibraryFolder)
83
84
  response.name.should eq('wildflowers')
84
85
  end
@@ -92,7 +93,7 @@ describe ConstantContact::Services::LibraryService do
92
93
  response = RestClient::Response.create('', net_http_resp, {}, @request)
93
94
  RestClient.stub(:delete).and_return(response)
94
95
 
95
- result = ConstantContact::Services::LibraryService.delete_library_folder(folder_id)
96
+ result = ConstantContact::Services::LibraryService.new(@client).delete_library_folder(folder_id)
96
97
  result.should be_true
97
98
  end
98
99
  end
@@ -105,7 +106,7 @@ describe ConstantContact::Services::LibraryService do
105
106
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
106
107
  RestClient.stub(:get).and_return(response)
107
108
 
108
- files = ConstantContact::Services::LibraryService.get_library_trash({:sort_by => 'SIZE_DESC'})
109
+ files = ConstantContact::Services::LibraryService.new(@client).get_library_trash({:sort_by => 'SIZE_DESC'})
109
110
  files.should be_kind_of(ConstantContact::Components::ResultSet)
110
111
  files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
111
112
  files.results.first.name.should eq('menu_form.pdf')
@@ -119,7 +120,7 @@ describe ConstantContact::Services::LibraryService do
119
120
  response = RestClient::Response.create('', net_http_resp, {}, @request)
120
121
  RestClient.stub(:delete).and_return(response)
121
122
 
122
- result = ConstantContact::Services::LibraryService.delete_library_trash()
123
+ result = ConstantContact::Services::LibraryService.new(@client).delete_library_trash()
123
124
  result.should be_true
124
125
  end
125
126
  end
@@ -132,7 +133,7 @@ describe ConstantContact::Services::LibraryService do
132
133
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
133
134
  RestClient.stub(:get).and_return(response)
134
135
 
135
- files = ConstantContact::Services::LibraryService.get_library_files({:type => 'ALL'})
136
+ files = ConstantContact::Services::LibraryService.new(@client).get_library_files({:type => 'ALL'})
136
137
  files.should be_kind_of(ConstantContact::Components::ResultSet)
137
138
  files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
138
139
  files.results.first.name.should eq('IMG_0341.JPG')
@@ -148,7 +149,7 @@ describe ConstantContact::Services::LibraryService do
148
149
  response = RestClient::Response.create(json_response, net_http_resp, {}, @request)
149
150
  RestClient.stub(:get).and_return(response)
150
151
 
151
- files = ConstantContact::Services::LibraryService.get_library_files_by_folder(folder_id, {:limit => 10})
152
+ files = ConstantContact::Services::LibraryService.new(@client).get_library_files_by_folder(folder_id, {:limit => 10})
152
153
  files.should be_kind_of(ConstantContact::Components::ResultSet)
153
154
  files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
154
155
  files.results.first.name.should eq('IMG_0341.JPG')
@@ -163,7 +164,7 @@ describe ConstantContact::Services::LibraryService do
163
164
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
164
165
  RestClient.stub(:get).and_return(response)
165
166
 
166
- file = ConstantContact::Services::LibraryService.get_library_file(6)
167
+ file = ConstantContact::Services::LibraryService.new(@client).get_library_file(6)
167
168
  file.should be_kind_of(ConstantContact::Components::LibraryFile)
168
169
  file.name.should eq('IMG_0261.JPG')
169
170
  end
@@ -183,7 +184,7 @@ describe ConstantContact::Services::LibraryService do
183
184
  response = RestClient::Response.create("", net_http_resp, {}, @request)
184
185
  RestClient.stub(:post).and_return(response)
185
186
 
186
- response = ConstantContact::Services::LibraryService.add_library_file(file_name, folder_id, description, source, file_type, contents)
187
+ response = ConstantContact::Services::LibraryService.new(@client).add_library_file(file_name, folder_id, description, source, file_type, contents)
187
188
  response.should be_kind_of(String)
188
189
  response.should eq('123456789')
189
190
  end
@@ -198,7 +199,7 @@ describe ConstantContact::Services::LibraryService do
198
199
  RestClient.stub(:put).and_return(response)
199
200
  file = ConstantContact::Components::LibraryFile.create(JSON.parse(json))
200
201
 
201
- response = ConstantContact::Services::LibraryService.update_library_file(file)
202
+ response = ConstantContact::Services::LibraryService.new(@client).update_library_file(file)
202
203
  response.should be_kind_of(ConstantContact::Components::LibraryFile)
203
204
  response.name.should eq('IMG_0261.JPG')
204
205
  end
@@ -212,7 +213,7 @@ describe ConstantContact::Services::LibraryService do
212
213
  response = RestClient::Response.create('', net_http_resp, {}, @request)
213
214
  RestClient.stub(:delete).and_return(response)
214
215
 
215
- result = ConstantContact::Services::LibraryService.delete_library_file(file_id)
216
+ result = ConstantContact::Services::LibraryService.new(@client).delete_library_file(file_id)
216
217
  result.should be_true
217
218
  end
218
219
  end
@@ -226,7 +227,7 @@ describe ConstantContact::Services::LibraryService do
226
227
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
227
228
  RestClient.stub(:get).and_return(response)
228
229
 
229
- statuses = ConstantContact::Services::LibraryService.get_library_files_upload_status(file_id)
230
+ statuses = ConstantContact::Services::LibraryService.new(@client).get_library_files_upload_status(file_id)
230
231
  statuses.should be_kind_of(Array)
231
232
  statuses.first.should be_kind_of(ConstantContact::Components::UploadStatus)
232
233
  statuses.first.status.should eq('Active')
@@ -243,7 +244,7 @@ describe ConstantContact::Services::LibraryService do
243
244
  response = RestClient::Response.create(json, net_http_resp, {}, @request)
244
245
  RestClient.stub(:put).and_return(response)
245
246
 
246
- results = ConstantContact::Services::LibraryService.move_library_files(folder_id, file_id)
247
+ results = ConstantContact::Services::LibraryService.new(@client).move_library_files(folder_id, file_id)
247
248
  results.should be_kind_of(Array)
248
249
  results.first.should be_kind_of(ConstantContact::Components::MoveResults)
249
250
  results.first.uri.should eq('https://api.d1.constantcontact.com/v2/library/files/9')