Class: TrophyApiClient::UpdateMetricRequestItem
- Inherits:
-
Object
- Object
- TrophyApiClient::UpdateMetricRequestItem
- Defined in:
- lib/trophy_api_client/types/update_metric_request_item.rb
Overview
A metric update object. ‘id` is required; `name`, `unitType`, and `units` are
optional. `key` cannot be changed through this 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 metric to update.
-
#name ⇒ String
readonly
The updated metric name.
-
#unit_type ⇒ TrophyApiClient::UpdateMetricRequestItemUnitType
readonly
The updated metric unit type.
-
#units ⇒ String
readonly
The updated units value.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::UpdateMetricRequestItem
Deserialize a JSON object to an instance of UpdateMetricRequestItem.
-
.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: OMIT, unit_type: OMIT, units: OMIT, additional_properties: nil) ⇒ TrophyApiClient::UpdateMetricRequestItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of UpdateMetricRequestItem to a JSON object.
Constructor Details
#initialize(id:, name: OMIT, unit_type: OMIT, units: OMIT, additional_properties: nil) ⇒ TrophyApiClient::UpdateMetricRequestItem
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 35 def initialize(id:, name: OMIT, unit_type: OMIT, units: OMIT, additional_properties: nil) @id = id @name = name if name != OMIT @unit_type = unit_type if unit_type != OMIT @units = units if units != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "name": name, "unitType": unit_type, "units": units }.reject do |_k, v| v == OMIT end 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/update_metric_request_item.rb', line 21 def additional_properties @additional_properties end |
#id ⇒ String (readonly)
Returns The UUID of the metric to update.
12 13 14 |
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 12 def id @id end |
#name ⇒ String (readonly)
Returns The updated metric name.
14 15 16 |
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 14 def name @name end |
#unit_type ⇒ TrophyApiClient::UpdateMetricRequestItemUnitType (readonly)
Returns The updated metric unit type.
16 17 18 |
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 16 def unit_type @unit_type end |
#units ⇒ String (readonly)
Returns The updated units value. For ‘unitType: currency`, this must be a supported `MetricCurrency` code such as `USD`.
19 20 21 |
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 19 def units @units end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::UpdateMetricRequestItem
Deserialize a JSON object to an instance of UpdateMetricRequestItem
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 50 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"] unit_type = parsed_json["unitType"] units = parsed_json["units"] new( id: id, name: name, 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.
79 80 81 82 83 84 |
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 79 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.unit_type&.is_a?(TrophyApiClient::UpdateMetricRequestItemUnitType) != 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 UpdateMetricRequestItem to a JSON object
69 70 71 |
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 69 def to_json(*_args) @_field_set&.to_json end |