Class: BankOfThailand::Client

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

Overview

HTTP client for making requests to the BOT API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) {|Configuration| ... } ⇒ Client

Initialize a new Client

Examples:

With global configuration

client = BankOfThailand::Client.new

With instance configuration

client = BankOfThailand::Client.new do |config|
  config.api_token = "your_token"
end

Yields:



24
25
26
27
28
# File 'lib/bank_of_thailand/client.rb', line 24

def initialize(config = nil)
  @config = config || BankOfThailand.configuration.dup
  yield(@config) if block_given?
  @config.validate!
end

Instance Attribute Details

#configConfiguration (readonly)



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

def config
  @config
end

Instance Method Details

#average_exchange_rateAverageExchangeRate

Access average exchange rate endpoints



50
51
52
# File 'lib/bank_of_thailand/client.rb', line 50

def average_exchange_rate
  @average_exchange_rate ||= AverageExchangeRate.new(self)
end

#debt_securitiesResources::DebtSecurities

Access debt securities auction endpoints



38
39
40
# File 'lib/bank_of_thailand/client.rb', line 38

def debt_securities
  @debt_securities ||= Resources::DebtSecurities.new(self)
end

#deposit_rateDepositRate

Access deposit rate endpoints



56
57
58
# File 'lib/bank_of_thailand/client.rb', line 56

def deposit_rate
  @deposit_rate ||= DepositRate.new(self)
end

#exchange_rateResources::ExchangeRate

Access exchange rate endpoints



32
33
34
# File 'lib/bank_of_thailand/client.rb', line 32

def exchange_rate
  @exchange_rate ||= Resources::ExchangeRate.new(self)
end

#financial_holidaysFinancialHolidays

Access financial holidays endpoints



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

def financial_holidays
  @financial_holidays ||= FinancialHolidays.new(self)
end

#get(path, params = {}) ⇒ Hash

Make a GET request

Raises:



101
102
103
# File 'lib/bank_of_thailand/client.rb', line 101

def get(path, params = {})
  request(:get, path, params: params)
end

#implied_rateImpliedRate

Access implied rate endpoints



86
87
88
# File 'lib/bank_of_thailand/client.rb', line 86

def implied_rate
  @implied_rate ||= ImpliedRate.new(self)
end

#interbank_rateInterbankRate

Access interbank rate endpoints



68
69
70
# File 'lib/bank_of_thailand/client.rb', line 68

def interbank_rate
  @interbank_rate ||= InterbankRate.new(self)
end

#license_checkResources::LicenseCheck

Access license check endpoints



44
45
46
# File 'lib/bank_of_thailand/client.rb', line 44

def license_check
  @license_check ||= Resources::LicenseCheck.new(self)
end

#loan_rateLoanRate

Access loan rate endpoints



74
75
76
# File 'lib/bank_of_thailand/client.rb', line 74

def loan_rate
  @loan_rate ||= LoanRate.new(self)
end

#post(path, body: {}, params: {}) ⇒ Hash

Make a POST request

Raises:



111
112
113
# File 'lib/bank_of_thailand/client.rb', line 111

def post(path, body: {}, params: {})
  request(:post, path, body: body, params: params)
end

#search_seriesSearchSeries

Access search series endpoints



92
93
94
# File 'lib/bank_of_thailand/client.rb', line 92

def search_series
  @search_series ||= SearchSeries.new(self)
end

#swap_pointSwapPoint

Access swap point endpoints



80
81
82
# File 'lib/bank_of_thailand/client.rb', line 80

def swap_point
  @swap_point ||= SwapPoint.new(self)
end