Class: SpreeCmCommissioner::VendorCreationTelegramAlertSender

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

Instance Method Summary collapse

Instance Method Details

#admin_chat_idObject



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

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

#alert_messageObject



19
20
21
22
# File 'app/interactors/spree_cm_commissioner/vendor_creation_telegram_alert_sender.rb', line 19

def alert_message
  factory = SpreeCmCommissioner::VendorTelegramMessageFactory.new(vendor: vendor)
  factory.message
end

#callObject



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

def call
  return if admin_chat_id.blank?

  send_alert
end

#send_alertObject



11
12
13
14
15
16
17
# File 'app/interactors/spree_cm_commissioner/vendor_creation_telegram_alert_sender.rb', line 11

def send_alert
  TelegramNotificationSender.call(
    chat_id: admin_chat_id,
    message: alert_message,
    parse_mode: 'HTML'
  )
end