Class: TrophyApiClient::WebhooksStreakExtendedPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/webhooks_streak_extended_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:, streak:, additional_properties: nil) ⇒ TrophyApiClient::WebhooksStreakExtendedPayload



29
30
31
32
33
34
35
# File 'lib/trophy_api_client/types/webhooks_streak_extended_payload.rb', line 29

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

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



17
18
19
# File 'lib/trophy_api_client/types/webhooks_streak_extended_payload.rb', line 17

def additional_properties
  @additional_properties
end

#streakTrophyApiClient::BaseStreakResponse (readonly)



15
16
17
# File 'lib/trophy_api_client/types/webhooks_streak_extended_payload.rb', line 15

def streak
  @streak
end

#typeString (readonly)



11
12
13
# File 'lib/trophy_api_client/types/webhooks_streak_extended_payload.rb', line 11

def type
  @type
end

#userTrophyApiClient::User (readonly)



13
14
15
# File 'lib/trophy_api_client/types/webhooks_streak_extended_payload.rb', line 13

def user
  @user
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::WebhooksStreakExtendedPayload

Deserialize a JSON object to an instance of WebhooksStreakExtendedPayload



41
42
43
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_extended_payload.rb', line 41

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
  if parsed_json["streak"].nil?
    streak = nil
  else
    streak = parsed_json["streak"].to_json
    streak = TrophyApiClient::BaseStreakResponse.from_json(json_object: streak)
  end
  new(
    type: type,
    user: user,
    streak: streak,
    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.


78
79
80
81
82
# File 'lib/trophy_api_client/types/webhooks_streak_extended_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)
  TrophyApiClient::BaseStreakResponse.validate_raw(obj: obj.streak)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of WebhooksStreakExtendedPayload to a JSON object



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

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