Class: NewDemoApiClient::WeatherMetadata

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slug:, label:, segmentation:, asof_date:, indicator_start_date:, countries: OMIT, categories: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::WeatherMetadata

Parameters:

  • slug (String)

    Slugified label for the weather indicator

  • label (String)

    Label for the weather indicator

  • segmentation (String)

    The segmentation type of the weather indicator

  • asof_date (String)

    The date of the full revision of the input data for the indicator

  • indicator_start_date (String)

    The earliest date a data point in the indicator is considered valid

  • countries (Array<String>) (defaults to: OMIT)
  • categories (Array<String>) (defaults to: OMIT)

    A list of categories the indicator covers - If null, the indicator includes all covered categories

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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_dateString (readonly)

Returns The date of the full revision of the input data for the indicator.

Returns:

  • (String)

    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

#categoriesArray<String> (readonly)

Returns A list of categories the indicator covers - If null, the indicator includes all covered categories.

Returns:

  • (Array<String>)

    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

#countriesArray<String> (readonly)

Returns:

  • (Array<String>)


19
20
21
# File 'lib/test_sdk/types/weather_metadata.rb', line 19

def countries
  @countries
end

#indicator_start_dateString (readonly)

Returns The earliest date a data point in the indicator is considered valid.

Returns:

  • (String)

    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

#labelString (readonly)

Returns Label for the weather indicator.

Returns:

  • (String)

    Label for the weather indicator



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

def label
  @label
end

#segmentationString (readonly)

Returns The segmentation type of the weather indicator.

Returns:

  • (String)

    The segmentation type of the weather indicator



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

def segmentation
  @segmentation
end

#slugString (readonly)

Returns Slugified label for the weather indicator.

Returns:

  • (String)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


93
94
95
# File 'lib/test_sdk/types/weather_metadata.rb', line 93

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