Class: SpreeCmCommissioner::TelegramAlerts::EventCreation

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/telegram_alerts/event_creation.rb

Instance Method Summary collapse

Instance Method Details

#call(event:) ⇒ Object

Send Telegram alert for new event creation

Parameters:

  • event (Spree::Taxon)

    The event taxon



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/spree_cm_commissioner/telegram_alerts/event_creation.rb', line 8

def call(event:)
  chat_id = admin_chat_id
  return failure(nil, 'Telegram chat ID not configured') if chat_id.blank?

  SpreeCmCommissioner::TelegramNotificationSender.call(
    chat_id: chat_id,
    message: alert_message(event),
    parse_mode: 'HTML'
  )

  success(message: 'Event alert sent successfully')
rescue StandardError => e
  failure(nil, "Failed to send Telegram alert: #{e.message}")
end