Class: TrophyApiClient::WebhooksLeaderboardFinishedPayload

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, leaderboard:, additional_properties: nil) ⇒ TrophyApiClient::WebhooksLeaderboardFinishedPayload



25
26
27
28
29
30
# File 'lib/trophy_api_client/types/webhooks_leaderboard_finished_payload.rb', line 25

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

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



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

def additional_properties
  @additional_properties
end

#leaderboardTrophyApiClient::LeaderboardResponseWithRankings (readonly)



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

def leaderboard
  @leaderboard
end

#typeString (readonly)



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

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::WebhooksLeaderboardFinishedPayload

Deserialize a JSON object to an instance of WebhooksLeaderboardFinishedPayload



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/trophy_api_client/types/webhooks_leaderboard_finished_payload.rb', line 36

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


66
67
68
69
# File 'lib/trophy_api_client/types/webhooks_leaderboard_finished_payload.rb', line 66

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::LeaderboardResponseWithRankings.validate_raw(obj: obj.leaderboard)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of WebhooksLeaderboardFinishedPayload to a JSON object



56
57
58
# File 'lib/trophy_api_client/types/webhooks_leaderboard_finished_payload.rb', line 56

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