class ConstantContact::Services::EventSpotService

Public Instance Methods

add_event(event) click to toggle source

Create a new event @param [Event] event - Event to be created @return [Event]

# 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) click to toggle source

Create a new event item for an event @param [Integer] event_id - id of event to be associated with the event item @param [EventItem] event_item - event item to be created @return [EventItem]

# 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) click to toggle source

Create a new event item attribute for an event item @param [Integer] event_id - id of event to be associated with the event item attribute @param [Integer] item_id - id of event item to be associated with the event item attribute @param [EventItemAttribute] event_item_attribute - event item attribute to be created @return [EventItemAttribute]

# 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) click to toggle source

Create a new event fee @param [Integer] event - Valid event id @param [EventFee] fee - Event fee to be created @return [EventFee]

# 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) click to toggle source

Create a new promocode for an event @param [Integer] event_id - id of event to be associated with the promocode @param [Promocode] promocode - promocode to be created @return [Promocode]

# 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) click to toggle source

Cancel a specific EventSpot event @param [Event] event - Event to be updated @return [Event]

# 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) click to toggle source

Delete a specific event item for an event @param [Integer] event_id - id of event to delete an event item for @param [Integer] item_id - id of event item to be deleted @return [Boolean]

# 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) click to toggle source

Delete a specific event item for an event @param [Integer] event_id - id of event to delete an event item attribute for @param [Integer] item_id - id of event item to delete an event item attribute for @param [Integer] attribute_id - id of attribute to be deleted @return [Boolean]

# 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) click to toggle source

Delete an individual event fee @param [Integer] event - Valid event id @param [Integer] fee - Valid fee id @return [Boolean]

# 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) click to toggle source

Delete a specific promocode for an event @param [Integer] event_id - id of event to delete a promocode for @param [Integer] promocode_id - id of promocode to be deleted @return [Boolean]

# 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) click to toggle source

Get event details for a specific event @param [Integer] event - Valid event id @return [Event]

# 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) click to toggle source

Get an individual event item @param [Integer] event_id - id of event to retrieve item for @param [Integer] item_id - id of item to be retrieved @return [EventItem]

# 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) click to toggle source

Get an individual event item attribute @param [Integer] event_id - id of event to retrieve item for @param [Integer] item_id - id of item to retrieve attribute for @param [Integer] attribute_id - id of attribute to be retrieved @return [EventItemAttribute]

# 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) click to toggle source

Get an array of attributes for an individual event item @param [Integer] event_id - event id to retrieve item for @param [Integer] item_id - event item id to retrieve attributes for @return [Array<EventItemAttribute>]

# 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) click to toggle source

Get an array of event items for an individual event @param [Integer] event_id - event id to retrieve items for @return [Array<EventItem>]

# 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 = {}) click to toggle source

Get a set of events @param [Hash] opts query parameters to be appended to the request @option opts [String] status email campaigns status of DRAFT, RUNNING, SENT, SCHEDULED. @option opts [String] modified_since ISO-8601 date string to return campaigns modified since then. @option opts [Integer] limit number of campaigns to return, 1 to 50. @return [ResultSet<Event>]

# 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) click to toggle source

Get an individual event fee @param [Integer] event - Valid event id @param [Integer] fee - Valid fee id @return [EventFee]

# 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) click to toggle source

Get an array of event fees @param [Integer] event - Valid event id @return [Array<EventFee>]

# 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) click to toggle source

Get an individual promocode @param [Integer] event_id - id of event to retrieve item for @param [Integer] promocode_id - id of item to be retrieved @return [Promocode]

# 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) click to toggle source

Get an array of promocodes for an individual event @param [Integer] event_id - event id to retrieve promocodes for @return [Array<Promocode>]

# 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) click to toggle source

Get an individual event registant @param [Integer] event - Valid event id @param [Integer] registrant - Valid fee id @return [Registrant]

# 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) click to toggle source

Get a set of event registrants @param [Integer] event - Valid event id @return [ResultSet<Registrant>]

# 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) click to toggle source

Publish a specific EventSpot event @param [Event] event - Event to be updated @return [Event]

# 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) click to toggle source

Update a specific EventSpot event @param [Event] event - Event to be updated @return [Event]

# 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) click to toggle source

Update a specific event item for an event @param [Integer] event_id - id of event associated with the event item @param [EventItem] event_item - event item to be updated @return [EventItem]

# 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) click to toggle source

Update a specific event item attribute for an event item @param [Integer] event_id - id of event associated with the event item @param [Integer] item_id - id of event item associated with the event item attribute @param [EventItemAttribute] event_item_attribute - event item to be updated @return [EventItemAttribute]

# 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) click to toggle source

Update an individual event fee @param [Integer] event - Valid event id @param [Integer] fee - Valid fee id @return [EventFee]

# 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) click to toggle source

Update a specific promocode for an event @param [Integer] event_id - id of event associated with the promocode @param [Promocode] promocode - promocode to be updated @return [Promocode]

# 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