Class: God::Contacts::Sendhub
- Inherits:
-
Contact
- Object
- Contact
- God::Contacts::Sendhub
- Defined in:
- lib/sendhub/plugins/god.rb
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.from ⇒ Object
Returns the value of attribute from.
-
.secret_key ⇒ Object
Returns the value of attribute secret_key.
Instance Attribute Summary collapse
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/sendhub/plugins/god.rb', line 7 def api_key @api_key end |
.from ⇒ Object
Returns the value of attribute from.
7 8 9 |
# File 'lib/sendhub/plugins/god.rb', line 7 def from @from end |
.secret_key ⇒ Object
Returns the value of attribute secret_key.
7 8 9 |
# File 'lib/sendhub/plugins/god.rb', line 7 def secret_key @secret_key end |
Instance Attribute Details
#to ⇒ Object
Returns the value of attribute to.
18 19 20 |
# File 'lib/sendhub/plugins/god.rb', line 18 def to @to end |
Instance Method Details
#notify(message, time, priority, category, host) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sendhub/plugins/god.rb', line 20 def notify(, time, priority, category, host) puts "#{}" data = { :message => , :time => time, :priority => priority, :category => category, :host => host } client = ::Sendhub::Client.new(:api_key => arg(:api_key), :secret_key => arg(:secret_key)) res = client.send_email( :from => arg(:from), :to => arg(:to), :subject => "[god] #{}", :body => data.inspect ) applog(nil, :info, res.inspect) rescue Object => e applog(nil, :info, "failed to send email to #{arg(:to)}: #{e.}") applog(nil, :debug, e.backtrace.join("\n")) end |
#valid? ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/sendhub/plugins/god.rb', line 10 def valid? valid = true valid &= complain("Attribute 'api_key' must be specified", self) unless arg(:api_key) valid &= complain("Attribute 'secret_key' must be specified", self) unless arg(:secret_key) valid &= complain("Attribute 'from' must be specified", self) unless arg(:from) valid end |