Class: Billimatic::Signature
- Inherits:
-
Object
- Object
- Billimatic::Signature
- Defined in:
- lib/billimatic/signature.rb
Instance Attribute Summary collapse
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
- #check?(billimatic_request_id, signature_to_check, body) ⇒ Boolean
-
#initialize(secret) ⇒ Signature
constructor
A new instance of Signature.
Constructor Details
#initialize(secret) ⇒ Signature
Returns a new instance of Signature.
5 6 7 |
# File 'lib/billimatic/signature.rb', line 5 def initialize(secret) @secret = secret end |
Instance Attribute Details
#secret ⇒ Object
Returns the value of attribute secret.
3 4 5 |
# File 'lib/billimatic/signature.rb', line 3 def secret @secret end |
Instance Method Details
#check?(billimatic_request_id, signature_to_check, body) ⇒ Boolean
9 10 11 12 |
# File 'lib/billimatic/signature.rb', line 9 def check?(billimatic_request_id, signature_to_check, body) billimatic_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), secret, "#{billimatic_request_id}#{body}") signature_to_check == billimatic_signature end |