Sha256: 1d92a5e06ada20e7a251836a9283783feae71cdc9e7a04fc88c0e0a3d3ed2a38

Contents?: true

Size: 855 Bytes

Versions: 4

Compression:

Stored size: 855 Bytes

Contents

# -*- encoding: utf-8 -*-
$:.unshift File.dirname(__FILE__)
require "net/https"
require "rest-client"

module SendgridRuby
  class Sendgrid

    attr_accessor :debug_output

    def initialize(username, password, options={"turn_off_ssl_verification" => false})
      @username = username
      @password = password
      @options = options
      @debug_output = false
    end

    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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sendgrid_ruby-0.0.6 lib/sendgrid_ruby.rb
sendgrid_ruby-0.0.5 lib/sendgrid_ruby.rb
sendgrid_ruby-0.0.4 lib/sendgrid_ruby.rb
sendgrid_ruby-0.0.3 lib/sendgrid_ruby.rb