Class: SendgridRuby::Sendgrid
- Inherits:
-
Object
- Object
- SendgridRuby::Sendgrid
- Defined in:
- lib/sendgrid_ruby.rb
Instance Attribute Summary collapse
-
#debug_output ⇒ Object
Returns the value of attribute debug_output.
Instance Method Summary collapse
-
#initialize(username, password, options = {"turn_off_ssl_verification" => false}) ⇒ Sendgrid
constructor
A new instance of Sendgrid.
- #send(email) ⇒ Object
Constructor Details
#initialize(username, password, options = {"turn_off_ssl_verification" => false}) ⇒ Sendgrid
Returns a new instance of Sendgrid.
11 12 13 14 15 16 |
# File 'lib/sendgrid_ruby.rb', line 11 def initialize(username, password, ={"turn_off_ssl_verification" => false}) @username = username @password = password @options = @debug_output = false end |
Instance Attribute Details
#debug_output ⇒ Object
Returns the value of attribute debug_output.
9 10 11 |
# File 'lib/sendgrid_ruby.rb', line 9 def debug_output @debug_output end |
Instance Method Details
#send(email) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sendgrid_ruby.rb', line 18 def send(email) form = email.to_web_format form['api_user'] = @username form['api_key'] = @password RestClient.log = $stderr if @debug_output headers = Hash.new headers[:content_type] = :json response = RestClient.post 'https://api.sendgrid.com/api/mail.send.json', form, :content_type => :json, "User-Agent" => "sendgrid/#{SendgridRuby::VERSION};ruby" JSON.parse(response.body) end |