Class: NewDemoApiClient::WeatherMetadata
- Inherits:
-
Object
- Object
- NewDemoApiClient::WeatherMetadata
- Defined in:
- lib/test_sdk/types/weather_metadata.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#asof_date ⇒ String
readonly
The date of the full revision of the input data for the indicator.
-
#categories ⇒ Array<String>
readonly
A list of categories the indicator covers - If null, the indicator includes all covered categories.
- #countries ⇒ Array<String> readonly
-
#indicator_start_date ⇒ String
readonly
The earliest date a data point in the indicator is considered valid.
-
#label ⇒ String
readonly
Label for the weather indicator.
-
#segmentation ⇒ String
readonly
The segmentation type of the weather indicator.
-
#slug ⇒ String
readonly
Slugified label for the weather indicator.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ NewDemoApiClient::WeatherMetadata
Deserialize a JSON object to an instance of WeatherMetadata.
-
.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.
Instance Method Summary collapse
- #initialize(slug:, label:, segmentation:, asof_date:, indicator_start_date:, countries: OMIT, categories: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::WeatherMetadata constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WeatherMetadata to a JSON object.
Constructor Details
#initialize(slug:, label:, segmentation:, asof_date:, indicator_start_date:, countries: OMIT, categories: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::WeatherMetadata
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 41 def initialize(slug:, label:, segmentation:, asof_date:, indicator_start_date:, countries: OMIT, categories: OMIT, additional_properties: nil) @slug = slug @label = label @segmentation = segmentation @asof_date = asof_date @indicator_start_date = indicator_start_date @countries = countries if countries != OMIT @categories = categories if categories != OMIT @additional_properties = additional_properties @_field_set = { "slug": slug, "label": label, "segmentation": segmentation, "asof_date": asof_date, "indicator_start_date": indicator_start_date, "countries": countries, "categories": categories }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
24 25 26 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 24 def additional_properties @additional_properties end |
#asof_date ⇒ String (readonly)
Returns The date of the full revision of the input data for the indicator.
15 16 17 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 15 def asof_date @asof_date end |
#categories ⇒ Array<String> (readonly)
Returns A list of categories the indicator covers - If null, the indicator includes all covered categories.
22 23 24 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 22 def categories @categories end |
#countries ⇒ Array<String> (readonly)
19 20 21 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 19 def countries @countries end |
#indicator_start_date ⇒ String (readonly)
Returns The earliest date a data point in the indicator is considered valid.
17 18 19 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 17 def indicator_start_date @indicator_start_date end |
#label ⇒ String (readonly)
Returns Label for the weather indicator.
11 12 13 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 11 def label @label end |
#segmentation ⇒ String (readonly)
Returns The segmentation type of the weather indicator.
13 14 15 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 13 def segmentation @segmentation end |
#slug ⇒ String (readonly)
Returns Slugified label for the weather indicator.
9 10 11 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 9 def slug @slug end |
Class Method Details
.from_json(json_object:) ⇒ NewDemoApiClient::WeatherMetadata
Deserialize a JSON object to an instance of WeatherMetadata
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 68 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) slug = parsed_json["slug"] label = parsed_json["label"] segmentation = parsed_json["segmentation"] asof_date = parsed_json["asof_date"] indicator_start_date = parsed_json["indicator_start_date"] countries = parsed_json["countries"] categories = parsed_json["categories"] new( slug: slug, label: label, segmentation: segmentation, asof_date: asof_date, indicator_start_date: indicator_start_date, countries: countries, categories: categories, 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.
103 104 105 106 107 108 109 110 111 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 103 def self.validate_raw(obj:) obj.slug.is_a?(String) != false || raise("Passed value for field obj.slug 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.segmentation.is_a?(String) != false || raise("Passed value for field obj.segmentation is not the expected type, validation failed.") obj.asof_date.is_a?(String) != false || raise("Passed value for field obj.asof_date is not the expected type, validation failed.") obj.indicator_start_date.is_a?(String) != false || raise("Passed value for field obj.indicator_start_date is not the expected type, validation failed.") obj.countries&.is_a?(Array) != false || raise("Passed value for field obj.countries is not the expected type, validation failed.") obj.categories&.is_a?(Array) != false || raise("Passed value for field obj.categories is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WeatherMetadata to a JSON object
93 94 95 |
# File 'lib/test_sdk/types/weather_metadata.rb', line 93 def to_json(*_args) @_field_set&.to_json end |