Class: Truelayer::CardsRepository

Inherits:
BaseRepository show all
Defined in:
lib/truelayer/cards_repository.rb

Instance Method Summary collapse

Methods inherited from BaseRepository

#initialize

Constructor Details

This class inherits a constructor from Truelayer::BaseRepository

Instance Method Details

#all_cards(webhook_uri: nil) ⇒ Object



11
12
13
14
15
# File 'lib/truelayer/cards_repository.rb', line 11

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

#current_balance(card_id, webhook_uri: nil) ⇒ Object



24
25
26
27
28
29
# File 'lib/truelayer/cards_repository.rb', line 24

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

#find_card(card_id, webhook_uri: nil) ⇒ Object



17
18
19
20
21
22
# File 'lib/truelayer/cards_repository.rb', line 17

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

#transactions(card_id, from: nil, to: nil, webhook_uri: nil) ⇒ Object



31
32
33
34
35
36
# File 'lib/truelayer/cards_repository.rb', line 31

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