Class: Platbamobilom::Verification
- Inherits:
-
Object
- Object
- Platbamobilom::Verification
- Defined in:
- lib/platbamobilom/verification.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
-
#initialize(id:, result:, phone:, signature:) ⇒ Verification
constructor
A new instance of Verification.
- #verify(secret) ⇒ Object
Constructor Details
#initialize(id:, result:, phone:, signature:) ⇒ Verification
Returns a new instance of Verification.
8 9 10 11 12 13 |
# File 'lib/platbamobilom/verification.rb', line 8 def initialize(id:, result:, phone:, signature:) @id = id @result = result @phone = phone @signature = signature end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/platbamobilom/verification.rb', line 3 def id @id end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
5 6 7 |
# File 'lib/platbamobilom/verification.rb', line 5 def phone @phone end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'lib/platbamobilom/verification.rb', line 4 def result @result end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
6 7 8 |
# File 'lib/platbamobilom/verification.rb', line 6 def signature @signature end |
Instance Method Details
#verify(secret) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/platbamobilom/verification.rb', line 15 def verify(secret) signing_data = [id, result, phone].join digest = OpenSSL::Digest.new('sha256') hmac = OpenSSL::HMAC.digest(digest, secret, signing_data) our_signature = hmac.unpack('H*').join.upcase our_signature == signature end |