Class: TrophyApiClient::OneOffAchievementResponse
- Inherits:
-
Object
- Object
- TrophyApiClient::OneOffAchievementResponse
- Defined in:
- lib/trophy_api_client/types/one_off_achievement_response.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#achieved_at ⇒ DateTime
readonly
The date and time the achievement was completed, in ISO 8601 format.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#badge_url ⇒ String
readonly
The URL of the badge image for the achievement, if one has been uploaded.
-
#id ⇒ String
readonly
The unique ID of the achievement.
-
#key ⇒ String
readonly
The key used to reference this achievement in the API.
-
#name ⇒ String
readonly
The name of this achievement.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::OneOffAchievementResponse
Deserialize a JSON object to an instance of OneOffAchievementResponse.
-
.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: OMIT, badge_url: OMIT, key: OMIT, achieved_at: OMIT, additional_properties: nil) ⇒ TrophyApiClient::OneOffAchievementResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of OneOffAchievementResponse to a JSON object.
Constructor Details
#initialize(id:, name: OMIT, badge_url: OMIT, key: OMIT, achieved_at: OMIT, additional_properties: nil) ⇒ TrophyApiClient::OneOffAchievementResponse
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 34 def initialize(id:, name: OMIT, badge_url: OMIT, key: OMIT, achieved_at: OMIT, additional_properties: nil) @id = id @name = name if name != OMIT @badge_url = badge_url if badge_url != OMIT @key = key if key != OMIT @achieved_at = achieved_at if achieved_at != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "name": name, "badgeUrl": badge_url, "key": key, "achievedAt": achieved_at }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#achieved_at ⇒ DateTime (readonly)
Returns The date and time the achievement was completed, in ISO 8601 format.
18 19 20 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 18 def achieved_at @achieved_at end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 20 def additional_properties @additional_properties end |
#badge_url ⇒ String (readonly)
Returns The URL of the badge image for the achievement, if one has been uploaded.
14 15 16 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 14 def badge_url @badge_url end |
#id ⇒ String (readonly)
Returns The unique ID of the achievement.
10 11 12 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 10 def id @id end |
#key ⇒ String (readonly)
Returns The key used to reference this achievement in the API.
16 17 18 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 16 def key @key end |
#name ⇒ String (readonly)
Returns The name of this achievement.
12 13 14 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 12 def name @name end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::OneOffAchievementResponse
Deserialize a JSON object to an instance of OneOffAchievementResponse
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 56 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"] badge_url = parsed_json["badgeUrl"] key = parsed_json["key"] achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?) new( id: id, name: name, badge_url: badge_url, key: key, achieved_at: achieved_at, 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.
87 88 89 90 91 92 93 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 87 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.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url 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.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of OneOffAchievementResponse to a JSON object
77 78 79 |
# File 'lib/trophy_api_client/types/one_off_achievement_response.rb', line 77 def to_json(*_args) @_field_set&.to_json end |