class Myfinance::Resources::Attachment

Public Instance Methods

create(entity_id, file, params = {}) click to toggle source

Create an attachment

API

Method: POST /entities/:entity_id/attachments

Documentation: sandbox.myfinance.com.br/docs/api/attachments#post_create

# File lib/myfinance/resources/attachment.rb, line 40
def create(entity_id, file, params = {})
  params.merge!(attachment: file)
  http.post("/entities/#{entity_id}/attachments", { body: { attachment: params }, multipart: true }) do |response|
    respond_with_object(response, 'attachment')
  end
end
destroy(entity_id, attachment_id) click to toggle source

Destroy an attachment

API

Method: DELETE /entities/:entity_id/attachments/:attachment_id

Documentation: sandbox.myfinance.com.br/docs/api/attachments#delete_destroy

# File lib/myfinance/resources/attachment.rb, line 55
def destroy(entity_id, attachment_id)
  http.delete("/entities/#{entity_id}/attachments/#{attachment_id}")
end
find(entity_id, attachment_id) click to toggle source

Show attachment details

API

Method: GET /entities/:entity_id/attachments/:id

Documentation: sandbox.myfinance.com.br/docs/api/attachments#get_show

# File lib/myfinance/resources/attachment.rb, line 26
def find(entity_id, attachment_id)
  http.get("/entities/#{entity_id}/attachments/#{attachment_id}") do |response|
    respond_with_object(response, 'attachment')
  end
end
find_all(entity_id, params = { page: 1 }) click to toggle source

List all attachments of the entity

API

Method: GET /entities/:entity_id/attachments

Documentation: sandbox.myfinance.com.br/docs/api/attachments#get_index

# File lib/myfinance/resources/attachment.rb, line 12
def find_all(entity_id, params = { page: 1 })
  http.get("/entities/#{entity_id}/attachments", body: params) do |response|
    respond_with_collection(response)
  end
end