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,297 @@
1
+ #
2
+ # library_service.rb
3
+ # ConstantContact
4
+ #
5
+ # Copyright (c) 2013 Constant Contact. All rights reserved.
6
+
7
+ module ConstantContact
8
+ module Services
9
+ class LibraryService < BaseService
10
+ class << self
11
+
12
+ # Retrieve MyLibrary usage information
13
+ # @param [String] access_token - Constant Contact OAuth2 access token
14
+ # @return [LibrarySummary]
15
+ def get_library_info(access_token)
16
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_info')
17
+
18
+ response = RestClient.get(url, get_headers(access_token))
19
+ Components::LibrarySummary.create(JSON.parse(response.body).first)
20
+ end
21
+
22
+
23
+ # Retrieve a list of MyLibrary folders
24
+ # @param [String] access_token - Constant Contact OAuth2 access token
25
+ # @param [Hash] params - hash of query parameters and values to append to the request.
26
+ # Allowed parameters include:
27
+ # sort_by - The method to sort by, valid values are :
28
+ # CREATED_DATE - sorts by date folder was added, ascending (earliest to latest)
29
+ # CREATED_DATE_DESC - (default) sorts by date folder was added, descending (latest to earliest)
30
+ # MODIFIED_DATE - sorts by date folder was last modified, ascending (earliest to latest)
31
+ # MODIFIED_DATE_DESC - sorts by date folder was last modified, descending (latest to earliest)
32
+ # NAME - sorts alphabetically by folder name, a to z
33
+ # NAME_DESC - sorts alphabetically by folder name, z to a
34
+ # limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
35
+ # @return [ResultSet<LibraryFolder>]
36
+ def get_library_folders(access_token, params)
37
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folders')
38
+ url = build_url(url, params)
39
+ response = RestClient.get(url, get_headers(access_token))
40
+ folders = []
41
+ body = JSON.parse(response.body)
42
+ body['results'].each do |folder|
43
+ folders << Components::LibraryFolder.create(folder)
44
+ end
45
+ Components::ResultSet.new(folders, body['meta'])
46
+ end
47
+
48
+
49
+ # Create a new MyLibrary folder
50
+ # @param [String] access_token - Constant Contact OAuth2 access token
51
+ # @param [LibraryFolder] folder - MyLibrary folder to be created
52
+ # @return [LibraryFolder]
53
+ def add_library_folder(access_token, folder)
54
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folders')
55
+ url = build_url(url)
56
+ payload = folder.to_json
57
+ response = RestClient.post(url, payload, get_headers(access_token))
58
+ Components::LibraryFolder.create(JSON.parse(response.body))
59
+ end
60
+
61
+
62
+ # Retrieve a specific MyLibrary folder using the folder_id path parameter
63
+ # @param [String] access_token - Constant Contact OAuth2 access token
64
+ # @param [String] folder_id - The ID for the folder to return
65
+ # @return [LibraryFolder]
66
+ def get_library_folder(access_token, folder_id)
67
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_folder'), folder_id)
68
+ url = build_url(url)
69
+ response = RestClient.get(url, get_headers(access_token))
70
+ Components::LibraryFolder.create(JSON.parse(response.body))
71
+ end
72
+
73
+
74
+ # Update a specific MyLibrary folder
75
+ # @param [String] access_token - Constant Contact OAuth2 access token
76
+ # @param [LibraryFolder] folder - MyLibrary folder to be updated
77
+ # @return [LibraryFolder]
78
+ def update_library_folder(access_token, folder)
79
+ url = Util::Config.get('endpoints.base_url') +
80
+ sprintf(Util::Config.get('endpoints.library_folder'), folder.id)
81
+ url = build_url(url)
82
+ payload = folder.to_json
83
+ response = RestClient.put(url, payload, get_headers(access_token))
84
+ Components::LibraryFolder.create(JSON.parse(response.body))
85
+ end
86
+
87
+
88
+ # Delete a MyLibrary folder
89
+ # @param [String] access_token - Constant Contact OAuth2 access token
90
+ # @param [String] folder_id - The ID for the MyLibrary folder to delete
91
+ # @return [Boolean]
92
+ def delete_library_folder(access_token, folder_id)
93
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_folder'), folder_id)
94
+ url = build_url(url)
95
+ response = RestClient.delete(url, get_headers(access_token))
96
+ response.code == 204
97
+ end
98
+
99
+
100
+ # Retrieve all files in the Trash folder
101
+ # @param [String] access_token - Constant Contact OAuth2 access token
102
+ # @param [Hash] params - hash of query parameters and values to append to the request.
103
+ # Allowed parameters include:
104
+ # type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
105
+ # sort_by - The method to sort by, valid values are :
106
+ # ADDED_DATE - sorts by date folder was added, ascending (earliest to latest)
107
+ # ADDED_DATE_DESC - (default) sorts by date folder was added, descending (latest to earliest)
108
+ # MODIFIED_DATE - sorts by date folder was last modified, ascending (earliest to latest)
109
+ # MODIFIED_DATE_DESC - sorts by date folder was last modified, descending (latest to earliest)
110
+ # NAME - sorts alphabetically by file name, a to z
111
+ # NAME_DESC - sorts alphabetically by file name, z to a
112
+ # SIZE - sorts by file size, smallest to largest
113
+ # SIZE_DESC - sorts by file size, largest to smallest
114
+ # DIMENSION - sorts by file dimensions (hxw), smallest to largest
115
+ # DIMENSION_DESC - sorts by file dimensions (hxw), largest to smallest
116
+ # limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
117
+ # @return [ResultSet<LibraryFile>]
118
+ def get_library_trash(access_token, params)
119
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folder_trash')
120
+ url = build_url(url, params)
121
+ response = RestClient.get(url, get_headers(access_token))
122
+ files = []
123
+ body = JSON.parse(response.body)
124
+ body['results'].each do |file|
125
+ files << Components::LibraryFile.create(file)
126
+ end
127
+ Components::ResultSet.new(files, body['meta'])
128
+ end
129
+
130
+
131
+ # Permanently deletes all files in the Trash folder
132
+ # @param [String] access_token - Constant Contact OAuth2 access token
133
+ # @return [Boolean]
134
+ def delete_library_trash(access_token)
135
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_folder_trash')
136
+ url = build_url(url)
137
+ response = RestClient.delete(url, get_headers(access_token))
138
+ response.code == 204
139
+ end
140
+
141
+
142
+ # Retrieve a collection of MyLibrary files in the Constant Contact account
143
+ # @param [String] access_token - Constant Contact OAuth2 access token
144
+ # @param [Hash] params - hash of query parameters and values to append to the request.
145
+ # Allowed parameters include:
146
+ # type - Specifies the type of files to retrieve, valid values are : ALL, IMAGES, or DOCUMENTS
147
+ # source - Specifies to retrieve files from a particular source, valid values are :
148
+ # ALL - (default) files from all sources
149
+ # MyComputer
150
+ # StockImage
151
+ # Facebook
152
+ # Instagram
153
+ # Shutterstock
154
+ # Mobile
155
+ # limit - Specifies the number of results displayed per page of output, from 1 - 1000, default = 50.
156
+ # @return [ResultSet<LibraryFile>]
157
+ def get_library_files(access_token, params = {})
158
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_files')
159
+ url = build_url(url, params)
160
+ response = RestClient.get(url, get_headers(access_token))
161
+ files = []
162
+ body = JSON.parse(response.body)
163
+ body['results'].each do |file|
164
+ files << Components::LibraryFile.create(file)
165
+ end
166
+ Components::ResultSet.new(files, body['meta'])
167
+ end
168
+
169
+
170
+ # 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
+ # @param [String] folder_id - Specifies the folder from which to retrieve files
173
+ # @param [Hash] params - hash of query parameters and values to append to the request.
174
+ # Allowed parameters include:
175
+ # limit - Specifies the number of results displayed per page of output, from 1 - 50, default = 50.
176
+ # @return [ResultSet<LibraryFile>]
177
+ def get_library_files_by_folder(access_token, folder_id, params = {})
178
+ url = Util::Config.get('endpoints.base_url') +
179
+ sprintf(Util::Config.get('endpoints.library_files_by_folder'), folder_id)
180
+ url = build_url(url, params)
181
+ response = RestClient.get(url, get_headers(access_token))
182
+ files = []
183
+ body = JSON.parse(response.body)
184
+ body['results'].each do |file|
185
+ files << Components::LibraryFile.create(file)
186
+ end
187
+ Components::ResultSet.new(files, body['meta'])
188
+ end
189
+
190
+
191
+ # Retrieve a MyLibrary file using the file_id path parameter
192
+ # @param [String] access_token - Constant Contact OAuth2 access token
193
+ # @param [String] file_id - Specifies the MyLibrary file for which to retrieve information
194
+ # @return [LibraryFile]
195
+ def get_library_file(access_token, file_id)
196
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file_id)
197
+ url = build_url(url)
198
+ response = RestClient.get(url, get_headers(access_token))
199
+ Components::LibraryFile.create(JSON.parse(response.body))
200
+ end
201
+
202
+
203
+ # Adds a new MyLibrary file using the multipart content-type
204
+ # @param [String] access_token - Constant Contact OAuth2 access token
205
+ # @param [String] file_name - The name of the file (ie: dinnerplate-special.jpg)
206
+ # @param [String] folder_id - Folder id to add the file to
207
+ # @param [String] description - The description of the file provided by user
208
+ # @param [String] source - indicates the source of the original file;
209
+ # image files can be uploaded from the following sources :
210
+ # MyComputer, StockImage, Facebook - MyLibrary Plus customers only,
211
+ # Instagram - MyLibrary Plus customers only, Shutterstock, Mobile
212
+ # @param [String] file_type - Specifies the file type, valid values are: JPEG, JPG, GIF, PDF, PNG
213
+ # @param [String] contents - The content of the file
214
+ # @return [LibraryFile]
215
+ def add_library_file(access_token, file_name, folder_id, description, source, file_type, contents)
216
+ url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.library_files')
217
+ url = build_url(url)
218
+
219
+ payload = { :file_name => file_name, :folder_id => folder_id,
220
+ :description => description, :source => source, :file_type => file_type,
221
+ :data => contents, :multipart => true }
222
+
223
+ response = RestClient.post(url, payload, get_headers(access_token))
224
+ location = response.headers[:location] || ''
225
+ location.split('/').last
226
+ end
227
+
228
+
229
+ # Update information for a specific MyLibrary file
230
+ # @param [String] access_token - Constant Contact OAuth2 access token
231
+ # @param [LibraryFile] file - Library File to be updated
232
+ # @return [LibraryFile]
233
+ def update_library_file(access_token, file)
234
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file.id)
235
+ url = build_url(url)
236
+ payload = file.to_json
237
+ response = RestClient.put(url, payload, get_headers(access_token))
238
+ Components::LibraryFile.create(JSON.parse(response.body))
239
+ end
240
+
241
+
242
+ # Delete one or more MyLibrary files specified by the fileId path parameter;
243
+ # separate multiple file IDs with a comma.
244
+ # 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
+ # @param [String] file_id - Specifies the MyLibrary file to delete
247
+ # @return [Boolean]
248
+ def delete_library_file(access_token, file_id)
249
+ url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.library_file'), file_id)
250
+ url = build_url(url)
251
+ response = RestClient.delete(url, get_headers(access_token))
252
+ response.code == 204
253
+ end
254
+
255
+
256
+ # Retrieve the upload status for one or more MyLibrary files using the file_id path parameter;
257
+ # separate multiple file IDs with a comma
258
+ # @param [String] access_token - Constant Contact OAuth2 access token
259
+ # @param [String] file_id - Specifies the files for which to retrieve upload status information
260
+ # @return [Array<UploadStatus>]
261
+ def get_library_files_upload_status(access_token, file_id)
262
+ url = Util::Config.get('endpoints.base_url') +
263
+ sprintf(Util::Config.get('endpoints.library_file_upload_status'), file_id)
264
+ url = build_url(url)
265
+ response = RestClient.get(url, get_headers(access_token))
266
+ statuses = []
267
+ JSON.parse(response.body).each do |status|
268
+ statuses << Components::UploadStatus.create(status)
269
+ end
270
+ statuses
271
+ end
272
+
273
+
274
+ # Move one or more MyLibrary files to a different folder in the user's account
275
+ # specify the destination folder using the folder_id path parameter.
276
+ # @param [String] access_token - Constant Contact OAuth2 access token
277
+ # @param [String] folder_id - Specifies the destination MyLibrary folder to which the files will be moved
278
+ # @param [String] file_id - Specifies the files to move, in a string of comma separated file ids (e.g. 8,9)
279
+ # @return [Array<MoveResults>]
280
+ def move_library_files(access_token, folder_id, file_id)
281
+ url = Util::Config.get('endpoints.base_url') +
282
+ sprintf(Util::Config.get('endpoints.library_file_move'), folder_id)
283
+ url = build_url(url)
284
+
285
+ payload = file_id.split(',').map {|id| id.strip}.to_json
286
+ response = RestClient.put(url, payload, get_headers(access_token))
287
+ results = []
288
+ JSON.parse(response.body).each do |result|
289
+ results << Components::MoveResults.create(result)
290
+ end
291
+ results
292
+ end
293
+
294
+ end
295
+ end
296
+ end
297
+ end
@@ -11,10 +11,11 @@ module ConstantContact
11
11
 
12
12
  # Get lists within an account
13
13
  # @param [String] access_token - Constant Contact OAuth2 access token
14
+ # @param [Hash] params - query parameters to be appended to the request
14
15
  # @return [Array<ContactList>]
15
- def get_lists(access_token)
16
+ def get_lists(access_token, params = {})
16
17
  url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.lists')
17
- url = build_url(url)
18
+ url = build_url(url, params)
18
19
  response = RestClient.get(url, get_headers(access_token))
19
20
  lists = []
20
21
  JSON.parse(response.body).each do |contact|
@@ -65,11 +66,11 @@ module ConstantContact
65
66
  # Get all contacts from an individual list
66
67
  # @param [String] access_token - Constant Contact OAuth2 access token
67
68
  # @param [Integer] list_id - list id to retrieve contacts for
68
- # @param [Hash] param - query parameters to attach to request
69
+ # @param [Hash] params - query parameters to attach to request
69
70
  # @return [Array<Contact>]
70
- def get_contacts_from_list(access_token, list_id, param = nil)
71
+ def get_contacts_from_list(access_token, list_id, params = nil)
71
72
  url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.list_contacts'), list_id)
72
- url = build_url(url, param)
73
+ url = build_url(url, params)
73
74
  response = RestClient.get(url, get_headers(access_token))
74
75
  contacts = []
75
76
  body = JSON.parse(response.body)
@@ -5,142 +5,160 @@
5
5
  # Copyright (c) 2013 Constant Contact. All rights reserved.
6
6
 
7
7
  module ConstantContact
8
- module Util
9
- class Config
8
+ module Util
9
+ class Config
10
10
 
11
- # Return a hash of configuration strings
12
- # @return [Hash] - hash of configuration properties
13
- @props = {
14
- # REST endpoints
15
- :endpoints => {
16
- :base_url => 'https://api.constantcontact.com/v2/',
11
+ # Return a hash of configuration strings
12
+ # @return [Hash] - hash of configuration properties
13
+ @props = {
14
+ # REST endpoints
15
+ :endpoints => {
16
+ :base_url => 'https://api.constantcontact.com/v2/',
17
17
 
18
- :activity => 'activities/%s',
19
- :activities => 'activities',
20
- :export_contacts_activity => 'activities/exportcontacts',
21
- :clear_lists_activity => 'activities/clearlists',
22
- :remove_from_lists_activity => 'activities/removefromlists',
23
- :add_contacts_activity => 'activities/addcontacts',
18
+ :activity => 'activities/%s',
19
+ :activities => 'activities',
20
+ :export_contacts_activity => 'activities/exportcontacts',
21
+ :clear_lists_activity => 'activities/clearlists',
22
+ :remove_from_lists_activity => 'activities/removefromlists',
23
+ :add_contacts_activity => 'activities/addcontacts',
24
24
 
25
- :account_verified_addresses => 'account/verifiedemailaddresses',
25
+ :account_verified_addresses => 'account/verifiedemailaddresses',
26
26
 
27
- :contact => 'contacts/%s',
28
- :contacts => 'contacts',
29
- :lists => 'lists',
30
- :list => 'lists/%s',
31
- :list_contacts => 'lists/%s/contacts',
32
- :contact_lists => 'contacts/%s/lists',
33
- :contact_list => 'contacts/%s/lists/%s',
27
+ :contact => 'contacts/%s',
28
+ :contacts => 'contacts',
29
+ :lists => 'lists',
30
+ :list => 'lists/%s',
31
+ :list_contacts => 'lists/%s/contacts',
32
+ :contact_lists => 'contacts/%s/lists',
33
+ :contact_list => 'contacts/%s/lists/%s',
34
34
 
35
- :campaigns => 'emailmarketing/campaigns',
36
- :campaign => 'emailmarketing/campaigns/%s',
37
- :campaign_schedules => 'emailmarketing/campaigns/%s/schedules',
38
- :campaign_schedule => 'emailmarketing/campaigns/%s/schedules/%s',
39
- :campaign_test_sends => 'emailmarketing/campaigns/%s/tests',
40
- :campaign_tracking_summary => 'emailmarketing/campaigns/%s/tracking/reports/summary',
41
- :campaign_tracking_bounces => 'emailmarketing/campaigns/%s/tracking/bounces',
42
- :campaign_tracking_clicks => 'emailmarketing/campaigns/%s/tracking/clicks',
43
- :campaign_tracking_forwards => 'emailmarketing/campaigns/%s/tracking/forwards',
44
- :campaign_tracking_opens => 'emailmarketing/campaigns/%s/tracking/opens',
45
- :campaign_tracking_sends => 'emailmarketing/campaigns/%s/tracking/sends',
46
- :campaign_tracking_unsubscribes => 'emailmarketing/campaigns/%s/tracking/unsubscribes',
47
- :campaign_tracking_link => 'emailmarketing/campaigns/%s/tracking/clicks/%s',
35
+ :campaigns => 'emailmarketing/campaigns',
36
+ :campaign => 'emailmarketing/campaigns/%s',
37
+ :campaign_schedules => 'emailmarketing/campaigns/%s/schedules',
38
+ :campaign_schedule => 'emailmarketing/campaigns/%s/schedules/%s',
39
+ :campaign_test_sends => 'emailmarketing/campaigns/%s/tests',
40
+ :campaign_tracking_summary => 'emailmarketing/campaigns/%s/tracking/reports/summary',
41
+ :campaign_tracking_bounces => 'emailmarketing/campaigns/%s/tracking/bounces',
42
+ :campaign_tracking_clicks => 'emailmarketing/campaigns/%s/tracking/clicks',
43
+ :campaign_tracking_forwards => 'emailmarketing/campaigns/%s/tracking/forwards',
44
+ :campaign_tracking_opens => 'emailmarketing/campaigns/%s/tracking/opens',
45
+ :campaign_tracking_sends => 'emailmarketing/campaigns/%s/tracking/sends',
46
+ :campaign_tracking_unsubscribes => 'emailmarketing/campaigns/%s/tracking/unsubscribes',
47
+ :campaign_tracking_link => 'emailmarketing/campaigns/%s/tracking/clicks/%s',
48
48
 
49
- :contact_tracking_summary => 'contacts/%s/tracking/reports/summary',
50
- :contact_tracking_bounces => 'contacts/%s/tracking/bounces',
51
- :contact_tracking_clicks => 'contacts/%s/tracking/clicks',
52
- :contact_tracking_forwards => 'contacts/%s/tracking/forwards',
53
- :contact_tracking_opens => 'contacts/%s/tracking/opens',
54
- :contact_tracking_sends => 'contacts/%s/tracking/sends',
55
- :contact_tracking_unsubscribes => 'contacts/%s/tracking/unsubscribes',
56
- :contact_tracking_link => 'contacts/%s/tracking/clicks/%s'
57
- },
49
+ :events => 'eventspot/events',
50
+ :event => 'eventspot/events/%s',
51
+ :event_fees => 'eventspot/events/%s/fees',
52
+ :event_fee => 'eventspot/events/%s/fees/%s',
53
+ :event_registrants => 'eventspot/events/%s/registrants',
54
+ :event_registrant => 'eventspot/events/%s/registrants/%s',
58
55
 
59
- # OAuth2 Authorization related configuration options
60
- :auth => {
61
- :base_url => 'https://oauth2.constantcontact.com/oauth2/',
62
- :response_type_code => 'code',
63
- :response_type_token => 'token',
64
- :authorization_code_grant_type => 'authorization_code',
65
- :authorization_endpoint => 'oauth/siteowner/authorize',
66
- :token_endpoint => 'oauth/token',
56
+ :contact_tracking_summary => 'contacts/%s/tracking/reports/summary',
57
+ :contact_tracking_bounces => 'contacts/%s/tracking/bounces',
58
+ :contact_tracking_clicks => 'contacts/%s/tracking/clicks',
59
+ :contact_tracking_forwards => 'contacts/%s/tracking/forwards',
60
+ :contact_tracking_opens => 'contacts/%s/tracking/opens',
61
+ :contact_tracking_sends => 'contacts/%s/tracking/sends',
62
+ :contact_tracking_unsubscribes => 'contacts/%s/tracking/unsubscribes',
63
+ :contact_tracking_link => 'contacts/%s/tracking/clicks/%s',
64
+
65
+ :library_info => 'library/info',
66
+ :library_files => 'library/files',
67
+ :library_files_by_folder => 'library/folders/%s/files',
68
+ :library_folders => 'library/folders',
69
+ :library_folder => 'library/folders/%s',
70
+ :library_folder_trash => 'library/folders/trash/files',
71
+ :library_file => 'library/files/%s',
72
+ :library_file_upload_status => 'library/files/uploadstatus/%s',
73
+ :library_file_move => 'library/folders/%s/files'
74
+ },
75
+
76
+ # OAuth2 Authorization related configuration options
77
+ :auth => {
78
+ :base_url => 'https://oauth2.constantcontact.com/oauth2/',
79
+ :response_type_code => 'code',
80
+ :response_type_token => 'token',
81
+ :authorization_code_grant_type => 'authorization_code',
82
+ :authorization_endpoint => 'oauth/siteowner/authorize',
83
+ :token_endpoint => 'oauth/token',
84
+ :token_info => 'tokeninfo.htm',
67
85
  :api_key => '',
68
86
  :api_secret => '',
69
87
  :redirect_uri => ''
70
- },
88
+ },
71
89
 
72
- # Column names used with bulk activities
73
- :activities_columns => {
74
- :email => 'EMAIL',
75
- :first_name => 'FIRST NAME',
76
- :middle_name => 'MIDDLE NAME',
77
- :last_name => 'LAST NAME',
78
- :job_title => 'JOB TITLE',
79
- :company_name => 'COMPANY NAME',
80
- :work_phone => 'WORK PHONE',
81
- :home_phone => 'HOME PHONE',
82
- :address1 => 'ADDRESS LINE 1',
83
- :address2 => 'ADDRESS LINE 2',
84
- :address3 => 'ADDRESS LINE 3',
85
- :city => 'CITY',
86
- :state => 'STATE',
87
- :state_province => 'US STATE/CA PROVINCE',
88
- :country => 'COUNTRY',
89
- :postal_code => 'ZIP/POSTAL CODE',
90
- :sub_postal_code => 'SUB ZIP/POSTAL CODE',
91
- :custom_field_1 => 'CUSTOM FIELD 1',
92
- :custom_field_2 => 'CUSTOM FIELD 2',
93
- :custom_field_3 => 'CUSTOM FIELD 3',
94
- :custom_field_4 => 'CUSTOM FIELD 4',
95
- :custom_field_5 => 'CUSTOM FIELD 5',
96
- :custom_field_6 => 'CUSTOM FIELD 6',
97
- :custom_field_7 => 'CUSTOM FIELD 7',
98
- :custom_field_8 => 'CUSTOM FIELD 8',
99
- :custom_field_9 => 'CUSTOM FIELD 9',
100
- :custom_field_10 => 'CUSTOM FIELD 10',
101
- :custom_field_11 => 'CUSTOM FIELD 11',
102
- :custom_field_12 => 'CUSTOM FIELD 12',
103
- :custom_field_13 => 'CUSTOM FIELD 13',
104
- :custom_field_14 => 'CUSTOM FIELD 14',
105
- :custom_field_15 => 'CUSTOM FIELD 15'
106
- },
90
+ # Column names used with bulk activities
91
+ :activities_columns => {
92
+ :email => 'EMAIL',
93
+ :first_name => 'FIRST NAME',
94
+ :middle_name => 'MIDDLE NAME',
95
+ :last_name => 'LAST NAME',
96
+ :job_title => 'JOB TITLE',
97
+ :company_name => 'COMPANY NAME',
98
+ :work_phone => 'WORK PHONE',
99
+ :home_phone => 'HOME PHONE',
100
+ :address1 => 'ADDRESS LINE 1',
101
+ :address2 => 'ADDRESS LINE 2',
102
+ :address3 => 'ADDRESS LINE 3',
103
+ :city => 'CITY',
104
+ :state => 'STATE',
105
+ :state_province => 'US STATE/CA PROVINCE',
106
+ :country => 'COUNTRY',
107
+ :postal_code => 'ZIP/POSTAL CODE',
108
+ :sub_postal_code => 'SUB ZIP/POSTAL CODE',
109
+ :custom_field_1 => 'CUSTOM FIELD 1',
110
+ :custom_field_2 => 'CUSTOM FIELD 2',
111
+ :custom_field_3 => 'CUSTOM FIELD 3',
112
+ :custom_field_4 => 'CUSTOM FIELD 4',
113
+ :custom_field_5 => 'CUSTOM FIELD 5',
114
+ :custom_field_6 => 'CUSTOM FIELD 6',
115
+ :custom_field_7 => 'CUSTOM FIELD 7',
116
+ :custom_field_8 => 'CUSTOM FIELD 8',
117
+ :custom_field_9 => 'CUSTOM FIELD 9',
118
+ :custom_field_10 => 'CUSTOM FIELD 10',
119
+ :custom_field_11 => 'CUSTOM FIELD 11',
120
+ :custom_field_12 => 'CUSTOM FIELD 12',
121
+ :custom_field_13 => 'CUSTOM FIELD 13',
122
+ :custom_field_14 => 'CUSTOM FIELD 14',
123
+ :custom_field_15 => 'CUSTOM FIELD 15'
124
+ },
107
125
 
108
- # Errors to be returned for various exceptions
109
- :errors => {
110
- :id_or_object => 'Only an id or %s object are allowed for this method.'
111
- }
112
- }
126
+ # Errors to be returned for various exceptions
127
+ :errors => {
128
+ :id_or_object => 'Only an id or %s object are allowed for this method.'
129
+ }
130
+ }
113
131
 
114
- class << self
132
+ class << self
115
133
  attr_accessor :props
116
134
 
117
- def configure
135
+ def configure
118
136
  yield props if block_given?
119
137
  end
120
138
 
121
- # Get a configuration property given a specified location, example usage: Config::get('auth.token_endpoint')
122
- # @param [String] index - location of the property to obtain
123
- # @return [String]
124
- def get(index)
125
- properties = index.split('.')
126
- get_value(properties, props)
127
- end
139
+ # Get a configuration property given a specified location, example usage: Config::get('auth.token_endpoint')
140
+ # @param [String] index - location of the property to obtain
141
+ # @return [String]
142
+ def get(index)
143
+ properties = index.split('.')
144
+ get_value(properties, props)
145
+ end
128
146
 
129
- private
147
+ private
130
148
 
131
- # Navigate through a config array looking for a particular index
132
- # @param [Array] index The index sequence we are navigating down
133
- # @param [Hash, String] value The portion of the config array to process
134
- # @return [String]
135
- def get_value(index, value)
136
- index = index.is_a?(Array) ? index : [index]
137
- key = index.shift.to_sym
138
- value.is_a?(Hash) and value[key] and value[key].is_a?(Hash) ?
139
- get_value(index, value[key]) :
140
- value[key]
141
- end
142
- end
149
+ # Navigate through a config array looking for a particular index
150
+ # @param [Array] index The index sequence we are navigating down
151
+ # @param [Hash, String] value The portion of the config array to process
152
+ # @return [String]
153
+ def get_value(index, value)
154
+ index = index.is_a?(Array) ? index : [index]
155
+ key = index.shift.to_sym
156
+ value.is_a?(Hash) and value[key] and value[key].is_a?(Hash) ?
157
+ get_value(index, value[key]) :
158
+ value[key]
159
+ end
160
+ end
143
161
 
144
- end
145
- end
162
+ end
163
+ end
146
164
  end