Class: InvestecOpenApi::Client
- Inherits:
-
Object
- Object
- InvestecOpenApi::Client
- Defined in:
- lib/investec_open_api/client.rb
Instance Method Summary collapse
- #accounts ⇒ Object
- #authenticate! ⇒ Object
- #balance(account_id) ⇒ Object
-
#pending_transactions(account_id, options = {}) ⇒ Object
Get pending transactions for an account.
-
#transactions(account_id, options = {}) ⇒ Object
Get cleared transactions for an account.
- #transfer_multiple(account_id, transfers, profile_id = nil) ⇒ Object
Instance Method Details
#accounts ⇒ Object
16 17 18 19 20 21 |
# File 'lib/investec_open_api/client.rb', line 16 def accounts response = connection.get("za/pb/v1/accounts") response.body["data"]["accounts"].map do |account_raw| InvestecOpenApi::Models::Account.from_api(account_raw) end end |
#authenticate! ⇒ Object
12 13 14 |
# File 'lib/investec_open_api/client.rb', line 12 def authenticate! @token = get_oauth_token["access_token"] end |
#balance(account_id) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/investec_open_api/client.rb', line 44 def balance(account_id) endpoint_url = "za/pb/v1/accounts/#{account_id}/balance" response = connection.get(endpoint_url) raise "Error fetching balance" if response.body["data"].nil? InvestecOpenApi::Models::Balance.from_api(response.body["data"]) end |
#pending_transactions(account_id, options = {}) ⇒ Object
Get pending transactions for an account
39 40 41 42 |
# File 'lib/investec_open_api/client.rb', line 39 def pending_transactions(account_id, = {}) endpoint_url = "za/pb/v1/accounts/#{account_id}/pending-transactions" perform_transaction_request(endpoint_url, ) end |
#transactions(account_id, options = {}) ⇒ Object
Get cleared transactions for an account
29 30 31 32 |
# File 'lib/investec_open_api/client.rb', line 29 def transactions(account_id, = {}) endpoint_url = "za/pb/v1/accounts/#{account_id}/transactions" perform_transaction_request(endpoint_url, ) end |
#transfer_multiple(account_id, transfers, profile_id = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/investec_open_api/client.rb', line 53 def transfer_multiple( account_id, transfers, profile_id = nil ) endpoint_url = "za/pb/v1/accounts/#{account_id}/transfermultiple" data = { transferList: transfers.map(&:to_h), } data[:profileId] = profile_id if profile_id response = connection.post( endpoint_url, JSON.generate(data) ) response.body end |