Class: TrophyApiClient::Users::UsersMetricEventSummaryResponseItem

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date:, total:, change:, additional_properties: nil) ⇒ TrophyApiClient::Users::UsersMetricEventSummaryResponseItem



30
31
32
33
34
35
36
# File 'lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb', line 30

def initialize(date:, total:, change:, additional_properties: nil)
  @date = date
  @total = total
  @change = change
  @additional_properties = additional_properties
  @_field_set = { "date": date, "total": total, "change": change }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



17
18
19
# File 'lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb', line 17

def additional_properties
  @additional_properties
end

#changeFloat (readonly)



15
16
17
# File 'lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb', line 15

def change
  @change
end

#dateString (readonly)



11
12
13
# File 'lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb', line 11

def date
  @date
end

#totalFloat (readonly)



13
14
15
# File 'lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb', line 13

def total
  @total
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::Users::UsersMetricEventSummaryResponseItem

Deserialize a JSON object to an instance of UsersMetricEventSummaryResponseItem



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb', line 42

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  date = parsed_json["date"]
  total = parsed_json["total"]
  change = parsed_json["change"]
  new(
    date: date,
    total: total,
    change: change,
    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.


69
70
71
72
73
# File 'lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb', line 69

def self.validate_raw(obj:)
  obj.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
  obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
  obj.change.is_a?(Float) != false || raise("Passed value for field obj.change is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of UsersMetricEventSummaryResponseItem to a JSON object



59
60
61
# File 'lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb', line 59

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