Class: SpreeCmCommissioner::TelegramDebugPinCodeSender

Inherits:
BaseInteractor
  • Object
show all
Defined in:
app/interactors/spree_cm_commissioner/telegram_debug_pin_code_sender.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



13
14
15
16
17
18
19
20
21
22
# File 'app/interactors/spree_cm_commissioner/telegram_debug_pin_code_sender.rb', line 13

def body
  text = []

  text << "<b>From: #{name}</b>"
  text << "<b>PIN CODE sent to #{pin_code.contact}</b>"
  text << "<code>#{pin_code.code}</code> is your #{pin_code.readable_type}"
  text << "⚠️ Error: <code>#{error_message}<code> ⚠️" if error_message.present?

  text.compact.join("\n")
end

#callObject



5
6
7
8
9
10
11
# File 'app/interactors/spree_cm_commissioner/telegram_debug_pin_code_sender.rb', line 5

def call
  telegram_client.send_message(
    chat_id: chat_id,
    parse_mode: 'HTML',
    text: body
  )
end

#chat_idObject



24
25
26
# File 'app/interactors/spree_cm_commissioner/telegram_debug_pin_code_sender.rb', line 24

def chat_id
  ENV.fetch('EXCEPTION_NOTIFIER_TELEGRAM_CHANNEL_ID', nil)
end

#telegram_clientObject



28
29
30
# File 'app/interactors/spree_cm_commissioner/telegram_debug_pin_code_sender.rb', line 28

def telegram_client
  ::Telegram.bots[:exception_notifier]
end