Class: Plivo::XPlivoSignature
- Inherits:
-
Object
- Object
- Plivo::XPlivoSignature
- Defined in:
- lib/plivo.rb
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#post_params ⇒ Object
Returns the value of attribute post_params.
-
#signature ⇒ Object
Returns the value of attribute signature.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(signature, uri, post_params, auth_token) ⇒ XPlivoSignature
constructor
A new instance of XPlivoSignature.
- #is_valid? ⇒ Boolean
Constructor Details
#initialize(signature, uri, post_params, auth_token) ⇒ XPlivoSignature
Returns a new instance of XPlivoSignature.
16 17 18 19 20 21 |
# File 'lib/plivo.rb', line 16 def initialize(signature, uri, post_params, auth_token) @signature = signature @uri = uri @post_params = post_params @auth_token = auth_token end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
14 15 16 |
# File 'lib/plivo.rb', line 14 def auth_token @auth_token end |
#post_params ⇒ Object
Returns the value of attribute post_params.
14 15 16 |
# File 'lib/plivo.rb', line 14 def post_params @post_params end |
#signature ⇒ Object
Returns the value of attribute signature.
14 15 16 |
# File 'lib/plivo.rb', line 14 def signature @signature end |
#uri ⇒ Object
Returns the value of attribute uri.
14 15 16 |
# File 'lib/plivo.rb', line 14 def uri @uri end |
Instance Method Details
#is_valid? ⇒ Boolean
23 24 25 26 |
# File 'lib/plivo.rb', line 23 def is_valid? uri = @post_params.sort.reduce(@uri) {|_, (key, val)| _ += key + val} return Base64.encode64(OpenSSL::HMAC.digest('sha1', @auth_token, uri)).chomp.eql? @signature end |