Class: Myfinance::Resources::FinancialTransaction

Inherits:
Base
  • Object
show all
Defined in:
lib/myfinance/resources/financial_transaction.rb

Instance Attribute Summary

Attributes inherited from Base

#http

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Myfinance::Resources::Base

Instance Method Details

#create(entity_id, deposit_account_id, params = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/myfinance/resources/financial_transaction.rb', line 41

def create(entity_id, , params = {})
  #
  # Create a financial transaction
  #
  # [API]
  #   Method: <tt>POST entities/:entity_id/deposit_accounts/:deposit_account_id/financial_transactions</tt>
  #
  #   Documentation: https://app.myfinance.com.br/docs/api/financial_transactions#post_create
  #
  body = { financial_transaction: params }
  http.post(path(entity_id, ), { body: body }) do |response|
    respond_with_object(response, "financial_transaction")
  end
end

#destroy(entity_id, deposit_account_id, id) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/myfinance/resources/financial_transaction.rb', line 71

def destroy(entity_id, , id)
  # Delete a financial transaction
  #
  # [API]
  #   Method: <tt>DELETE entities/:entity_id/deposit_accounts/:deposit_account_id/financial_transactions/:id</tt>
  #
  #   Documentation: https://app.myfinance.com.br/docs/api/financial_transactions#delete_destroy
  #
  ft_path = path(entity_id, ) + "/#{id}"
  http.delete(ft_path, body: {}) do |response|
    response
  end
end

#destroy_many(entity_id, deposit_account_id, ids = []) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/myfinance/resources/financial_transaction.rb', line 85

def destroy_many(entity_id, , ids=[])
  # Delete many financial transactions
  #
  # [API]
  #   Method: <tt>DELETE entities/:entity_id/deposit_accounts/:deposit_account_id/financial_transactions/destroy_many?selected_ids=:id1,id2,id3</tt>
  #
  #   Documentation: https://app.myfinance.com.br/docs/api/financial_transactions#delete_destroy_many
  #
  ft_path = destroy_many_path(entity_id, , ids)
  http.delete(ft_path, body: {}) do |response|
    response
  end
end

#find(entity_id, deposit_account_id, id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/myfinance/resources/financial_transaction.rb', line 26

def find(entity_id, , id)
  #
  # Show a financial transaction
  #
  # [API]
  #   Method: <tt>GET entities/:entity_id/deposit_accounts/:deposit_account_id/financial_transactions/:id</tt>
  #
  #   Documentation: https://app.myfinance.com.br/docs/api/financial_transactions#get_show
  #
  ft_path = path(entity_id, ) + "/#{id}"
  http.get(ft_path, body: {}) do |response|
    respond_with_object(response, "financial_transaction")
  end
end

#find_all(entity_id, deposit_account_id, page = nil) ⇒ Object

A wrapper to Myfinance financial transaction API

[API] Documentation: https://app.myfinance.com.br/docs/api/financial_transactions



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/myfinance/resources/financial_transaction.rb', line 10

def find_all(entity_id, , page = nil)
  #
  # List all financial transactions
  #
  # [API]
  #   Method: <tt>GET entities/:entity_id/deposit_accounts/:deposit_account_id/financial_transactions</tt>
  #
  #   Documentation: https://app.myfinance.com.br/docs/api/financial_transactions#get_index
  #
  fts_path = index_path(entity_id, , page)

  http.get(fts_path, body: {}) do |response|
    respond_with_collection(response)
  end       
end

#update(entity_id, deposit_account_id, id, params = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/myfinance/resources/financial_transaction.rb', line 56

def update(entity_id, , id, params = {})
  # Update a financial transaction
  #
  # [API]
  #   Method: <tt>PUT entities/:entity_id/deposit_accounts/:deposit_account_id/financial_transactions/:id</tt>
  #
  #   Documentation: https://app.myfinance.com.br/docs/api/financial_transactions#put_update
  #
  ft_path = path(entity_id, ) + "/#{id}"
  body = { financial_transaction: params }
  http.put(ft_path, { body: body }) do |response|
    respond_with_object(response, "financial_transaction")
  end
end