Sha256: 3bb8b03259c7a71ba8776c4d1c7e364a57840c3bc2ba1f9b96d4516c837a4699

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Notification
    class Api
        attr_accessor :notification_type, :notification_level

        def initialize(notification_type: ENV['NOTIFICATION_TYPE'], notification_level: ENV['NOTIFICATION_LEVEL'])
            self.notification_type = notification_type
            self.notification_level = notification_level || 'error'
        end

        def send_backup_notification(result, date, database, backup_path)
            return if notification_type.nil?
            case notification_type
            when 'slack'
                Slack.new.backup_notification(result, date, database, backup_path, notification_level)
            when 'webhook'
                Webhook.new.backup_notification(result, date, database, backup_path, notification_level)
            end
        end

        def send_notification(message)
            return if notification_type.nil?
            case notification_type
            when 'slack'
                Slack.new.notify(message)
            when 'webhook'
                p 'webhook'
            end
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-ops-0.2.2 lib/capistrano/ops/notification/api.rb
capistrano-ops-0.2.1 lib/capistrano/ops/notification/api.rb