Class: Monobank::Auth::Corporate
- Inherits:
-
Object
- Object
- Monobank::Auth::Corporate
- Defined in:
- lib/monobank/auth/corporate.rb
Instance Method Summary collapse
-
#initialize(private_key:, key_id: nil, request_id: nil) ⇒ Corporate
constructor
A new instance of Corporate.
- #to_headers(pathname:) ⇒ Object
Constructor Details
#initialize(private_key:, key_id: nil, request_id: nil) ⇒ Corporate
Returns a new instance of Corporate.
4 5 6 7 8 |
# File 'lib/monobank/auth/corporate.rb', line 4 def initialize(private_key:, key_id: nil, request_id: nil) @private_key = init_key(private_key:) @key_id = key_id @request_id = request_id end |
Instance Method Details
#to_headers(pathname:) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/monobank/auth/corporate.rb', line 10 def to_headers(pathname:) time = Time.now.to_i { 'X-Time' => time.to_s, 'X-Sign' => Base64.strict_encode64(sign(pathname:, time:)) }.tap do |headers| headers['X-Key-Id'] = key_id unless key_id.nil? headers['X-Request-Id'] = request_id unless request_id.nil? end end |