Sha256: 18b40ae37f1341161a8dd2a4d49eb3cd64cbabb490702eb709b440da5b6f8711
Contents?: true
Size: 1.55 KB
Versions: 5
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true require 'truelayer/base_repository' require 'truelayer/response' require 'truelayer/account' require 'truelayer/balance' require 'truelayer/transaction' module Truelayer class AccountsRepository < BaseRepository def all_accounts(webhook_uri: nil) response = get('/data/v1/accounts', params: async_params(webhook_uri)) Response.build_with_results(json: response.body, results_class: Account) end def find_account(account_id, webhook_uri: nil) url = format_url('/data/v1/accounts/:account_id', account_id: account_id) response = get(url, params: async_params(webhook_uri)) Response.build_with_results(json: response.body, results_class: Account) end def current_balance(account_id, webhook_uri: nil) url = format_url('/data/v1/accounts/:account_id/balance', account_id: account_id) response = get(url, params: async_params(webhook_uri)) Response.build_with_results(json: response.body, results_class: Balance) end def transactions(account_id, from: nil, to: nil, webhook_uri: nil) url = format_url('/data/v1/accounts/:account_id/transactions', account_id: account_id) response = get(url, params: { from: from, to: to }.merge(async_params(webhook_uri))) Response.build_with_results(json: response.body, results_class: Transaction) end private def async_params(webhook_uri) {}.tap do |params| if webhook_uri params[:async] = true params[:webhook_uri] = webhook_uri end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems