Class: FreeAgent::BankTransactionsResource
- Inherits:
-
Resource
- Object
- Resource
- FreeAgent::BankTransactionsResource
show all
- Defined in:
- lib/free_agent/resources/bank_transactions.rb
Instance Attribute Summary
Attributes inherited from Resource
#client
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#create(bank_account:, statement:) ⇒ Object
Statement should be an array of transactions
17
18
19
20
|
# File 'lib/free_agent/resources/bank_transactions.rb', line 17
def create(bank_account:, statement:)
response = post_request("bank_transactions/statement?bank_account=#{bank_account}", body: {statement: statement})
response.success?
end
|
#delete(id:) ⇒ Object
31
32
33
34
|
# File 'lib/free_agent/resources/bank_transactions.rb', line 31
def delete(id:)
response = delete_request("bank_transactions/#{id}")
response.success?
end
|
#list(bank_account:, **params) ⇒ Object
4
5
6
7
8
9
|
# File 'lib/free_agent/resources/bank_transactions.rb', line 4
def list(bank_account:, **params)
attributes = {bank_account: bank_account}
response = get_request("bank_transactions", params: attributes.merge(params))
Collection.from_response(response, type: BankTransaction, key: "bank_transactions")
end
|
#retrieve(id:) ⇒ Object
11
12
13
14
|
# File 'lib/free_agent/resources/bank_transactions.rb', line 11
def retrieve(id:)
response = get_request("bank_transactions/#{id}")
BankTransaction.new(response.body["bank_transaction"])
end
|
#upload(bank_account:, statement:) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/free_agent/resources/bank_transactions.rb', line 22
def upload(bank_account:, statement:)
payload = {}
payload[:statement] = Faraday::Multipart::FilePart.new(statement, 'text/x-ruby')
response = client.connection_upload.post "bank_transactions/statement?bank_account=#{bank_account}", payload
response.success?
end
|