Module: TheCity::API::Events

Includes:
Utils
Included in:
Client
Defined in:
lib/the_city/api/events.rb

Instance Method Summary collapse

Instance Method Details

#event(id) ⇒ TheCity::Event #event(id, options = {}) ⇒ TheCity::Event

Returns an Event by id

Overloads:

  • #event(id) ⇒ TheCity::Event

    Parameters:

    • id (Integer)

      The id of the event.

  • #event(id, options = {}) ⇒ TheCity::Event

    Parameters:

    • id (Integer)

      The id of the event.

    • options (Hash) (defaults to: {})

      A customizable set of options.

    Options Hash (options):

    • :force_download (Boolean)

      Forces the request to hit the server and flush the cached response

Returns:

Raises:

See Also:



45
46
47
48
49
50
51
# File 'lib/the_city/api/events.rb', line 45

def event(*args)
  @events ||= {}
  arguments = TheCity::Arguments.new(args)
  eid = args.shift
  @events[eid] = nil if arguments.options.delete(:force_download)
  @events[eid] ||= object_from_response(TheCity::Event, :get, "/events/#{eid}", arguments.options, {:client => self})
end

#post_event(options) ⇒ TheCity::Event

Posts an Event to The City

Parameters:

  • options (Hash)

    A customizable set of options.

Options Hash (options):

  • :group_id (Integer)

    The id of the group you will be posting to.

  • :title (String)

    The title of the event.

  • :body (String)

    The body text of the event.

  • :starting_at (Time)

    The body text of the event.

  • :ending_at (Time)

    The body text of the event.

Returns:

Raises:

See Also:



22
23
24
25
26
27
28
29
30
# File 'lib/the_city/api/events.rb', line 22

def post_event(options)
  raise(Error::ArgumentError, "Must supply a options[:group_id] for the events's originating group") unless options[:group_id]
  raise(Error::ArgumentError, "Title (options[:title]) required") unless options[:title]
  raise(Error::ArgumentError, "Body (options[:body]) required") unless options[:body]
  raise(Error::ArgumentError, "Starting At (options[:starting_at]) required") unless options[:starting_at]
  raise(Error::ArgumentError, "Ending At (options[:ending_at]) required") unless options[:ending_at]
  gid = options[:group_id] || 0
  object_from_response(TheCity::Event, :post, "/groups/#{gid}/events/", options, {:client => self})
end