class ReamazeAPI::Message

Public Instance Methods

all(params = {}) click to toggle source

Public: Retrieves messages.

params - Hash of parameters (those not listed below are passed directly

to the API):
:conversation_slug - Optional conversation slug

API Routes

GET /messages
GET /conversations/{slug}/messages

See also: www.reamaze.com/api/get_messages

Returns a Hash.

# File lib/reamaze_api/message.rb, line 17
def all(params = {})
  params = Utils.symbolize_hash(params)
  url    = message_path(params.delete(:conversation_slug))

  paginate url, :messages, params
end
create(params) click to toggle source

Public: Create a new message under the given conversation.

params - Hash of parameters (those not listed below are passed directly

to the API):
:conversation_slug - Required conversation slug

API Routes

POST /conversations/{slug}/messages

See also: www.reamaze.com/api/post_messages

Returns a Hash.

# File lib/reamaze_api/message.rb, line 37
def create(params)
  params = Utils.symbolize_hash(params)
  slug   = params.fetch(:conversation_slug)

  params.delete :conversation_slug

  post message_path(slug), params
rescue KeyError => e
  Utils.error_hash(e)
end

Private Instance Methods

message_path(conversation_slug = nil) click to toggle source

Private: Messages API path. If a conversation slug is supplied the returned path is prefixed with “/conversations/#{slug}”.

conversation_slug - The conversation slug

Returns a String.

# File lib/reamaze_api/message.rb, line 56
def message_path(conversation_slug = nil)
  if conversation_slug
    "/conversations/#{conversation_slug}/messages"
  else
    "/messages"
  end
end