Class: HolidayAPI::V1
- Inherits:
-
Object
- Object
- HolidayAPI::V1
- Defined in:
- lib/ruby-holidayapi.rb
Instance Method Summary collapse
- #holidays(params = Hash.new) ⇒ Object
-
#initialize(key = false) ⇒ V1
constructor
A new instance of V1.
Constructor Details
#initialize(key = false) ⇒ V1
Returns a new instance of V1.
8 9 10 |
# File 'lib/ruby-holidayapi.rb', line 8 def initialize(key = false) @key = key end |
Instance Method Details
#holidays(params = Hash.new) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby-holidayapi.rb', line 12 def holidays(params = Hash.new) if !params.has_key?('key') params['key'] = @key end uri = Addressable::URI.new uri.query_values = params uri = URI("https://holidayapi.com/v1/holidays?#{uri.query}") Net::HTTP.start( uri.host, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE ) do |http| request = Net::HTTP::Get.new uri response = http.request request return JSON.parse(response.body) end end |