Module: LibTAD::Client::HolidaysService
- Included in:
- LibTAD::Client
- Defined in:
- lib/services/holidays.rb
Overview
Holidays API.
Instance Method Summary collapse
-
#get_holidays(country:, year: nil, lang: nil, types: nil, timezone: nil) ⇒ Array<::LibTAD::Holidays::Holiday>
The Holidays service can be used to retrieve the list of holidays for a country.
Instance Method Details
#get_holidays(country:, year: nil, lang: nil, types: nil, timezone: nil) ⇒ Array<::LibTAD::Holidays::Holiday>
The Holidays service can be used to retrieve the list of holidays for a country.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/services/holidays.rb', line 16 def get_holidays(country:, year: nil, lang: nil, types: nil, timezone: nil) args = { country: country, lang: lang, types: (types unless ![*types].all? { |e| ::LibTAD::Holidays::HOLIDAY_TYPE.include?(e) }), year: if year.nil? then ::Time.now.year else year end, tz: timezone }.compact response = get('holidays', args) holidays = response.fetch('holidays', []) holidays.collect do |e| ::LibTAD::Holidays::Holiday.new(e) end end |