Class: TrophyApiClient::WebhooksStreakLostPayload
- Inherits:
-
Object
- Object
- TrophyApiClient::WebhooksStreakLostPayload
- Defined in:
- lib/trophy_api_client/types/webhooks_streak_lost_payload.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#length ⇒ Integer
readonly
The length of the streak that was lost.
-
#type ⇒ String
readonly
The webhook event type.
-
#user ⇒ TrophyApiClient::User
readonly
The user who lost the streak.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::WebhooksStreakLostPayload
Deserialize a JSON object to an instance of WebhooksStreakLostPayload.
-
.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(type:, user:, length:, additional_properties: nil) ⇒ TrophyApiClient::WebhooksStreakLostPayload constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WebhooksStreakLostPayload to a JSON object.
Constructor Details
#initialize(type:, user:, length:, additional_properties: nil) ⇒ TrophyApiClient::WebhooksStreakLostPayload
28 29 30 31 32 33 34 |
# File 'lib/trophy_api_client/types/webhooks_streak_lost_payload.rb', line 28 def initialize(type:, user:, length:, additional_properties: nil) @type = type @user = user @length = length @additional_properties = additional_properties @_field_set = { "type": type, "user": user, "length": length } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
16 17 18 |
# File 'lib/trophy_api_client/types/webhooks_streak_lost_payload.rb', line 16 def additional_properties @additional_properties end |
#length ⇒ Integer (readonly)
14 15 16 |
# File 'lib/trophy_api_client/types/webhooks_streak_lost_payload.rb', line 14 def length @length end |
#type ⇒ String (readonly)
10 11 12 |
# File 'lib/trophy_api_client/types/webhooks_streak_lost_payload.rb', line 10 def type @type end |
#user ⇒ TrophyApiClient::User (readonly)
12 13 14 |
# File 'lib/trophy_api_client/types/webhooks_streak_lost_payload.rb', line 12 def user @user end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::WebhooksStreakLostPayload
Deserialize a JSON object to an instance of WebhooksStreakLostPayload
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/trophy_api_client/types/webhooks_streak_lost_payload.rb', line 40 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) type = parsed_json["type"] if parsed_json["user"].nil? user = nil else user = parsed_json["user"].to_json user = TrophyApiClient::User.from_json(json_object: user) end length = parsed_json["length"] new( type: type, user: user, length: length, 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.
72 73 74 75 76 |
# File 'lib/trophy_api_client/types/webhooks_streak_lost_payload.rb', line 72 def self.validate_raw(obj:) obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") TrophyApiClient::User.validate_raw(obj: obj.user) obj.length.is_a?(Integer) != false || raise("Passed value for field obj.length is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WebhooksStreakLostPayload to a JSON object
62 63 64 |
# File 'lib/trophy_api_client/types/webhooks_streak_lost_payload.rb', line 62 def to_json(*_args) @_field_set&.to_json end |