Class: Calendarific::V2
- Inherits:
-
Object
- Object
- Calendarific::V2
- Defined in:
- lib/ruby-calendarific.rb
Instance Method Summary collapse
- #holidays(params = Hash.new) ⇒ Object
-
#initialize(api_key = false) ⇒ V2
constructor
A new instance of V2.
Constructor Details
#initialize(api_key = false) ⇒ V2
Returns a new instance of V2.
8 9 10 |
# File 'lib/ruby-calendarific.rb', line 8 def initialize(api_key = false) @api_key = api_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-calendarific.rb', line 12 def holidays(params = Hash.new) if !params.has_key?('api_key') params['api_key'] = @api_key end uri = Addressable::URI.new uri.query_values = params uri = URI("https://calendarific.com/api/v2/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 |