Class: TrophyApiClient::UpdateMetricRequestItem

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name: OMIT, unit_type: OMIT, units: OMIT, additional_properties: nil) ⇒ TrophyApiClient::UpdateMetricRequestItem

Parameters:

  • id (String)

    The UUID of the metric to update.

  • name (String) (defaults to: OMIT)

    The updated metric name.

  • unit_type (TrophyApiClient::UpdateMetricRequestItemUnitType) (defaults to: OMIT)

    The updated metric unit type.

  • units (String) (defaults to: OMIT)

    The updated units value. For ‘unitType: currency`, this must be a supported `MetricCurrency` code such as `USD`.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#idString (readonly)

Returns The UUID of the metric to update.

Returns:

  • (String)

    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

#nameString (readonly)

Returns The updated metric name.

Returns:

  • (String)

    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_typeTrophyApiClient::UpdateMetricRequestItemUnitType (readonly)

Returns The updated metric unit type.

Returns:



16
17
18
# File 'lib/trophy_api_client/types/update_metric_request_item.rb', line 16

def unit_type
  @unit_type
end

#unitsString (readonly)

Returns The updated units value. For ‘unitType: currency`, this must be a supported `MetricCurrency` code such as `USD`.

Returns:

  • (String)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


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