class Sendgrid::Web::Client

Public Class Methods

base_uri() click to toggle source

Returns the configured root_url.

# File lib/sendgrid/web/client.rb, line 25
def self.base_uri
  config.root_url
end
config() click to toggle source

Retrieve the current global configuration object and if none exists, then create an empty one.

@see config

# File lib/sendgrid/web/client.rb, line 20
def self.config
  @@config ||= Sendgrid::Web::Configurator.new
end
configure(&block) click to toggle source

Sets the global configuration object shared between all clients. You can use it like so:

Sendgrid::Web::Client.configure do |config|
  config.username = 'foo'
  config.password = 'bar'
end

@return [Sendgrid::Web::Configurator]

# File lib/sendgrid/web/client.rb, line 12
def self.configure(&block)
  @@config = Sendgrid::Web::Configurator.new(&block)
end

Public Instance Methods

config() click to toggle source

Retrieve the current global configuration object and if none exists, then create an empty one.

@see .config

# File lib/sendgrid/web/client.rb, line 33
def config
  @@config ||= Sendgrid::Web::Configurator.new
end

Private Instance Methods

config=(configurator) click to toggle source
# File lib/sendgrid/web/client.rb, line 44
def config=(configurator)
  @@config = configurator
end
connection() click to toggle source
# File lib/sendgrid/web/client.rb, line 48
def connection
  @connection = API
end
craft_response(response) click to toggle source
# File lib/sendgrid/web/client.rb, line 65
def craft_response(response)
  Sendgrid::Web::Response.new(response.code, response.body)
end
default_params(additions = {}) click to toggle source
# File lib/sendgrid/web/client.rb, line 52
def default_params(additions = {})
  params = Sendgrid::Web::Parameters.new
  defaults = {
    query: {
      api_user: config.username,
      api_key:  config.password
    }
  }
  params.replace(defaults)
  params[:query].merge!(additions)
  params
end