Class: TrophyApiClient::CreatedMetric
- Inherits:
-
Object
- Object
- TrophyApiClient::CreatedMetric
- Defined in:
- lib/trophy_api_client/types/created_metric.rb
Overview
A successfully created metric returned from the create endpoint.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#id ⇒ String
readonly
The UUID of the created metric.
-
#key ⇒ String
readonly
The metric key.
-
#name ⇒ String
readonly
The metric name.
-
#unit_type ⇒ TrophyApiClient::CreatedMetricUnitType
readonly
The metric unit type.
-
#units ⇒ String
readonly
The stored units value for the metric.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::CreatedMetric
Deserialize a JSON object to an instance of CreatedMetric.
-
.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(id:, name:, key:, unit_type:, units:, additional_properties: nil) ⇒ TrophyApiClient::CreatedMetric constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreatedMetric to a JSON object.
Constructor Details
#initialize(id:, name:, key:, unit_type:, units:, additional_properties: nil) ⇒ TrophyApiClient::CreatedMetric
35 36 37 38 39 40 41 42 43 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 35 def initialize(id:, name:, key:, unit_type:, units:, additional_properties: nil) @id = id @name = name @key = key @unit_type = unit_type @units = units @additional_properties = additional_properties @_field_set = { "id": id, "name": name, "key": key, "unitType": unit_type, "units": units } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
21 22 23 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 21 def additional_properties @additional_properties end |
#id ⇒ String (readonly)
Returns The UUID of the created metric.
11 12 13 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 11 def id @id end |
#key ⇒ String (readonly)
Returns The metric key.
15 16 17 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 15 def key @key end |
#name ⇒ String (readonly)
Returns The metric name.
13 14 15 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 13 def name @name end |
#unit_type ⇒ TrophyApiClient::CreatedMetricUnitType (readonly)
Returns The metric unit type.
17 18 19 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 17 def unit_type @unit_type end |
#units ⇒ String (readonly)
Returns The stored units value for the metric.
19 20 21 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 19 def units @units end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::CreatedMetric
Deserialize a JSON object to an instance of CreatedMetric
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 49 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] name = parsed_json["name"] key = parsed_json["key"] unit_type = parsed_json["unitType"] units = parsed_json["units"] new( id: id, name: name, key: key, unit_type: unit_type, units: units, 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.
80 81 82 83 84 85 86 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 80 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.") obj.unit_type.is_a?(TrophyApiClient::CreatedMetricUnitType) != false || raise("Passed value for field obj.unit_type is not the expected type, validation failed.") obj.units.is_a?(String) != false || raise("Passed value for field obj.units is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CreatedMetric to a JSON object
70 71 72 |
# File 'lib/trophy_api_client/types/created_metric.rb', line 70 def to_json(*_args) @_field_set&.to_json end |