Class: TrophyApiClient::StreakRankingUser

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

Overview

A user with their streak length in the rankings.

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

Parameters:

  • user_id (String)

    The ID of the user.

  • name (String) (defaults to: OMIT)

    The name of the user. May be null if no name is set.

  • streak_length (Integer)

    The user’s streak length (active or longest depending on query parameter).

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(user_id:, streak_length:, name: OMIT, additional_properties: nil)
  @user_id = user_id
  @name = name if name != OMIT
  @streak_length = streak_length
  @additional_properties = additional_properties
  @_field_set = { "userId": user_id, "name": name, "streakLength": streak_length }.reject do |_k, v|
    v == OMIT
  end
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_ranking_user.rb', line 16

def additional_properties
  @additional_properties
end

#nameString (readonly)

Returns The name of the user. May be null if no name is set.

Returns:

  • (String)

    The name of the user. May be null if no name is set.



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

def name
  @name
end

#streak_lengthInteger (readonly)

Returns The user’s streak length (active or longest depending on query parameter).

Returns:

  • (Integer)

    The user’s streak length (active or longest depending on query parameter).



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

def streak_length
  @streak_length
end

#user_idString (readonly)

Returns The ID of the user.

Returns:

  • (String)

    The ID of the user.



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

def user_id
  @user_id
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::StreakRankingUser

Deserialize a JSON object to an instance of StreakRankingUser

Parameters:

  • json_object (String)

Returns:



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

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"]
  name = parsed_json["name"]
  streak_length = parsed_json["streakLength"]
  new(
    user_id: user_id,
    name: name,
    streak_length: streak_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)


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

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.name&.is_a?(String) != false || raise("Passed value for field obj.name 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.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of StreakRankingUser to a JSON object

Returns:

  • (String)


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

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