Class: BnmAPI::DailyFXTurnover

Inherits:
Object
  • Object
show all
Defined in:
lib/bnmapi/daily_fx_turnover.rb

Constant Summary collapse

ENDPOINT =
'/fx-turn-over'

Class Method Summary collapse

Class Method Details

.by_date(date) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bnmapi/daily_fx_turnover.rb', line 10

def self.by_date(date)
  date_string = if date.is_a?(Date)
    "#{date.year}-#{date.month}-#{date.day}"
  else
    d = Date.parse(date)
    "#{d.year}-#{d.month}-#{d.day}"
  end

  res = fetch_data(ENDPOINT + '/date/' + date_string)
  present_data(res['data'], res['meta']['last_updated'])
end

.by_month(year:, month:) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/bnmapi/daily_fx_turnover.rb', line 22

def self.by_month(year:, month:)
  res = fetch_data("#{ENDPOINT}/year/#{year}/month/#{month}")

  collection = []
  res['data'].each do |data|
    collection << present_data(data, res['meta']['last_updated'])
  end

  collection
end

.latestObject



5
6
7
8
# File 'lib/bnmapi/daily_fx_turnover.rb', line 5

def self.latest
  res = fetch_data(ENDPOINT)
  present_data(res['data'], res['meta']['last_updated'])
end