Class: CommandTower::Messaging::Rendering::RenderedPayload

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#html_bodyObject (readonly)

Returns the value of attribute html_body

Returns:

  • (Object)

    the current value of html_body



6
7
8
# File 'app/services/command_tower/messaging/rendering/rendered_payload.rb', line 6

def html_body
  @html_body
end

#recipient_addressObject (readonly)

Returns the value of attribute recipient_address

Returns:

  • (Object)

    the current value of recipient_address



6
7
8
# File 'app/services/command_tower/messaging/rendering/rendered_payload.rb', line 6

def recipient_address
  @recipient_address
end

#subjectObject (readonly)

Returns the value of attribute subject

Returns:

  • (Object)

    the current value of subject



6
7
8
# File 'app/services/command_tower/messaging/rendering/rendered_payload.rb', line 6

def subject
  @subject
end

#text_bodyObject (readonly)

Returns the value of attribute text_body

Returns:

  • (Object)

    the current value of text_body



6
7
8
# File 'app/services/command_tower/messaging/rendering/rendered_payload.rb', line 6

def text_body
  @text_body
end

Class Method Details

.build(recipient_address:, subject:, text_body:, html_body:) ⇒ Object

Raises:

  • (ArgumentError)


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

def self.build(recipient_address:, subject:, text_body:, html_body:)
  values = [recipient_address, subject, text_body, html_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!(subject, "subject")
  validate_required_string!(text_body, "text_body")
  validate_required_string!(html_body, "html_body")

  new(
    recipient_address:,
    subject:,
    text_body:,
    html_body:,
  ).freeze
end