Sha256: 97f8bdb36e316ff73bd5ce5e7a4b1afdd99aa6e3f9d912289db3d21969c59b06

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require 'httparty'
require 'md5'

module Integrity
  class Notifier
    class Notifyio < Notifier::Base
      attr_reader :config

      def self.to_haml
        @haml ||= File.read(File.dirname(__FILE__) + "/config.haml")
      end

      def deliver!
        post(config['email'], config['api_key'], short_message, full_message)
      end

      def to_s
        'Notifyio'
      end
      
      private
      
      def post(emails, api_key, title, body)
        return if emails.nil? || email.empty? || api_key.nil? || api_key.empty?
        emails.split(',').each do |email|
          email_hash = MD5.hexdigest(email.strip!)
          HTTParty.post "http://api.notify.io/v1/notify/#{email_hash}",   :headers => {'content-type' => 'application/x-www-form-urlencoded'},
                                                                          :body => {:api_key => api_key},
                                                                          :query => {
                                                                                      :api_key => api_key,
                                                                                      :title => title,
                                                                                      :text => body
                                                                                    }
          
        end
      end
      
    end

    register Notifyio
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
integrity-notifyio-0.2.0 lib/integrity/notifier/notifyio.rb