Class: CommandTower::Messaging::Execution::AdapterRequest
- Inherits:
-
Data
- Object
- Data
- CommandTower::Messaging::Execution::AdapterRequest
- Defined in:
- app/services/command_tower/messaging/execution/adapter_request.rb
Instance Attribute Summary collapse
-
#attempt_id ⇒ Object
readonly
Returns the value of attribute attempt_id.
-
#channel_delivery_id ⇒ Object
readonly
Returns the value of attribute channel_delivery_id.
-
#channel_key ⇒ Object
readonly
Returns the value of attribute channel_key.
-
#communication_id ⇒ Object
readonly
Returns the value of attribute communication_id.
-
#eligible_endpoint_ids ⇒ Object
readonly
Returns the value of attribute eligible_endpoint_ids.
-
#rendered ⇒ Object
readonly
Returns the value of attribute rendered.
Class Method Summary collapse
Instance Attribute Details
#attempt_id ⇒ Object (readonly)
Returns the value of attribute 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_id ⇒ Object (readonly)
Returns the value of attribute 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_key ⇒ Object (readonly)
Returns the value of attribute channel_key
6 7 8 |
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 6 def channel_key @channel_key end |
#communication_id ⇒ Object (readonly)
Returns the value of attribute communication_id
6 7 8 |
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 6 def communication_id @communication_id end |
#eligible_endpoint_ids ⇒ Object (readonly)
Returns the value of attribute eligible_endpoint_ids
6 7 8 |
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 6 def eligible_endpoint_ids @eligible_endpoint_ids end |
#rendered ⇒ Object (readonly)
Returns the value of attribute 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:, eligible_endpoint_ids: []) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 54 |
# File 'app/services/command_tower/messaging/execution/adapter_request.rb', line 14 def self.build( channel_delivery_id:, communication_id:, channel_key:, attempt_id:, rendered:, eligible_endpoint_ids: [] ) 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) || rendered.is_a?(Rendering::RenderedPushPayload) raise InvalidAdapterContractError, "rendered must be a RenderedPayload, RenderedSmsPayload, RenderedPushoverPayload, or RenderedPushPayload" end raise InvalidAdapterContractError, "rendered must be frozen" unless rendered.frozen? raise InvalidAdapterContractError, "eligible_endpoint_ids must be an Array" unless eligible_endpoint_ids.is_a?(Array) ids = eligible_endpoint_ids.map do |id| integer_id = Integer(id, exception: false) raise InvalidAdapterContractError, "eligible_endpoint_ids must be Integers" if integer_id.nil? integer_id end new( channel_delivery_id:, communication_id:, channel_key:, attempt_id:, rendered:, eligible_endpoint_ids: ids.freeze, ).freeze end |