Class: TrophyApiClient::PointsLevelSummaryResponseItem

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/points_level_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(level:, users:, additional_properties: nil) ⇒ TrophyApiClient::PointsLevelSummaryResponseItem

Parameters:

  • level (TrophyApiClient::PointsLevel)
  • users (Integer)

    The number of users currently at this level

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



25
26
27
28
29
30
# File 'lib/trophy_api_client/types/points_level_summary_response_item.rb', line 25

def initialize(level:, users:, additional_properties: nil)
  @level = level
  @users = users
  @additional_properties = additional_properties
  @_field_set = { "level": level, "users": users }
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



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

def additional_properties
  @additional_properties
end

#levelTrophyApiClient::PointsLevel (readonly)



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

def level
  @level
end

#usersInteger (readonly)

Returns The number of users currently at this level.

Returns:

  • (Integer)

    The number of users currently at this level



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

def users
  @users
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::PointsLevelSummaryResponseItem

Deserialize a JSON object to an instance of PointsLevelSummaryResponseItem

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["level"].nil?
    level = nil
  else
    level = parsed_json["level"].to_json
    level = TrophyApiClient::PointsLevel.from_json(json_object: level)
  end
  users = parsed_json["users"]
  new(
    level: level,
    users: users,
    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
# File 'lib/trophy_api_client/types/points_level_summary_response_item.rb', line 66

def self.validate_raw(obj:)
  TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
  obj.users.is_a?(Integer) != false || raise("Passed value for field obj.users is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PointsLevelSummaryResponseItem to a JSON object

Returns:

  • (String)


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

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