Class: TrophyApiClient::WebhooksPointsBoostFinishedPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/webhooks_points_boost_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:, timestamp:, boost:, additional_properties: nil) ⇒ TrophyApiClient::WebhooksPointsBoostFinishedPayload

Parameters:

  • type (String)

    The webhook event type.

  • timestamp (DateTime)

    When the event occurred (ISO 8601).

  • boost (TrophyApiClient::PointsBoostWebhookPayload)

    The points boost that finished.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(type:, timestamp:, boost:, additional_properties: nil)
  @type = type
  @timestamp = timestamp
  @boost = boost
  @additional_properties = additional_properties
  @_field_set = { "type": type, "timestamp": timestamp, "boost": boost }
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



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

def additional_properties
  @additional_properties
end

#boostTrophyApiClient::PointsBoostWebhookPayload (readonly)

Returns The points boost that finished.

Returns:



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

def boost
  @boost
end

#timestampDateTime (readonly)

Returns When the event occurred (ISO 8601).

Returns:

  • (DateTime)

    When the event occurred (ISO 8601).



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

def timestamp
  @timestamp
end

#typeString (readonly)

Returns The webhook event type.

Returns:

  • (String)

    The webhook event type.



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

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::WebhooksPointsBoostFinishedPayload

Deserialize a JSON object to an instance of WebhooksPointsBoostFinishedPayload

Parameters:

  • json_object (String)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/trophy_api_client/types/webhooks_points_boost_finished_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"]
  timestamp = (DateTime.parse(parsed_json["timestamp"]) unless parsed_json["timestamp"].nil?)
  if parsed_json["boost"].nil?
    boost = nil
  else
    boost = parsed_json["boost"].to_json
    boost = TrophyApiClient::PointsBoostWebhookPayload.from_json(json_object: boost)
  end
  new(
    type: type,
    timestamp: timestamp,
    boost: boost,
    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)


73
74
75
76
77
# File 'lib/trophy_api_client/types/webhooks_points_boost_finished_payload.rb', line 73

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.")
  obj.timestamp.is_a?(DateTime) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.")
  TrophyApiClient::PointsBoostWebhookPayload.validate_raw(obj: obj.boost)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of WebhooksPointsBoostFinishedPayload to a JSON object

Returns:

  • (String)


63
64
65
# File 'lib/trophy_api_client/types/webhooks_points_boost_finished_payload.rb', line 63

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