Class: TrophyApiClient::StreakResponseStreakHistoryItem

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

Overview

An object representing a past streak period.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(period_start:, period_end:, length:, additional_properties: nil) ⇒ TrophyApiClient::StreakResponseStreakHistoryItem

Parameters:

  • period_start (String)

    The date this streak period started.

  • period_end (String)

    The date this streak period ended.

  • length (Integer)

    The length of the user’s streak during this period.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



28
29
30
31
32
33
34
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 28

def initialize(period_start:, period_end:, length:, additional_properties: nil)
  @period_start = period_start
  @period_end = period_end
  @length = length
  @additional_properties = additional_properties
  @_field_set = { "periodStart": period_start, "periodEnd": period_end, "length": length }
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



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

def additional_properties
  @additional_properties
end

#lengthInteger (readonly)

Returns The length of the user’s streak during this period.

Returns:

  • (Integer)

    The length of the user’s streak during this period.



14
15
16
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 14

def length
  @length
end

#period_endString (readonly)

Returns The date this streak period ended.

Returns:

  • (String)

    The date this streak period ended.



12
13
14
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 12

def period_end
  @period_end
end

#period_startString (readonly)

Returns The date this streak period started.

Returns:

  • (String)

    The date this streak period started.



10
11
12
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 10

def period_start
  @period_start
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::StreakResponseStreakHistoryItem

Deserialize a JSON object to an instance of StreakResponseStreakHistoryItem

Parameters:

  • json_object (String)

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 40

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  period_start = parsed_json["periodStart"]
  period_end = parsed_json["periodEnd"]
  length = parsed_json["length"]
  new(
    period_start: period_start,
    period_end: period_end,
    length: length,
    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)


67
68
69
70
71
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 67

def self.validate_raw(obj:)
  obj.period_start.is_a?(String) != false || raise("Passed value for field obj.period_start is not the expected type, validation failed.")
  obj.period_end.is_a?(String) != false || raise("Passed value for field obj.period_end is not the expected type, validation failed.")
  obj.length.is_a?(Integer) != false || raise("Passed value for field obj.length is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of StreakResponseStreakHistoryItem to a JSON object

Returns:

  • (String)


57
58
59
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 57

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