Module: TheCity::API::Topics

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

Instance Method Summary collapse

Instance Method Details

#post_topic(options) ⇒ TheCity::Topic

Posts a topic 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 topic.

  • :body (String)

    The body text of the topic.

Returns:

Raises:

See Also:



20
21
22
23
24
25
26
# File 'lib/the_city/api/topics.rb', line 20

def post_topic(options)
  raise(Error::ArgumentError, "Must supply a options[:group_id] for the topic'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]
  gid = options[:group_id] || 0
  object_from_response(TheCity::Topic, :post, "/groups/#{gid}/topics/", options, {:client => self})
end

#topic(id) ⇒ TheCity::Topic #topic(id, options = {}) ⇒ TheCity::Topic

Returns a topic by id

Overloads:

  • #topic(id) ⇒ TheCity::Topic

    Parameters:

    • id (Integer)

      The id of the topic.

  • #topic(id, options = {}) ⇒ TheCity::Topic

    Parameters:

    • id (Integer)

      The id of the topic.

    • 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:



41
42
43
44
45
46
47
# File 'lib/the_city/api/topics.rb', line 41

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