Sha256: 3c56ca11c210ebb4c9824ec53b304e13d15baca976db7f95b8ce8cad50acb4f0
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require 'truelayer/base_repository' require 'truelayer/response' require 'truelayer/card' require 'truelayer/balance' require 'truelayer/transaction' module Truelayer class CardsRepository < BaseRepository def all_cards(webhook_uri: nil) response = get('/data/v1/cards', params: async_params(webhook_uri)) Response.build_with_results(json: response.body, results_class: Card) end def find_card(card_id, webhook_uri: nil) url = format_url('/data/v1/cards/:card_id', card_id: card_id) response = get(url, params: async_params(webhook_uri)) Response.build_with_results(json: response.body, results_class: Card) end def current_balance(card_id, webhook_uri: nil) url = format_url('/data/v1/cards/:card_id/balance', card_id: card_id) response = get(url, params: async_params(webhook_uri)) Response.build_with_results(json: response.body, results_class: Balance) end def transactions(card_id, from: nil, to: nil, webhook_uri: nil) url = format_url('/data/v1/cards/:card_id/transactions', card_id: card_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
4 entries across 4 versions & 1 rubygems