Class: CommandTower::Messaging::Execution::AdapterRequest

Inherits:
Data
  • Object
show all
Defined in:
app/services/command_tower/messaging/execution/adapter_request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#attempt_idObject (readonly)

Returns the value of attribute attempt_id

Returns:

  • (Object)

    the current value of attempt_id



6
7
8
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 6

def attempt_id
  @attempt_id
end

#channel_delivery_idObject (readonly)

Returns the value of attribute channel_delivery_id

Returns:

  • (Object)

    the current value of channel_delivery_id



6
7
8
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 6

def channel_delivery_id
  @channel_delivery_id
end

#channel_keyObject (readonly)

Returns the value of attribute channel_key

Returns:

  • (Object)

    the current value of channel_key



6
7
8
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 6

def channel_key
  @channel_key
end

#communication_idObject (readonly)

Returns the value of attribute communication_id

Returns:

  • (Object)

    the current value of communication_id



6
7
8
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 6

def communication_id
  @communication_id
end

#renderedObject (readonly)

Returns the value of attribute rendered

Returns:

  • (Object)

    the current value of rendered



6
7
8
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 6

def rendered
  @rendered
end

Class Method Details

.build(channel_delivery_id:, communication_id:, channel_key:, attempt_id:, rendered:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 13

def self.build(channel_delivery_id:, communication_id:, channel_key:, attempt_id:, rendered:)
  raise InvalidAdapterContractError, "arbitrary hashes are not accepted" if [channel_delivery_id, communication_id, channel_key, attempt_id].any? { |v| v.is_a?(Hash) }
  raise InvalidAdapterContractError, "channel_delivery_id is required" if blank?(channel_delivery_id)
  raise InvalidAdapterContractError, "communication_id is required" if blank?(communication_id)
  raise InvalidAdapterContractError, "attempt_id is required" if blank?(attempt_id)
  raise InvalidAdapterContractError, "channel_key is required" if blank?(channel_key)
  raise InvalidAdapterContractError, "channel_key must be a String" unless channel_key.is_a?(String)
  raise InvalidAdapterContractError, "rendered is required" if rendered.nil?
  unless rendered.is_a?(Rendering::RenderedPayload) ||
      rendered.is_a?(Rendering::RenderedSmsPayload) ||
      rendered.is_a?(Rendering::RenderedPushoverPayload)
    raise InvalidAdapterContractError,
          "rendered must be a RenderedPayload, RenderedSmsPayload, or RenderedPushoverPayload"
  end
  raise InvalidAdapterContractError, "rendered must be frozen" unless rendered.frozen?

  new(
    channel_delivery_id:,
    communication_id:,
    channel_key:,
    attempt_id:,
    rendered:,
  ).freeze
end