Class: Myfinance::Resources::Attachment
- Defined in:
- lib/myfinance/resources/attachment.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(entity_id, file, params = {}) ⇒ Object
Create an attachment.
-
#destroy(entity_id, attachment_id) ⇒ Object
Destroy an attachment.
-
#find(entity_id, attachment_id) ⇒ Object
Show attachment details.
-
#find_all(entity_id, params = { page: 1 }) ⇒ Object
List all attachments of the entity.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Myfinance::Resources::Base
Instance Method Details
#create(entity_id, file, params = {}) ⇒ Object
Create an attachment
[API] Method: POST /entities/:entity_id/attachments
Documentation: https://sandbox.myfinance.com.br/docs/api/attachments#post_create
40 41 42 43 44 45 |
# 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) ⇒ Object
Destroy an attachment
[API] Method: DELETE /entities/:entity_id/attachments/:attachment_id
Documentation: https://sandbox.myfinance.com.br/docs/api/attachments#delete_destroy
55 56 57 |
# File 'lib/myfinance/resources/attachment.rb', line 55 def destroy(entity_id, ) http.delete("/entities/#{entity_id}/attachments/#{}") end |
#find(entity_id, attachment_id) ⇒ Object
Show attachment details
[API] Method: GET /entities/:entity_id/attachments/:id
Documentation: https://sandbox.myfinance.com.br/docs/api/attachments#get_show
26 27 28 29 30 |
# File 'lib/myfinance/resources/attachment.rb', line 26 def find(entity_id, ) http.get("/entities/#{entity_id}/attachments/#{}") do |response| respond_with_object(response, 'attachment') end end |
#find_all(entity_id, params = { page: 1 }) ⇒ Object
List all attachments of the entity
[API] Method: GET /entities/:entity_id/attachments
Documentation: https://sandbox.myfinance.com.br/docs/api/attachments#get_index
12 13 14 15 16 |
# 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 |