Class: TrophyApiClient::CreatePointsLevelRequestItem
- Inherits:
-
Object
- Object
- TrophyApiClient::CreatePointsLevelRequestItem
- Defined in:
- lib/trophy_api_client/types/create_points_level_request_item.rb
Overview
A points level to create.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#badge ⇒ TrophyApiClient::CreatePointsLevelRequestItemBadge
readonly
An optional badge for the level.
-
#description ⇒ String
readonly
An optional description of the level.
-
#key ⇒ String
readonly
A unique key for the level.
-
#name ⇒ String
readonly
The name of the level.
-
#points ⇒ Integer
readonly
The threshold points value for the level.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::CreatePointsLevelRequestItem
Deserialize a JSON object to an instance of CreatePointsLevelRequestItem.
-
.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(name:, key:, points:, description: OMIT, badge: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatePointsLevelRequestItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreatePointsLevelRequestItem to a JSON object.
Constructor Details
#initialize(name:, key:, points:, description: OMIT, badge: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatePointsLevelRequestItem
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 37 def initialize(name:, key:, points:, description: OMIT, badge: OMIT, additional_properties: nil) @name = name @key = key @points = points @description = description if description != OMIT @badge = badge if badge != OMIT @additional_properties = additional_properties @_field_set = { "name": name, "key": key, "points": points, "description": description, "badge": badge }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
22 23 24 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 22 def additional_properties @additional_properties end |
#badge ⇒ TrophyApiClient::CreatePointsLevelRequestItemBadge (readonly)
Returns An optional badge for the level.
20 21 22 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 20 def badge @badge end |
#description ⇒ String (readonly)
Returns An optional description of the level.
18 19 20 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 18 def description @description end |
#key ⇒ String (readonly)
Returns A unique key for the level. Only alphanumeric characters, hyphens, and underscores are permitted.
14 15 16 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 14 def key @key end |
#name ⇒ String (readonly)
Returns The name of the level.
11 12 13 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 11 def name @name end |
#points ⇒ Integer (readonly)
Returns The threshold points value for the level.
16 17 18 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 16 def points @points end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::CreatePointsLevelRequestItem
Deserialize a JSON object to an instance of CreatePointsLevelRequestItem
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 59 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) name = parsed_json["name"] key = parsed_json["key"] points = parsed_json["points"] description = parsed_json["description"] if parsed_json["badge"].nil? badge = nil else badge = parsed_json["badge"].to_json badge = TrophyApiClient::CreatePointsLevelRequestItemBadge.from_json(json_object: badge) end new( name: name, key: key, points: points, description: description, badge: badge, 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.
95 96 97 98 99 100 101 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 95 def self.validate_raw(obj:) 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.points.is_a?(Integer) != false || raise("Passed value for field obj.points 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.badge.nil? || TrophyApiClient::CreatePointsLevelRequestItemBadge.validate_raw(obj: obj.badge) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CreatePointsLevelRequestItem to a JSON object
85 86 87 |
# File 'lib/trophy_api_client/types/create_points_level_request_item.rb', line 85 def to_json(*_args) @_field_set&.to_json end |