Class: Courier::Notifications::MessageRouting
- Inherits:
-
Object
- Object
- Courier::Notifications::MessageRouting
- Defined in:
- lib/trycourier/notifications/types/message_routing.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Notifications::MessageRouting
Deserialize a JSON object to an instance of MessageRouting.
-
.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(method:, channels:, additional_properties: nil) ⇒ Notifications::MessageRouting constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of MessageRouting to a JSON object.
Constructor Details
#initialize(method:, channels:, additional_properties: nil) ⇒ Notifications::MessageRouting
16 17 18 19 20 21 22 23 |
# File 'lib/trycourier/notifications/types/message_routing.rb', line 16 def initialize(method:, channels:, additional_properties: nil) # @type [Notifications::MessageRoutingMethod] @method = method # @type [Array<Notifications::MessageRoutingChannel>] @channels = channels # @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.
10 11 12 |
# File 'lib/trycourier/notifications/types/message_routing.rb', line 10 def additional_properties @additional_properties end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
10 11 12 |
# File 'lib/trycourier/notifications/types/message_routing.rb', line 10 def channels @channels end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
10 11 12 |
# File 'lib/trycourier/notifications/types/message_routing.rb', line 10 def method @method end |
Class Method Details
.from_json(json_object:) ⇒ Notifications::MessageRouting
Deserialize a JSON object to an instance of MessageRouting
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/trycourier/notifications/types/message_routing.rb', line 29 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) method = struct.method channels = parsed_json["channels"]&.map do |v| v = v.to_json Notifications::MessageRoutingChannel.from_json(json_object: v) end new(method: method, channels: channels, 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.
51 52 53 54 |
# File 'lib/trycourier/notifications/types/message_routing.rb', line 51 def self.validate_raw(obj:) obj.method.is_a?(Notifications::MessageRoutingMethod) != false || raise("Passed value for field obj.method 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.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of MessageRouting to a JSON object
43 44 45 |
# File 'lib/trycourier/notifications/types/message_routing.rb', line 43 def to_json(*_args) { "method": @method, "channels": @channels }.to_json end |