Class: CommandTower::Messaging::Rendering::RenderedSmsPayload

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

Overview

Provider-neutral SMS rendered payload. Recipient is resolved separately at execution and included here for the adapter request contract (same as email).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



8
9
10
# File 'app/services/command_tower/messaging/rendering/rendered_sms_payload.rb', line 8

def body
  @body
end

#recipient_addressObject (readonly)

Returns the value of attribute recipient_address

Returns:

  • (Object)

    the current value of recipient_address



8
9
10
# File 'app/services/command_tower/messaging/rendering/rendered_sms_payload.rb', line 8

def recipient_address
  @recipient_address
end

Class Method Details

.build(recipient_address:, body:) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/command_tower/messaging/rendering/rendered_sms_payload.rb', line 12

def self.build(recipient_address:, body:)
  values = [recipient_address, body]
  raise ArgumentError, "arbitrary hashes are not accepted" if values.any? { |v| v.is_a?(Hash) }
  raise ArgumentError, "ActiveRecord objects are not accepted" if values.any? { |v| active_record_like?(v) }
  raise ArgumentError, "raw exception objects are not accepted" if values.any? { |v| v.is_a?(Exception) }

  validate_required_string!(recipient_address, "recipient_address")
  validate_required_string!(body, "body")

  new(
    recipient_address:,
    body:,
  ).freeze
end