Module: FidorApi::Client::DSL::Messages

Defined in:
lib/fidor_api/client/dsl/messages.rb

Instance Method Summary collapse

Instance Method Details

#message(id, options = {}) ⇒ Object



9
10
11
# File 'lib/fidor_api/client/dsl/messages.rb', line 9

def message(id, options = {})
  fetch(:single, Model::Message, "messages/#{id}", options)
end

#message_attachment(id) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/fidor_api/client/dsl/messages.rb', line 13

def message_attachment(id)
  response = connection.get("messages/#{id}/attachment")

  Model::Message::Attachment.new(
    type:     response.headers['content-type'],
    filename: response.headers['content-disposition'][/filename="([^"]+)"/, 1],
    content:  response.body
  )
end

#message_content(id) ⇒ Object



23
24
25
26
27
# File 'lib/fidor_api/client/dsl/messages.rb', line 23

def message_content(id)
  response = connection.get("messages/#{id}/content")

  Model::Message::Content.new(raw: response.body)
end

#messages(options = {}) ⇒ Object



5
6
7
# File 'lib/fidor_api/client/dsl/messages.rb', line 5

def messages(options = {})
  fetch(:collection, Model::Message, 'messages', options)
end