Class: Tolliver::Services::Methods::Slack
- Inherits:
-
Object
- Object
- Tolliver::Services::Methods::Slack
- Defined in:
- lib/tolliver/services/methods/slack.rb
Instance Method Summary collapse
- #deliver(notification_receiver) ⇒ Object
- #is_notification_delivery_valid?(_) ⇒ Boolean
- #is_notification_receiver_valid?(notification_receiver) ⇒ Boolean
- #is_notification_valid?(notification) ⇒ Boolean
Instance Method Details
#deliver(notification_receiver) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tolliver/services/methods/slack.rb', line 31 def deliver(notification_receiver) # Prepare notification notification = notification_receiver.notification_delivery.notification # Send message begin ensure_slack_id(notification_receiver) client.chat_postMessage(channel: notification_receiver.receiver_slack_id, text: notification.) notification_receiver.status = 'sent' rescue StandardError => e notification_receiver.status = 'error' notification_receiver. = e. end # Mark as sent notification_receiver.sent_at = Time.current # Save notification_receiver.save true end |
#is_notification_delivery_valid?(_) ⇒ Boolean
22 23 24 |
# File 'lib/tolliver/services/methods/slack.rb', line 22 def is_notification_delivery_valid?(_) true end |
#is_notification_receiver_valid?(notification_receiver) ⇒ Boolean
26 27 28 29 |
# File 'lib/tolliver/services/methods/slack.rb', line 26 def is_notification_receiver_valid?(notification_receiver) return false if notification_receiver.receiver_slack_id.blank? && notification_receiver.receiver_email.blank? true end |
#is_notification_valid?(notification) ⇒ Boolean
17 18 19 20 |
# File 'lib/tolliver/services/methods/slack.rb', line 17 def is_notification_valid?(notification) return false if notification..blank? true end |