class Services::Infrastructure::Adapters::Weather::GoogleWeatherResponse
Google Weather API response
Wraps the raw JSON from the Weather API and exposes:
-
data — Hash from the API (e.g.
currentTime,temperature,weatherCondition,relativeHumidity). -
source —
:api_responseor:cached_response
Example
response = GoogleCurrentWeatherResponse.new(api_json, :api_response) response.data["temperature"]["degrees"] # => 25.3 response.source # => :api_response
Attributes
Public Class Methods
Source
# File app/services/infrastructure/adapters/weather/google_weather_response.rb 26 def initialize(data, source) 27 raise ArgumentError, "Data cannot be nil" if data.nil? 28 raise ArgumentError, "Source must be a symbol" unless source.is_a?(Symbol) 29 30 @data = data 31 @source = source 32 end
Builds a response from raw data and source.
-
data — Hash from the
WeatherAPI (must not benil). -
source — Symbol
:api_responseor:cached_response.