Class: TrophyApiClient::CreatedAdminPointsSystem
- Inherits:
-
Object
- Object
- TrophyApiClient::CreatedAdminPointsSystem
- Defined in:
- lib/trophy_api_client/types/created_admin_points_system.rb
Overview
A points system returned from the creation endpoint. Extends AdminPointsSystem
with optional sub-entity arrays that are present when those sub-entities were
included in the creation request.
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.
-
#boosts ⇒ Array<TrophyApiClient::AdminPointsBoost>
readonly
Boosts created alongside the system.
-
#description ⇒ String
readonly
The points system description.
-
#id ⇒ String
readonly
The UUID of the points system.
-
#key ⇒ String
readonly
The points system key.
-
#levels ⇒ Array<TrophyApiClient::AdminPointsLevel>
readonly
Levels created alongside the system.
-
#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.
-
#triggers ⇒ Array<TrophyApiClient::AdminPointsTrigger>
readonly
Triggers created alongside the system.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::CreatedAdminPointsSystem
Deserialize a JSON object to an instance of CreatedAdminPointsSystem.
-
.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:, levels: OMIT, boosts: OMIT, triggers: OMIT, badge: OMIT, max_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatedAdminPointsSystem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreatedAdminPointsSystem to a JSON object.
Constructor Details
#initialize(id:, name:, key:, description:, status:, levels: OMIT, boosts: OMIT, triggers: OMIT, badge: OMIT, max_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatedAdminPointsSystem
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 62 def initialize(id:, name:, key:, description:, status:, levels: OMIT, boosts: OMIT, triggers: OMIT, badge: OMIT, max_points: OMIT, additional_properties: nil) @levels = levels if levels != OMIT @boosts = boosts if boosts != OMIT @triggers = triggers if triggers != OMIT @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 = { "levels": levels, "boosts": boosts, "triggers": triggers, "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.
40 41 42 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 40 def additional_properties @additional_properties end |
#badge ⇒ TrophyApiClient::AdminPointsSystemBadge (readonly)
Returns The badge for the points system.
36 37 38 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 36 def badge @badge end |
#boosts ⇒ Array<TrophyApiClient::AdminPointsBoost> (readonly)
Returns Boosts created alongside the system. Present when boosts were provided in the request.
21 22 23 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 21 def boosts @boosts end |
#description ⇒ String (readonly)
Returns The points system description.
32 33 34 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 32 def description @description end |
#id ⇒ String (readonly)
Returns The UUID of the points system.
26 27 28 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 26 def id @id end |
#key ⇒ String (readonly)
Returns The points system key.
30 31 32 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 30 def key @key end |
#levels ⇒ Array<TrophyApiClient::AdminPointsLevel> (readonly)
Returns Levels created alongside the system. Present when levels were provided in the request.
18 19 20 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 18 def levels @levels end |
#max_points ⇒ Integer (readonly)
Returns The maximum points a user can earn.
38 39 40 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 38 def max_points @max_points end |
#name ⇒ String (readonly)
Returns The points system name.
28 29 30 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 28 def name @name end |
#status ⇒ TrophyApiClient::AdminPointsSystemStatus (readonly)
Returns The points system status.
34 35 36 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 34 def status @status end |
#triggers ⇒ Array<TrophyApiClient::AdminPointsTrigger> (readonly)
Returns Triggers created alongside the system. Present when triggers were provided in the request.
24 25 26 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 24 def triggers @triggers end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::CreatedAdminPointsSystem
Deserialize a JSON object to an instance of CreatedAdminPointsSystem
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 95 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) levels = parsed_json["levels"]&.map do |item| item = item.to_json TrophyApiClient::AdminPointsLevel.from_json(json_object: item) end boosts = parsed_json["boosts"]&.map do |item| item = item.to_json TrophyApiClient::AdminPointsBoost.from_json(json_object: item) end triggers = parsed_json["triggers"]&.map do |item| item = item.to_json TrophyApiClient::AdminPointsTrigger.from_json(json_object: item) end 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( levels: levels, boosts: boosts, triggers: triggers, 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.
150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 150 def self.validate_raw(obj:) obj.levels&.is_a?(Array) != false || raise("Passed value for field obj.levels is not the expected type, validation failed.") obj.boosts&.is_a?(Array) != false || raise("Passed value for field obj.boosts is not the expected type, validation failed.") obj.triggers&.is_a?(Array) != false || raise("Passed value for field obj.triggers is not the expected type, validation failed.") 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 CreatedAdminPointsSystem to a JSON object
140 141 142 |
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 140 def to_json(*_args) @_field_set&.to_json end |