Class: Voxmail::Request
- Inherits:
-
Object
- Object
- Voxmail::Request
- Defined in:
- lib/voxmail/request.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#publickey ⇒ Object
Returns the value of attribute publickey.
-
#secretkey ⇒ Object
Returns the value of attribute secretkey.
Instance Method Summary collapse
- #client(method, *args) ⇒ Object
-
#initialize ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize ⇒ Request
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
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/voxmail/request.rb', line 3 def host @host end |
#publickey ⇒ Object
Returns the value of attribute publickey.
3 4 5 |
# File 'lib/voxmail/request.rb', line 3 def publickey @publickey end |
#secretkey ⇒ Object
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 |