Class: Courier::Send::RoutingStrategyProvider
- Inherits:
-
Object
- Object
- Courier::Send::RoutingStrategyProvider
- Defined in:
- lib/trycourier/send/types/routing_strategy_provider.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#if_ ⇒ Object
readonly
Returns the value of attribute if_.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::RoutingStrategyProvider
Deserialize a JSON object to an instance of RoutingStrategyProvider.
-
.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(name:, metadata:, config: nil, if_: nil, additional_properties: nil) ⇒ Send::RoutingStrategyProvider constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of RoutingStrategyProvider to a JSON object.
Constructor Details
#initialize(name:, metadata:, config: nil, if_: nil, additional_properties: nil) ⇒ Send::RoutingStrategyProvider
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 17 def initialize(name:, metadata:, config: nil, if_: nil, additional_properties: nil) # @type [String] @name = name # @type [Hash{String => String}] @config = config # @type [String] @if_ = if_ # @type [Send::Metadata] @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.
9 10 11 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 9 def additional_properties @additional_properties end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 9 def config @config end |
#if_ ⇒ Object (readonly)
Returns the value of attribute if_.
9 10 11 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 9 def if_ @if_ end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 9 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 9 def name @name end |
Class Method Details
.from_json(json_object:) ⇒ Send::RoutingStrategyProvider
Deserialize a JSON object to an instance of RoutingStrategyProvider
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 34 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) name = struct.name config = struct.config if_ = struct.if if parsed_json["metadata"].nil? = nil else = parsed_json["metadata"].to_json = Send::Metadata.from_json(json_object: ) end new(name: name, config: config, if_: if_, 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.
60 61 62 63 64 65 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 60 def self.validate_raw(obj:) obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.config&.is_a?(Hash) != false || raise("Passed value for field obj.config 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.") Send::Metadata.validate_raw(obj: obj.) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of RoutingStrategyProvider to a JSON object
52 53 54 |
# File 'lib/trycourier/send/types/routing_strategy_provider.rb', line 52 def to_json(*_args) { "name": @name, "config": @config, "if": @if_, "metadata": @metadata }.to_json end |