Class: TrophyApiClient::AdminPointsSystem
- Inherits:
-
Object
- Object
- TrophyApiClient::AdminPointsSystem
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#badge ⇒ TrophyApiClient::AdminPointsSystemBadge
readonly
The badge for the points system.
-
#description ⇒ String
readonly
The points system description.
-
#id ⇒ String
readonly
The UUID of the points system.
-
#key ⇒ String
readonly
The points system key.
-
#max_points ⇒ Integer
readonly
The maximum points a user can earn.
-
#name ⇒ String
readonly
The points system name.
-
#status ⇒ TrophyApiClient::AdminPointsSystemStatus
readonly
The points system status.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::AdminPointsSystem
Deserialize a JSON object to an instance of AdminPointsSystem.
-
.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.
Instance Method Summary collapse
- #initialize(id:, name:, key:, description:, status:, badge: OMIT, max_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminPointsSystem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AdminPointsSystem to a JSON object.
Constructor Details
#initialize(id:, name:, key:, description:, status:, badge: OMIT, max_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminPointsSystem
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_properties ⇒ OpenStruct (readonly)
Returns 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 |
#badge ⇒ TrophyApiClient::AdminPointsSystemBadge (readonly)
Returns The badge for the points system.
22 23 24 |
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 22 def badge @badge end |
#description ⇒ String (readonly)
Returns The points system description.
18 19 20 |
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 18 def description @description end |
#id ⇒ String (readonly)
Returns 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 |
#key ⇒ String (readonly)
Returns The points system key.
16 17 18 |
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 16 def key @key end |
#max_points ⇒ Integer (readonly)
Returns 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 |
#name ⇒ String (readonly)
Returns The points system name.
14 15 16 |
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 14 def name @name end |
#status ⇒ TrophyApiClient::AdminPointsSystemStatus (readonly)
Returns The points system status.
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
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.
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
98 99 100 |
# File 'lib/trophy_api_client/types/admin_points_system.rb', line 98 def to_json(*_args) @_field_set&.to_json end |