Class: Myfinance::Resources::FinancialAccount
- Defined in:
- lib/myfinance/resources/financial_account.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(entity_id, params = {}) ⇒ Object
Creates a payable/receivable account.
-
#destroy(entity_id, id) ⇒ Object
Destroys a payable/receivable account.
- #destroy_many(entity_id, ids) ⇒ Object
- #destroy_recurrence(entity_id, id) ⇒ Object
- #find(entity_id, id) ⇒ Object
- #find_all(entity_id, page = nil) ⇒ Object
-
#initialize(http) ⇒ FinancialAccount
constructor
A new instance of FinancialAccount.
-
#update(entity_id, id, params = {}) ⇒ Object
Updates a payable/receivable account.
Constructor Details
#initialize(http) ⇒ FinancialAccount
Returns a new instance of FinancialAccount.
5 6 7 8 9 |
# File 'lib/myfinance/resources/financial_account.rb', line 5 def initialize(http) @http = http set_method_for(pay_or_receive_method) set_method_for(undo_payment_or_receivement) end |
Instance Method Details
#create(entity_id, params = {}) ⇒ Object
Creates a payable/receivable account
[API] Method: POST /entities/:entity_id/payable_accounts Method: POST /entities/:entity_id/receivable_accounts
Documentation: https://app.myfinance.com.br/docs/api/payable_accounts#post_create
Documentation: https://app.myfinance.com.br/docs/api/receivable_accounts#post_create
29 30 31 |
# File 'lib/myfinance/resources/financial_account.rb', line 29 def create(entity_id, params = {}) request_and_build_object_response(:post, endpoint_for(nil, entity_id, :create), params) end |
#destroy(entity_id, id) ⇒ Object
Destroys a payable/receivable account
[API] Method: DELETE /entities/:entity_id/payable_accounts/:id Method: DELETE /entities/:entity_id/receivable_accounts/:id
Documentation: https://app.myfinance.com.br/docs/api/payable_accounts#delete_destroy
Documentation: https://app.myfinance.com.br/docs/api/receivable_accounts#delete_destroy
57 58 59 60 61 |
# File 'lib/myfinance/resources/financial_account.rb', line 57 def destroy(entity_id, id) http.delete(endpoint_for(id, entity_id, :destroy)) do |_response| true end end |
#destroy_many(entity_id, ids) ⇒ Object
69 70 71 72 73 |
# File 'lib/myfinance/resources/financial_account.rb', line 69 def destroy_many(entity_id, ids) http.delete(destroy_many_endpoint(ids, entity_id)) do |_response| true end end |
#destroy_recurrence(entity_id, id) ⇒ Object
63 64 65 66 67 |
# File 'lib/myfinance/resources/financial_account.rb', line 63 def destroy_recurrence(entity_id, id) http.delete(endpoint_for(id, entity_id, :destroy_recurrence)) do |_response| true end end |
#find(entity_id, id) ⇒ Object
15 16 17 |
# File 'lib/myfinance/resources/financial_account.rb', line 15 def find(entity_id, id) request_and_build_object_response(:get, endpoint_for(id, entity_id, :show)) end |
#find_all(entity_id, page = nil) ⇒ Object
11 12 13 |
# File 'lib/myfinance/resources/financial_account.rb', line 11 def find_all(entity_id, page = nil) request_and_build_collection_response(:get, index_endpoint(entity_id, page)) end |
#update(entity_id, id, params = {}) ⇒ Object
Updates a payable/receivable account
[API] Method: PUT /entities/:entity_id/payable_accounts/:id Method: PUT /entities/:entity_id/receivable_accounts/:id
Documentation: https://app.myfinance.com.br/docs/api/payable_accounts#put_update
Documentation: https://app.myfinance.com.br/docs/api/receivable_accounts#put_update
43 44 45 |
# File 'lib/myfinance/resources/financial_account.rb', line 43 def update(entity_id, id, params = {}) request_and_build_object_response(:put, endpoint_for(id, entity_id, :update), params) end |