Class: TrophyApiClient::AdminPointsSystem

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

Overview

A points system returned from the admin points systems endpoints.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, key:, description:, status:, badge: OMIT, max_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminPointsSystem

Parameters:

  • id (String)

    The UUID of the points system.

  • name (String)

    The points system name.

  • key (String)

    The points system key.

  • description (String)

    The points system description.

  • status (TrophyApiClient::AdminPointsSystemStatus)

    The points system status.

  • badge (TrophyApiClient::AdminPointsSystemBadge) (defaults to: OMIT)

    The badge for the points system.

  • max_points (Integer) (defaults to: OMIT)

    The maximum points a user can earn.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 42

def initialize(id:, name:, key:, description:, status:, badge: OMIT, max_points: OMIT, additional_properties: nil)
  @id = id
  @name = name
  @key = key
  @description = description
  @status = status
  @badge = badge if badge != OMIT
  @max_points = max_points if max_points != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "name": name,
    "key": key,
    "description": description,
    "status": status,
    "badge": badge,
    "maxPoints": max_points
  }.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



26
27
28
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 26

def additional_properties
  @additional_properties
end

#badgeTrophyApiClient::AdminPointsSystemBadge (readonly)

Returns The badge for the points system.

Returns:



22
23
24
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 22

def badge
  @badge
end

#descriptionString (readonly)

Returns The points system description.

Returns:

  • (String)

    The points system description.



18
19
20
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 18

def description
  @description
end

#idString (readonly)

Returns The UUID of the points system.

Returns:

  • (String)

    The UUID of the points system.



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

def id
  @id
end

#keyString (readonly)

Returns The points system key.

Returns:

  • (String)

    The points system key.



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

def key
  @key
end

#max_pointsInteger (readonly)

Returns The maximum points a user can earn.

Returns:

  • (Integer)

    The maximum points a user can earn.



24
25
26
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 24

def max_points
  @max_points
end

#nameString (readonly)

Returns The points system name.

Returns:

  • (String)

    The points system name.



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

def name
  @name
end

#statusTrophyApiClient::AdminPointsSystemStatus (readonly)

Returns The points system status.

Returns:



20
21
22
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 20

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::AdminPointsSystem

Deserialize a JSON object to an instance of AdminPointsSystem

Parameters:

  • json_object (String)

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 68

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  name = parsed_json["name"]
  key = parsed_json["key"]
  description = parsed_json["description"]
  status = parsed_json["status"]
  if parsed_json["badge"].nil?
    badge = nil
  else
    badge = parsed_json["badge"].to_json
    badge = TrophyApiClient::AdminPointsSystemBadge.from_json(json_object: badge)
  end
  max_points = parsed_json["maxPoints"]
  new(
    id: id,
    name: name,
    key: key,
    description: description,
    status: status,
    badge: badge,
    max_points: max_points,
    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)


108
109
110
111
112
113
114
115
116
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 108

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.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.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
  obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.status.is_a?(TrophyApiClient::AdminPointsSystemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.badge.nil? || TrophyApiClient::AdminPointsSystemBadge.validate_raw(obj: obj.badge)
  obj.max_points&.is_a?(Integer) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AdminPointsSystem to a JSON object

Returns:

  • (String)


98
99
100
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 98

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