Class: InvestecOpenApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/investec_open_api/client.rb

Constant Summary collapse

INVESTEC_API_URL =
"https://openapi.investec.com/"

Instance Method Summary collapse

Instance Method Details

#accountsObject



15
16
17
18
19
20
# File 'lib/investec_open_api/client.rb', line 15

def accounts
  response = connection.get("za/pb/v1/accounts")
  response.body["data"]["accounts"].map do ||
    InvestecOpenApi::Models::Account.from_api()
  end
end

#authenticate!Object



11
12
13
# File 'lib/investec_open_api/client.rb', line 11

def authenticate!
  @token = get_oauth_token["access_token"]
end

#transactions(account_id, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/investec_open_api/client.rb', line 22

def transactions(, options = {})
  endpoint_url = "za/pb/v1/accounts/#{}/transactions"

  unless options.empty?
    query_string = URI.encode_www_form(options.camelize)
    endpoint_url += "?#{query_string}"
  end
  
  response = connection.get(endpoint_url)
  response.body["data"]["transactions"].map do |transaction_raw|
    InvestecOpenApi::Models::Transaction.from_api(transaction_raw)
  end
end