Class: PedicelPay::TokenHeader
- Inherits:
-
Object
- Object
- PedicelPay::TokenHeader
- Defined in:
- lib/pedicel-pay/token_header.rb
Constant Summary collapse
- Error =
Class.new(PedicelPay::Error)
Instance Attribute Summary collapse
-
#data_hash ⇒ Object
Returns the value of attribute data_hash.
-
#ephemeral_pubkey ⇒ Object
Returns the value of attribute ephemeral_pubkey.
-
#pubkey_hash ⇒ Object
Returns the value of attribute pubkey_hash.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
Instance Method Summary collapse
-
#initialize(data_hash: nil, ephemeral_pubkey: nil, pubkey_hash: nil, transaction_id: nil) ⇒ TokenHeader
constructor
A new instance of TokenHeader.
- #sample ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(data_hash: nil, ephemeral_pubkey: nil, pubkey_hash: nil, transaction_id: nil) ⇒ TokenHeader
Returns a new instance of TokenHeader.
11 12 13 14 |
# File 'lib/pedicel-pay/token_header.rb', line 11 def initialize(data_hash: nil, ephemeral_pubkey: nil, pubkey_hash: nil, transaction_id: nil) @data_hash, @ephemeral_pubkey, @pubkey_hash, @transaction_id = \ data_hash, ephemeral_pubkey, pubkey_hash, transaction_id end |
Instance Attribute Details
#data_hash ⇒ Object
Returns the value of attribute data_hash.
5 6 7 |
# File 'lib/pedicel-pay/token_header.rb', line 5 def data_hash @data_hash end |
#ephemeral_pubkey ⇒ Object
Returns the value of attribute ephemeral_pubkey.
5 6 7 |
# File 'lib/pedicel-pay/token_header.rb', line 5 def ephemeral_pubkey @ephemeral_pubkey end |
#pubkey_hash ⇒ Object
Returns the value of attribute pubkey_hash.
5 6 7 |
# File 'lib/pedicel-pay/token_header.rb', line 5 def pubkey_hash @pubkey_hash end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
5 6 7 |
# File 'lib/pedicel-pay/token_header.rb', line 5 def transaction_id @transaction_id end |
Instance Method Details
#sample ⇒ Object
29 30 31 32 33 |
# File 'lib/pedicel-pay/token_header.rb', line 29 def sample self.transaction_id ||= PedicelPay.config[:random].bytes(32) self end |
#to_hash ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pedicel-pay/token_header.rb', line 16 def to_hash raise Error, 'missing ephemeral_pubkey' unless ephemeral_pubkey result = { 'ephemeralPublicKey' => Base64.strict_encode64(Helper.ec_key_to_pkey_public_key(ephemeral_pubkey).to_der), 'publicKeyHash' => pubkey_hash, 'transactionId' => Helper.bytestring_to_hex(transaction_id), } result.merge!('applicationData' => data_hash) if data_hash result end |