Class: FidorApi::Message

Inherits:
Resource show all
Extended by:
AmountAttributes, ModelAttribute
Defined in:
lib/fidor_api/message.rb

Defined Under Namespace

Modules: ClientSupport Classes: Attachment

Instance Attribute Summary

Attributes inherited from Resource

#client

Class Method Summary collapse

Methods included from AmountAttributes

amount_attribute, attributes, extended

Methods inherited from Resource

#initialize, model_name, #persisted?, request

Constructor Details

This class inherits a constructor from FidorApi::Resource

Class Method Details

.all(access_token, options = {}) ⇒ Object



20
21
22
# File 'lib/fidor_api/message.rb', line 20

def self.all(access_token, options = {})
  Collection.build(self, request(access_token: access_token, endpoint: "/messages", query_params: options).body)
end

.attachment(access_token, id) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/fidor_api/message.rb', line 28

def self.attachment(access_token, id)
  response = request(access_token: access_token, endpoint: "/messages/#{id}/attachment")

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

.find(access_token, id) ⇒ Object



24
25
26
# File 'lib/fidor_api/message.rb', line 24

def self.find(access_token, id)
  new(request(access_token: access_token, endpoint: "/messages/#{id}").body)
end