Class: Sendhub::Client

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

Constant Summary collapse

VERSION =
'0.1.5'

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
# File 'lib/sendhub/client.rb', line 6

def initialize(config=nil)
  config[:host] ||= 'api.sendhub.net'
  @uri = URI.parse('http://'+config[:host]+'/')
  
  @api_key = config[:api_key]
  @secret_key = config[:secret_key]
  
  puts "SendhubRubyClient: #{@uri}, #{@api_key}"
end

Instance Method Details

#get(options = {}) ⇒ Object



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

def get(options={})
  res = _get('/email/' + options[:email_id])
  Sendhub::Response.new(res)
end

#send_email(options = {}) ⇒ Object



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

def send_email(options={})
  res = _post '/emails', nil, options
  #res.merge!('redirect_url' => @uri.to_s+"merchants/#{@merchant_id}/transactions/#{res['id']}")
  #res.merge!('secret_token' => securely_hash_data("#{res['id']}-#{res['amount']}"))
  Sendhub::Response.new(res)
end