Class: Voxmail::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/voxmail/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRequest

Returns a new instance of Request.



5
6
7
8
9
10
11
12
# File 'lib/voxmail/request.rb', line 5

def initialize
    @host = ENV['VOXMAILHOST'] || 'voxmailgem.voxmail.it'
    @secretkey = ENV['VOXMAILSECRETKEY'] || 'ae041cf49a95854ffcfc9ab56cfdeb1e'
    @publickey = ENV['VOXMAILPUBLICKEY'] || 'b31d119a48a5e5fb57819312be55e83e'
    @args = []
    @client = XMLRPC::Client.new(host, "/services/xmlrpc", 80)
    #@client.http_header_extra = { 'Content-Type' => 'text/xml' }
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/voxmail/request.rb', line 3

def host
  @host
end

#publickeyObject

Returns the value of attribute publickey.



3
4
5
# File 'lib/voxmail/request.rb', line 3

def publickey
  @publickey
end

#secretkeyObject

Returns the value of attribute secretkey.



3
4
5
# File 'lib/voxmail/request.rb', line 3

def secretkey
  @secretkey
end

Instance Method Details

#client(method, *args) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/voxmail/request.rb', line 14

def client(method, *args)
    digest = OpenSSL::Digest.new('sha256')
    ts = Time.now.to_i;
    nonce = rand(100000000).to_s;
    pk = publickey+";"+ts.to_s+";"+nonce+";"+method
    hash = OpenSSL::HMAC.hexdigest(digest,secretkey, pk)
    @client.call( method, "API"+publickey, ts, nonce, hash, *args )
end