Class: NewDemoApiClient::WeatherGauge

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date:, label:, weather_gauge: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::WeatherGauge



29
30
31
32
33
34
35
36
37
# File 'lib/test_sdk/types/weather_gauge.rb', line 29

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

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



16
17
18
# File 'lib/test_sdk/types/weather_gauge.rb', line 16

def additional_properties
  @additional_properties
end

#dateString (readonly)



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

def date
  @date
end

#labelString (readonly)



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

def label
  @label
end

#weather_gaugeFloat (readonly)



14
15
16
# File 'lib/test_sdk/types/weather_gauge.rb', line 14

def weather_gauge
  @weather_gauge
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::WeatherGauge

Deserialize a JSON object to an instance of WeatherGauge



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/test_sdk/types/weather_gauge.rb', line 43

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  date = parsed_json["date"]
  label = parsed_json["label"]
  weather_gauge = parsed_json["weather_gauge"]
  new(
    date: date,
    label: label,
    weather_gauge: weather_gauge,
    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.


70
71
72
73
74
# File 'lib/test_sdk/types/weather_gauge.rb', line 70

def self.validate_raw(obj:)
  obj.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
  obj.label.is_a?(String) != false || raise("Passed value for field obj.label 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.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of WeatherGauge to a JSON object



60
61
62
# File 'lib/test_sdk/types/weather_gauge.rb', line 60

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