Class: TrophyApiClient::BulkStreakResponseItem

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id:, streak_length:, extended:, additional_properties: nil) ⇒ TrophyApiClient::BulkStreakResponseItem

Parameters:

  • user_id (String)

    The ID of the user.

  • streak_length (Integer)

    The length of the user’s streak.

  • extended (String)

    The timestamp the streak was extended, as a string.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(user_id:, streak_length:, extended:, additional_properties: nil)
  @user_id = user_id
  @streak_length = streak_length
  @extended = extended
  @additional_properties = additional_properties
  @_field_set = { "userId": user_id, "streakLength": streak_length, "extended": extended }
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



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

def additional_properties
  @additional_properties
end

#extendedString (readonly)

Returns The timestamp the streak was extended, as a string.

Returns:

  • (String)

    The timestamp the streak was extended, as a string.



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

def extended
  @extended
end

#streak_lengthInteger (readonly)

Returns The length of the user’s streak.

Returns:

  • (Integer)

    The length of the user’s streak.



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

def streak_length
  @streak_length
end

#user_idString (readonly)

Returns The ID of the user.

Returns:

  • (String)

    The ID of the user.



9
10
11
# File 'lib/trophy_api_client/types/bulk_streak_response_item.rb', line 9

def user_id
  @user_id
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::BulkStreakResponseItem

Deserialize a JSON object to an instance of BulkStreakResponseItem

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  user_id = parsed_json["userId"]
  streak_length = parsed_json["streakLength"]
  extended = parsed_json["extended"]
  new(
    user_id: user_id,
    streak_length: streak_length,
    extended: extended,
    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)


66
67
68
69
70
# File 'lib/trophy_api_client/types/bulk_streak_response_item.rb', line 66

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

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of BulkStreakResponseItem to a JSON object

Returns:

  • (String)


56
57
58
# File 'lib/trophy_api_client/types/bulk_streak_response_item.rb', line 56

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