Class: NewDemoApiClient::WeatherComponents

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/types/weather_components.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stage:, date:, weather_gauge: OMIT, actual_annualized: OMIT, potential_annualized: OMIT, potential_annualized_forecast: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::WeatherComponents



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/test_sdk/types/weather_components.rb', line 56

def initialize(stage:, date:, weather_gauge: OMIT, actual_annualized: OMIT, potential_annualized: OMIT,
               potential_annualized_forecast: OMIT, additional_properties: nil)
  @stage = stage
  @date = date
  @weather_gauge = weather_gauge if weather_gauge != OMIT
  @actual_annualized = actual_annualized if actual_annualized != OMIT
  @potential_annualized = potential_annualized if potential_annualized != OMIT
  @potential_annualized_forecast = potential_annualized_forecast if potential_annualized_forecast != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "stage": stage,
    "date": date,
    "weather_gauge": weather_gauge,
    "actual_annualized": actual_annualized,
    "potential_annualized": potential_annualized,
    "potential_annualized_forecast": potential_annualized_forecast
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#actual_annualizedFloat (readonly)



18
19
20
# File 'lib/test_sdk/types/weather_components.rb', line 18

def actual_annualized
  @actual_annualized
end

#additional_propertiesOpenStruct (readonly)



31
32
33
# File 'lib/test_sdk/types/weather_components.rb', line 31

def additional_properties
  @additional_properties
end

#dateString (readonly)



11
12
13
# File 'lib/test_sdk/types/weather_components.rb', line 11

def date
  @date
end

#potential_annualizedFloat (readonly)



24
25
26
# File 'lib/test_sdk/types/weather_components.rb', line 24

def potential_annualized
  @potential_annualized
end

#potential_annualized_forecastFloat (readonly)



29
30
31
# File 'lib/test_sdk/types/weather_components.rb', line 29

def potential_annualized_forecast
  @potential_annualized_forecast
end

#stageString (readonly)



9
10
11
# File 'lib/test_sdk/types/weather_components.rb', line 9

def stage
  @stage
end

#weather_gaugeFloat (readonly)



13
14
15
# File 'lib/test_sdk/types/weather_components.rb', line 13

def weather_gauge
  @weather_gauge
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::WeatherComponents

Deserialize a JSON object to an instance of WeatherComponents



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/test_sdk/types/weather_components.rb', line 81

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  stage = parsed_json["stage"]
  date = parsed_json["date"]
  weather_gauge = parsed_json["weather_gauge"]
  actual_annualized = parsed_json["actual_annualized"]
  potential_annualized = parsed_json["potential_annualized"]
  potential_annualized_forecast = parsed_json["potential_annualized_forecast"]
  new(
    stage: stage,
    date: date,
    weather_gauge: weather_gauge,
    actual_annualized: actual_annualized,
    potential_annualized: potential_annualized,
    potential_annualized_forecast: potential_annualized_forecast,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


114
115
116
117
118
119
120
121
# File 'lib/test_sdk/types/weather_components.rb', line 114

def self.validate_raw(obj:)
  obj.stage.is_a?(String) != false || raise("Passed value for field obj.stage is not the expected type, validation failed.")
  obj.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
  obj.weather_gauge&.is_a?(Float) != false || raise("Passed value for field obj.weather_gauge is not the expected type, validation failed.")
  obj.actual_annualized&.is_a?(Float) != false || raise("Passed value for field obj.actual_annualized is not the expected type, validation failed.")
  obj.potential_annualized&.is_a?(Float) != false || raise("Passed value for field obj.potential_annualized is not the expected type, validation failed.")
  obj.potential_annualized_forecast&.is_a?(Float) != false || raise("Passed value for field obj.potential_annualized_forecast is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of WeatherComponents to a JSON object



104
105
106
# File 'lib/test_sdk/types/weather_components.rb', line 104

def to_json(*_args)
  @_field_set&.to_json
end