constantcontact 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -2
- data/README.md +56 -1
- data/constantcontact.gemspec +1 -1
- data/lib/constantcontact/api.rb +111 -97
- data/lib/constantcontact/services/account_service.rb +20 -22
- data/lib/constantcontact/services/activity_service.rb +98 -100
- data/lib/constantcontact/services/base_service.rb +46 -44
- data/lib/constantcontact/services/campaign_schedule_service.rb +72 -74
- data/lib/constantcontact/services/campaign_tracking_service.rb +103 -105
- data/lib/constantcontact/services/contact_service.rb +73 -75
- data/lib/constantcontact/services/contact_tracking_service.rb +103 -105
- data/lib/constantcontact/services/email_marketing_service.rb +64 -66
- data/lib/constantcontact/services/event_spot_service.rb +356 -358
- data/lib/constantcontact/services/library_service.rb +228 -230
- data/lib/constantcontact/services/list_service.rb +55 -57
- data/lib/constantcontact/version.rb +1 -1
- data/spec/constantcontact/api_spec.rb +2 -4
- data/spec/constantcontact/services/account_service_spec.rb +3 -2
- data/spec/constantcontact/services/activity_service_spec.rb +10 -9
- data/spec/constantcontact/services/base_service_spec.rb +7 -5
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +7 -6
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +8 -7
- data/spec/constantcontact/services/contact_service_spec.rb +8 -7
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +8 -7
- data/spec/constantcontact/services/email_marketing_spec.rb +7 -6
- data/spec/constantcontact/services/event_spot_spec.rb +28 -27
- data/spec/constantcontact/services/library_service_spec.rb +17 -16
- data/spec/constantcontact/services/list_service_spec.rb +6 -5
- metadata +20 -20
@@ -7,275 +7,273 @@
|
|
7
7
|
module ConstantContact
|
8
8
|
module Services
|
9
9
|
class LibraryService < BaseService
|
10
|
-
class << self
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
# Retrieve MyLibrary usage information
|
12
|
+
# @return [LibrarySummary]
|
13
|
+
def get_library_info()
|
14
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_info')
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
response = RestClient.get(url, get_headers())
|
17
|
+
Components::LibrarySummary.create(JSON.parse(response.body).first)
|
18
|
+
end
|
20
19
|
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
Components::ResultSet.new(folders, body['meta'])
|
21
|
+
# Retrieve a list of MyLibrary folders
|
22
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
23
|
+
# Allowed parameters include:
|
24
|
+
# sort_by - The method to sort by, valid values are :
|
25
|
+
# CREATED_DATE - sorts by date folder was added, ascending (earliest to latest)
|
26
|
+
# CREATED_DATE_DESC - (default) sorts by date folder was added, descending (latest to earliest)
|
27
|
+
# MODIFIED_DATE - sorts by date folder was last modified, ascending (earliest to latest)
|
28
|
+
# MODIFIED_DATE_DESC - sorts by date folder was last modified, descending (latest to earliest)
|
29
|
+
# NAME - sorts alphabetically by folder name, a to z
|
30
|
+
# NAME_DESC - sorts alphabetically by folder name, z to a
|
31
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
32
|
+
# @return [ResultSet<LibraryFolder>]
|
33
|
+
def get_library_folders(params)
|
34
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folders')
|
35
|
+
url = build_url(url, params)
|
36
|
+
response = RestClient.get(url, get_headers())
|
37
|
+
folders = []
|
38
|
+
body = JSON.parse(response.body)
|
39
|
+
body['results'].each do |folder|
|
40
|
+
folders << Components::LibraryFolder.create(folder)
|
44
41
|
end
|
42
|
+
Components::ResultSet.new(folders, body['meta'])
|
43
|
+
end
|
45
44
|
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
# Create a new MyLibrary folder
|
47
|
+
# @param [LibraryFolder] folder - MyLibrary folder to be created
|
48
|
+
# @return [LibraryFolder]
|
49
|
+
def add_library_folder(folder)
|
50
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folders')
|
51
|
+
url = build_url(url)
|
52
|
+
payload = folder.to_json
|
53
|
+
response = RestClient.post(url, payload, get_headers())
|
54
|
+
Components::LibraryFolder.create(JSON.parse(response.body))
|
55
|
+
end
|
57
56
|
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
58
|
+
# Retrieve a specific MyLibrary folder using the folder_id path parameter
|
59
|
+
# @param [String] folder_id - The ID for the folder to return
|
60
|
+
# @return [LibraryFolder]
|
61
|
+
def get_library_folder(folder_id)
|
62
|
+
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_folder'), folder_id)
|
63
|
+
url = build_url(url)
|
64
|
+
response = RestClient.get(url, get_headers())
|
65
|
+
Components::LibraryFolder.create(JSON.parse(response.body))
|
66
|
+
end
|
68
67
|
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
69
|
+
# Update a specific MyLibrary folder
|
70
|
+
# @param [LibraryFolder] folder - MyLibrary folder to be updated
|
71
|
+
# @return [LibraryFolder]
|
72
|
+
def update_library_folder(folder)
|
73
|
+
url = Util::Config.get('endpoints.base_url') +
|
74
|
+
sprintf(Util::Config.get('endpoints.library_folder'), folder.id)
|
75
|
+
url = build_url(url)
|
76
|
+
payload = folder.to_json
|
77
|
+
response = RestClient.put(url, payload, get_headers())
|
78
|
+
Components::LibraryFolder.create(JSON.parse(response.body))
|
79
|
+
end
|
81
80
|
|
82
81
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
82
|
+
# Delete a MyLibrary folder
|
83
|
+
# @param [String] folder_id - The ID for the MyLibrary folder to delete
|
84
|
+
# @return [Boolean]
|
85
|
+
def delete_library_folder(folder_id)
|
86
|
+
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_folder'), folder_id)
|
87
|
+
url = build_url(url)
|
88
|
+
response = RestClient.delete(url, get_headers())
|
89
|
+
response.code == 204
|
90
|
+
end
|
92
91
|
|
93
92
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
end
|
120
|
-
Components::ResultSet.new(files, body['meta'])
|
93
|
+
# Retrieve all files in the Trash folder
|
94
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
95
|
+
# Allowed parameters include:
|
96
|
+
# type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
|
97
|
+
# sort_by - The method to sort by, valid values are :
|
98
|
+
# ADDED_DATE - sorts by date folder was added, ascending (earliest to latest)
|
99
|
+
# ADDED_DATE_DESC - (default) sorts by date folder was added, descending (latest to earliest)
|
100
|
+
# MODIFIED_DATE - sorts by date folder was last modified, ascending (earliest to latest)
|
101
|
+
# MODIFIED_DATE_DESC - sorts by date folder was last modified, descending (latest to earliest)
|
102
|
+
# NAME - sorts alphabetically by file name, a to z
|
103
|
+
# NAME_DESC - sorts alphabetically by file name, z to a
|
104
|
+
# SIZE - sorts by file size, smallest to largest
|
105
|
+
# SIZE_DESC - sorts by file size, largest to smallest
|
106
|
+
# DIMENSION - sorts by file dimensions (hxw), smallest to largest
|
107
|
+
# DIMENSION_DESC - sorts by file dimensions (hxw), largest to smallest
|
108
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
109
|
+
# @return [ResultSet<LibraryFile>]
|
110
|
+
def get_library_trash(params)
|
111
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folder_trash')
|
112
|
+
url = build_url(url, params)
|
113
|
+
response = RestClient.get(url, get_headers())
|
114
|
+
files = []
|
115
|
+
body = JSON.parse(response.body)
|
116
|
+
body['results'].each do |file|
|
117
|
+
files << Components::LibraryFile.create(file)
|
121
118
|
end
|
119
|
+
Components::ResultSet.new(files, body['meta'])
|
120
|
+
end
|
122
121
|
|
123
122
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
123
|
+
# Permanently deletes all files in the Trash folder
|
124
|
+
# @return [Boolean]
|
125
|
+
def delete_library_trash()
|
126
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folder_trash')
|
127
|
+
url = build_url(url)
|
128
|
+
response = RestClient.delete(url, get_headers())
|
129
|
+
response.code == 204
|
130
|
+
end
|
132
131
|
|
133
132
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
157
|
-
Components::ResultSet.new(files, body['meta'])
|
133
|
+
# Retrieve a collection of MyLibrary files in the Constant Contact account
|
134
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
135
|
+
# Allowed parameters include:
|
136
|
+
# type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
|
137
|
+
# source - Specifies to retrieve files from a particular source, valid values are :
|
138
|
+
# ALL - (default) files from all sources
|
139
|
+
# MyComputer
|
140
|
+
# StockImage
|
141
|
+
# Facebook
|
142
|
+
# Instagram
|
143
|
+
# Shutterstock
|
144
|
+
# Mobile
|
145
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 1000, default = 50.
|
146
|
+
# @return [ResultSet<LibraryFile>]
|
147
|
+
def get_library_files(params = {})
|
148
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_files')
|
149
|
+
url = build_url(url, params)
|
150
|
+
response = RestClient.get(url, get_headers())
|
151
|
+
files = []
|
152
|
+
body = JSON.parse(response.body)
|
153
|
+
body['results'].each do |file|
|
154
|
+
files << Components::LibraryFile.create(file)
|
158
155
|
end
|
156
|
+
Components::ResultSet.new(files, body['meta'])
|
157
|
+
end
|
159
158
|
|
160
159
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
end
|
177
|
-
Components::ResultSet.new(files, body['meta'])
|
160
|
+
# Retrieves all files from a MyLibrary folder specified by the folder_id path parameter
|
161
|
+
# @param [String] folder_id - Specifies the folder from which to retrieve files
|
162
|
+
# @param [Hash] params - hash of query parameters and values to append to the request.
|
163
|
+
# Allowed parameters include:
|
164
|
+
# limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
|
165
|
+
# @return [ResultSet<LibraryFile>]
|
166
|
+
def get_library_files_by_folder(folder_id, params = {})
|
167
|
+
url = Util::Config.get('endpoints.base_url') +
|
168
|
+
sprintf(Util::Config.get('endpoints.library_files_by_folder'), folder_id)
|
169
|
+
url = build_url(url, params)
|
170
|
+
response = RestClient.get(url, get_headers())
|
171
|
+
files = []
|
172
|
+
body = JSON.parse(response.body)
|
173
|
+
body['results'].each do |file|
|
174
|
+
files << Components::LibraryFile.create(file)
|
178
175
|
end
|
176
|
+
Components::ResultSet.new(files, body['meta'])
|
177
|
+
end
|
179
178
|
|
180
179
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
180
|
+
# Retrieve a MyLibrary file using the file_id path parameter
|
181
|
+
# @param [String] file_id - Specifies the MyLibrary file for which to retrieve information
|
182
|
+
# @return [LibraryFile]
|
183
|
+
def get_library_file(file_id)
|
184
|
+
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file_id)
|
185
|
+
url = build_url(url)
|
186
|
+
response = RestClient.get(url, get_headers())
|
187
|
+
Components::LibraryFile.create(JSON.parse(response.body))
|
188
|
+
end
|
190
189
|
|
191
190
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
191
|
+
# Adds a new MyLibrary file using the multipart content-type
|
192
|
+
# @param [String] file_name - The name of the file (ie: dinnerplate-special.jpg)
|
193
|
+
# @param [String] folder_id - Folder id to add the file to
|
194
|
+
# @param [String] description - The description of the file provided by user
|
195
|
+
# @param [String] source - indicates the source of the original file;
|
196
|
+
# image files can be uploaded from the following sources :
|
197
|
+
# MyComputer, StockImage, Facebook - MyLibrary Plus customers only,
|
198
|
+
# Instagram - MyLibrary Plus customers only, Shutterstock, Mobile
|
199
|
+
# @param [String] file_type - Specifies the file type, valid values are: JPEG, JPG, GIF, PDF, PNG
|
200
|
+
# @param [String] contents - The content of the file
|
201
|
+
# @return [LibraryFile]
|
202
|
+
def add_library_file(file_name, folder_id, description, source, file_type, contents)
|
203
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_files')
|
204
|
+
url = build_url(url)
|
205
|
+
|
206
|
+
payload = { :file_name => file_name, :folder_id => folder_id,
|
207
|
+
:description => description, :source => source, :file_type => file_type,
|
208
|
+
:data => contents, :multipart => true }
|
209
|
+
|
210
|
+
response = RestClient.post(url, payload, get_headers())
|
211
|
+
location = response.headers[:location] || ''
|
212
|
+
location.split('/').last
|
213
|
+
end
|
215
214
|
|
216
215
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
216
|
+
# Update information for a specific MyLibrary file
|
217
|
+
# @param [LibraryFile] file - Library File to be updated
|
218
|
+
# @return [LibraryFile]
|
219
|
+
def update_library_file(file)
|
220
|
+
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file.id)
|
221
|
+
url = build_url(url)
|
222
|
+
payload = file.to_json
|
223
|
+
response = RestClient.put(url, payload, get_headers())
|
224
|
+
Components::LibraryFile.create(JSON.parse(response.body))
|
225
|
+
end
|
227
226
|
|
228
227
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
228
|
+
# Delete one or more MyLibrary files specified by the fileId path parameter;
|
229
|
+
# separate multiple file IDs with a comma.
|
230
|
+
# Deleted files are moved from their current folder into the system Trash folder, and its status is set to Deleted.
|
231
|
+
# @param [String] file_id - Specifies the MyLibrary file to delete
|
232
|
+
# @return [Boolean]
|
233
|
+
def delete_library_file(file_id)
|
234
|
+
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file_id)
|
235
|
+
url = build_url(url)
|
236
|
+
response = RestClient.delete(url, get_headers())
|
237
|
+
response.code == 204
|
238
|
+
end
|
240
239
|
|
241
240
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
end
|
255
|
-
statuses
|
241
|
+
# Retrieve the upload status for one or more MyLibrary files using the file_id path parameter;
|
242
|
+
# separate multiple file IDs with a comma
|
243
|
+
# @param [String] file_id - Specifies the files for which to retrieve upload status information
|
244
|
+
# @return [Array<UploadStatus>]
|
245
|
+
def get_library_files_upload_status(file_id)
|
246
|
+
url = Util::Config.get('endpoints.base_url') +
|
247
|
+
sprintf(Util::Config.get('endpoints.library_file_upload_status'), file_id)
|
248
|
+
url = build_url(url)
|
249
|
+
response = RestClient.get(url, get_headers())
|
250
|
+
statuses = []
|
251
|
+
JSON.parse(response.body).each do |status|
|
252
|
+
statuses << Components::UploadStatus.create(status)
|
256
253
|
end
|
254
|
+
statuses
|
255
|
+
end
|
257
256
|
|
258
257
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
end
|
275
|
-
results
|
258
|
+
# Move one or more MyLibrary files to a different folder in the user's account
|
259
|
+
# specify the destination folder using the folder_id path parameter.
|
260
|
+
# @param [String] folder_id - Specifies the destination MyLibrary folder to which the files will be moved
|
261
|
+
# @param [String] file_id - Specifies the files to move, in a string of comma separated file ids (e.g. 8,9)
|
262
|
+
# @return [Array<MoveResults>]
|
263
|
+
def move_library_files(folder_id, file_id)
|
264
|
+
url = Util::Config.get('endpoints.base_url') +
|
265
|
+
sprintf(Util::Config.get('endpoints.library_file_move'), folder_id)
|
266
|
+
url = build_url(url)
|
267
|
+
|
268
|
+
payload = file_id.split(',').map {|id| id.strip}.to_json
|
269
|
+
response = RestClient.put(url, payload, get_headers())
|
270
|
+
results = []
|
271
|
+
JSON.parse(response.body).each do |result|
|
272
|
+
results << Components::MoveResults.create(result)
|
276
273
|
end
|
277
|
-
|
274
|
+
results
|
278
275
|
end
|
276
|
+
|
279
277
|
end
|
280
278
|
end
|
281
279
|
end
|