Class: Courier::Send::RoutingStrategyChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/send/types/routing_strategy_channel.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel:, config: nil, method: nil, providers: nil, if_: nil, additional_properties: nil) ⇒ Send::RoutingStrategyChannel

Parameters:

  • channel (String)
  • config (Hash{String => String}) (defaults to: nil)
  • method (Send::RoutingMethod) (defaults to: nil)
  • providers (Send::MESSAGE_PROVIDERS) (defaults to: nil)
  • if_ (String) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 19

def initialize(channel:, config: nil, method: nil, providers: nil, if_: nil, additional_properties: nil)
  # @type [String]
  @channel = channel
  # @type [Hash{String => String}]
  @config = config
  # @type [Send::RoutingMethod]
  @method = method
  # @type [Send::MESSAGE_PROVIDERS]
  @providers = providers
  # @type [String]
  @if_ = if_
  # @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/send/types/routing_strategy_channel.rb', line 10

def additional_properties
  @additional_properties
end

#channelObject (readonly)

Returns the value of attribute channel.



10
11
12
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 10

def channel
  @channel
end

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 10

def config
  @config
end

#if_Object (readonly)

Returns the value of attribute if_.



10
11
12
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 10

def if_
  @if_
end

#methodObject (readonly)

Returns the value of attribute method.



10
11
12
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 10

def method
  @method
end

#providersObject (readonly)

Returns the value of attribute providers.



10
11
12
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 10

def providers
  @providers
end

Class Method Details

.from_json(json_object:) ⇒ Send::RoutingStrategyChannel

Deserialize a JSON object to an instance of RoutingStrategyChannel

Parameters:

  • json_object (JSON)

Returns:



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 38

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  channel = struct.channel
  config = struct.config
  method = struct.method
  providers = struct.providers
  if_ = struct.if
  new(channel: channel, config: config, method: method, providers: providers, if_: if_,
      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)


61
62
63
64
65
66
67
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 61

def self.validate_raw(obj:)
  obj.channel.is_a?(String) != false || raise("Passed value for field obj.channel 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.method&.is_a?(Send::RoutingMethod) != false || raise("Passed value for field obj.method is not the expected type, validation failed.")
  obj.providers&.is_a?(Hash) != false || raise("Passed value for field obj.providers 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.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of RoutingStrategyChannel to a JSON object

Returns:

  • (JSON)


53
54
55
# File 'lib/trycourier/send/types/routing_strategy_channel.rb', line 53

def to_json(*_args)
  { "channel": @channel, "config": @config, "method": @method, "providers": @providers, "if": @if_ }.to_json
end