Class: DNS::Monitor::Mandrill
- Inherits:
-
Object
- Object
- DNS::Monitor::Mandrill
- Defined in:
- lib/dns/monitor/mandrill.rb
Constant Summary collapse
- API_URL =
'https://mandrillapp.com/api/1.0/messages/send.json'
Instance Attribute Summary collapse
-
#from_email ⇒ Object
readonly
Returns the value of attribute from_email.
-
#recipient_email ⇒ Object
readonly
Returns the value of attribute recipient_email.
Instance Method Summary collapse
-
#initialize(api_key, recipient_email) ⇒ Mandrill
constructor
A new instance of Mandrill.
- #message(text) ⇒ Object
- #request(text) ⇒ Object
Constructor Details
#initialize(api_key, recipient_email) ⇒ Mandrill
Returns a new instance of Mandrill.
8 9 10 11 12 |
# File 'lib/dns/monitor/mandrill.rb', line 8 def initialize(api_key, recipient_email) @api_key = api_key @recipient_email = recipient_email @from_email = "dns-monitor@#{@recipient_email.split('@').last}" end |
Instance Attribute Details
#from_email ⇒ Object (readonly)
Returns the value of attribute from_email.
6 7 8 |
# File 'lib/dns/monitor/mandrill.rb', line 6 def from_email @from_email end |
#recipient_email ⇒ Object (readonly)
Returns the value of attribute recipient_email.
6 7 8 |
# File 'lib/dns/monitor/mandrill.rb', line 6 def recipient_email @recipient_email end |
Instance Method Details
#message(text) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/dns/monitor/mandrill.rb', line 14 def (text) Net::HTTP.post( URI(API_URL), request(text).to_json, 'Content-Type' => 'application/json' ) end |
#request(text) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/dns/monitor/mandrill.rb', line 22 def request(text) { "key" => @api_key, "message" => { #"html" => "<p>Example HTML content</p>", "text" => text, "subject" => "DNS Change Alert", "from_email" => @from_email, "from_name" => "DNS Monitor", "to" => [ { "email" => @recipient_email, "name" => @recipient_email, "type" => "to" } ], #"headers" => { #"Reply-To" => "[email protected]" #}, #"important" => false, #"track_opens" => null, #"track_clicks" => null, #"auto_text" => null, #"auto_html" => null, #"inline_css" => null, #"url_strip_qs" => null, #"preserve_recipients" => null, #"view_content_link" => null, #"bcc_address" => "[email protected]", #"tracking_domain" => null, #"signing_domain" => null, #"return_path_domain" => null, #"merge" => true, #"merge_language" => "mailchimp", #"global_merge_vars" => [ #{ #"name" => "merge1", #"content" => "merge1 content" #} #], #"merge_vars" => [ #{ #"rcpt" => "[email protected]", #"vars" => [ #{ #"name" => "merge2", #"content" => "merge2 content" #} #] #} #], #"tags" => [ #"password-resets" #], #"subaccount" => "customer-123", #"google_analytics_domains" => [ #"example.com" #], #"google_analytics_campaign" => "[email protected]", #"metadata" => { #"website" => "www.example.com" #}, #"recipient_metadata" => [ #{ #"rcpt" => "[email protected]", #"values" => { #"user_id" => 123456 #} #} #], #"attachments" => [ #{ #"type" => "text/plain", #"name" => "myfile.txt", #"content" => "ZXhhbXBsZSBmaWxl" #} #], #"images" => [ #{ #"type" => "image/png", #"name" => "IMAGECID", #"content" => "ZXhhbXBsZSBmaWxl" #} #] }, #"async" => false, #"ip_pool" => "Main Pool", #"send_at" => "example send_at" } end |