Class: Starling::Client

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

Overview

The client for the Starling Bank API, providing authenticated access to the various endpoints offered in the API, with a uniform, idiomatic Ruby interface.

Constant Summary collapse

ENVIRONMENT_BASE_URLS =

URLs for the two Starling Bank API environments, production and sandbox

{
  production: 'https://api.starlingbank.com',
  sandbox: 'https://api-sandbox.starlingbank.com'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, environment: :production, default_headers: {}, connection_options: {}) ⇒ Starling::Client

Instantiates a client for accessing the Starling Bank API

Parameters:

  • access_token (String)

    A personal access token for the Starling Bank API

  • environment (Symbol)

    The API environment to use, either :production or :sandbox

  • default_headers (Hash)

    A set of HTTP headers to add to each request, alongside the library's defaults defined in ApiService#library_default_headers

  • connection_options (Hash)

    A hash of options to be passed in when instantiating Faraday (for example for setting the request timeout)


25
26
27
28
29
30
31
# File 'lib/starling/client.rb', line 25

def initialize(access_token:, environment: :production, default_headers: {},
               connection_options: {})
  @api_service = ApiService.new(fetch_base_url_for_environment(environment),
                                access_token: access_token,
                                default_headers: default_headers,
                                connection_options: connection_options)
end

Instance Method Details

#accountStarling::Services::AccountService

Provides access to the Account API

Returns:


37
38
39
# File 'lib/starling/client.rb', line 37

def 
  Services::AccountService.new(@api_service)
end

#account_balanceStarling::Services::AccountBalanceService

Provides access to the Account Balance API

Returns:


46
47
48
# File 'lib/starling/client.rb', line 46

def 
  Services::AccountBalanceService.new(@api_service)
end

#addressesStarling::Services::AddressesService

Provides access to the Addresses API

Returns:


103
104
105
# File 'lib/starling/client.rb', line 103

def addresses
  Services::AddressesService.new(@api_service)
end

#cardStarling::Services::CardService

Provides access to the Card API

Returns:


79
80
81
# File 'lib/starling/client.rb', line 79

def card
  Services::CardService.new(@api_service)
end

#contact_accountsStarling::Services::ContactAccountsService

Provides access to the Contact Accounts API

Returns:


129
130
131
# File 'lib/starling/client.rb', line 129

def contact_accounts
  Services::ContactAccountsService.new(@api_service)
end

#contactsStarling::Services::ContactsService

Provides access to the Contacts API

Returns:


120
121
122
# File 'lib/starling/client.rb', line 120

def contacts
  Services::ContactsService.new(@api_service)
end

#customerStarling::Services::CustomerService

Provides access to the Customer API

Returns:


95
96
97
# File 'lib/starling/client.rb', line 95

def customer
  Services::CustomerService.new(@api_service)
end

#direct_debit_mandatesStarling::Services::DirectDebitMandatesService

Provides access to the Direct Debit Mandates API

Returns:


112
113
114
# File 'lib/starling/client.rb', line 112

def direct_debit_mandates
  Services::DirectDebitMandatesService.new(@api_service)
end

#direct_debit_transactionsStarling::Services::DirectDebitTransactionsService

Provides access to the Transaction Direct Debit API

Returns:


168
169
170
# File 'lib/starling/client.rb', line 168

def direct_debit_transactions
  Services::DirectDebitTransactionsService.new(@api_service)
end

#inbound_faster_payments_transactionsStarling::Services::InboundFasterPaymentsTransactionsService

Provides access to the Transaction Faster Payment In API

Returns:


143
144
145
# File 'lib/starling/client.rb', line 143

def inbound_faster_payments_transactions
  Services::InboundFasterPaymentsTransactionsService.new(@api_service)
end

#mastercard_transactionsStarling::Services::MastercardTransactionsService

Provides access to the Transaction Mastercard API

Returns:


186
187
188
# File 'lib/starling/client.rb', line 186

def mastercard_transactions
  Services::MastercardTransactionsService.new(@api_service)
end

#meStarling::Services::MeService

Provides access to the Who Am I (Me) API

Returns:


87
88
89
# File 'lib/starling/client.rb', line 87

def me
  Services::MeService.new(@api_service)
end

#merchant_locationsStarling::Services::MerchantLocationsService

Provides access to the Merchants Locations API

Returns:


71
72
73
# File 'lib/starling/client.rb', line 71

def merchant_locations
  Services::MerchantLocationsService.new(@api_service)
end

#merchantsStarling::Services::MerchantsService

Provides access to the Merchants API

Returns:


62
63
64
# File 'lib/starling/client.rb', line 62

def merchants
  Services::MerchantsService.new(@api_service)
end

#outbound_faster_payments_transactionsStarling::Services::OutboundFasterPaymentsTransactionsService

Provides access to the Transaction Faster Payment Out API

Returns:


158
159
160
# File 'lib/starling/client.rb', line 158

def outbound_faster_payments_transactions
  Services::OutboundFasterPaymentsTransactionsService.new(@api_service)
end

#paymentsStarling::Services::PaymentsService

Provides access to the Payment API

Returns:


176
177
178
# File 'lib/starling/client.rb', line 176

def payments
  Services::PaymentsService.new(@api_service)
end

#transactionsStarling::Services::TransactionsService

Provides access to the Transactions API

Returns:


54
55
56
# File 'lib/starling/client.rb', line 54

def transactions
  Services::TransactionsService.new(@api_service)
end