Class: ConstantContact::Services::EventSpotService
- Inherits:
-
BaseService
- Object
- BaseService
- ConstantContact::Services::EventSpotService
- Defined in:
- lib/constantcontact/services/event_spot_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
Instance Method Summary collapse
-
#add_event(event) ⇒ Event
Create a new event.
-
#add_event_item(event_id, event_item) ⇒ EventItem
Create a new event item for an event.
-
#add_event_item_attribute(event_id, item_id, event_item_attribute) ⇒ EventItemAttribute
Create a new event item attribute for an event item.
-
#add_fee(event, fee) ⇒ EventFee
Create a new event fee.
-
#add_promocode(event_id, promocode) ⇒ Promocode
Create a new promocode for an event.
-
#cancel_event(event) ⇒ Event
Cancel a specific EventSpot event.
-
#delete_event_item(event_id, item_id) ⇒ Boolean
Delete a specific event item for an event.
-
#delete_event_item_attribute(event_id, item_id, attribute_id) ⇒ Boolean
Delete a specific event item for an event.
-
#delete_fee(event, fee) ⇒ Boolean
Delete an individual event fee.
-
#delete_promocode(event_id, promocode_id) ⇒ Boolean
Delete a specific promocode for an event.
-
#get_event(event) ⇒ Event
Get event details for a specific event.
-
#get_event_item(event_id, item_id) ⇒ EventItem
Get an individual event item.
-
#get_event_item_attribute(event_id, item_id, attribute_id) ⇒ EventItemAttribute
Get an individual event item attribute.
-
#get_event_item_attributes(event_id, item_id) ⇒ Array<EventItemAttribute>
Get an array of attributes for an individual event item.
-
#get_event_items(event_id) ⇒ Array<EventItem>
Get an array of event items for an individual event.
-
#get_events(opts = {}) ⇒ ResultSet<Event>
Get a set of events.
-
#get_fee(event, fee) ⇒ EventFee
Get an individual event fee.
-
#get_fees(event) ⇒ Array<EventFee>
Get an array of event fees.
-
#get_promocode(event_id, promocode_id) ⇒ Promocode
Get an individual promocode.
-
#get_promocodes(event_id) ⇒ Array<Promocode>
Get an array of promocodes for an individual event.
-
#get_registrant(event, registrant) ⇒ Registrant
Get an individual event registant.
-
#get_registrants(event) ⇒ ResultSet<Registrant>
Get a set of event registrants.
-
#publish_event(event) ⇒ Event
Publish a specific EventSpot event.
-
#update_event(event) ⇒ Event
Update a specific EventSpot event.
-
#update_event_item(event_id, event_item) ⇒ EventItem
Update a specific event item for an event.
-
#update_event_item_attribute(event_id, item_id, event_item_attribute) ⇒ EventItemAttribute
Update a specific event item attribute for an event item.
-
#update_fee(event, fee) ⇒ EventFee
Update an individual event fee.
-
#update_promocode(event_id, promocode) ⇒ Promocode
Update a specific promocode for an event.
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from ConstantContact::Services::BaseService
Instance Method Details
#add_event(event) ⇒ Event
Create a new event
14 15 16 17 18 19 20 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 14 def add_event(event) url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.events') url = build_url(url) payload = event.to_json response = RestClient.post(url, payload, get_headers()) Components::Event.create(JSON.parse(response.body)) end |
#add_event_item(event_id, event_item) ⇒ EventItem
Create a new event item for an event
259 260 261 262 263 264 265 266 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 259 def add_event_item(event_id, event_item) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_items'), event_id) url = build_url(url) payload = event_item.to_json response = RestClient.post(url, payload, get_headers()) Components::EventItem.create(JSON.parse(response.body)) end |
#add_event_item_attribute(event_id, item_id, event_item_attribute) ⇒ EventItemAttribute
Create a new event item attribute for an event item
334 335 336 337 338 339 340 341 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 334 def add_event_item_attribute(event_id, item_id, event_item_attribute) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_item_attributes'), event_id, item_id) url = build_url(url) payload = event_item_attribute.to_json response = RestClient.post(url, payload, get_headers()) Components::EventItemAttribute.create(JSON.parse(response.body)) end |
#add_fee(event, fee) ⇒ EventFee
Create a new event fee
103 104 105 106 107 108 109 110 111 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 103 def add_fee(event, fee) event_id = get_id_for(event) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_fees'), event_id) url = build_url(url) payload = fee.to_json response = RestClient.post(url, payload, get_headers()) Components::EventFee.create(JSON.parse(response.body)) end |
#add_promocode(event_id, promocode) ⇒ Promocode
Create a new promocode for an event
408 409 410 411 412 413 414 415 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 408 def add_promocode(event_id, promocode) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_promocodes'), event_id) url = build_url(url) payload = promocode.to_json response = RestClient.post(url, payload, get_headers()) Components::Promocode.create(JSON.parse(response.body)) end |
#cancel_event(event) ⇒ Event
Cancel a specific EventSpot event
88 89 90 91 92 93 94 95 96 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 88 def cancel_event(event) event_id = get_id_for(event) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event'), event_id) url = build_url(url) payload = [{ :op => "REPLACE", :path => "#/status", :value => "CANCELLED" }].to_json response = RestClient.patch(url, payload, get_headers()) Components::Event.create(JSON.parse(response.body)) end |
#delete_event_item(event_id, item_id) ⇒ Boolean
Delete a specific event item for an event
273 274 275 276 277 278 279 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 273 def delete_event_item(event_id, item_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id) url = build_url(url) response = RestClient.delete(url, get_headers()) response.code == 204 end |
#delete_event_item_attribute(event_id, item_id, attribute_id) ⇒ Boolean
Delete a specific event item for an event
349 350 351 352 353 354 355 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 349 def delete_event_item_attribute(event_id, item_id, attribute_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_item_attribute'), event_id, item_id, attribute_id) url = build_url(url) response = RestClient.delete(url, get_headers()) response.code == 204 end |
#delete_fee(event, fee) ⇒ Boolean
Delete an individual event fee
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 176 def delete_fee(event, fee) event_id = get_id_for(event) fee_id = get_id_for(fee) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id) url = build_url(url) response = RestClient.delete(url, get_headers()) response.code == 204 end |
#delete_promocode(event_id, promocode_id) ⇒ Boolean
Delete a specific promocode for an event
422 423 424 425 426 427 428 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 422 def delete_promocode(event_id, promocode_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode_id) url = build_url(url) response = RestClient.delete(url, get_headers()) response.code == 204 end |
#get_event(event) ⇒ Event
Get event details for a specific event
47 48 49 50 51 52 53 54 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 47 def get_event(event) event_id = get_id_for(event) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event'), event_id) url = build_url(url) response = RestClient.get(url, get_headers()) Components::Event.create(JSON.parse(response.body)) end |
#get_event_item(event_id, item_id) ⇒ EventItem
Get an individual event item
246 247 248 249 250 251 252 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 246 def get_event_item(event_id, item_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id) url = build_url(url) response = RestClient.get(url, get_headers()) Components::EventItem.create(JSON.parse(response.body)) end |
#get_event_item_attribute(event_id, item_id, attribute_id) ⇒ EventItemAttribute
Get an individual event item attribute
320 321 322 323 324 325 326 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 320 def get_event_item_attribute(event_id, item_id, attribute_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_item_attribute'), event_id, item_id, attribute_id) url = build_url(url) response = RestClient.get(url, get_headers()) Components::EventItemAttribute.create(JSON.parse(response.body)) end |
#get_event_item_attributes(event_id, item_id) ⇒ Array<EventItemAttribute>
Get an array of attributes for an individual event item
300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 300 def get_event_item_attributes(event_id, item_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_item_attributes'), event_id, item_id) url = build_url(url) response = RestClient.get(url, get_headers()) event_item_attributes = [] JSON.parse(response.body).each do |event_item_attribute| event_item_attributes << Components::EventItemAttribute.create(event_item_attribute) end event_item_attributes end |
#get_event_items(event_id) ⇒ Array<EventItem>
Get an array of event items for an individual event
227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 227 def get_event_items(event_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_items'), event_id) url = build_url(url) response = RestClient.get(url, get_headers()) event_items = [] JSON.parse(response.body).each do |event_item| event_items << Components::EventItem.create(event_item) end event_items end |
#get_events(opts = {}) ⇒ ResultSet<Event>
Get a set of events
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 29 def get_events(opts = {}) url = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.events') url = build_url(url, opts) response = RestClient.get(url, get_headers()) body = JSON.parse(response.body) events = body['results'].collect do |event| Components::Event.create_summary(event) end Components::ResultSet.new(events, body['meta']) end |
#get_fee(event, fee) ⇒ EventFee
Get an individual event fee
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 136 def get_fee(event, fee) event_id = get_id_for(event) fee_id = get_id_for(fee) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id) url = build_url(url) response = RestClient.get(url, get_headers()) fee = Components::EventFee.create(JSON.parse(response.body)) end |
#get_fees(event) ⇒ Array<EventFee>
Get an array of event fees
117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 117 def get_fees(event) event_id = get_id_for(event) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_fees'), event_id) url = build_url(url) response = RestClient.get(url, get_headers()) body = JSON.parse(response.body) fees = body.collect do |fee| Components::EventFee.create(fee) end end |
#get_promocode(event_id, promocode_id) ⇒ Promocode
Get an individual promocode
395 396 397 398 399 400 401 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 395 def get_promocode(event_id, promocode_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode_id) url = build_url(url) response = RestClient.get(url, get_headers()) Components::Promocode.create(JSON.parse(response.body)) end |
#get_promocodes(event_id) ⇒ Array<Promocode>
Get an array of promocodes for an individual event
376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 376 def get_promocodes(event_id) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_promocodes'), event_id) url = build_url(url) response = RestClient.get(url, get_headers()) promocodes = [] JSON.parse(response.body).each do |promocode| promocodes << Components::Promocode.create(promocode) end promocodes end |
#get_registrant(event, registrant) ⇒ Registrant
Get an individual event registant
212 213 214 215 216 217 218 219 220 221 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 212 def get_registrant(event, registrant) event_id = get_id_for(event) registrant_id = get_id_for(registrant) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_registrant'), event_id, registrant_id) url = build_url(url) response = RestClient.get(url, get_headers()) Components::Registrant.create(JSON.parse(response.body)) end |
#get_registrants(event) ⇒ ResultSet<Registrant>
Get a set of event registrants
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 191 def get_registrants(event) event_id = event.kind_of?(ConstantContact::Components::Event) ? event.id : event url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_registrants'), event_id) url = build_url(url) response = RestClient.get(url, get_headers()) body = JSON.parse(response.body) registrants = body['results'].collect do |registrant| Components::Registrant.create(registrant) end Components::ResultSet.new(registrants, body['meta']) end |
#publish_event(event) ⇒ Event
Publish a specific EventSpot event
74 75 76 77 78 79 80 81 82 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 74 def publish_event(event) event_id = get_id_for(event) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event'), event_id) url = build_url(url) payload = [{:op => "REPLACE", :path => "#/status", :value => "ACTIVE"}].to_json response = RestClient.patch(url, payload, get_headers()) Components::Event.create(JSON.parse(response.body)) end |
#update_event(event) ⇒ Event
Update a specific EventSpot event
60 61 62 63 64 65 66 67 68 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 60 def update_event(event) event_id = get_id_for(event) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event'), event_id) url = build_url(url) payload = event.to_json response = RestClient.put(url, payload, get_headers()) Components::Event.create(JSON.parse(response.body)) end |
#update_event_item(event_id, event_item) ⇒ EventItem
Update a specific event item for an event
286 287 288 289 290 291 292 293 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 286 def update_event_item(event_id, event_item) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_item'), event_id, event_item.id) url = build_url(url) payload = event_item.to_json response = RestClient.put(url, payload, get_headers()) Components::EventItem.create(JSON.parse(response.body)) end |
#update_event_item_attribute(event_id, item_id, event_item_attribute) ⇒ EventItemAttribute
Update a specific event item attribute for an event item
363 364 365 366 367 368 369 370 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 363 def update_event_item_attribute(event_id, item_id, event_item_attribute) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_item'), event_id, item_id, event_item_attribute.id) url = build_url(url) payload = event_item_attribute.to_json response = RestClient.put(url, payload, get_headers()) Components::EventItemAttribute.create(JSON.parse(response.body)) end |
#update_fee(event, fee) ⇒ EventFee
Update an individual event fee
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 152 def update_fee(event, fee) event_id = get_id_for(event) if fee.kind_of?(ConstantContact::Components::EventFee) fee_id = fee.id elsif fee.kind_of?(Hash) fee_id = fee['id'] else raise ArgumentError.new "Fee must be a Hash or ConstantContact::Components::Fee" end url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_fee'), event_id, fee_id) url = build_url(url) payload = fee.to_json response = RestClient.put(url, payload, get_headers()) fee = Components::EventFee.create(JSON.parse(response.body)) end |
#update_promocode(event_id, promocode) ⇒ Promocode
Update a specific promocode for an event
435 436 437 438 439 440 441 442 |
# File 'lib/constantcontact/services/event_spot_service.rb', line 435 def update_promocode(event_id, promocode) url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.event_promocode'), event_id, promocode.id) url = build_url(url) payload = promocode.to_json response = RestClient.put(url, payload, get_headers()) Components::Promocode.create(JSON.parse(response.body)) end |