Class: Sendhub::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sendhub/http.rb,
lib/sendhub/client.rb

Constant Summary collapse

VERSION =
'0.1.22'

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sendhub/client.rb', line 6

def initialize(config=nil)
  config[:host] ||= 'api.sendhub.net'
  config[:protocol] ||= 'https'
  @uri = URI.parse(config[:protocol]+'://'+config[:host]+'/')

  @api_key = config[:api_key]
  @secret_key = config[:secret_key]
  @notification_url = config[:notification_url]

  puts "SendhubRubyClient (v#{VERSION}): #{@uri}, #{@api_key}, #{@notification_url}"
end

Instance Method Details

#get_email(options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/sendhub/client.rb', line 23

def get_email(options={})
  email_id = options.delete(:id)
  res = _get('/emails/' + email_id, options)
  Sendhub::Response.new(res)
end

#send_email(options = {}) ⇒ Object



18
19
20
21
# File 'lib/sendhub/client.rb', line 18

def send_email(options={})
  res = _post '/emails', nil, options
  Sendhub::Response.new(res)
end