constantcontact 1.3.2 → 2.0.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 +5 -5
- data/constantcontact.gemspec +2 -2
- data/lib/constantcontact/api.rb +223 -307
- data/lib/constantcontact/services/account_service.rb +5 -7
- data/lib/constantcontact/services/activity_service.rb +16 -24
- data/lib/constantcontact/services/base_service.rb +3 -4
- data/lib/constantcontact/services/campaign_schedule_service.rb +12 -18
- data/lib/constantcontact/services/campaign_tracking_service.rb +14 -21
- data/lib/constantcontact/services/contact_service.rb +14 -21
- data/lib/constantcontact/services/contact_tracking_service.rb +14 -21
- data/lib/constantcontact/services/email_marketing_service.rb +10 -15
- data/lib/constantcontact/services/event_spot_service.rb +56 -85
- data/lib/constantcontact/services/library_service.rb +32 -48
- data/lib/constantcontact/services/list_service.rb +10 -15
- data/lib/constantcontact/util/config.rb +5 -3
- data/lib/constantcontact/version.rb +3 -3
- data/spec/constantcontact/api_spec.rb +121 -103
- data/spec/constantcontact/services/account_service_spec.rb +15 -1
- data/spec/constantcontact/services/activity_service_spec.rb +9 -14
- data/spec/constantcontact/services/base_service_spec.rb +2 -1
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +6 -6
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +7 -7
- data/spec/constantcontact/services/contact_service_spec.rb +7 -7
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +7 -7
- data/spec/constantcontact/services/email_marketing_spec.rb +5 -5
- data/spec/constantcontact/services/event_spot_spec.rb +27 -27
- data/spec/constantcontact/services/library_service_spec.rb +16 -16
- data/spec/constantcontact/services/list_service_spec.rb +5 -5
- metadata +2 -2
@@ -10,18 +10,16 @@ module ConstantContact
|
|
10
10
|
class << self
|
11
11
|
|
12
12
|
# Retrieve MyLibrary usage information
|
13
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
13
|
# @return [LibrarySummary]
|
15
|
-
def get_library_info(
|
14
|
+
def get_library_info()
|
16
15
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_info')
|
17
16
|
|
18
|
-
response = RestClient.get(url, get_headers(
|
17
|
+
response = RestClient.get(url, get_headers())
|
19
18
|
Components::LibrarySummary.create(JSON.parse(response.body).first)
|
20
19
|
end
|
21
20
|
|
22
21
|
|
23
22
|
# Retrieve a list of MyLibrary folders
|
24
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
25
23
|
# @param [Hash] params - hash of query parameters and values to append to the request.
|
26
24
|
# Allowed parameters include:
|
27
25
|
# sort_by - The method to sort by, valid values are :
|
@@ -33,10 +31,10 @@ module ConstantContact
|
|
33
31
|
# NAME_DESC - sorts alphabetically by folder name, z to a
|
34
32
|
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
35
33
|
# @return [ResultSet<LibraryFolder>]
|
36
|
-
def get_library_folders(
|
34
|
+
def get_library_folders(params)
|
37
35
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folders')
|
38
36
|
url = build_url(url, params)
|
39
|
-
response = RestClient.get(url, get_headers(
|
37
|
+
response = RestClient.get(url, get_headers())
|
40
38
|
folders = []
|
41
39
|
body = JSON.parse(response.body)
|
42
40
|
body['results'].each do |folder|
|
@@ -47,58 +45,53 @@ module ConstantContact
|
|
47
45
|
|
48
46
|
|
49
47
|
# Create a new MyLibrary folder
|
50
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
51
48
|
# @param [LibraryFolder] folder - MyLibrary folder to be created
|
52
49
|
# @return [LibraryFolder]
|
53
|
-
def add_library_folder(
|
50
|
+
def add_library_folder(folder)
|
54
51
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folders')
|
55
52
|
url = build_url(url)
|
56
53
|
payload = folder.to_json
|
57
|
-
response = RestClient.post(url, payload, get_headers(
|
54
|
+
response = RestClient.post(url, payload, get_headers())
|
58
55
|
Components::LibraryFolder.create(JSON.parse(response.body))
|
59
56
|
end
|
60
57
|
|
61
58
|
|
62
59
|
# Retrieve a specific MyLibrary folder using the folder_id path parameter
|
63
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
64
60
|
# @param [String] folder_id - The ID for the folder to return
|
65
61
|
# @return [LibraryFolder]
|
66
|
-
def get_library_folder(
|
62
|
+
def get_library_folder(folder_id)
|
67
63
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_folder'), folder_id)
|
68
64
|
url = build_url(url)
|
69
|
-
response = RestClient.get(url, get_headers(
|
65
|
+
response = RestClient.get(url, get_headers())
|
70
66
|
Components::LibraryFolder.create(JSON.parse(response.body))
|
71
67
|
end
|
72
68
|
|
73
69
|
|
74
70
|
# Update a specific MyLibrary folder
|
75
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
76
71
|
# @param [LibraryFolder] folder - MyLibrary folder to be updated
|
77
72
|
# @return [LibraryFolder]
|
78
|
-
def update_library_folder(
|
73
|
+
def update_library_folder(folder)
|
79
74
|
url = Util::Config.get('endpoints.base_url') +
|
80
75
|
sprintf(Util::Config.get('endpoints.library_folder'), folder.id)
|
81
76
|
url = build_url(url)
|
82
77
|
payload = folder.to_json
|
83
|
-
response = RestClient.put(url, payload, get_headers(
|
78
|
+
response = RestClient.put(url, payload, get_headers())
|
84
79
|
Components::LibraryFolder.create(JSON.parse(response.body))
|
85
80
|
end
|
86
81
|
|
87
82
|
|
88
83
|
# Delete a MyLibrary folder
|
89
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
90
84
|
# @param [String] folder_id - The ID for the MyLibrary folder to delete
|
91
85
|
# @return [Boolean]
|
92
|
-
def delete_library_folder(
|
86
|
+
def delete_library_folder(folder_id)
|
93
87
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_folder'), folder_id)
|
94
88
|
url = build_url(url)
|
95
|
-
response = RestClient.delete(url, get_headers(
|
89
|
+
response = RestClient.delete(url, get_headers())
|
96
90
|
response.code == 204
|
97
91
|
end
|
98
92
|
|
99
93
|
|
100
94
|
# Retrieve all files in the Trash folder
|
101
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
102
95
|
# @param [Hash] params - hash of query parameters and values to append to the request.
|
103
96
|
# Allowed parameters include:
|
104
97
|
# type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
|
@@ -115,10 +108,10 @@ module ConstantContact
|
|
115
108
|
# DIMENSION_DESC - sorts by file dimensions (hxw), largest to smallest
|
116
109
|
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
117
110
|
# @return [ResultSet<LibraryFile>]
|
118
|
-
def get_library_trash(
|
111
|
+
def get_library_trash(params)
|
119
112
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folder_trash')
|
120
113
|
url = build_url(url, params)
|
121
|
-
response = RestClient.get(url, get_headers(
|
114
|
+
response = RestClient.get(url, get_headers())
|
122
115
|
files = []
|
123
116
|
body = JSON.parse(response.body)
|
124
117
|
body['results'].each do |file|
|
@@ -129,18 +122,16 @@ module ConstantContact
|
|
129
122
|
|
130
123
|
|
131
124
|
# Permanently deletes all files in the Trash folder
|
132
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
133
125
|
# @return [Boolean]
|
134
|
-
def delete_library_trash(
|
126
|
+
def delete_library_trash()
|
135
127
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folder_trash')
|
136
128
|
url = build_url(url)
|
137
|
-
response = RestClient.delete(url, get_headers(
|
129
|
+
response = RestClient.delete(url, get_headers())
|
138
130
|
response.code == 204
|
139
131
|
end
|
140
132
|
|
141
133
|
|
142
134
|
# Retrieve a collection of MyLibrary files in the Constant Contact account
|
143
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
144
135
|
# @param [Hash] params - hash of query parameters and values to append to the request.
|
145
136
|
# Allowed parameters include:
|
146
137
|
# type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
|
@@ -154,10 +145,10 @@ module ConstantContact
|
|
154
145
|
# Mobile
|
155
146
|
# limit - Specifies the number of results displayed per page of output, from 1 - 1000, default = 50.
|
156
147
|
# @return [ResultSet<LibraryFile>]
|
157
|
-
def get_library_files(
|
148
|
+
def get_library_files(params = {})
|
158
149
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_files')
|
159
150
|
url = build_url(url, params)
|
160
|
-
response = RestClient.get(url, get_headers(
|
151
|
+
response = RestClient.get(url, get_headers())
|
161
152
|
files = []
|
162
153
|
body = JSON.parse(response.body)
|
163
154
|
body['results'].each do |file|
|
@@ -168,17 +159,16 @@ module ConstantContact
|
|
168
159
|
|
169
160
|
|
170
161
|
# Retrieves all files from a MyLibrary folder specified by the folder_id path parameter
|
171
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
172
162
|
# @param [String] folder_id - Specifies the folder from which to retrieve files
|
173
163
|
# @param [Hash] params - hash of query parameters and values to append to the request.
|
174
164
|
# Allowed parameters include:
|
175
165
|
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
176
166
|
# @return [ResultSet<LibraryFile>]
|
177
|
-
def get_library_files_by_folder(
|
167
|
+
def get_library_files_by_folder(folder_id, params = {})
|
178
168
|
url = Util::Config.get('endpoints.base_url') +
|
179
169
|
sprintf(Util::Config.get('endpoints.library_files_by_folder'), folder_id)
|
180
170
|
url = build_url(url, params)
|
181
|
-
response = RestClient.get(url, get_headers(
|
171
|
+
response = RestClient.get(url, get_headers())
|
182
172
|
files = []
|
183
173
|
body = JSON.parse(response.body)
|
184
174
|
body['results'].each do |file|
|
@@ -189,19 +179,17 @@ module ConstantContact
|
|
189
179
|
|
190
180
|
|
191
181
|
# Retrieve a MyLibrary file using the file_id path parameter
|
192
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
193
182
|
# @param [String] file_id - Specifies the MyLibrary file for which to retrieve information
|
194
183
|
# @return [LibraryFile]
|
195
|
-
def get_library_file(
|
184
|
+
def get_library_file(file_id)
|
196
185
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file_id)
|
197
186
|
url = build_url(url)
|
198
|
-
response = RestClient.get(url, get_headers(
|
187
|
+
response = RestClient.get(url, get_headers())
|
199
188
|
Components::LibraryFile.create(JSON.parse(response.body))
|
200
189
|
end
|
201
190
|
|
202
191
|
|
203
192
|
# Adds a new MyLibrary file using the multipart content-type
|
204
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
205
193
|
# @param [String] file_name - The name of the file (ie: dinnerplate-special.jpg)
|
206
194
|
# @param [String] folder_id - Folder id to add the file to
|
207
195
|
# @param [String] description - The description of the file provided by user
|
@@ -212,7 +200,7 @@ module ConstantContact
|
|
212
200
|
# @param [String] file_type - Specifies the file type, valid values are: JPEG, JPG, GIF, PDF, PNG
|
213
201
|
# @param [String] contents - The content of the file
|
214
202
|
# @return [LibraryFile]
|
215
|
-
def add_library_file(
|
203
|
+
def add_library_file(file_name, folder_id, description, source, file_type, contents)
|
216
204
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_files')
|
217
205
|
url = build_url(url)
|
218
206
|
|
@@ -220,21 +208,20 @@ module ConstantContact
|
|
220
208
|
:description => description, :source => source, :file_type => file_type,
|
221
209
|
:data => contents, :multipart => true }
|
222
210
|
|
223
|
-
response = RestClient.post(url, payload, get_headers(
|
211
|
+
response = RestClient.post(url, payload, get_headers())
|
224
212
|
location = response.headers[:location] || ''
|
225
213
|
location.split('/').last
|
226
214
|
end
|
227
215
|
|
228
216
|
|
229
217
|
# Update information for a specific MyLibrary file
|
230
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
231
218
|
# @param [LibraryFile] file - Library File to be updated
|
232
219
|
# @return [LibraryFile]
|
233
|
-
def update_library_file(
|
220
|
+
def update_library_file(file)
|
234
221
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file.id)
|
235
222
|
url = build_url(url)
|
236
223
|
payload = file.to_json
|
237
|
-
response = RestClient.put(url, payload, get_headers(
|
224
|
+
response = RestClient.put(url, payload, get_headers())
|
238
225
|
Components::LibraryFile.create(JSON.parse(response.body))
|
239
226
|
end
|
240
227
|
|
@@ -242,27 +229,25 @@ module ConstantContact
|
|
242
229
|
# Delete one or more MyLibrary files specified by the fileId path parameter;
|
243
230
|
# separate multiple file IDs with a comma.
|
244
231
|
# Deleted files are moved from their current folder into the system Trash folder, and its status is set to Deleted.
|
245
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
246
232
|
# @param [String] file_id - Specifies the MyLibrary file to delete
|
247
233
|
# @return [Boolean]
|
248
|
-
def delete_library_file(
|
234
|
+
def delete_library_file(file_id)
|
249
235
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file_id)
|
250
236
|
url = build_url(url)
|
251
|
-
response = RestClient.delete(url, get_headers(
|
237
|
+
response = RestClient.delete(url, get_headers())
|
252
238
|
response.code == 204
|
253
239
|
end
|
254
240
|
|
255
241
|
|
256
242
|
# Retrieve the upload status for one or more MyLibrary files using the file_id path parameter;
|
257
243
|
# separate multiple file IDs with a comma
|
258
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
259
244
|
# @param [String] file_id - Specifies the files for which to retrieve upload status information
|
260
245
|
# @return [Array<UploadStatus>]
|
261
|
-
def get_library_files_upload_status(
|
246
|
+
def get_library_files_upload_status(file_id)
|
262
247
|
url = Util::Config.get('endpoints.base_url') +
|
263
248
|
sprintf(Util::Config.get('endpoints.library_file_upload_status'), file_id)
|
264
249
|
url = build_url(url)
|
265
|
-
response = RestClient.get(url, get_headers(
|
250
|
+
response = RestClient.get(url, get_headers())
|
266
251
|
statuses = []
|
267
252
|
JSON.parse(response.body).each do |status|
|
268
253
|
statuses << Components::UploadStatus.create(status)
|
@@ -273,17 +258,16 @@ module ConstantContact
|
|
273
258
|
|
274
259
|
# Move one or more MyLibrary files to a different folder in the user's account
|
275
260
|
# specify the destination folder using the folder_id path parameter.
|
276
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
277
261
|
# @param [String] folder_id - Specifies the destination MyLibrary folder to which the files will be moved
|
278
262
|
# @param [String] file_id - Specifies the files to move, in a string of comma separated file ids (e.g. 8,9)
|
279
263
|
# @return [Array<MoveResults>]
|
280
|
-
def move_library_files(
|
264
|
+
def move_library_files(folder_id, file_id)
|
281
265
|
url = Util::Config.get('endpoints.base_url') +
|
282
266
|
sprintf(Util::Config.get('endpoints.library_file_move'), folder_id)
|
283
267
|
url = build_url(url)
|
284
268
|
|
285
269
|
payload = file_id.split(',').map {|id| id.strip}.to_json
|
286
|
-
response = RestClient.put(url, payload, get_headers(
|
270
|
+
response = RestClient.put(url, payload, get_headers())
|
287
271
|
results = []
|
288
272
|
JSON.parse(response.body).each do |result|
|
289
273
|
results << Components::MoveResults.create(result)
|
@@ -10,13 +10,12 @@ module ConstantContact
|
|
10
10
|
class << self
|
11
11
|
|
12
12
|
# Get lists within an account
|
13
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
14
13
|
# @param [Hash] params - query parameters to be appended to the request
|
15
14
|
# @return [Array<ContactList>]
|
16
|
-
def get_lists(
|
15
|
+
def get_lists(params = {})
|
17
16
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.lists')
|
18
17
|
url = build_url(url, params)
|
19
|
-
response = RestClient.get(url, get_headers(
|
18
|
+
response = RestClient.get(url, get_headers())
|
20
19
|
lists = []
|
21
20
|
JSON.parse(response.body).each do |contact|
|
22
21
|
lists << Components::ContactList.create(contact)
|
@@ -26,52 +25,48 @@ module ConstantContact
|
|
26
25
|
|
27
26
|
|
28
27
|
# Add a new list to the Constant Contact account
|
29
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
30
28
|
# @param [ContactList] list
|
31
29
|
# @return [ContactList]
|
32
|
-
def add_list(
|
30
|
+
def add_list(list)
|
33
31
|
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.lists')
|
34
32
|
url = build_url(url)
|
35
33
|
payload = list.to_json
|
36
|
-
response = RestClient.post(url, payload, get_headers(
|
34
|
+
response = RestClient.post(url, payload, get_headers())
|
37
35
|
Components::ContactList.create(JSON.parse(response.body))
|
38
36
|
end
|
39
37
|
|
40
38
|
|
41
39
|
# Update a Contact List
|
42
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
43
40
|
# @param [ContactList] list - ContactList to be updated
|
44
41
|
# @return [ContactList]
|
45
|
-
def update_list(
|
42
|
+
def update_list(list)
|
46
43
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.list'), list.id)
|
47
44
|
url = build_url(url)
|
48
45
|
payload = list.to_json
|
49
|
-
response = RestClient.put(url, payload, get_headers(
|
46
|
+
response = RestClient.put(url, payload, get_headers())
|
50
47
|
Components::ContactList.create(JSON.parse(response.body))
|
51
48
|
end
|
52
49
|
|
53
50
|
|
54
51
|
# Get an individual contact list
|
55
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
56
52
|
# @param [Integer] list_id - list id
|
57
53
|
# @return [ContactList]
|
58
|
-
def get_list(
|
54
|
+
def get_list(list_id)
|
59
55
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.list'), list_id)
|
60
56
|
url = build_url(url)
|
61
|
-
response = RestClient.get(url, get_headers(
|
57
|
+
response = RestClient.get(url, get_headers())
|
62
58
|
Components::ContactList.create(JSON.parse(response.body))
|
63
59
|
end
|
64
60
|
|
65
61
|
|
66
62
|
# Get all contacts from an individual list
|
67
|
-
# @param [String] access_token - Constant Contact OAuth2 access token
|
68
63
|
# @param [Integer] list_id - list id to retrieve contacts for
|
69
64
|
# @param [Hash] params - query parameters to attach to request
|
70
65
|
# @return [Array<Contact>]
|
71
|
-
def get_contacts_from_list(
|
66
|
+
def get_contacts_from_list(list_id, params = nil)
|
72
67
|
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.list_contacts'), list_id)
|
73
68
|
url = build_url(url, params)
|
74
|
-
response = RestClient.get(url, get_headers(
|
69
|
+
response = RestClient.get(url, get_headers())
|
75
70
|
contacts = []
|
76
71
|
body = JSON.parse(response.body)
|
77
72
|
body['results'].each do |contact|
|
@@ -132,9 +132,11 @@ module ConstantContact
|
|
132
132
|
|
133
133
|
# Errors to be returned for various exceptions
|
134
134
|
:errors => {
|
135
|
-
:
|
136
|
-
:
|
137
|
-
:
|
135
|
+
:api_key_missing => 'api_key required either explicitly or in configuration.',
|
136
|
+
:access_token_missing => 'access_token required explicitly.',
|
137
|
+
:id_or_object => 'Only an id or %s object are allowed for this method.',
|
138
|
+
:invalid_webhook => 'Invalid Webhook. The x-ctct-hmac-sha256 does not correspond to message encryption.',
|
139
|
+
:api_secret_missing => 'The api_secret is missing in explicit call or configuration.'
|
138
140
|
}
|
139
141
|
}
|
140
142
|
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# version.rb
|
3
3
|
# ConstantContact
|
4
4
|
#
|
5
|
-
# Copyright (c)
|
5
|
+
# Copyright (c) 2015 Constant Contact. All rights reserved.
|
6
6
|
|
7
7
|
module ConstantContact
|
8
8
|
module SDK
|
9
9
|
# Gem version
|
10
|
-
VERSION = "
|
10
|
+
VERSION = "2.0.0"
|
11
11
|
end
|
12
|
-
end
|
12
|
+
end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
require 'spec_helper'
|
8
8
|
|
9
9
|
describe ConstantContact::Api do
|
10
|
-
|
10
|
+
|
11
11
|
before(:all) {
|
12
12
|
ConstantContact::Util::Config.configure do |config|
|
13
13
|
config[:auth].delete :api_key
|
@@ -15,13 +15,19 @@ describe ConstantContact::Api do
|
|
15
15
|
config[:auth].delete :redirect_uri
|
16
16
|
end
|
17
17
|
}
|
18
|
-
|
18
|
+
|
19
19
|
it "without api_key defined" do
|
20
20
|
lambda {
|
21
21
|
ConstantContact::Api.new
|
22
|
-
}.should raise_error(ArgumentError)
|
22
|
+
}.should raise_error(ArgumentError, ConstantContact::Util::Config.get('errors.api_key_missing'))
|
23
|
+
end
|
24
|
+
|
25
|
+
it "without access_token defined" do
|
26
|
+
lambda {
|
27
|
+
ConstantContact::Api.new('api_key')
|
28
|
+
}.should raise_error(ArgumentError, ConstantContact::Util::Config.get('errors.access_token_missing'))
|
23
29
|
end
|
24
|
-
|
30
|
+
|
25
31
|
context "with middle-ware configuration" do
|
26
32
|
before(:all) do
|
27
33
|
ConstantContact::Services::BaseService.api_key = nil
|
@@ -33,13 +39,13 @@ describe ConstantContact::Api do
|
|
33
39
|
end
|
34
40
|
let(:proc) { lambda { ConstantContact::Api.new } }
|
35
41
|
it "use implicit config" do
|
36
|
-
proc.
|
42
|
+
proc.should raise_error(ArgumentError, ConstantContact::Util::Config.get('errors.access_token_missing'))
|
37
43
|
end
|
38
|
-
it "has the correct
|
44
|
+
it "has the correct implicit api key" do
|
39
45
|
ConstantContact::Services::BaseService.api_key.should == "config_api_key"
|
40
46
|
end
|
41
47
|
end
|
42
|
-
|
48
|
+
|
43
49
|
context "with middle-ware configuration" do
|
44
50
|
before(:all) do
|
45
51
|
ConstantContact::Services::BaseService.api_key = nil
|
@@ -48,16 +54,30 @@ describe ConstantContact::Api do
|
|
48
54
|
config[:auth][:api_secret] = "config_api_secret"
|
49
55
|
config[:auth][:redirect_uri] = "config_redirect_uri"
|
50
56
|
end
|
51
|
-
ConstantContact::Api.new
|
57
|
+
ConstantContact::Api.new('explicit_api_key', 'access_token')
|
52
58
|
end
|
53
59
|
it "has the correct explicit api key" do
|
54
60
|
ConstantContact::Services::BaseService.api_key.should == "explicit_api_key"
|
55
61
|
end
|
56
62
|
end
|
57
|
-
|
63
|
+
|
58
64
|
describe "test methods" do
|
59
65
|
before(:each) do
|
60
|
-
@api = ConstantContact::Api.new('api key')
|
66
|
+
@api = ConstantContact::Api.new('api key', 'access token')
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#get_account_info" do
|
70
|
+
it "gets a summary of account information" do
|
71
|
+
json_response = load_file('account_info_response.json')
|
72
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
73
|
+
|
74
|
+
response = RestClient::Response.create(json_response, net_http_resp, {})
|
75
|
+
RestClient.stub(:get).and_return(response)
|
76
|
+
|
77
|
+
result = @api.get_account_info()
|
78
|
+
result.should be_kind_of(ConstantContact::Components::AccountInfo)
|
79
|
+
result.website.should eq('http://www.example.com')
|
80
|
+
end
|
61
81
|
end
|
62
82
|
|
63
83
|
describe "#get_verified_email_addresses" do
|
@@ -68,7 +88,7 @@ describe ConstantContact::Api do
|
|
68
88
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
69
89
|
RestClient.stub(:get).and_return(response)
|
70
90
|
|
71
|
-
email_addresses = @api.get_verified_email_addresses(
|
91
|
+
email_addresses = @api.get_verified_email_addresses()
|
72
92
|
|
73
93
|
email_addresses.should be_kind_of(Array)
|
74
94
|
email_addresses.first.should be_kind_of(ConstantContact::Components::VerifiedEmailAddress)
|
@@ -83,7 +103,7 @@ describe ConstantContact::Api do
|
|
83
103
|
|
84
104
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
85
105
|
RestClient.stub(:get).and_return(response)
|
86
|
-
contacts = @api.get_contacts(
|
106
|
+
contacts = @api.get_contacts({:limit => 60})
|
87
107
|
|
88
108
|
contacts.should be_kind_of(ConstantContact::Components::ResultSet)
|
89
109
|
contacts.results.first.should be_kind_of(ConstantContact::Components::Contact)
|
@@ -98,7 +118,7 @@ describe ConstantContact::Api do
|
|
98
118
|
|
99
119
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
100
120
|
RestClient.stub(:get).and_return(response)
|
101
|
-
contact = @api.get_contact(
|
121
|
+
contact = @api.get_contact(1)
|
102
122
|
|
103
123
|
contact.should be_kind_of(ConstantContact::Components::Contact)
|
104
124
|
end
|
@@ -111,7 +131,7 @@ describe ConstantContact::Api do
|
|
111
131
|
|
112
132
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
113
133
|
RestClient.stub(:get).and_return(response)
|
114
|
-
contacts = @api.get_contact_by_email('
|
134
|
+
contacts = @api.get_contact_by_email('rmartone@systems.com')
|
115
135
|
|
116
136
|
contacts.results.first.should be_kind_of(ConstantContact::Components::Contact)
|
117
137
|
end
|
@@ -126,7 +146,7 @@ describe ConstantContact::Api do
|
|
126
146
|
RestClient.stub(:post).and_return(response)
|
127
147
|
new_contact = ConstantContact::Components::Contact.create(JSON.parse(json_response))
|
128
148
|
|
129
|
-
contact = @api.add_contact(
|
149
|
+
contact = @api.add_contact(new_contact)
|
130
150
|
contact.should be_kind_of(ConstantContact::Components::Contact)
|
131
151
|
contact.status.should eq('ACTIVE')
|
132
152
|
end
|
@@ -140,7 +160,7 @@ describe ConstantContact::Api do
|
|
140
160
|
response = RestClient::Response.create('', net_http_resp, {})
|
141
161
|
RestClient.stub(:delete).and_return(response)
|
142
162
|
|
143
|
-
result = @api.delete_contact(
|
163
|
+
result = @api.delete_contact(contact_id)
|
144
164
|
result.should be_true
|
145
165
|
end
|
146
166
|
end
|
@@ -153,7 +173,7 @@ describe ConstantContact::Api do
|
|
153
173
|
response = RestClient::Response.create('', net_http_resp, {})
|
154
174
|
RestClient.stub(:delete).and_return(response)
|
155
175
|
|
156
|
-
result = @api.delete_contact_from_lists(
|
176
|
+
result = @api.delete_contact_from_lists(contact_id)
|
157
177
|
result.should be_true
|
158
178
|
end
|
159
179
|
end
|
@@ -167,7 +187,7 @@ describe ConstantContact::Api do
|
|
167
187
|
response = RestClient::Response.create('', net_http_resp, {})
|
168
188
|
RestClient.stub(:delete).and_return(response)
|
169
189
|
|
170
|
-
result = @api.delete_contact_from_list(
|
190
|
+
result = @api.delete_contact_from_list(contact_id, list_id)
|
171
191
|
result.should be_true
|
172
192
|
end
|
173
193
|
end
|
@@ -180,7 +200,7 @@ describe ConstantContact::Api do
|
|
180
200
|
response = RestClient::Response.create(json, net_http_resp, {})
|
181
201
|
RestClient.stub(:put).and_return(response)
|
182
202
|
contact = ConstantContact::Components::Contact.create(JSON.parse(json))
|
183
|
-
result = @api.update_contact(
|
203
|
+
result = @api.update_contact(contact)
|
184
204
|
|
185
205
|
result.should be_kind_of(ConstantContact::Components::Contact)
|
186
206
|
result.status.should eq('ACTIVE')
|
@@ -194,7 +214,7 @@ describe ConstantContact::Api do
|
|
194
214
|
|
195
215
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
196
216
|
RestClient.stub(:get).and_return(response)
|
197
|
-
lists = @api.get_lists(
|
217
|
+
lists = @api.get_lists()
|
198
218
|
|
199
219
|
lists.should be_kind_of(Array)
|
200
220
|
lists.first.should be_kind_of(ConstantContact::Components::ContactList)
|
@@ -210,7 +230,7 @@ describe ConstantContact::Api do
|
|
210
230
|
response = RestClient::Response.create(json, net_http_resp, {})
|
211
231
|
RestClient.stub(:get).and_return(response)
|
212
232
|
|
213
|
-
list = @api.get_list(
|
233
|
+
list = @api.get_list(1)
|
214
234
|
list.should be_kind_of(ConstantContact::Components::ContactList)
|
215
235
|
list.name.should eq('Monthly Specials')
|
216
236
|
end
|
@@ -225,7 +245,7 @@ describe ConstantContact::Api do
|
|
225
245
|
RestClient.stub(:post).and_return(response)
|
226
246
|
new_list = ConstantContact::Components::ContactList.create(JSON.parse(json))
|
227
247
|
|
228
|
-
list = @api.add_list(
|
248
|
+
list = @api.add_list(new_list)
|
229
249
|
list.should be_kind_of(ConstantContact::Components::ContactList)
|
230
250
|
list.status.should eq('ACTIVE')
|
231
251
|
end
|
@@ -240,7 +260,7 @@ describe ConstantContact::Api do
|
|
240
260
|
RestClient.stub(:put).and_return(response)
|
241
261
|
list = ConstantContact::Components::ContactList.create(JSON.parse(json))
|
242
262
|
|
243
|
-
result = @api.update_list(
|
263
|
+
result = @api.update_list(list)
|
244
264
|
result.should be_kind_of(ConstantContact::Components::ContactList)
|
245
265
|
result.status.should eq('ACTIVE')
|
246
266
|
end
|
@@ -256,12 +276,12 @@ describe ConstantContact::Api do
|
|
256
276
|
RestClient.stub(:get).and_return(response)
|
257
277
|
list = ConstantContact::Components::ContactList.create(JSON.parse(json_list))
|
258
278
|
|
259
|
-
contacts = @api.get_contacts_from_list(
|
279
|
+
contacts = @api.get_contacts_from_list(list, "?limit=4&next=true")
|
260
280
|
contacts.should be_kind_of(ConstantContact::Components::ResultSet)
|
261
281
|
contacts.results.first.should be_kind_of(ConstantContact::Components::Contact)
|
262
282
|
contacts.results.first.fax.should eq('318-978-7575')
|
263
283
|
|
264
|
-
contacts = @api.get_contacts_from_list(
|
284
|
+
contacts = @api.get_contacts_from_list(list, 4)
|
265
285
|
contacts.should be_kind_of(ConstantContact::Components::ResultSet)
|
266
286
|
contacts.results.first.should be_kind_of(ConstantContact::Components::Contact)
|
267
287
|
contacts.results.first.fax.should eq('318-978-7575')
|
@@ -276,7 +296,7 @@ describe ConstantContact::Api do
|
|
276
296
|
response = RestClient::Response.create(json, net_http_resp, {})
|
277
297
|
RestClient.stub(:get).and_return(response)
|
278
298
|
|
279
|
-
events = @api.get_events(
|
299
|
+
events = @api.get_events()
|
280
300
|
events.should be_kind_of(ConstantContact::Components::ResultSet)
|
281
301
|
events.results.collect{|e| e.should be_kind_of(ConstantContact::Components::Event) }
|
282
302
|
end
|
@@ -289,7 +309,7 @@ describe ConstantContact::Api do
|
|
289
309
|
|
290
310
|
response = RestClient::Response.create(json, net_http_resp, {})
|
291
311
|
RestClient.stub(:get).and_return(response)
|
292
|
-
event = @api.get_event(
|
312
|
+
event = @api.get_event(1)
|
293
313
|
|
294
314
|
event.should be_kind_of(ConstantContact::Components::Event)
|
295
315
|
end
|
@@ -304,7 +324,7 @@ describe ConstantContact::Api do
|
|
304
324
|
RestClient.stub(:post).and_return(response)
|
305
325
|
|
306
326
|
event = ConstantContact::Components::Event.create(JSON.parse(json))
|
307
|
-
added = @api.add_event(
|
327
|
+
added = @api.add_event(event)
|
308
328
|
|
309
329
|
added.should respond_to(:id)
|
310
330
|
added.id.should_not be_empty
|
@@ -322,7 +342,7 @@ describe ConstantContact::Api do
|
|
322
342
|
RestClient.stub(:patch).and_return(response)
|
323
343
|
|
324
344
|
event = ConstantContact::Components::Event.create(JSON.parse(json))
|
325
|
-
updated = @api.publish_event(
|
345
|
+
updated = @api.publish_event(event)
|
326
346
|
updated.should be_kind_of(ConstantContact::Components::Event)
|
327
347
|
updated.should respond_to(:status)
|
328
348
|
updated.status.should eq("ACTIVE")
|
@@ -340,7 +360,7 @@ describe ConstantContact::Api do
|
|
340
360
|
RestClient.stub(:patch).and_return(response)
|
341
361
|
|
342
362
|
event = ConstantContact::Components::Event.create(JSON.parse(json))
|
343
|
-
updated = @api.cancel_event(
|
363
|
+
updated = @api.cancel_event(event)
|
344
364
|
updated.should be_kind_of(ConstantContact::Components::Event)
|
345
365
|
updated.should respond_to(:status)
|
346
366
|
updated.status.should eq("CANCELLED")
|
@@ -356,7 +376,7 @@ describe ConstantContact::Api do
|
|
356
376
|
response = RestClient::Response.create(fees_json, net_http_resp, {})
|
357
377
|
RestClient.stub(:get).and_return(response)
|
358
378
|
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
359
|
-
fees = @api.get_event_fees(
|
379
|
+
fees = @api.get_event_fees(event)
|
360
380
|
#fees.should be_kind_of(ConstantContact::Components::ResultSet)
|
361
381
|
#fees.results.collect{|f| f.should be_kind_of(ConstantContact::Components::Fee) }
|
362
382
|
|
@@ -376,7 +396,7 @@ describe ConstantContact::Api do
|
|
376
396
|
|
377
397
|
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
378
398
|
fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
|
379
|
-
retrieved = @api.get_event_fee(
|
399
|
+
retrieved = @api.get_event_fee(event, fee)
|
380
400
|
retrieved.should be_kind_of(ConstantContact::Components::EventFee)
|
381
401
|
end
|
382
402
|
end
|
@@ -392,7 +412,7 @@ describe ConstantContact::Api do
|
|
392
412
|
|
393
413
|
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
394
414
|
fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
|
395
|
-
added = @api.add_event_fee(
|
415
|
+
added = @api.add_event_fee(event, fee)
|
396
416
|
added.should be_kind_of(ConstantContact::Components::EventFee)
|
397
417
|
added.id.should_not be_empty
|
398
418
|
end
|
@@ -411,7 +431,7 @@ describe ConstantContact::Api do
|
|
411
431
|
|
412
432
|
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
413
433
|
fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
|
414
|
-
updated = @api.update_event_fee(
|
434
|
+
updated = @api.update_event_fee(event, fee)
|
415
435
|
updated.should be_kind_of(ConstantContact::Components::EventFee)
|
416
436
|
updated.fee.should_not eq(fee.fee)
|
417
437
|
updated.fee.should eq(fee.fee + 1)
|
@@ -429,7 +449,7 @@ describe ConstantContact::Api do
|
|
429
449
|
|
430
450
|
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
431
451
|
fee = ConstantContact::Components::EventFee.create(JSON.parse(fee_json))
|
432
|
-
@api.delete_event_fee(
|
452
|
+
@api.delete_event_fee(event, fee).should be_true
|
433
453
|
end
|
434
454
|
end
|
435
455
|
|
@@ -443,7 +463,7 @@ describe ConstantContact::Api do
|
|
443
463
|
RestClient.stub(:get).and_return(response)
|
444
464
|
|
445
465
|
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
446
|
-
registrants = @api.get_event_registrants(
|
466
|
+
registrants = @api.get_event_registrants(event)
|
447
467
|
registrants.should be_kind_of(ConstantContact::Components::ResultSet)
|
448
468
|
registrants.results.collect{|r| r .should be_kind_of(ConstantContact::Components::Registrant) }
|
449
469
|
end
|
@@ -460,7 +480,7 @@ describe ConstantContact::Api do
|
|
460
480
|
|
461
481
|
event = ConstantContact::Components::Event.create(JSON.parse(event_json))
|
462
482
|
registrant = ConstantContact::Components::Registrant.create(JSON.parse(registrant_json))
|
463
|
-
retrieved = @api.get_event_registrant(
|
483
|
+
retrieved = @api.get_event_registrant(event, registrant)
|
464
484
|
retrieved.should be_kind_of(ConstantContact::Components::Registrant)
|
465
485
|
retrieved.id.should_not be_empty
|
466
486
|
end
|
@@ -474,7 +494,7 @@ describe ConstantContact::Api do
|
|
474
494
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
475
495
|
RestClient.stub(:get).and_return(response)
|
476
496
|
|
477
|
-
results = @api.get_event_items(
|
497
|
+
results = @api.get_event_items(1)
|
478
498
|
results.should be_kind_of(Array)
|
479
499
|
results.first.should be_kind_of(ConstantContact::Components::EventItem)
|
480
500
|
results.first.name.should eq('Running Belt')
|
@@ -489,7 +509,7 @@ describe ConstantContact::Api do
|
|
489
509
|
response = RestClient::Response.create(json, net_http_resp, {})
|
490
510
|
RestClient.stub(:get).and_return(response)
|
491
511
|
|
492
|
-
result = @api.get_event_item(
|
512
|
+
result = @api.get_event_item(1, 1)
|
493
513
|
result.should be_kind_of(ConstantContact::Components::EventItem)
|
494
514
|
result.name.should eq('Running Belt')
|
495
515
|
end
|
@@ -504,7 +524,7 @@ describe ConstantContact::Api do
|
|
504
524
|
RestClient.stub(:post).and_return(response)
|
505
525
|
event_item = ConstantContact::Components::EventItem.create(JSON.parse(json))
|
506
526
|
|
507
|
-
result = @api.add_event_item(
|
527
|
+
result = @api.add_event_item(1, event_item)
|
508
528
|
result.should be_kind_of(ConstantContact::Components::EventItem)
|
509
529
|
result.name.should eq('Running Belt')
|
510
530
|
end
|
@@ -517,7 +537,7 @@ describe ConstantContact::Api do
|
|
517
537
|
response = RestClient::Response.create('', net_http_resp, {})
|
518
538
|
RestClient.stub(:delete).and_return(response)
|
519
539
|
|
520
|
-
result = @api.delete_event_item(
|
540
|
+
result = @api.delete_event_item(1, 1)
|
521
541
|
result.should be_true
|
522
542
|
end
|
523
543
|
end
|
@@ -531,7 +551,7 @@ describe ConstantContact::Api do
|
|
531
551
|
RestClient.stub(:put).and_return(response)
|
532
552
|
event_item = ConstantContact::Components::EventItem.create(JSON.parse(json))
|
533
553
|
|
534
|
-
result = @api.update_event_item(
|
554
|
+
result = @api.update_event_item(1, event_item)
|
535
555
|
result.should be_kind_of(ConstantContact::Components::EventItem)
|
536
556
|
result.name.should eq('Running Belt')
|
537
557
|
end
|
@@ -545,7 +565,7 @@ describe ConstantContact::Api do
|
|
545
565
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
546
566
|
RestClient.stub(:get).and_return(response)
|
547
567
|
|
548
|
-
results = @api.get_event_item_attributes(
|
568
|
+
results = @api.get_event_item_attributes(1, 1)
|
549
569
|
results.should be_kind_of(Array)
|
550
570
|
results.first.should be_kind_of(ConstantContact::Components::EventItemAttribute)
|
551
571
|
results.first.name.should eq('Royal Blue')
|
@@ -560,7 +580,7 @@ describe ConstantContact::Api do
|
|
560
580
|
response = RestClient::Response.create(json, net_http_resp, {})
|
561
581
|
RestClient.stub(:get).and_return(response)
|
562
582
|
|
563
|
-
result = @api.get_event_item_attribute(
|
583
|
+
result = @api.get_event_item_attribute(1, 1, 1)
|
564
584
|
result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
|
565
585
|
result.name.should eq('Hi-Vis Green')
|
566
586
|
end
|
@@ -575,7 +595,7 @@ describe ConstantContact::Api do
|
|
575
595
|
RestClient.stub(:post).and_return(response)
|
576
596
|
event_item_attribute = ConstantContact::Components::EventItemAttribute.create(JSON.parse(json))
|
577
597
|
|
578
|
-
result = @api.add_event_item_attribute(
|
598
|
+
result = @api.add_event_item_attribute(1, 1, event_item_attribute)
|
579
599
|
result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
|
580
600
|
result.name.should eq('Hi-Vis Green')
|
581
601
|
end
|
@@ -588,7 +608,7 @@ describe ConstantContact::Api do
|
|
588
608
|
response = RestClient::Response.create('', net_http_resp, {})
|
589
609
|
RestClient.stub(:delete).and_return(response)
|
590
610
|
|
591
|
-
result = @api.delete_event_item_attribute(
|
611
|
+
result = @api.delete_event_item_attribute(1, 1, 1)
|
592
612
|
result.should be_true
|
593
613
|
end
|
594
614
|
end
|
@@ -602,7 +622,7 @@ describe ConstantContact::Api do
|
|
602
622
|
RestClient.stub(:put).and_return(response)
|
603
623
|
event_item_attribute = ConstantContact::Components::EventItemAttribute.create(JSON.parse(json))
|
604
624
|
|
605
|
-
result = @api.update_event_item_attribute(
|
625
|
+
result = @api.update_event_item_attribute(1, 1, event_item_attribute)
|
606
626
|
result.should be_kind_of(ConstantContact::Components::EventItemAttribute)
|
607
627
|
result.name.should eq('Hi-Vis Green')
|
608
628
|
end
|
@@ -616,7 +636,7 @@ describe ConstantContact::Api do
|
|
616
636
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
617
637
|
RestClient.stub(:get).and_return(response)
|
618
638
|
|
619
|
-
results = @api.get_promocodes(
|
639
|
+
results = @api.get_promocodes(1)
|
620
640
|
results.should be_kind_of(Array)
|
621
641
|
results.first.should be_kind_of(ConstantContact::Components::Promocode)
|
622
642
|
results.first.code_name.should eq('REDUCED_FEE')
|
@@ -631,7 +651,7 @@ describe ConstantContact::Api do
|
|
631
651
|
response = RestClient::Response.create(json, net_http_resp, {})
|
632
652
|
RestClient.stub(:get).and_return(response)
|
633
653
|
|
634
|
-
result = @api.get_promocode(
|
654
|
+
result = @api.get_promocode(1, 1)
|
635
655
|
result.should be_kind_of(ConstantContact::Components::Promocode)
|
636
656
|
result.code_name.should eq('TOTAL_FEE')
|
637
657
|
end
|
@@ -646,7 +666,7 @@ describe ConstantContact::Api do
|
|
646
666
|
RestClient.stub(:post).and_return(response)
|
647
667
|
promocode = ConstantContact::Components::Promocode.create(JSON.parse(json))
|
648
668
|
|
649
|
-
result = @api.add_promocode(
|
669
|
+
result = @api.add_promocode(1, promocode)
|
650
670
|
result.should be_kind_of(ConstantContact::Components::Promocode)
|
651
671
|
result.code_name.should eq('TOTAL_FEE')
|
652
672
|
end
|
@@ -659,7 +679,7 @@ describe ConstantContact::Api do
|
|
659
679
|
response = RestClient::Response.create('', net_http_resp, {})
|
660
680
|
RestClient.stub(:delete).and_return(response)
|
661
681
|
|
662
|
-
result = @api.delete_promocode(
|
682
|
+
result = @api.delete_promocode(1, 1)
|
663
683
|
result.should be_true
|
664
684
|
end
|
665
685
|
end
|
@@ -673,7 +693,7 @@ describe ConstantContact::Api do
|
|
673
693
|
RestClient.stub(:put).and_return(response)
|
674
694
|
promocode = ConstantContact::Components::Promocode.create(JSON.parse(json))
|
675
695
|
|
676
|
-
result = @api.update_promocode(
|
696
|
+
result = @api.update_promocode(1, promocode)
|
677
697
|
result.should be_kind_of(ConstantContact::Components::Promocode)
|
678
698
|
result.code_name.should eq('TOTAL_FEE')
|
679
699
|
end
|
@@ -687,7 +707,7 @@ describe ConstantContact::Api do
|
|
687
707
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
688
708
|
RestClient.stub(:get).and_return(response)
|
689
709
|
|
690
|
-
campaigns = @api.get_email_campaigns(
|
710
|
+
campaigns = @api.get_email_campaigns({:limit => 2})
|
691
711
|
campaigns.should be_kind_of(ConstantContact::Components::ResultSet)
|
692
712
|
campaigns.results.first.should be_kind_of(ConstantContact::Components::Campaign)
|
693
713
|
campaigns.results.first.name.should eq('1357157252225')
|
@@ -702,7 +722,7 @@ describe ConstantContact::Api do
|
|
702
722
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
703
723
|
RestClient.stub(:get).and_return(response)
|
704
724
|
|
705
|
-
campaign = @api.get_email_campaign(
|
725
|
+
campaign = @api.get_email_campaign(1)
|
706
726
|
campaign.should be_kind_of(ConstantContact::Components::Campaign)
|
707
727
|
campaign.name.should eq('Campaign Name')
|
708
728
|
end
|
@@ -717,7 +737,7 @@ describe ConstantContact::Api do
|
|
717
737
|
RestClient.stub(:post).and_return(response)
|
718
738
|
new_campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
719
739
|
|
720
|
-
campaign = @api.add_email_campaign(
|
740
|
+
campaign = @api.add_email_campaign(new_campaign)
|
721
741
|
campaign.should be_kind_of(ConstantContact::Components::Campaign)
|
722
742
|
campaign.name.should eq('Campaign Name')
|
723
743
|
end
|
@@ -732,7 +752,7 @@ describe ConstantContact::Api do
|
|
732
752
|
RestClient.stub(:delete).and_return(response)
|
733
753
|
campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
734
754
|
|
735
|
-
result = @api.delete_email_campaign(
|
755
|
+
result = @api.delete_email_campaign(campaign)
|
736
756
|
result.should be_true
|
737
757
|
end
|
738
758
|
end
|
@@ -746,7 +766,7 @@ describe ConstantContact::Api do
|
|
746
766
|
RestClient.stub(:put).and_return(response)
|
747
767
|
campaign = ConstantContact::Components::Campaign.create(JSON.parse(json))
|
748
768
|
|
749
|
-
result = @api.update_email_campaign(
|
769
|
+
result = @api.update_email_campaign(campaign)
|
750
770
|
result.should be_kind_of(ConstantContact::Components::Campaign)
|
751
771
|
result.name.should eq('Campaign Name')
|
752
772
|
end
|
@@ -762,7 +782,7 @@ describe ConstantContact::Api do
|
|
762
782
|
RestClient.stub(:post).and_return(response)
|
763
783
|
new_schedule = ConstantContact::Components::Schedule.create(JSON.parse(json))
|
764
784
|
|
765
|
-
schedule = @api.add_email_campaign_schedule(
|
785
|
+
schedule = @api.add_email_campaign_schedule(campaign_id, new_schedule)
|
766
786
|
schedule.should be_kind_of(ConstantContact::Components::Schedule)
|
767
787
|
schedule.scheduled_date.should eq('2013-05-10T11:07:43.626Z')
|
768
788
|
end
|
@@ -777,7 +797,7 @@ describe ConstantContact::Api do
|
|
777
797
|
response = RestClient::Response.create(json, net_http_resp, {})
|
778
798
|
RestClient.stub(:get).and_return(response)
|
779
799
|
|
780
|
-
schedules = @api.get_email_campaign_schedules(
|
800
|
+
schedules = @api.get_email_campaign_schedules(campaign_id)
|
781
801
|
schedules.first.should be_kind_of(ConstantContact::Components::Schedule)
|
782
802
|
schedules.first.scheduled_date.should eq('2012-12-16T11:07:43.626Z')
|
783
803
|
end
|
@@ -794,7 +814,7 @@ describe ConstantContact::Api do
|
|
794
814
|
response = RestClient::Response.create(json, net_http_resp, {})
|
795
815
|
RestClient.stub(:get).and_return(response)
|
796
816
|
|
797
|
-
schedule = @api.get_email_campaign_schedule(
|
817
|
+
schedule = @api.get_email_campaign_schedule(campaign_id, schedule_id)
|
798
818
|
schedule.should be_kind_of(ConstantContact::Components::Schedule)
|
799
819
|
schedule.scheduled_date.should eq('2013-05-10T11:07:43.626Z')
|
800
820
|
end
|
@@ -809,7 +829,7 @@ describe ConstantContact::Api do
|
|
809
829
|
response = RestClient::Response.create('', net_http_resp, {})
|
810
830
|
RestClient.stub(:delete).and_return(response)
|
811
831
|
|
812
|
-
result = @api.delete_email_campaign_schedule(
|
832
|
+
result = @api.delete_email_campaign_schedule(campaign_id, schedule_id)
|
813
833
|
result.should be_true
|
814
834
|
end
|
815
835
|
end
|
@@ -824,7 +844,7 @@ describe ConstantContact::Api do
|
|
824
844
|
RestClient.stub(:put).and_return(response)
|
825
845
|
schedule = ConstantContact::Components::Schedule.create(JSON.parse(json))
|
826
846
|
|
827
|
-
result = @api.update_email_campaign_schedule(
|
847
|
+
result = @api.update_email_campaign_schedule(campaign_id, schedule)
|
828
848
|
result.should be_kind_of(ConstantContact::Components::Schedule)
|
829
849
|
result.scheduled_date.should eq('2013-05-10T11:07:43.626Z')
|
830
850
|
end
|
@@ -841,7 +861,7 @@ describe ConstantContact::Api do
|
|
841
861
|
RestClient.stub(:post).and_return(response)
|
842
862
|
test_send = ConstantContact::Components::TestSend.create(JSON.parse(json_request))
|
843
863
|
|
844
|
-
result = @api.send_email_campaign_test(
|
864
|
+
result = @api.send_email_campaign_test(campaign_id, test_send)
|
845
865
|
result.should be_kind_of(ConstantContact::Components::TestSend)
|
846
866
|
result.personal_message.should eq('This is a test send of the email campaign message.')
|
847
867
|
end
|
@@ -857,7 +877,7 @@ describe ConstantContact::Api do
|
|
857
877
|
response = RestClient::Response.create(json, net_http_resp, {})
|
858
878
|
RestClient.stub(:get).and_return(response)
|
859
879
|
|
860
|
-
set = @api.get_email_campaign_bounces(
|
880
|
+
set = @api.get_email_campaign_bounces(campaign_id, params)
|
861
881
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
862
882
|
set.results.first.should be_kind_of(ConstantContact::Components::BounceActivity)
|
863
883
|
set.results.first.activity_type.should eq('EMAIL_BOUNCE')
|
@@ -874,7 +894,7 @@ describe ConstantContact::Api do
|
|
874
894
|
response = RestClient::Response.create(json, net_http_resp, {})
|
875
895
|
RestClient.stub(:get).and_return(response)
|
876
896
|
|
877
|
-
set = @api.get_email_campaign_clicks(
|
897
|
+
set = @api.get_email_campaign_clicks(campaign_id, params)
|
878
898
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
879
899
|
set.results.first.should be_kind_of(ConstantContact::Components::ClickActivity)
|
880
900
|
set.results.first.activity_type.should eq('EMAIL_CLICK')
|
@@ -891,7 +911,7 @@ describe ConstantContact::Api do
|
|
891
911
|
response = RestClient::Response.create(json, net_http_resp, {})
|
892
912
|
RestClient.stub(:get).and_return(response)
|
893
913
|
|
894
|
-
set = @api.get_email_campaign_forwards(
|
914
|
+
set = @api.get_email_campaign_forwards(campaign_id, params)
|
895
915
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
896
916
|
set.results.first.should be_kind_of(ConstantContact::Components::ForwardActivity)
|
897
917
|
set.results.first.activity_type.should eq('EMAIL_FORWARD')
|
@@ -908,7 +928,7 @@ describe ConstantContact::Api do
|
|
908
928
|
response = RestClient::Response.create(json, net_http_resp, {})
|
909
929
|
RestClient.stub(:get).and_return(response)
|
910
930
|
|
911
|
-
set = @api.get_email_campaign_opens(
|
931
|
+
set = @api.get_email_campaign_opens(campaign_id, params)
|
912
932
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
913
933
|
set.results.first.should be_kind_of(ConstantContact::Components::OpenActivity)
|
914
934
|
set.results.first.activity_type.should eq('EMAIL_OPEN')
|
@@ -925,7 +945,7 @@ describe ConstantContact::Api do
|
|
925
945
|
response = RestClient::Response.create(json, net_http_resp, {})
|
926
946
|
RestClient.stub(:get).and_return(response)
|
927
947
|
|
928
|
-
set = @api.get_email_campaign_sends(
|
948
|
+
set = @api.get_email_campaign_sends(campaign_id, params)
|
929
949
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
930
950
|
set.results.first.should be_kind_of(ConstantContact::Components::SendActivity)
|
931
951
|
set.results.first.activity_type.should eq('EMAIL_SEND')
|
@@ -942,7 +962,7 @@ describe ConstantContact::Api do
|
|
942
962
|
response = RestClient::Response.create(json, net_http_resp, {})
|
943
963
|
RestClient.stub(:get).and_return(response)
|
944
964
|
|
945
|
-
set = @api.get_email_campaign_unsubscribes(
|
965
|
+
set = @api.get_email_campaign_unsubscribes(campaign_id, params)
|
946
966
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
947
967
|
set.results.first.should be_kind_of(ConstantContact::Components::UnsubscribeActivity)
|
948
968
|
set.results.first.activity_type.should eq('EMAIL_UNSUBSCRIBE')
|
@@ -958,7 +978,7 @@ describe ConstantContact::Api do
|
|
958
978
|
response = RestClient::Response.create(json, net_http_resp, {})
|
959
979
|
RestClient.stub(:get).and_return(response)
|
960
980
|
|
961
|
-
summary = @api.get_email_campaign_summary_report(
|
981
|
+
summary = @api.get_email_campaign_summary_report(campaign_id)
|
962
982
|
summary.should be_kind_of(ConstantContact::Components::TrackingSummary)
|
963
983
|
summary.sends.should eq(15)
|
964
984
|
end
|
@@ -974,7 +994,7 @@ describe ConstantContact::Api do
|
|
974
994
|
response = RestClient::Response.create(json, net_http_resp, {})
|
975
995
|
RestClient.stub(:get).and_return(response)
|
976
996
|
|
977
|
-
set = @api.get_contact_bounces(
|
997
|
+
set = @api.get_contact_bounces(contact_id, params)
|
978
998
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
979
999
|
set.results.first.should be_kind_of(ConstantContact::Components::BounceActivity)
|
980
1000
|
set.results.first.activity_type.should eq('EMAIL_BOUNCE')
|
@@ -991,7 +1011,7 @@ describe ConstantContact::Api do
|
|
991
1011
|
response = RestClient::Response.create(json, net_http_resp, {})
|
992
1012
|
RestClient.stub(:get).and_return(response)
|
993
1013
|
|
994
|
-
set = @api.get_contact_clicks(
|
1014
|
+
set = @api.get_contact_clicks(contact_id, params)
|
995
1015
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
996
1016
|
set.results.first.should be_kind_of(ConstantContact::Components::ClickActivity)
|
997
1017
|
set.results.first.activity_type.should eq('EMAIL_CLICK')
|
@@ -1008,7 +1028,7 @@ describe ConstantContact::Api do
|
|
1008
1028
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1009
1029
|
RestClient.stub(:get).and_return(response)
|
1010
1030
|
|
1011
|
-
set = @api.get_contact_forwards(
|
1031
|
+
set = @api.get_contact_forwards(contact_id, params)
|
1012
1032
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
1013
1033
|
set.results.first.should be_kind_of(ConstantContact::Components::ForwardActivity)
|
1014
1034
|
set.results.first.activity_type.should eq('EMAIL_FORWARD')
|
@@ -1025,7 +1045,7 @@ describe ConstantContact::Api do
|
|
1025
1045
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1026
1046
|
RestClient.stub(:get).and_return(response)
|
1027
1047
|
|
1028
|
-
set = @api.get_contact_opens(
|
1048
|
+
set = @api.get_contact_opens(contact_id, params)
|
1029
1049
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
1030
1050
|
set.results.first.should be_kind_of(ConstantContact::Components::OpenActivity)
|
1031
1051
|
set.results.first.activity_type.should eq('EMAIL_OPEN')
|
@@ -1042,7 +1062,7 @@ describe ConstantContact::Api do
|
|
1042
1062
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1043
1063
|
RestClient.stub(:get).and_return(response)
|
1044
1064
|
|
1045
|
-
set = @api.get_contact_sends(
|
1065
|
+
set = @api.get_contact_sends(contact_id, params)
|
1046
1066
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
1047
1067
|
set.results.first.should be_kind_of(ConstantContact::Components::SendActivity)
|
1048
1068
|
set.results.first.activity_type.should eq('EMAIL_SEND')
|
@@ -1059,7 +1079,7 @@ describe ConstantContact::Api do
|
|
1059
1079
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1060
1080
|
RestClient.stub(:get).and_return(response)
|
1061
1081
|
|
1062
|
-
set = @api.get_contact_unsubscribes(
|
1082
|
+
set = @api.get_contact_unsubscribes(contact_id, params)
|
1063
1083
|
set.should be_kind_of(ConstantContact::Components::ResultSet)
|
1064
1084
|
set.results.first.should be_kind_of(ConstantContact::Components::UnsubscribeActivity)
|
1065
1085
|
set.results.first.activity_type.should eq('EMAIL_UNSUBSCRIBE')
|
@@ -1075,7 +1095,7 @@ describe ConstantContact::Api do
|
|
1075
1095
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1076
1096
|
RestClient.stub(:get).and_return(response)
|
1077
1097
|
|
1078
|
-
summary = @api.get_contact_summary_report(
|
1098
|
+
summary = @api.get_contact_summary_report(contact_id)
|
1079
1099
|
summary.should be_kind_of(ConstantContact::Components::TrackingSummary)
|
1080
1100
|
summary.sends.should eq(15)
|
1081
1101
|
end
|
@@ -1089,7 +1109,7 @@ describe ConstantContact::Api do
|
|
1089
1109
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1090
1110
|
RestClient.stub(:get).and_return(response)
|
1091
1111
|
|
1092
|
-
activities = @api.get_activities(
|
1112
|
+
activities = @api.get_activities()
|
1093
1113
|
activities.first.should be_kind_of(ConstantContact::Components::Activity)
|
1094
1114
|
activities.first.type.should eq('REMOVE_CONTACTS_FROM_LISTS')
|
1095
1115
|
end
|
@@ -1103,7 +1123,7 @@ describe ConstantContact::Api do
|
|
1103
1123
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1104
1124
|
RestClient.stub(:get).and_return(response)
|
1105
1125
|
|
1106
|
-
activity = @api.get_activity('
|
1126
|
+
activity = @api.get_activity('a07e1ilbm7shdg6ikeo')
|
1107
1127
|
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1108
1128
|
activity.type.should eq('REMOVE_CONTACTS_FROM_LISTS')
|
1109
1129
|
end
|
@@ -1149,7 +1169,7 @@ describe ConstantContact::Api do
|
|
1149
1169
|
|
1150
1170
|
add_contact = ConstantContact::Components::AddContacts.new(contacts, lists)
|
1151
1171
|
|
1152
|
-
activity = @api.add_create_contacts_activity(
|
1172
|
+
activity = @api.add_create_contacts_activity(add_contact)
|
1153
1173
|
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1154
1174
|
activity.type.should eq('ADD_CONTACTS')
|
1155
1175
|
end
|
@@ -1165,7 +1185,7 @@ describe ConstantContact::Api do
|
|
1165
1185
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1166
1186
|
RestClient.stub(:post).and_return(response)
|
1167
1187
|
|
1168
|
-
activity = @api.add_create_contacts_activity_from_file('
|
1188
|
+
activity = @api.add_create_contacts_activity_from_file('contacts.txt', content, lists)
|
1169
1189
|
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1170
1190
|
activity.type.should eq('ADD_CONTACTS')
|
1171
1191
|
end
|
@@ -1184,7 +1204,7 @@ describe ConstantContact::Api do
|
|
1184
1204
|
response = RestClient::Response.create(json_clear_lists, net_http_resp, {})
|
1185
1205
|
RestClient.stub(:post).and_return(response)
|
1186
1206
|
|
1187
|
-
activity = @api.add_clear_lists_activity(
|
1207
|
+
activity = @api.add_clear_lists_activity(lists)
|
1188
1208
|
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1189
1209
|
activity.type.should eq('CLEAR_CONTACTS_FROM_LISTS')
|
1190
1210
|
end
|
@@ -1201,7 +1221,7 @@ describe ConstantContact::Api do
|
|
1201
1221
|
email_addresses = ["djellesma@constantcontact.com"]
|
1202
1222
|
|
1203
1223
|
activity = @api.add_remove_contacts_from_lists_activity(
|
1204
|
-
|
1224
|
+
email_addresses, lists)
|
1205
1225
|
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1206
1226
|
activity.type.should eq('REMOVE_CONTACTS_FROM_LISTS')
|
1207
1227
|
end
|
@@ -1217,8 +1237,7 @@ describe ConstantContact::Api do
|
|
1217
1237
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1218
1238
|
RestClient.stub(:post).and_return(response)
|
1219
1239
|
|
1220
|
-
activity = @api.add_remove_contacts_from_lists_activity_from_file(
|
1221
|
-
'token', 'contacts.txt', content, lists)
|
1240
|
+
activity = @api.add_remove_contacts_from_lists_activity_from_file('contacts.txt', content, lists)
|
1222
1241
|
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1223
1242
|
activity.type.should eq('REMOVE_CONTACTS_FROM_LISTS')
|
1224
1243
|
end
|
@@ -1234,8 +1253,7 @@ describe ConstantContact::Api do
|
|
1234
1253
|
RestClient.stub(:post).and_return(response)
|
1235
1254
|
export_contacts = ConstantContact::Components::ExportContacts.new(JSON.parse(json_request))
|
1236
1255
|
|
1237
|
-
activity = @api.add_export_contacts_activity(
|
1238
|
-
'token', export_contacts)
|
1256
|
+
activity = @api.add_export_contacts_activity(export_contacts)
|
1239
1257
|
activity.should be_kind_of(ConstantContact::Components::Activity)
|
1240
1258
|
activity.type.should eq('EXPORT_CONTACTS')
|
1241
1259
|
end
|
@@ -1249,7 +1267,7 @@ describe ConstantContact::Api do
|
|
1249
1267
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1250
1268
|
RestClient.stub(:get).and_return(response)
|
1251
1269
|
|
1252
|
-
info = @api.get_library_info(
|
1270
|
+
info = @api.get_library_info()
|
1253
1271
|
info.should be_kind_of(ConstantContact::Components::LibrarySummary)
|
1254
1272
|
info.usage_summary['folder_count'].should eq(6)
|
1255
1273
|
end
|
@@ -1263,7 +1281,7 @@ describe ConstantContact::Api do
|
|
1263
1281
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1264
1282
|
RestClient.stub(:get).and_return(response)
|
1265
1283
|
|
1266
|
-
folders = @api.get_library_folders(
|
1284
|
+
folders = @api.get_library_folders({:limit => 2})
|
1267
1285
|
folders.should be_kind_of(ConstantContact::Components::ResultSet)
|
1268
1286
|
folders.results.first.should be_kind_of(ConstantContact::Components::LibraryFolder)
|
1269
1287
|
folders.results.first.name.should eq('backgrounds')
|
@@ -1279,7 +1297,7 @@ describe ConstantContact::Api do
|
|
1279
1297
|
RestClient.stub(:post).and_return(response)
|
1280
1298
|
new_folder = ConstantContact::Components::LibraryFolder.create(JSON.parse(json))
|
1281
1299
|
|
1282
|
-
folder = @api.add_library_folder(
|
1300
|
+
folder = @api.add_library_folder(new_folder)
|
1283
1301
|
folder.should be_kind_of(ConstantContact::Components::LibraryFolder)
|
1284
1302
|
folder.name.should eq('wildflowers')
|
1285
1303
|
end
|
@@ -1293,7 +1311,7 @@ describe ConstantContact::Api do
|
|
1293
1311
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1294
1312
|
RestClient.stub(:get).and_return(response)
|
1295
1313
|
|
1296
|
-
folder = @api.get_library_folder(
|
1314
|
+
folder = @api.get_library_folder(6)
|
1297
1315
|
folder.should be_kind_of(ConstantContact::Components::LibraryFolder)
|
1298
1316
|
folder.name.should eq('wildflowers')
|
1299
1317
|
end
|
@@ -1308,7 +1326,7 @@ describe ConstantContact::Api do
|
|
1308
1326
|
RestClient.stub(:put).and_return(response)
|
1309
1327
|
folder = ConstantContact::Components::LibraryFolder.create(JSON.parse(json))
|
1310
1328
|
|
1311
|
-
response = @api.update_library_folder(
|
1329
|
+
response = @api.update_library_folder(folder)
|
1312
1330
|
response.should be_kind_of(ConstantContact::Components::LibraryFolder)
|
1313
1331
|
response.name.should eq('wildflowers')
|
1314
1332
|
end
|
@@ -1322,7 +1340,7 @@ describe ConstantContact::Api do
|
|
1322
1340
|
response = RestClient::Response.create('', net_http_resp, {})
|
1323
1341
|
RestClient.stub(:delete).and_return(response)
|
1324
1342
|
|
1325
|
-
result = @api.delete_library_folder(
|
1343
|
+
result = @api.delete_library_folder(folder_id)
|
1326
1344
|
result.should be_true
|
1327
1345
|
end
|
1328
1346
|
end
|
@@ -1335,7 +1353,7 @@ describe ConstantContact::Api do
|
|
1335
1353
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1336
1354
|
RestClient.stub(:get).and_return(response)
|
1337
1355
|
|
1338
|
-
files = @api.get_library_trash(
|
1356
|
+
files = @api.get_library_trash({:sort_by => 'SIZE_DESC'})
|
1339
1357
|
files.should be_kind_of(ConstantContact::Components::ResultSet)
|
1340
1358
|
files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1341
1359
|
files.results.first.name.should eq('menu_form.pdf')
|
@@ -1349,7 +1367,7 @@ describe ConstantContact::Api do
|
|
1349
1367
|
response = RestClient::Response.create('', net_http_resp, {})
|
1350
1368
|
RestClient.stub(:delete).and_return(response)
|
1351
1369
|
|
1352
|
-
result = @api.delete_library_trash(
|
1370
|
+
result = @api.delete_library_trash()
|
1353
1371
|
result.should be_true
|
1354
1372
|
end
|
1355
1373
|
end
|
@@ -1362,7 +1380,7 @@ describe ConstantContact::Api do
|
|
1362
1380
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1363
1381
|
RestClient.stub(:get).and_return(response)
|
1364
1382
|
|
1365
|
-
files = @api.get_library_files(
|
1383
|
+
files = @api.get_library_files({:type => 'ALL'})
|
1366
1384
|
files.should be_kind_of(ConstantContact::Components::ResultSet)
|
1367
1385
|
files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1368
1386
|
files.results.first.name.should eq('IMG_0341.JPG')
|
@@ -1378,7 +1396,7 @@ describe ConstantContact::Api do
|
|
1378
1396
|
response = RestClient::Response.create(json_response, net_http_resp, {})
|
1379
1397
|
RestClient.stub(:get).and_return(response)
|
1380
1398
|
|
1381
|
-
files = @api.get_library_files_by_folder(
|
1399
|
+
files = @api.get_library_files_by_folder(folder_id, {:limit => 10})
|
1382
1400
|
files.should be_kind_of(ConstantContact::Components::ResultSet)
|
1383
1401
|
files.results.first.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1384
1402
|
files.results.first.name.should eq('IMG_0341.JPG')
|
@@ -1393,7 +1411,7 @@ describe ConstantContact::Api do
|
|
1393
1411
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1394
1412
|
RestClient.stub(:get).and_return(response)
|
1395
1413
|
|
1396
|
-
file = @api.get_library_file(
|
1414
|
+
file = @api.get_library_file(6)
|
1397
1415
|
file.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1398
1416
|
file.name.should eq('IMG_0261.JPG')
|
1399
1417
|
end
|
@@ -1413,7 +1431,7 @@ describe ConstantContact::Api do
|
|
1413
1431
|
response = RestClient::Response.create("", net_http_resp, {})
|
1414
1432
|
RestClient.stub(:post).and_return(response)
|
1415
1433
|
|
1416
|
-
response = @api.add_library_file(
|
1434
|
+
response = @api.add_library_file(file_name, folder_id, description, source, file_type, contents)
|
1417
1435
|
response.should be_kind_of(String)
|
1418
1436
|
response.should eq('123456789')
|
1419
1437
|
end
|
@@ -1428,7 +1446,7 @@ describe ConstantContact::Api do
|
|
1428
1446
|
RestClient.stub(:put).and_return(response)
|
1429
1447
|
file = ConstantContact::Components::LibraryFile.create(JSON.parse(json))
|
1430
1448
|
|
1431
|
-
response = @api.update_library_file(
|
1449
|
+
response = @api.update_library_file(file)
|
1432
1450
|
response.should be_kind_of(ConstantContact::Components::LibraryFile)
|
1433
1451
|
response.name.should eq('IMG_0261.JPG')
|
1434
1452
|
end
|
@@ -1442,7 +1460,7 @@ describe ConstantContact::Api do
|
|
1442
1460
|
response = RestClient::Response.create('', net_http_resp, {})
|
1443
1461
|
RestClient.stub(:delete).and_return(response)
|
1444
1462
|
|
1445
|
-
result = @api.delete_library_file(
|
1463
|
+
result = @api.delete_library_file(file_id)
|
1446
1464
|
result.should be_true
|
1447
1465
|
end
|
1448
1466
|
end
|
@@ -1456,7 +1474,7 @@ describe ConstantContact::Api do
|
|
1456
1474
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1457
1475
|
RestClient.stub(:get).and_return(response)
|
1458
1476
|
|
1459
|
-
statuses = @api.get_library_files_upload_status(
|
1477
|
+
statuses = @api.get_library_files_upload_status(file_id)
|
1460
1478
|
statuses.should be_kind_of(Array)
|
1461
1479
|
statuses.first.should be_kind_of(ConstantContact::Components::UploadStatus)
|
1462
1480
|
statuses.first.status.should eq('Active')
|
@@ -1473,7 +1491,7 @@ describe ConstantContact::Api do
|
|
1473
1491
|
response = RestClient::Response.create(json, net_http_resp, {})
|
1474
1492
|
RestClient.stub(:put).and_return(response)
|
1475
1493
|
|
1476
|
-
results = @api.move_library_files(
|
1494
|
+
results = @api.move_library_files(folder_id, file_id)
|
1477
1495
|
results.should be_kind_of(Array)
|
1478
1496
|
results.first.should be_kind_of(ConstantContact::Components::MoveResults)
|
1479
1497
|
results.first.uri.should eq('https://api.d1.constantcontact.com/v2/library/files/9')
|