Class: Sendgrid::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sendgrid_api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_user, api_key) ⇒ Client

Returns a new instance of Client.



3
4
5
6
# File 'lib/sendgrid_api/client.rb', line 3

def initialize(api_user, api_key)
  @api_user = api_user
  @api_key  = api_key
end

Instance Method Details

#request(path, params = {}) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/sendgrid_api/client.rb', line 8

def request(path, params={})
  uri = URI.join("http://sendgrid.com/api/", "#{path}.json")
  post_params = {"api_user" => @api_user,
                 "api_key"  => @api_key}.merge(params)
  response = Net::HTTP.post_form(uri, post_params)
  Sendgrid::Response.new(response)
end