Class: LucidIntercom::SendMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/lucid_intercom/send_message.rb

Instance Method Summary collapse

Constructor Details

#initialize(post_request: Container[:post_request]) ⇒ SendMessage

Returns a new instance of SendMessage.

Parameters:

  • post_request (#call) (defaults to: Container[:post_request])


10
11
12
# File 'lib/lucid_intercom/send_message.rb', line 10

def initialize(post_request: Container[:post_request])
  @post_request = post_request
end

Instance Method Details

#call(to, body) ⇒ Object

Parameters:

  • to (String)

    a user email address

  • body (String)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lucid_intercom/send_message.rb', line 18

def call(to, body)
  @post_request.('messages', {
    message_type: 'inapp',
    body: body,
    from: {
      type: 'admin',
      id: LucidIntercom.config.admin_id,
    },
    to: {
      type: 'user',
      email: to,
    },
  })
end