Class: TrophyApiClient::Users::UsersPointsEventSummaryResponseItem

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/users/types/users_points_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::UsersPointsEventSummaryResponseItem

Parameters:

  • date (String)

    The date of the data point. For weekly or monthly aggregations, this is the first date of the period.

  • total (Float)

    The user’s total points at the end of this date.

  • change (Float)

    The change in the user’s total points during this period.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



30
31
32
33
34
35
36
# File 'lib/trophy_api_client/users/types/users_points_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)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#changeFloat (readonly)

Returns The change in the user’s total points during this period.

Returns:

  • (Float)

    The change in the user’s total points during this period.



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

def change
  @change
end

#dateString (readonly)

Returns The date of the data point. For weekly or monthly aggregations, this is the first date of the period.

Returns:

  • (String)

    The date of the data point. For weekly or monthly aggregations, this is the first date of the period.



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

def date
  @date
end

#totalFloat (readonly)

Returns The user’s total points at the end of this date.

Returns:

  • (Float)

    The user’s total points at the end of this date.



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

def total
  @total
end

Class Method Details

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

Deserialize a JSON object to an instance of UsersPointsEventSummaryResponseItem

Parameters:

  • json_object (String)

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/trophy_api_client/users/types/users_points_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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


69
70
71
72
73
# File 'lib/trophy_api_client/users/types/users_points_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 UsersPointsEventSummaryResponseItem to a JSON object

Returns:

  • (String)


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

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