Module: TheCity::API::Prayers

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

Instance Method Summary collapse

Instance Method Details

#post_prayer(options) ⇒ TheCity::Prayer

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

  • :body (String)

    The body text of the prayer.

Returns:

Raises:

See Also:



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

def post_prayer(options)
  raise(Error::ArgumentError, "Must supply a options[:group_id] for the prayers'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::Prayer, :post, "/groups/#{gid}/prayers/", options, {:client => self})
end

#prayer(id) ⇒ TheCity::Prayer #prayer(id, options = {}) ⇒ TheCity::Prayer

Returns a prayer by id

Overloads:

  • #prayer(id) ⇒ TheCity::Prayer

    Parameters:

    • id (Integer)

      The id of the prayer.

  • #prayer(id, options = {}) ⇒ TheCity::Prayer

    Parameters:

    • id (Integer)

      The id of the prayer.

    • 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/prayers.rb', line 41

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