Class: Courier::Bulk::InboundBulkTemplateMessage
- Inherits:
-
Object
- Object
- Courier::Bulk::InboundBulkTemplateMessage
- Defined in:
- lib/trycourier/bulk/types/inbound_bulk_template_message.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#brand_id ⇒ Object
readonly
Returns the value of attribute brand_id.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#expiry ⇒ Object
readonly
Returns the value of attribute expiry.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#providers ⇒ Object
readonly
Returns the value of attribute providers.
-
#routing ⇒ Object
readonly
Returns the value of attribute routing.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Bulk::InboundBulkTemplateMessage
Deserialize a JSON object to an instance of InboundBulkTemplateMessage.
-
.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.
Instance Method Summary collapse
- #initialize(template:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) ⇒ Bulk::InboundBulkTemplateMessage constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of InboundBulkTemplateMessage to a JSON object.
Constructor Details
#initialize(template:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) ⇒ Bulk::InboundBulkTemplateMessage
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 36 def initialize(template:, data: nil, brand_id: nil, channels: nil, context: nil, metadata: nil, providers: nil, routing: nil, timeout: nil, delay: nil, expiry: nil, additional_properties: nil) # @type [String] The id of the notification template to be rendered and sent to the recipient(s). # This field or the content field must be supplied. @template = template # @type [Send::MESSAGE_DATA] An arbitrary object that includes any data you want to pass to the message. # The data will populate the corresponding template or elements variables. @data = data # @type [String] @brand_id = brand_id # @type [Send::MESSAGE_CHANNELS] "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." @channels = channels # @type [Send::MessageContext] Context to load with this recipient. Will override any context set on message.context. @context = context # @type [Send::MessageMetadata] Metadata such as utm tracking attached with the notification through this channel. @metadata = # @type [Send::MESSAGE_PROVIDERS] An object whose keys are valid provider identifiers which map to an object. @providers = providers # @type [Send::Routing] @routing = routing # @type [Send::Timeout] Time in ms to attempt the channel before failing over to the next available channel. @timeout = timeout # @type [Send::Delay] Defines the time to wait before delivering the message. @delay = delay # @type [Send::Expiry] "Expiry allows you to set an absolute or relative time in which a message expires. # Note: This is only valid for the Courier Inbox channel as of 12-08-2022." @expiry = expiry # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def additional_properties @additional_properties end |
#brand_id ⇒ Object (readonly)
Returns the value of attribute brand_id.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def brand_id @brand_id end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def channels @channels end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def context @context end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def data @data end |
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def delay @delay end |
#expiry ⇒ Object (readonly)
Returns the value of attribute expiry.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def expiry @expiry end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def @metadata end |
#providers ⇒ Object (readonly)
Returns the value of attribute providers.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def providers @providers end |
#routing ⇒ Object (readonly)
Returns the value of attribute routing.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def routing @routing end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def template @template end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
17 18 19 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 17 def timeout @timeout end |
Class Method Details
.from_json(json_object:) ⇒ Bulk::InboundBulkTemplateMessage
Deserialize a JSON object to an instance of InboundBulkTemplateMessage
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 71 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) template = struct.template data = struct.data brand_id = struct.brand_id channels = struct.channels if parsed_json["context"].nil? context = nil else context = parsed_json["context"].to_json context = Send::MessageContext.from_json(json_object: context) end if parsed_json["metadata"].nil? = nil else = parsed_json["metadata"].to_json = Send::MessageMetadata.from_json(json_object: ) end providers = struct.providers if parsed_json["routing"].nil? routing = nil else routing = parsed_json["routing"].to_json routing = Send::Routing.from_json(json_object: routing) end if parsed_json["timeout"].nil? timeout = nil else timeout = parsed_json["timeout"].to_json timeout = Send::Timeout.from_json(json_object: timeout) end if parsed_json["delay"].nil? delay = nil else delay = parsed_json["delay"].to_json delay = Send::Delay.from_json(json_object: delay) end if parsed_json["expiry"].nil? expiry = nil else expiry = parsed_json["expiry"].to_json expiry = Send::Expiry.from_json(json_object: expiry) end new(template: template, data: data, brand_id: brand_id, channels: channels, context: context, metadata: , providers: providers, routing: routing, timeout: timeout, delay: delay, expiry: expiry, 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.
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 142 def self.validate_raw(obj:) obj.template.is_a?(String) != false || raise("Passed value for field obj.template is not the expected type, validation failed.") obj.data&.is_a?(Hash) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") obj.brand_id&.is_a?(String) != false || raise("Passed value for field obj.brand_id is not the expected type, validation failed.") obj.channels&.is_a?(Hash) != false || raise("Passed value for field obj.channels is not the expected type, validation failed.") obj.context.nil? || Send::MessageContext.validate_raw(obj: obj.context) obj..nil? || Send::MessageMetadata.validate_raw(obj: obj.) obj.providers&.is_a?(Hash) != false || raise("Passed value for field obj.providers is not the expected type, validation failed.") obj.routing.nil? || Send::Routing.validate_raw(obj: obj.routing) obj.timeout.nil? || Send::Timeout.validate_raw(obj: obj.timeout) obj.delay.nil? || Send::Delay.validate_raw(obj: obj.delay) obj.expiry.nil? || Send::Expiry.validate_raw(obj: obj.expiry) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of InboundBulkTemplateMessage to a JSON object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/trycourier/bulk/types/inbound_bulk_template_message.rb', line 122 def to_json(*_args) { "template": @template, "data": @data, "brand_id": @brand_id, "channels": @channels, "context": @context, "metadata": @metadata, "providers": @providers, "routing": @routing, "timeout": @timeout, "delay": @delay, "expiry": @expiry }.to_json end |