Sha256: 2b8456bf5e864fff8838d8ab7ea17cd97218efe414a2200339600777bafc34dc

Contents?: true

Size: 452 Bytes

Versions: 1

Compression:

Stored size: 452 Bytes

Contents

# frozen_string_literal: true

class OpenWeatherClient
  def initialize(city)
    @city = city
  end

  def call
    Decorators::OpenWeatherResponse.new(weather_data)
  end

  private

  attr_reader :city

  def weather_data
    Retryable.retryable(tries: 5) do
      @weather_data ||= RestClient.get(location_url)
    end
  end

  def location_url
    "api.openweathermap.org/data/2.5/weather?q=#{city}&appid=#{ENV['OPEN_WEATHER_API_KEY']}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weather_handler-0.1.2 lib/open_weather_client.rb