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: OMIT, additional_properties: nil) ⇒ TrophyApiClient::BulkStreakResponseItem

Parameters:

  • The ID of the user.

  • The length of the user’s streak.

  • (defaults to: OMIT)

    The timestamp the streak was extended, as a string. Null if the streak is not active.

  • (defaults to: nil)

    Additional properties unmapped to the current class definition



29
30
31
32
33
34
35
36
37
# File 'lib/trophy_api_client/types/bulk_streak_response_item.rb', line 29

def initialize(user_id:, streak_length:, extended: OMIT, additional_properties: nil)
  @user_id = user_id
  @streak_length = streak_length
  @extended = extended if extended != OMIT
  @additional_properties = additional_properties
  @_field_set = { "userId": user_id, "streakLength": streak_length, "extended": extended }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#extendedString (readonly)

Returns The timestamp the streak was extended, as a string. Null if the streak is not active.

Returns:

  • The timestamp the streak was extended, as a string. Null if the streak is not active.



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

def extended
  @extended
end

#streak_lengthInteger (readonly)

Returns The length of the user’s streak.

Returns:

  • 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:

  • 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:

Returns:



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

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:

Returns:



70
71
72
73
74
# File 'lib/trophy_api_client/types/bulk_streak_response_item.rb', line 70

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:



60
61
62
# File 'lib/trophy_api_client/types/bulk_streak_response_item.rb', line 60

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