Class: SpreeCmCommissioner::TelegramAlerts::OrderIntegrityAlert
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::TelegramAlerts::OrderIntegrityAlert
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/telegram_alerts/order_integrity_alert.rb
Overview
Abstract base class for order anomaly checks. Subclasses implement ‘anomaly?`, `emoji` and `title` to define what they detect and how the alert is presented; this class handles chat resolution, message building and delivery.
Direct Known Subclasses
Checks::OrderCompletePaymentNotPaid, Checks::PaymentPaidOrderNotComplete
Instance Method Summary collapse
Instance Method Details
#call(order:) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/spree_cm_commissioner/telegram_alerts/order_integrity_alert.rb', line 10 def call(order:) return success(message: 'No anomaly detected') unless anomaly?(order) chat_id = alert_chat_id return failure(nil, 'Order anomaly alert chat ID not configured') if chat_id.blank? TelegramNotificationSenderJob.perform_later( chat_id: chat_id, message: (order), parse_mode: 'HTML' ) success(message: 'Order alert sent successfully') rescue StandardError => e failure(nil, "Failed to send order alert: #{e.}") end |