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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +127 -136
  3. data/constantcontact.gemspec +4 -3
  4. data/lib/constantcontact.rb +63 -44
  5. data/lib/constantcontact/api.rb +932 -535
  6. data/lib/constantcontact/auth/oauth2.rb +86 -66
  7. data/lib/constantcontact/components/account/verified_email_address.rb +14 -14
  8. data/lib/constantcontact/components/activities/activity.rb +30 -30
  9. data/lib/constantcontact/components/activities/activity_error.rb +14 -14
  10. data/lib/constantcontact/components/activities/add_contacts.rb +1 -1
  11. data/lib/constantcontact/components/activities/add_contacts_import_data.rb +37 -36
  12. data/lib/constantcontact/components/component.rb +25 -0
  13. data/lib/constantcontact/components/contacts/address.rb +12 -12
  14. data/lib/constantcontact/components/contacts/contact.rb +50 -44
  15. data/lib/constantcontact/components/contacts/contact_list.rb +12 -12
  16. data/lib/constantcontact/components/contacts/custom_field.rb +14 -14
  17. data/lib/constantcontact/components/contacts/email_address.rb +14 -14
  18. data/lib/constantcontact/components/contacts/note.rb +13 -13
  19. data/lib/constantcontact/components/email_marketing/campaign.rb +41 -41
  20. data/lib/constantcontact/components/email_marketing/click_through_details.rb +14 -14
  21. data/lib/constantcontact/components/email_marketing/message_footer.rb +14 -14
  22. data/lib/constantcontact/components/email_marketing/schedule.rb +14 -15
  23. data/lib/constantcontact/components/email_marketing/test_send.rb +21 -21
  24. data/lib/constantcontact/components/event_spot/contact.rb +27 -0
  25. data/lib/constantcontact/components/event_spot/event.rb +63 -0
  26. data/lib/constantcontact/components/event_spot/event_track.rb +28 -0
  27. data/lib/constantcontact/components/event_spot/fee.rb +27 -0
  28. data/lib/constantcontact/components/event_spot/guest.rb +31 -0
  29. data/lib/constantcontact/components/event_spot/notification_option.rb +27 -0
  30. data/lib/constantcontact/components/event_spot/promo_code.rb +26 -0
  31. data/lib/constantcontact/components/event_spot/registrant.rb +54 -0
  32. data/lib/constantcontact/components/event_spot/registrant_field.rb +27 -0
  33. data/lib/constantcontact/components/event_spot/registrant_section.rb +34 -0
  34. data/lib/constantcontact/components/event_spot/sale_item.rb +27 -0
  35. data/lib/constantcontact/components/library/file/library_file.rb +27 -0
  36. data/lib/constantcontact/components/library/folder/library_folder.rb +26 -0
  37. data/lib/constantcontact/components/library/info/library_summary.rb +26 -0
  38. data/lib/constantcontact/components/library/info/move_results.rb +26 -0
  39. data/lib/constantcontact/components/library/info/upload_status.rb +26 -0
  40. data/lib/constantcontact/components/tracking/bounce_activity.rb +14 -14
  41. data/lib/constantcontact/components/tracking/click_activity.rb +14 -14
  42. data/lib/constantcontact/components/tracking/forward_activity.rb +14 -14
  43. data/lib/constantcontact/components/tracking/open_activity.rb +14 -14
  44. data/lib/constantcontact/components/tracking/send_activity.rb +14 -14
  45. data/lib/constantcontact/components/tracking/tracking_summary.rb +17 -17
  46. data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +14 -14
  47. data/lib/constantcontact/services/account_service.rb +4 -3
  48. data/lib/constantcontact/services/activity_service.rb +40 -3
  49. data/lib/constantcontact/services/base_service.rb +34 -6
  50. data/lib/constantcontact/services/campaign_tracking_service.rb +20 -20
  51. data/lib/constantcontact/services/contact_service.rb +10 -12
  52. data/lib/constantcontact/services/contact_tracking_service.rb +20 -20
  53. data/lib/constantcontact/services/email_marketing_service.rb +8 -10
  54. data/lib/constantcontact/services/event_spot_service.rb +254 -0
  55. data/lib/constantcontact/services/library_service.rb +297 -0
  56. data/lib/constantcontact/services/list_service.rb +6 -5
  57. data/lib/constantcontact/util/config.rb +135 -117
  58. data/lib/constantcontact/version.rb +1 -1
  59. data/spec/constantcontact/api_spec.rb +1223 -173
  60. data/spec/constantcontact/auth/oauth2_spec.rb +60 -47
  61. data/spec/constantcontact/components/contacts/address_spec.rb +1 -1
  62. data/spec/constantcontact/components/contacts/contact_list_spec.rb +1 -1
  63. data/spec/constantcontact/components/contacts/contact_spec.rb +1 -1
  64. data/spec/constantcontact/components/contacts/email_address_spec.rb +1 -1
  65. data/spec/constantcontact/services/activity_service_spec.rb +201 -0
  66. data/spec/constantcontact/services/base_service_spec.rb +27 -0
  67. data/spec/constantcontact/services/campaign_schedule_service_spec.rb +111 -0
  68. data/spec/constantcontact/services/campaign_tracking_service_spec.rb +127 -0
  69. data/spec/constantcontact/services/contact_service_spec.rb +24 -22
  70. data/spec/constantcontact/services/contact_tracking_service_spec.rb +127 -0
  71. data/spec/constantcontact/services/email_marketing_spec.rb +72 -66
  72. data/spec/constantcontact/services/event_spot_spec.rb +217 -0
  73. data/spec/constantcontact/services/library_service_spec.rb +248 -0
  74. data/spec/constantcontact/services/list_service_spec.rb +33 -17
  75. data/spec/spec_helper.rb +3 -1
  76. metadata +63 -7
@@ -0,0 +1,217 @@
1
+ #
2
+ # event_spot_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::EventSpotService do
10
+ describe "#get_events" do
11
+ it "returns an array of events" do
12
+ json = load_file('events.json')
13
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
14
+
15
+ response = RestClient::Response.create(json, net_http_resp, {})
16
+ RestClient.stub(:get).and_return(response)
17
+ events = ConstantContact::Services::EventSpotService.get_events('token')
18
+ events.should be_kind_of(ConstantContact::Components::ResultSet)
19
+ events.results.collect{|e| e.should be_kind_of(ConstantContact::Components::Event) }
20
+ end
21
+ end
22
+
23
+ describe "#get_event" do
24
+ it "returns an event" do
25
+ json = load_file('event.json')
26
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
27
+
28
+ response = RestClient::Response.create(json, net_http_resp, {})
29
+ RestClient.stub(:get).and_return(response)
30
+ event = ConstantContact::Services::EventSpotService.get_event('token', 1)
31
+
32
+ event.should be_kind_of(ConstantContact::Components::Event)
33
+ end
34
+ end
35
+
36
+ describe "#add_event" do
37
+ it "adds an event" do
38
+ json = load_file('event.json')
39
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
40
+
41
+ response = RestClient::Response.create(json, net_http_resp, {})
42
+ RestClient.stub(:post).and_return(response)
43
+ event = ConstantContact::Components::Event.create(JSON.parse(json))
44
+ added = ConstantContact::Services::EventSpotService.add_event('token', event)
45
+
46
+ added.should respond_to(:id)
47
+ added.id.should_not be_empty
48
+ end
49
+ end
50
+
51
+ describe "#delete_event" do
52
+ it "deletes an event" do
53
+ json = load_file('event.json')
54
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
55
+
56
+ response = RestClient::Response.create('', net_http_resp, {})
57
+ RestClient.stub(:delete).and_return(response)
58
+ event = ConstantContact::Components::Event.create(JSON.parse(json))
59
+ ConstantContact::Services::EventSpotService.delete_event('token', event).should be_true
60
+ end
61
+ end
62
+
63
+ describe "#publish_event" do
64
+ it "updates an event with status of ACTIVE" do
65
+ json = load_file('event.json')
66
+ hash = JSON.parse json
67
+ hash["status"] = "ACTIVE"
68
+
69
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
70
+ response = RestClient::Response.create(hash.to_json, net_http_resp, {})
71
+ RestClient.stub(:patch).and_return(response)
72
+
73
+ event = ConstantContact::Components::Event.create(JSON.parse(json))
74
+ updated = ConstantContact::Services::EventSpotService.publish_event('token', event)
75
+ updated.should be_kind_of(ConstantContact::Components::Event)
76
+ updated.should respond_to(:status)
77
+ updated.status.should eq("ACTIVE")
78
+ end
79
+ end
80
+
81
+ describe "#cancel_event" do
82
+ it "updates an event's status to CANCELLED" do
83
+ json = load_file('event.json')
84
+ hash = JSON.parse json
85
+ hash["status"] = "CANCELLED"
86
+
87
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
88
+ response = RestClient::Response.create(hash.to_json, net_http_resp, {})
89
+ RestClient.stub(:patch).and_return(response)
90
+
91
+ event = ConstantContact::Components::Event.create(JSON.parse(json))
92
+ updated = ConstantContact::Services::EventSpotService.cancel_event('token', event)
93
+ updated.should be_kind_of(ConstantContact::Components::Event)
94
+ updated.should respond_to(:status)
95
+ updated.status.should eq("CANCELLED")
96
+ end
97
+ end
98
+
99
+ describe "#get_fees" do
100
+ it "returns an array of fees for an event" do
101
+ event_json = load_file('event.json')
102
+ fees_json = load_file('fees.json')
103
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
104
+
105
+ response = RestClient::Response.create(fees_json, net_http_resp, {})
106
+ RestClient.stub(:get).and_return(response)
107
+ event = ConstantContact::Components::Event.create(JSON.parse(event_json))
108
+ fees = ConstantContact::Services::EventSpotService.get_fees('token', event)
109
+ #fees.should be_kind_of(ConstantContact::Components::ResultSet)
110
+ #fees.results.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
111
+
112
+ fees.should be_kind_of(Array) # inconsistent with oether APIs.
113
+ fees.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
114
+ end
115
+ end
116
+
117
+ describe "#get_fee" do
118
+ it "return an event fee" do
119
+ event_json = load_file('event.json')
120
+ fee_json = load_file('fees.json')
121
+
122
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
123
+ response = RestClient::Response.create(fee_json, net_http_resp, {})
124
+ RestClient.stub(:get).and_return(response)
125
+
126
+ event = ConstantContact::Components::Event.create(JSON.parse(event_json))
127
+ fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
128
+ retrieved = ConstantContact::Services::EventSpotService.get_fee('token', event, fee)
129
+ retrieved.should be_kind_of(ConstantContact::Components::Fee)
130
+ end
131
+ end
132
+
133
+ describe "#add_fee" do
134
+ it "adds an event fee" do
135
+ event_json = load_file('event.json')
136
+ fee_json = load_file('fee.json')
137
+
138
+ net_http_resp = Net::HTTPResponse.new(1.0, 201, 'Created')
139
+ response = RestClient::Response.create(fee_json, net_http_resp, {})
140
+ RestClient.stub(:post).and_return(response)
141
+
142
+ event = ConstantContact::Components::Event.create(JSON.parse(event_json))
143
+ fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
144
+ added = ConstantContact::Services::EventSpotService.add_fee('token', event, fee)
145
+ added.should be_kind_of(ConstantContact::Components::Fee)
146
+ added.id.should_not be_empty
147
+ end
148
+ end
149
+
150
+ describe "#update_fee" do
151
+ it "updates an event fee" do
152
+ event_json = load_file('event.json')
153
+ fee_json = load_file('fee.json')
154
+ hash = JSON.parse fee_json
155
+ hash['fee'] += 1
156
+
157
+ net_http_resp = Net::HTTPResponse.new(1.0, 201, 'Created')
158
+ response = RestClient::Response.create(hash.to_json, net_http_resp, {})
159
+ RestClient.stub(:put).and_return(response)
160
+
161
+ event = ConstantContact::Components::Event.create(JSON.parse(event_json))
162
+ fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
163
+ updated = ConstantContact::Services::EventSpotService.update_fee('token', event, fee)
164
+ updated.should be_kind_of(ConstantContact::Components::Fee)
165
+ updated.fee.should_not eq(fee.fee)
166
+ updated.fee.should eq(fee.fee + 1)
167
+ end
168
+ end
169
+
170
+ describe "#delete_fee" do
171
+ it "deletes an event fee" do
172
+ event_json = load_file('event.json')
173
+ fee_json = load_file('fees.json')
174
+
175
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
176
+ response = RestClient::Response.create('', net_http_resp, {})
177
+ RestClient.stub(:delete).and_return(response)
178
+
179
+ event = ConstantContact::Components::Event.create(JSON.parse(event_json))
180
+ fee = ConstantContact::Components::Fee.create(JSON.parse(fee_json))
181
+ ConstantContact::Services::EventSpotService.delete_fee('token', event, fee).should be_true
182
+ end
183
+ end
184
+
185
+ describe "#get_registrants" do
186
+ it "returns an array of event registrants" do
187
+ event_json = load_file('event.json')
188
+ registrants_json = load_file('registrants.json')
189
+
190
+ net_http_resp = Net::HTTPResponse.new(1.0, 201, 'Created')
191
+ response = RestClient::Response.create(registrants_json, net_http_resp, {})
192
+ RestClient.stub(:get).and_return(response)
193
+
194
+ event = ConstantContact::Components::Event.create(JSON.parse(event_json))
195
+ registrants = ConstantContact::Services::EventSpotService.get_registrants('token', event)
196
+ registrants.should be_kind_of(ConstantContact::Components::ResultSet)
197
+ registrants.results.collect{|r| r .should be_kind_of(ConstantContact::Components::Registrant) }
198
+ end
199
+ end
200
+
201
+ describe "#get_registrant" do
202
+ it "returns an event registrant" do
203
+ event_json = load_file('event.json')
204
+ registrant_json = load_file('registrant.json')
205
+
206
+ net_http_resp = Net::HTTPResponse.new(1.0, 201, 'Created')
207
+ response = RestClient::Response.create(registrant_json, net_http_resp, {})
208
+ RestClient.stub(:get).and_return(response)
209
+
210
+ event = ConstantContact::Components::Event.create(JSON.parse(event_json))
211
+ registrant = ConstantContact::Components::Registrant.create(JSON.parse(registrant_json))
212
+ retrieved = ConstantContact::Services::EventSpotService.get_registrant('token', event, registrant)
213
+ retrieved.should be_kind_of(ConstantContact::Components::Registrant)
214
+ retrieved.id.should_not be_empty
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,248 @@
1
+ #
2
+ # library_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::LibraryService do
10
+ describe "#get_library_info" do
11
+ it "retrieves a MyLibrary usage information" do
12
+ json_response = load_file('library_info_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
+ info = ConstantContact::Services::LibraryService.get_library_info('token')
19
+ info.should be_kind_of(ConstantContact::Components::LibrarySummary)
20
+ info.usage_summary['folder_count'].should eq(6)
21
+ end
22
+ end
23
+
24
+ describe "#get_library_folders" do
25
+ it "retrieves a list of MyLibrary folders" do
26
+ json_response = load_file('library_folders_response.json')
27
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
28
+
29
+ response = RestClient::Response.create(json_response, net_http_resp, {})
30
+ RestClient.stub(:get).and_return(response)
31
+
32
+ folders = ConstantContact::Services::LibraryService.get_library_folders('token', {:limit => 2})
33
+ folders.should be_kind_of(ConstantContact::Components::ResultSet)
34
+ folders.results.first.should be_kind_of(ConstantContact::Components::LibraryFolder)
35
+ folders.results.first.name.should eq('backgrounds')
36
+ end
37
+ end
38
+
39
+ describe "#add_library_folder" do
40
+ it "creates a new MyLibrary folder" do
41
+ json = load_file('library_folder_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_folder = ConstantContact::Components::LibraryFolder.create(JSON.parse(json))
47
+
48
+ folder = ConstantContact::Services::LibraryService.add_library_folder('token', new_folder)
49
+ folder.should be_kind_of(ConstantContact::Components::LibraryFolder)
50
+ folder.name.should eq('wildflowers')
51
+ end
52
+ end
53
+
54
+ describe "#get_library_folder" do
55
+ it "retrieves a specific MyLibrary folder using the folder_id path parameter" do
56
+ json = load_file('library_folder_response.json')
57
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
58
+
59
+ response = RestClient::Response.create(json, net_http_resp, {})
60
+ RestClient.stub(:get).and_return(response)
61
+
62
+ folder = ConstantContact::Services::LibraryService.get_library_folder('token', 6)
63
+ folder.should be_kind_of(ConstantContact::Components::LibraryFolder)
64
+ folder.name.should eq('wildflowers')
65
+ end
66
+ end
67
+
68
+ describe "#update_library_folder" do
69
+ it "retrieves a specific MyLibrary folder using the folder_id path parameter" do
70
+ json = load_file('library_folder_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
+ folder = ConstantContact::Components::LibraryFolder.create(JSON.parse(json))
76
+
77
+ response = ConstantContact::Services::LibraryService.update_library_folder('token', folder)
78
+ response.should be_kind_of(ConstantContact::Components::LibraryFolder)
79
+ response.name.should eq('wildflowers')
80
+ end
81
+ end
82
+
83
+ describe "#delete_library_folder" do
84
+ it "deletes a MyLibrary folder" do
85
+ folder_id = 6
86
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
87
+
88
+ response = RestClient::Response.create('', net_http_resp, {})
89
+ RestClient.stub(:delete).and_return(response)
90
+
91
+ result = ConstantContact::Services::LibraryService.delete_library_folder('token', folder_id)
92
+ result.should be_true
93
+ end
94
+ end
95
+
96
+ describe "#get_library_trash" do
97
+ it "retrieve all files in the Trash folder" do
98
+ json = load_file('library_trash_response.json')
99
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
100
+
101
+ response = RestClient::Response.create(json, net_http_resp, {})
102
+ RestClient.stub(:get).and_return(response)
103
+
104
+ files = ConstantContact::Services::LibraryService.get_library_trash('token', {:sort_by => 'SIZE_DESC'})
105
+ files.should be_kind_of(ConstantContact::Components::ResultSet)
106
+ files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
107
+ files.results.first.name.should eq('menu_form.pdf')
108
+ end
109
+ end
110
+
111
+ describe "#delete_library_trash" do
112
+ it "permanently deletes all files in the Trash folder" do
113
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
114
+
115
+ response = RestClient::Response.create('', net_http_resp, {})
116
+ RestClient.stub(:delete).and_return(response)
117
+
118
+ result = ConstantContact::Services::LibraryService.delete_library_trash('token')
119
+ result.should be_true
120
+ end
121
+ end
122
+
123
+ describe "#get_library_files" do
124
+ it "retrieves a collection of MyLibrary files in the Constant Contact account" do
125
+ json_response = load_file('library_files_response.json')
126
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
127
+
128
+ response = RestClient::Response.create(json_response, net_http_resp, {})
129
+ RestClient.stub(:get).and_return(response)
130
+
131
+ files = ConstantContact::Services::LibraryService.get_library_files('token', {:type => 'ALL'})
132
+ files.should be_kind_of(ConstantContact::Components::ResultSet)
133
+ files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
134
+ files.results.first.name.should eq('IMG_0341.JPG')
135
+ end
136
+ end
137
+
138
+ describe "#get_library_files_by_folder" do
139
+ it "retrieves a collection of MyLibrary files in the Constant Contact account" do
140
+ folder_id = -1
141
+ json_response = load_file('library_files_by_folder_response.json')
142
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
143
+
144
+ response = RestClient::Response.create(json_response, net_http_resp, {})
145
+ RestClient.stub(:get).and_return(response)
146
+
147
+ files = ConstantContact::Services::LibraryService.get_library_files_by_folder('token', folder_id, {:limit => 10})
148
+ files.should be_kind_of(ConstantContact::Components::ResultSet)
149
+ files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
150
+ files.results.first.name.should eq('IMG_0341.JPG')
151
+ end
152
+ end
153
+
154
+ describe "#get_library_file" do
155
+ it "retrieve a MyLibrary file using the file_id path parameter" do
156
+ json = load_file('library_file_response.json')
157
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
158
+
159
+ response = RestClient::Response.create(json, net_http_resp, {})
160
+ RestClient.stub(:get).and_return(response)
161
+
162
+ file = ConstantContact::Services::LibraryService.get_library_file('token', 6)
163
+ file.should be_kind_of(ConstantContact::Components::LibraryFile)
164
+ file.name.should eq('IMG_0261.JPG')
165
+ end
166
+ end
167
+
168
+ describe "#add_library_file" do
169
+ it "adds a new MyLibrary file using the multipart content-type" do
170
+ file_name = 'logo.jpg'
171
+ folder_id = 1
172
+ description = 'Logo'
173
+ source = 'MyComputer'
174
+ file_type = 'JPG'
175
+ contents = load_file('logo.jpg')
176
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
177
+ net_http_resp.add_field('Location', 'https://api.d1.constantcontact.com/v2/library/files/123456789')
178
+
179
+ response = RestClient::Response.create("", net_http_resp, {})
180
+ RestClient.stub(:post).and_return(response)
181
+
182
+ response = ConstantContact::Services::LibraryService.add_library_file('token', file_name, folder_id, description, source, file_type, contents)
183
+ response.should be_kind_of(String)
184
+ response.should eq('123456789')
185
+ end
186
+ end
187
+
188
+ describe "#update_library_file" do
189
+ it "updates information for a specific MyLibrary file" do
190
+ json = load_file('library_file_response.json')
191
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
192
+
193
+ response = RestClient::Response.create(json, net_http_resp, {})
194
+ RestClient.stub(:put).and_return(response)
195
+ file = ConstantContact::Components::LibraryFile.create(JSON.parse(json))
196
+
197
+ response = ConstantContact::Services::LibraryService.update_library_file('token', file)
198
+ response.should be_kind_of(ConstantContact::Components::LibraryFile)
199
+ response.name.should eq('IMG_0261.JPG')
200
+ end
201
+ end
202
+
203
+ describe "#delete_library_file" do
204
+ it "deletes one or more MyLibrary files specified by the fileId path parameter" do
205
+ file_id = '6, 7'
206
+ net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
207
+
208
+ response = RestClient::Response.create('', net_http_resp, {})
209
+ RestClient.stub(:delete).and_return(response)
210
+
211
+ result = ConstantContact::Services::LibraryService.delete_library_file('token', file_id)
212
+ result.should be_true
213
+ end
214
+ end
215
+
216
+ describe "#get_library_files_upload_status" do
217
+ it "retrieves the upload status for one or more MyLibrary files using the file_id path parameter" do
218
+ file_id = '6, 7'
219
+ json = load_file('library_files_upload_status_response.json')
220
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
221
+
222
+ response = RestClient::Response.create(json, net_http_resp, {})
223
+ RestClient.stub(:get).and_return(response)
224
+
225
+ statuses = ConstantContact::Services::LibraryService.get_library_files_upload_status('token', file_id)
226
+ statuses.should be_kind_of(Array)
227
+ statuses.first.should be_kind_of(ConstantContact::Components::UploadStatus)
228
+ statuses.first.status.should eq('Active')
229
+ end
230
+ end
231
+
232
+ describe "#move_library_files" do
233
+ it "moves one or more MyLibrary files to a different folder in the user's account" do
234
+ folder_id = 1
235
+ file_id = '8, 9'
236
+ json = load_file('library_files_move_results_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
+
242
+ results = ConstantContact::Services::LibraryService.move_library_files('token', folder_id, file_id)
243
+ results.should be_kind_of(Array)
244
+ results.first.should be_kind_of(ConstantContact::Components::MoveResults)
245
+ results.first.uri.should eq('https://api.d1.constantcontact.com/v2/library/files/9')
246
+ end
247
+ end
248
+ end