Class: SpreeCmCommissioner::TelegramNotificationSender

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

Instance Method Summary collapse

Instance Method Details

#callObject



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

def call
  telegram_client.send_message(
    chat_id: chat_id,
    parse_mode: parse_mode,
    text: message
  )
rescue ::Telegram::Bot::Error => e
  notifier_error_message(e.to_s)
end

#notifier_error_message(error_message) ⇒ Object



19
20
21
22
23
24
# File 'app/interactors/spree_cm_commissioner/telegram_notification_sender.rb', line 19

def notifier_error_message(error_message)
  ::Telegram.bots[:exception_notifier].send_message(
    chat_id: chat_id,
    text: "Telegram Notifier Error:\n#{error_message}\nSend Text:\n#{message}"
  )
end

#telegram_clientObject



15
16
17
# File 'app/interactors/spree_cm_commissioner/telegram_notification_sender.rb', line 15

def telegram_client
  context.telegram_client ||= ::Telegram.bots[:default]
end