Class: CommandTower::Messaging::Rendering::RenderedPushPayload

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

Overview

Provider-neutral Expo push rendered payload. recipient_address is the opaque first eligible endpoint id for the ChannelRenderer gate — never the Expo token. Fan-out uses AdapterRequest#eligible_endpoint_ids.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#body ⇒ Object (readonly)

Returns the value of attribute body

Returns:

  • (Object) —

    the current value of body



9
10
11
# File 'app/services/command_tower/messaging/rendering/rendered_push_payload.rb', line 9

def body
  @body
end

Returns the value of attribute deep_link

Returns:

  • (Object) —

    the current value of deep_link



9
10
11
# File 'app/services/command_tower/messaging/rendering/rendered_push_payload.rb', line 9

def deep_link
  @deep_link
end

#recipient_address ⇒ Object (readonly)

Returns the value of attribute recipient_address

Returns:

  • (Object) —

    the current value of recipient_address



9
10
11
# File 'app/services/command_tower/messaging/rendering/rendered_push_payload.rb', line 9

def recipient_address
  @recipient_address
end

#title ⇒ Object (readonly)

Returns the value of attribute title

Returns:

  • (Object) —

    the current value of title



9
10
11
# File 'app/services/command_tower/messaging/rendering/rendered_push_payload.rb', line 9

def title
  @title
end

Class Method Details

.build(recipient_address:, title:, body:, deep_link: nil) ⇒ Object

Raises:

  • (ArgumentError)


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

def self.build(recipient_address:, title:, body:, deep_link: nil)
  values = [recipient_address, title, body, deep_link]
  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!(title, "title")
  validate_required_string!(body, "body")
  unless deep_link.nil?
    raise ArgumentError, "deep_link must be a String" unless deep_link.is_a?(String)
    raise ArgumentError, "deep_link must not be blank when present" if deep_link.strip.empty?
  end

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