Class: Courier::Send::Channel
- Inherits:
-
Object
- Object
- Courier::Send::Channel
- Defined in:
- lib/trycourier/send/types/channel.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.
-
#if_ ⇒ Object
readonly
Returns the value of attribute if_.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#override ⇒ Object
readonly
Returns the value of attribute override.
-
#providers ⇒ Object
readonly
Returns the value of attribute providers.
-
#routing_method ⇒ Object
readonly
Returns the value of attribute routing_method.
-
#timeouts ⇒ Object
readonly
Returns the value of attribute timeouts.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::Channel
Deserialize a JSON object to an instance of Channel.
-
.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(brand_id: nil, providers: nil, routing_method: nil, if_: nil, timeouts: nil, override: nil, metadata: nil, additional_properties: nil) ⇒ Send::Channel constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of Channel to a JSON object.
Constructor Details
#initialize(brand_id: nil, providers: nil, routing_method: nil, if_: nil, timeouts: nil, override: nil, metadata: nil, additional_properties: nil) ⇒ Send::Channel
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/trycourier/send/types/channel.rb', line 29 def initialize(brand_id: nil, providers: nil, routing_method: nil, if_: nil, timeouts: nil, override: nil, metadata: nil, additional_properties: nil) # @type [String] Id of the brand that should be used for rendering the message. # If not specified, the brand configured as default brand will be used. @brand_id = brand_id # @type [Array<String>] A list of providers enabled for this channel. Courier will select # one provider to send through unless routing_method is set to all. @providers = providers # @type [Send::RoutingMethod] The method for selecting the providers to send the message with. # Single will send to one of the available providers for this channel, # all will send the message through all channels. Defaults to `single`. @routing_method = routing_method # @type [String] A JavaScript conditional expression to determine if the message should # be sent through the channel. Has access to the data and profile object. # For example, `data.name === profile.name` @if_ = if_ # @type [Send::Timeouts] @timeouts = timeouts # @type [Send::Override] Channel specific overrides. @override = override # @type [Send::ChannelMetadata] @metadata = # @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.
12 13 14 |
# File 'lib/trycourier/send/types/channel.rb', line 12 def additional_properties @additional_properties end |
#brand_id ⇒ Object (readonly)
Returns the value of attribute brand_id.
12 13 14 |
# File 'lib/trycourier/send/types/channel.rb', line 12 def brand_id @brand_id end |
#if_ ⇒ Object (readonly)
Returns the value of attribute if_.
12 13 14 |
# File 'lib/trycourier/send/types/channel.rb', line 12 def if_ @if_ end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
12 13 14 |
# File 'lib/trycourier/send/types/channel.rb', line 12 def @metadata end |
#override ⇒ Object (readonly)
Returns the value of attribute override.
12 13 14 |
# File 'lib/trycourier/send/types/channel.rb', line 12 def override @override end |
#providers ⇒ Object (readonly)
Returns the value of attribute providers.
12 13 14 |
# File 'lib/trycourier/send/types/channel.rb', line 12 def providers @providers end |
#routing_method ⇒ Object (readonly)
Returns the value of attribute routing_method.
12 13 14 |
# File 'lib/trycourier/send/types/channel.rb', line 12 def routing_method @routing_method end |
#timeouts ⇒ Object (readonly)
Returns the value of attribute timeouts.
12 13 14 |
# File 'lib/trycourier/send/types/channel.rb', line 12 def timeouts @timeouts end |
Class Method Details
.from_json(json_object:) ⇒ Send::Channel
Deserialize a JSON object to an instance of Channel
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/trycourier/send/types/channel.rb', line 59 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) brand_id = struct.brand_id providers = struct.providers routing_method = struct.routing_method if_ = struct.if if parsed_json["timeouts"].nil? timeouts = nil else timeouts = parsed_json["timeouts"].to_json timeouts = Send::Timeouts.from_json(json_object: timeouts) end override = struct.override if parsed_json["metadata"].nil? = nil else = parsed_json["metadata"].to_json = Send::ChannelMetadata.from_json(json_object: ) end new(brand_id: brand_id, providers: providers, routing_method: routing_method, if_: if_, timeouts: timeouts, override: override, metadata: , 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.
102 103 104 105 106 107 108 109 110 |
# File 'lib/trycourier/send/types/channel.rb', line 102 def self.validate_raw(obj:) obj.brand_id&.is_a?(String) != false || raise("Passed value for field obj.brand_id is not the expected type, validation failed.") obj.providers&.is_a?(Array) != false || raise("Passed value for field obj.providers is not the expected type, validation failed.") obj.routing_method&.is_a?(Send::RoutingMethod) != false || raise("Passed value for field obj.routing_method is not the expected type, validation failed.") obj.if_&.is_a?(String) != false || raise("Passed value for field obj.if_ is not the expected type, validation failed.") obj.timeouts.nil? || Send::Timeouts.validate_raw(obj: obj.timeouts) obj.override&.is_a?(Send::Override) != false || raise("Passed value for field obj.override is not the expected type, validation failed.") obj..nil? || Send::ChannelMetadata.validate_raw(obj: obj.) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of Channel to a JSON object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/trycourier/send/types/channel.rb', line 86 def to_json(*_args) { "brand_id": @brand_id, "providers": @providers, "routing_method": @routing_method, "if": @if_, "timeouts": @timeouts, "override": @override, "metadata": @metadata }.to_json end |