Class: Veryfi::Signature
- Inherits:
-
Object
- Object
- Veryfi::Signature
- Defined in:
- lib/veryfi/signature.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#digest ⇒ Object
private.
-
#initialize(secret, params, timestamp) ⇒ Signature
constructor
A new instance of Signature.
- #payload ⇒ Object
- #to_base64 ⇒ Object
Constructor Details
#initialize(secret, params, timestamp) ⇒ Signature
Returns a new instance of Signature.
10 11 12 13 14 |
# File 'lib/veryfi/signature.rb', line 10 def initialize(secret, params, ) @secret = secret @params = params @timestamp = end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/veryfi/signature.rb', line 8 def params @params end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
8 9 10 |
# File 'lib/veryfi/signature.rb', line 8 def secret @secret end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
8 9 10 |
# File 'lib/veryfi/signature.rb', line 8 def @timestamp end |
Instance Method Details
#digest ⇒ Object
private
22 23 24 |
# File 'lib/veryfi/signature.rb', line 22 def digest OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha256"), secret, payload) end |
#payload ⇒ Object
26 27 28 |
# File 'lib/veryfi/signature.rb', line 26 def payload "timestamp:#{}," + params.to_a.map { |i| "#{i[0]}:#{i[1]}" }.join(",") end |
#to_base64 ⇒ Object
16 17 18 |
# File 'lib/veryfi/signature.rb', line 16 def to_base64 Base64.encode64(digest).strip end |