Class: TrophyApiClient::WebhooksStreakFreezeConsumedPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, user:, consumed:, freezes:, additional_properties: nil) ⇒ TrophyApiClient::WebhooksStreakFreezeConsumedPayload

Parameters:

  • type (String)

    The webhook event type.

  • user (TrophyApiClient::User)

    The user whose streak freeze was consumed.

  • consumed (Integer)

    The number of freezes consumed.

  • freezes (Integer)

    The total number of freezes the user has left after the consumption.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



31
32
33
34
35
36
37
38
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 31

def initialize(type:, user:, consumed:, freezes:, additional_properties: nil)
  @type = type
  @user = user
  @consumed = consumed
  @freezes = freezes
  @additional_properties = additional_properties
  @_field_set = { "type": type, "user": user, "consumed": consumed, "freezes": freezes }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



18
19
20
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 18

def additional_properties
  @additional_properties
end

#consumedInteger (readonly)

Returns The number of freezes consumed.

Returns:

  • (Integer)

    The number of freezes consumed.



14
15
16
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 14

def consumed
  @consumed
end

#freezesInteger (readonly)

Returns The total number of freezes the user has left after the consumption.

Returns:

  • (Integer)

    The total number of freezes the user has left after the consumption.



16
17
18
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 16

def freezes
  @freezes
end

#typeString (readonly)

Returns The webhook event type.

Returns:

  • (String)

    The webhook event type.



10
11
12
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 10

def type
  @type
end

#userTrophyApiClient::User (readonly)

Returns The user whose streak freeze was consumed.

Returns:



12
13
14
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 12

def user
  @user
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::WebhooksStreakFreezeConsumedPayload

Deserialize a JSON object to an instance of WebhooksStreakFreezeConsumedPayload

Parameters:

  • json_object (String)

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 44

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
  consumed = parsed_json["consumed"]
  freezes = parsed_json["freezes"]
  new(
    type: type,
    user: user,
    consumed: consumed,
    freezes: freezes,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


78
79
80
81
82
83
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 78

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.consumed.is_a?(Integer) != false || raise("Passed value for field obj.consumed is not the expected type, validation failed.")
  obj.freezes.is_a?(Integer) != false || raise("Passed value for field obj.freezes is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of WebhooksStreakFreezeConsumedPayload to a JSON object

Returns:

  • (String)


68
69
70
# File 'lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb', line 68

def to_json(*_args)
  @_field_set&.to_json
end