Method: Weatherb::API#initialize
- Defined in:
- lib/weatherb/api.rb
#initialize(api_key) ⇒ API
Create a new instance of the Weatherb::API using your API key. Also create Faraday connection with ParseJson middleware.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/weatherb/api.rb', line 69 def initialize(api_key) @api_key = api_key @connection = Faraday.new API_URL do |conn| conn.response :json, content_type: /\bjson$/ conn.use FaradayMiddleware::RaiseError conn.adapter Faraday.default_adapter end end |