Class: Courier::Notifications::NotificationGetContentResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/notifications/types/notification_get_content_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blocks: nil, channels: nil, checksum: nil, additional_properties: nil) ⇒ Notifications::NotificationGetContentResponse

Parameters:



17
18
19
20
21
22
23
24
25
26
# File 'lib/trycourier/notifications/types/notification_get_content_response.rb', line 17

def initialize(blocks: nil, channels: nil, checksum: nil, additional_properties: nil)
  # @type [Array<Notifications::NotificationBlock>]
  @blocks = blocks
  # @type [Array<Notifications::NotificationChannel>]
  @channels = channels
  # @type [String]
  @checksum = checksum
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



10
11
12
# File 'lib/trycourier/notifications/types/notification_get_content_response.rb', line 10

def additional_properties
  @additional_properties
end

#blocksObject (readonly)

Returns the value of attribute blocks.



10
11
12
# File 'lib/trycourier/notifications/types/notification_get_content_response.rb', line 10

def blocks
  @blocks
end

#channelsObject (readonly)

Returns the value of attribute channels.



10
11
12
# File 'lib/trycourier/notifications/types/notification_get_content_response.rb', line 10

def channels
  @channels
end

#checksumObject (readonly)

Returns the value of attribute checksum.



10
11
12
# File 'lib/trycourier/notifications/types/notification_get_content_response.rb', line 10

def checksum
  @checksum
end

Class Method Details

.from_json(json_object:) ⇒ Notifications::NotificationGetContentResponse

Deserialize a JSON object to an instance of NotificationGetContentResponse

Parameters:

  • json_object (JSON)

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/trycourier/notifications/types/notification_get_content_response.rb', line 32

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  blocks = parsed_json["blocks"]&.map do |v|
    v = v.to_json
    Notifications::NotificationBlock.from_json(json_object: v)
  end
  channels = parsed_json["channels"]&.map do |v|
    v = v.to_json
    Notifications::NotificationChannel.from_json(json_object: v)
  end
  checksum = struct.checksum
  new(blocks: blocks, channels: channels, checksum: checksum, 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)


58
59
60
61
62
# File 'lib/trycourier/notifications/types/notification_get_content_response.rb', line 58

def self.validate_raw(obj:)
  obj.blocks&.is_a?(Array) != false || raise("Passed value for field obj.blocks is not the expected type, validation failed.")
  obj.channels&.is_a?(Array) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.")
  obj.checksum&.is_a?(String) != false || raise("Passed value for field obj.checksum is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of NotificationGetContentResponse to a JSON object

Returns:

  • (JSON)


50
51
52
# File 'lib/trycourier/notifications/types/notification_get_content_response.rb', line 50

def to_json(*_args)
  { "blocks": @blocks, "channels": @channels, "checksum": @checksum }.to_json
end