constantcontact-ruby 2.2.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 +7 -0
- data/.rspec +2 -0
- data/README.md +136 -0
- data/constantcontact-ruby.gemspec +31 -0
- data/lib/constantcontact/api.rb +1012 -0
- data/lib/constantcontact/auth/oauth2.rb +105 -0
- data/lib/constantcontact/auth/session_data_store.rb +69 -0
- data/lib/constantcontact/components/account/account_address.rb +26 -0
- data/lib/constantcontact/components/account/account_info.rb +38 -0
- data/lib/constantcontact/components/account/verified_email_address.rb +26 -0
- data/lib/constantcontact/components/activities/activity.rb +43 -0
- data/lib/constantcontact/components/activities/activity_error.rb +26 -0
- data/lib/constantcontact/components/activities/add_contacts.rb +127 -0
- data/lib/constantcontact/components/activities/add_contacts_import_data.rb +46 -0
- data/lib/constantcontact/components/activities/export_contacts.rb +30 -0
- data/lib/constantcontact/components/component.rb +48 -0
- data/lib/constantcontact/components/contacts/address.rb +27 -0
- data/lib/constantcontact/components/contacts/contact.rb +92 -0
- data/lib/constantcontact/components/contacts/contact_list.rb +26 -0
- data/lib/constantcontact/components/contacts/custom_field.rb +26 -0
- data/lib/constantcontact/components/contacts/email_address.rb +33 -0
- data/lib/constantcontact/components/contacts/note.rb +26 -0
- data/lib/constantcontact/components/email_marketing/campaign.rb +83 -0
- data/lib/constantcontact/components/email_marketing/campaign_preview.rb +29 -0
- data/lib/constantcontact/components/email_marketing/click_through_details.rb +27 -0
- data/lib/constantcontact/components/email_marketing/message_footer.rb +29 -0
- data/lib/constantcontact/components/email_marketing/schedule.rb +27 -0
- data/lib/constantcontact/components/email_marketing/test_send.rb +45 -0
- data/lib/constantcontact/components/event_spot/contact.rb +27 -0
- data/lib/constantcontact/components/event_spot/event.rb +69 -0
- data/lib/constantcontact/components/event_spot/event_address.rb +29 -0
- data/lib/constantcontact/components/event_spot/event_fee.rb +27 -0
- data/lib/constantcontact/components/event_spot/event_item.rb +36 -0
- data/lib/constantcontact/components/event_spot/event_item_attribute.rb +26 -0
- data/lib/constantcontact/components/event_spot/event_track.rb +31 -0
- data/lib/constantcontact/components/event_spot/guest.rb +31 -0
- data/lib/constantcontact/components/event_spot/guest_section.rb +34 -0
- data/lib/constantcontact/components/event_spot/notification_option.rb +27 -0
- data/lib/constantcontact/components/event_spot/online_meeting.rb +28 -0
- data/lib/constantcontact/components/event_spot/payment_address.rb +29 -0
- data/lib/constantcontact/components/event_spot/payment_summary.rb +33 -0
- data/lib/constantcontact/components/event_spot/promocode.rb +25 -0
- data/lib/constantcontact/components/event_spot/registrant.rb +52 -0
- data/lib/constantcontact/components/event_spot/registrant_fee.rb +29 -0
- data/lib/constantcontact/components/event_spot/registrant_field.rb +27 -0
- data/lib/constantcontact/components/event_spot/registrant_order.rb +39 -0
- data/lib/constantcontact/components/event_spot/registrant_promo_code.rb +31 -0
- data/lib/constantcontact/components/event_spot/registrant_promo_code_info.rb +27 -0
- data/lib/constantcontact/components/event_spot/registrant_section.rb +34 -0
- data/lib/constantcontact/components/event_spot/sale_item.rb +29 -0
- data/lib/constantcontact/components/library/file/library_file.rb +27 -0
- data/lib/constantcontact/components/library/folder/library_folder.rb +26 -0
- data/lib/constantcontact/components/library/info/library_summary.rb +26 -0
- data/lib/constantcontact/components/library/info/move_results.rb +26 -0
- data/lib/constantcontact/components/library/info/upload_status.rb +26 -0
- data/lib/constantcontact/components/result_set.rb +50 -0
- data/lib/constantcontact/components/tracking/bounce_activity.rb +28 -0
- data/lib/constantcontact/components/tracking/click_activity.rb +26 -0
- data/lib/constantcontact/components/tracking/forward_activity.rb +26 -0
- data/lib/constantcontact/components/tracking/open_activity.rb +26 -0
- data/lib/constantcontact/components/tracking/send_activity.rb +27 -0
- data/lib/constantcontact/components/tracking/tracking_activity.rb +26 -0
- data/lib/constantcontact/components/tracking/tracking_summary.rb +27 -0
- data/lib/constantcontact/components/tracking/unsubscribe_activity.rb +27 -0
- data/lib/constantcontact/exceptions/ctct_exception.rb +25 -0
- data/lib/constantcontact/exceptions/illegal_argument_exception.rb +11 -0
- data/lib/constantcontact/exceptions/oauth2_exception.rb +11 -0
- data/lib/constantcontact/exceptions/webhooks_exception.rb +11 -0
- data/lib/constantcontact/services/account_service.rb +39 -0
- data/lib/constantcontact/services/activity_service.rb +136 -0
- data/lib/constantcontact/services/base_service.rb +68 -0
- data/lib/constantcontact/services/campaign_schedule_service.rb +101 -0
- data/lib/constantcontact/services/campaign_tracking_service.rb +152 -0
- data/lib/constantcontact/services/contact_service.rb +105 -0
- data/lib/constantcontact/services/contact_tracking_service.rb +152 -0
- data/lib/constantcontact/services/email_marketing_service.rb +94 -0
- data/lib/constantcontact/services/event_spot_service.rb +448 -0
- data/lib/constantcontact/services/library_service.rb +281 -0
- data/lib/constantcontact/services/list_service.rb +81 -0
- data/lib/constantcontact/util/config.rb +180 -0
- data/lib/constantcontact/util/helpers.rb +27 -0
- data/lib/constantcontact/version.rb +12 -0
- data/lib/constantcontact/webhooks/helpers/validator.rb +30 -0
- data/lib/constantcontact/webhooks/models/billing_change_notification.rb +27 -0
- data/lib/constantcontact/webhooks/webhooks_util.rb +45 -0
- data/lib/constantcontact.rb +124 -0
- data/spec/constantcontact/api_spec.rb +1560 -0
- data/spec/constantcontact/auth/oauth2_spec.rb +125 -0
- data/spec/constantcontact/components/contacts/address_spec.rb +18 -0
- data/spec/constantcontact/components/contacts/contact_list_spec.rb +18 -0
- data/spec/constantcontact/components/contacts/contact_spec.rb +18 -0
- data/spec/constantcontact/components/contacts/custom_field_spec.rb +18 -0
- data/spec/constantcontact/components/contacts/email_address_spec.rb +18 -0
- data/spec/constantcontact/sdk_spec.rb +24 -0
- data/spec/constantcontact/services/account_service_spec.rb +46 -0
- data/spec/constantcontact/services/activity_service_spec.rb +244 -0
- data/spec/constantcontact/services/base_service_spec.rb +50 -0
- data/spec/constantcontact/services/campaign_schedule_service_spec.rb +115 -0
- data/spec/constantcontact/services/campaign_tracking_service_spec.rb +131 -0
- data/spec/constantcontact/services/contact_service_spec.rb +111 -0
- data/spec/constantcontact/services/contact_tracking_service_spec.rb +131 -0
- data/spec/constantcontact/services/email_marketing_spec.rb +100 -0
- data/spec/constantcontact/services/event_spot_spec.rb +423 -0
- data/spec/constantcontact/services/library_service_spec.rb +252 -0
- data/spec/constantcontact/services/list_service_spec.rb +89 -0
- data/spec/constantcontact/webhooks/webhooks_spec.rb +26 -0
- metadata +243 -0
@@ -0,0 +1,448 @@
|
|
1
|
+
#
|
2
|
+
# event_spot_service.rb
|
3
|
+
# ConstantContact
|
4
|
+
#
|
5
|
+
# Copyright (c) 2013 Constant Contact. All rights reserved.
|
6
|
+
|
7
|
+
module ConstantContact
|
8
|
+
module Services
|
9
|
+
class EventSpotService < BaseService
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# Create a new event
|
13
|
+
# @param [Event] event - Event to be created
|
14
|
+
# @return [Event]
|
15
|
+
def add_event(event)
|
16
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.events')
|
17
|
+
url = build_url(url)
|
18
|
+
payload = event.to_json
|
19
|
+
response = RestClient.post(url, payload, get_headers())
|
20
|
+
Components::Event.create(JSON.parse(response.body))
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# Get a set of events
|
25
|
+
# @param [Hash] opts query parameters to be appended to the request
|
26
|
+
# @option opts [String] status email campaigns status of DRAFT, RUNNING, SENT, SCHEDULED.
|
27
|
+
# @option opts [String] modified_since ISO-8601 date string to return campaigns modified since then.
|
28
|
+
# @option opts [Integer] limit number of campaigns to return, 1 to 50.
|
29
|
+
# @return [ResultSet<Event>]
|
30
|
+
def get_events(opts = {})
|
31
|
+
url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.events')
|
32
|
+
url = build_url(url, opts)
|
33
|
+
|
34
|
+
response = RestClient.get(url, get_headers())
|
35
|
+
body = JSON.parse(response.body)
|
36
|
+
|
37
|
+
events = body['results'].collect do |event|
|
38
|
+
Components::Event.create_summary(event)
|
39
|
+
end
|
40
|
+
|
41
|
+
Components::ResultSet.new(events, body['meta'], Components::Event)
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# Get event details for a specific event
|
46
|
+
# @param [Integer] event - Valid event id
|
47
|
+
# @return [Event]
|
48
|
+
def get_event(event)
|
49
|
+
event_id = get_id_for(event)
|
50
|
+
url = Util::Config.get('endpoints.base_url') +
|
51
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
52
|
+
url = build_url(url)
|
53
|
+
response = RestClient.get(url, get_headers())
|
54
|
+
Components::Event.create(JSON.parse(response.body))
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# Update a specific EventSpot event
|
59
|
+
# @param [Event] event - Event to be updated
|
60
|
+
# @return [Event]
|
61
|
+
def update_event(event)
|
62
|
+
event_id = get_id_for(event)
|
63
|
+
url = Util::Config.get('endpoints.base_url') +
|
64
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
65
|
+
url = build_url(url)
|
66
|
+
payload = event.to_json
|
67
|
+
response = RestClient.put(url, payload, get_headers())
|
68
|
+
Components::Event.create(JSON.parse(response.body))
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
# Publish a specific EventSpot event
|
73
|
+
# @param [Event] event - Event to be updated
|
74
|
+
# @return [Event]
|
75
|
+
def publish_event(event)
|
76
|
+
event_id = get_id_for(event)
|
77
|
+
url = Util::Config.get('endpoints.base_url') +
|
78
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
79
|
+
url = build_url(url)
|
80
|
+
payload = [{:op => "REPLACE", :path => "#/status", :value => "ACTIVE"}].to_json
|
81
|
+
response = RestClient.patch(url, payload, get_headers())
|
82
|
+
Components::Event.create(JSON.parse(response.body))
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
# Cancel a specific EventSpot event
|
87
|
+
# @param [Event] event - Event to be updated
|
88
|
+
# @return [Event]
|
89
|
+
def cancel_event(event)
|
90
|
+
event_id = get_id_for(event)
|
91
|
+
url = Util::Config.get('endpoints.base_url') +
|
92
|
+
sprintf(Util::Config.get('endpoints.event'), event_id)
|
93
|
+
url = build_url(url)
|
94
|
+
payload = [{ :op => "REPLACE", :path => "#/status", :value => "CANCELLED" }].to_json
|
95
|
+
response = RestClient.patch(url, payload, get_headers())
|
96
|
+
Components::Event.create(JSON.parse(response.body))
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
# Create a new event fee
|
101
|
+
# @param [Integer] event - Valid event id
|
102
|
+
# @param [EventFee] fee - Event fee to be created
|
103
|
+
# @return [EventFee]
|
104
|
+
def add_fee(event, fee)
|
105
|
+
event_id = get_id_for(event)
|
106
|
+
url = Util::Config.get('endpoints.base_url') +
|
107
|
+
sprintf(Util::Config.get('endpoints.event_fees'), event_id)
|
108
|
+
url = build_url(url)
|
109
|
+
payload = fee.to_json
|
110
|
+
response = RestClient.post(url, payload, get_headers())
|
111
|
+
Components::EventFee.create(JSON.parse(response.body))
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
# Get an array of event fees
|
116
|
+
# @param [Integer] event - Valid event id
|
117
|
+
# @return [Array<EventFee>]
|
118
|
+
def get_fees(event)
|
119
|
+
event_id = get_id_for(event)
|
120
|
+
url = Util::Config.get('endpoints.base_url') +
|
121
|
+
sprintf(Util::Config.get('endpoints.event_fees'), event_id)
|
122
|
+
url = build_url(url)
|
123
|
+
|
124
|
+
response = RestClient.get(url, get_headers())
|
125
|
+
body = JSON.parse(response.body)
|
126
|
+
|
127
|
+
fees = body.collect do |fee|
|
128
|
+
Components::EventFee.create(fee)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
# Get an individual event fee
|
134
|
+
# @param [Integer] event - Valid event id
|
135
|
+
# @param [Integer] fee - Valid fee id
|
136
|
+
# @return [EventFee]
|
137
|
+
def get_fee(event, fee)
|
138
|
+
event_id = get_id_for(event)
|
139
|
+
fee_id = get_id_for(fee)
|
140
|
+
url = Util::Config.get('endpoints.base_url') +
|
141
|
+
sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id)
|
142
|
+
url = build_url(url)
|
143
|
+
|
144
|
+
response = RestClient.get(url, get_headers())
|
145
|
+
fee = Components::EventFee.create(JSON.parse(response.body))
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
# Update an individual event fee
|
150
|
+
# @param [Integer] event - Valid event id
|
151
|
+
# @param [Integer] fee - Valid fee id
|
152
|
+
# @return [EventFee]
|
153
|
+
def update_fee(event, fee)
|
154
|
+
event_id = get_id_for(event)
|
155
|
+
if fee.kind_of?(ConstantContact::Components::EventFee)
|
156
|
+
fee_id = fee.id
|
157
|
+
elsif fee.kind_of?(Hash)
|
158
|
+
fee_id = fee['id']
|
159
|
+
else
|
160
|
+
raise ArgumentError.new "Fee must be a Hash or ConstantContact::Components::Fee"
|
161
|
+
end
|
162
|
+
|
163
|
+
url = Util::Config.get('endpoints.base_url') +
|
164
|
+
sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id)
|
165
|
+
url = build_url(url)
|
166
|
+
payload = fee.to_json
|
167
|
+
|
168
|
+
response = RestClient.put(url, payload, get_headers())
|
169
|
+
fee = Components::EventFee.create(JSON.parse(response.body))
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
# Delete an individual event fee
|
174
|
+
# @param [Integer] event - Valid event id
|
175
|
+
# @param [Integer] fee - Valid fee id
|
176
|
+
# @return [Boolean]
|
177
|
+
def delete_fee(event, fee)
|
178
|
+
event_id = get_id_for(event)
|
179
|
+
fee_id = get_id_for(fee)
|
180
|
+
url = Util::Config.get('endpoints.base_url') +
|
181
|
+
sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id)
|
182
|
+
url = build_url(url)
|
183
|
+
|
184
|
+
response = RestClient.delete(url, get_headers())
|
185
|
+
response.code == 204
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
# Get a set of event registrants
|
190
|
+
# @param [Integer] event - Valid event id
|
191
|
+
# @return [ResultSet<Registrant>]
|
192
|
+
def get_registrants(event, opts = {})
|
193
|
+
event_id = event.kind_of?(ConstantContact::Components::Event) ? event.id : event
|
194
|
+
url = Util::Config.get('endpoints.base_url') +
|
195
|
+
sprintf(Util::Config.get('endpoints.event_registrants'), event_id)
|
196
|
+
url = build_url(url, opts)
|
197
|
+
|
198
|
+
response = RestClient.get(url, get_headers())
|
199
|
+
body = JSON.parse(response.body)
|
200
|
+
|
201
|
+
registrants = body['results'].collect do |registrant|
|
202
|
+
Components::Registrant.create(registrant)
|
203
|
+
end
|
204
|
+
|
205
|
+
Components::ResultSet.new(registrants, body['meta'])
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
# Get an individual event registant
|
210
|
+
# @param [Integer] event - Valid event id
|
211
|
+
# @param [Integer] registrant - Valid fee id
|
212
|
+
# @return [Registrant]
|
213
|
+
def get_registrant(event, registrant)
|
214
|
+
event_id = get_id_for(event)
|
215
|
+
registrant_id = get_id_for(registrant)
|
216
|
+
url = Util::Config.get('endpoints.base_url') +
|
217
|
+
sprintf(Util::Config.get('endpoints.event_registrant'), event_id, registrant_id)
|
218
|
+
url = build_url(url)
|
219
|
+
|
220
|
+
response = RestClient.get(url, get_headers())
|
221
|
+
Components::Registrant.create(JSON.parse(response.body))
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
# Get an array of event items for an individual event
|
226
|
+
# @param [Integer] event_id - event id to retrieve items for
|
227
|
+
# @return [Array<EventItem>]
|
228
|
+
def get_event_items(event_id)
|
229
|
+
url = Util::Config.get('endpoints.base_url') +
|
230
|
+
sprintf(Util::Config.get('endpoints.event_items'), event_id)
|
231
|
+
url = build_url(url)
|
232
|
+
response = RestClient.get(url, get_headers())
|
233
|
+
|
234
|
+
event_items = []
|
235
|
+
JSON.parse(response.body).each do |event_item|
|
236
|
+
event_items << Components::EventItem.create(event_item)
|
237
|
+
end
|
238
|
+
|
239
|
+
event_items
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
# Get an individual event item
|
244
|
+
# @param [Integer] event_id - id of event to retrieve item for
|
245
|
+
# @param [Integer] item_id - id of item to be retrieved
|
246
|
+
# @return [EventItem]
|
247
|
+
def get_event_item(event_id, item_id)
|
248
|
+
url = Util::Config.get('endpoints.base_url') +
|
249
|
+
sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id)
|
250
|
+
url = build_url(url)
|
251
|
+
response = RestClient.get(url, get_headers())
|
252
|
+
Components::EventItem.create(JSON.parse(response.body))
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
# Create a new event item for an event
|
257
|
+
# @param [Integer] event_id - id of event to be associated with the event item
|
258
|
+
# @param [EventItem] event_item - event item to be created
|
259
|
+
# @return [EventItem]
|
260
|
+
def add_event_item(event_id, event_item)
|
261
|
+
url = Util::Config.get('endpoints.base_url') +
|
262
|
+
sprintf(Util::Config.get('endpoints.event_items'), event_id)
|
263
|
+
url = build_url(url)
|
264
|
+
payload = event_item.to_json
|
265
|
+
response = RestClient.post(url, payload, get_headers())
|
266
|
+
Components::EventItem.create(JSON.parse(response.body))
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
# Delete a specific event item for an event
|
271
|
+
# @param [Integer] event_id - id of event to delete an event item for
|
272
|
+
# @param [Integer] item_id - id of event item to be deleted
|
273
|
+
# @return [Boolean]
|
274
|
+
def delete_event_item(event_id, item_id)
|
275
|
+
url = Util::Config.get('endpoints.base_url') +
|
276
|
+
sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id)
|
277
|
+
url = build_url(url)
|
278
|
+
response = RestClient.delete(url, get_headers())
|
279
|
+
response.code == 204
|
280
|
+
end
|
281
|
+
|
282
|
+
|
283
|
+
# Update a specific event item for an event
|
284
|
+
# @param [Integer] event_id - id of event associated with the event item
|
285
|
+
# @param [EventItem] event_item - event item to be updated
|
286
|
+
# @return [EventItem]
|
287
|
+
def update_event_item(event_id, event_item)
|
288
|
+
url = Util::Config.get('endpoints.base_url') +
|
289
|
+
sprintf(Util::Config.get('endpoints.event_item'), event_id, event_item.id)
|
290
|
+
url = build_url(url)
|
291
|
+
payload = event_item.to_json
|
292
|
+
response = RestClient.put(url, payload, get_headers())
|
293
|
+
Components::EventItem.create(JSON.parse(response.body))
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
# Get an array of attributes for an individual event item
|
298
|
+
# @param [Integer] event_id - event id to retrieve item for
|
299
|
+
# @param [Integer] item_id - event item id to retrieve attributes for
|
300
|
+
# @return [Array<EventItemAttribute>]
|
301
|
+
def get_event_item_attributes(event_id, item_id)
|
302
|
+
url = Util::Config.get('endpoints.base_url') +
|
303
|
+
sprintf(Util::Config.get('endpoints.event_item_attributes'), event_id, item_id)
|
304
|
+
url = build_url(url)
|
305
|
+
response = RestClient.get(url, get_headers())
|
306
|
+
|
307
|
+
event_item_attributes = []
|
308
|
+
JSON.parse(response.body).each do |event_item_attribute|
|
309
|
+
event_item_attributes << Components::EventItemAttribute.create(event_item_attribute)
|
310
|
+
end
|
311
|
+
|
312
|
+
event_item_attributes
|
313
|
+
end
|
314
|
+
|
315
|
+
|
316
|
+
# Get an individual event item attribute
|
317
|
+
# @param [Integer] event_id - id of event to retrieve item for
|
318
|
+
# @param [Integer] item_id - id of item to retrieve attribute for
|
319
|
+
# @param [Integer] attribute_id - id of attribute to be retrieved
|
320
|
+
# @return [EventItemAttribute]
|
321
|
+
def get_event_item_attribute(event_id, item_id, attribute_id)
|
322
|
+
url = Util::Config.get('endpoints.base_url') +
|
323
|
+
sprintf(Util::Config.get('endpoints.event_item_attribute'), event_id, item_id, attribute_id)
|
324
|
+
url = build_url(url)
|
325
|
+
response = RestClient.get(url, get_headers())
|
326
|
+
Components::EventItemAttribute.create(JSON.parse(response.body))
|
327
|
+
end
|
328
|
+
|
329
|
+
|
330
|
+
# Create a new event item attribute for an event item
|
331
|
+
# @param [Integer] event_id - id of event to be associated with the event item attribute
|
332
|
+
# @param [Integer] item_id - id of event item to be associated with the event item attribute
|
333
|
+
# @param [EventItemAttribute] event_item_attribute - event item attribute to be created
|
334
|
+
# @return [EventItemAttribute]
|
335
|
+
def add_event_item_attribute(event_id, item_id, event_item_attribute)
|
336
|
+
url = Util::Config.get('endpoints.base_url') +
|
337
|
+
sprintf(Util::Config.get('endpoints.event_item_attributes'), event_id, item_id)
|
338
|
+
url = build_url(url)
|
339
|
+
payload = event_item_attribute.to_json
|
340
|
+
response = RestClient.post(url, payload, get_headers())
|
341
|
+
Components::EventItemAttribute.create(JSON.parse(response.body))
|
342
|
+
end
|
343
|
+
|
344
|
+
|
345
|
+
# Delete a specific event item for an event
|
346
|
+
# @param [Integer] event_id - id of event to delete an event item attribute for
|
347
|
+
# @param [Integer] item_id - id of event item to delete an event item attribute for
|
348
|
+
# @param [Integer] attribute_id - id of attribute to be deleted
|
349
|
+
# @return [Boolean]
|
350
|
+
def delete_event_item_attribute(event_id, item_id, attribute_id)
|
351
|
+
url = Util::Config.get('endpoints.base_url') +
|
352
|
+
sprintf(Util::Config.get('endpoints.event_item_attribute'), event_id, item_id, attribute_id)
|
353
|
+
url = build_url(url)
|
354
|
+
response = RestClient.delete(url, get_headers())
|
355
|
+
response.code == 204
|
356
|
+
end
|
357
|
+
|
358
|
+
|
359
|
+
# Update a specific event item attribute for an event item
|
360
|
+
# @param [Integer] event_id - id of event associated with the event item
|
361
|
+
# @param [Integer] item_id - id of event item associated with the event item attribute
|
362
|
+
# @param [EventItemAttribute] event_item_attribute - event item to be updated
|
363
|
+
# @return [EventItemAttribute]
|
364
|
+
def update_event_item_attribute(event_id, item_id, event_item_attribute)
|
365
|
+
url = Util::Config.get('endpoints.base_url') +
|
366
|
+
sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id, event_item_attribute.id)
|
367
|
+
url = build_url(url)
|
368
|
+
payload = event_item_attribute.to_json
|
369
|
+
response = RestClient.put(url, payload, get_headers())
|
370
|
+
Components::EventItemAttribute.create(JSON.parse(response.body))
|
371
|
+
end
|
372
|
+
|
373
|
+
|
374
|
+
# Get an array of promocodes for an individual event
|
375
|
+
# @param [Integer] event_id - event id to retrieve promocodes for
|
376
|
+
# @return [Array<Promocode>]
|
377
|
+
def get_promocodes(event_id)
|
378
|
+
url = Util::Config.get('endpoints.base_url') +
|
379
|
+
sprintf(Util::Config.get('endpoints.event_promocodes'), event_id)
|
380
|
+
url = build_url(url)
|
381
|
+
response = RestClient.get(url, get_headers())
|
382
|
+
|
383
|
+
promocodes = []
|
384
|
+
JSON.parse(response.body).each do |promocode|
|
385
|
+
promocodes << Components::Promocode.create(promocode)
|
386
|
+
end
|
387
|
+
|
388
|
+
promocodes
|
389
|
+
end
|
390
|
+
|
391
|
+
|
392
|
+
# Get an individual promocode
|
393
|
+
# @param [Integer] event_id - id of event to retrieve item for
|
394
|
+
# @param [Integer] promocode_id - id of item to be retrieved
|
395
|
+
# @return [Promocode]
|
396
|
+
def get_promocode(event_id, promocode_id)
|
397
|
+
url = Util::Config.get('endpoints.base_url') +
|
398
|
+
sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode_id)
|
399
|
+
url = build_url(url)
|
400
|
+
response = RestClient.get(url, get_headers())
|
401
|
+
Components::Promocode.create(JSON.parse(response.body))
|
402
|
+
end
|
403
|
+
|
404
|
+
|
405
|
+
# Create a new promocode for an event
|
406
|
+
# @param [Integer] event_id - id of event to be associated with the promocode
|
407
|
+
# @param [Promocode] promocode - promocode to be created
|
408
|
+
# @return [Promocode]
|
409
|
+
def add_promocode(event_id, promocode)
|
410
|
+
url = Util::Config.get('endpoints.base_url') +
|
411
|
+
sprintf(Util::Config.get('endpoints.event_promocodes'), event_id)
|
412
|
+
url = build_url(url)
|
413
|
+
payload = promocode.to_json
|
414
|
+
response = RestClient.post(url, payload, get_headers())
|
415
|
+
Components::Promocode.create(JSON.parse(response.body))
|
416
|
+
end
|
417
|
+
|
418
|
+
|
419
|
+
# Delete a specific promocode for an event
|
420
|
+
# @param [Integer] event_id - id of event to delete a promocode for
|
421
|
+
# @param [Integer] promocode_id - id of promocode to be deleted
|
422
|
+
# @return [Boolean]
|
423
|
+
def delete_promocode(event_id, promocode_id)
|
424
|
+
url = Util::Config.get('endpoints.base_url') +
|
425
|
+
sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode_id)
|
426
|
+
url = build_url(url)
|
427
|
+
response = RestClient.delete(url, get_headers())
|
428
|
+
response.code == 204
|
429
|
+
end
|
430
|
+
|
431
|
+
|
432
|
+
# Update a specific promocode for an event
|
433
|
+
# @param [Integer] event_id - id of event associated with the promocode
|
434
|
+
# @param [Promocode] promocode - promocode to be updated
|
435
|
+
# @return [Promocode]
|
436
|
+
def update_promocode(event_id, promocode)
|
437
|
+
url = Util::Config.get('endpoints.base_url') +
|
438
|
+
sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode.id)
|
439
|
+
url = build_url(url)
|
440
|
+
payload = promocode.to_json
|
441
|
+
response = RestClient.put(url, payload, get_headers())
|
442
|
+
Components::Promocode.create(JSON.parse(response.body))
|
443
|
+
end
|
444
|
+
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|