Class: Bankid::Auth
- Inherits:
-
Object
- Object
- Bankid::Auth
- Defined in:
- lib/bankid.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate_authentication(ip:, id_number: nil) ⇒ Object
- #generate_qr(start_token:, start_secret:, seconds:) ⇒ Object
-
#initialize(env: "development", cert_password: "qwerty123") ⇒ Auth
constructor
A new instance of Auth.
- #poll(order_ref:) ⇒ Object
Constructor Details
#initialize(env: "development", cert_password: "qwerty123") ⇒ Auth
Returns a new instance of Auth.
34 35 36 37 38 39 40 |
# File 'lib/bankid.rb', line 34 def initialize(env: "development", cert_password: "qwerty123") @stubs = [] @env = env @url = Bankid.const_get("#{env.upcase}_URL") @cert_password = cert_password @cert, @key, @root_cert = load_certificates end |
Class Method Details
.clear_stubs ⇒ Object
30 31 32 |
# File 'lib/bankid.rb', line 30 def self.clear_stubs remove_instance_variable(:@stubs) if defined?(@stubs) end |
.endpoint_stub(endpoint) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bankid.rb', line 22 def self.endpoint_stub(endpoint) unless defined?(@stubs) raise "You should stub the endpoint `#{endpoint}` with the `Bankid::Auth.stub_endpoint` method" end @stubs[endpoint] end |
.stub_endpoint(endpoint, data) ⇒ Object
17 18 19 20 |
# File 'lib/bankid.rb', line 17 def self.stub_endpoint(endpoint, data) @stubs = {} unless defined?(@stubs) @stubs[endpoint] = data end |
Instance Method Details
#generate_authentication(ip:, id_number: nil) ⇒ Object
53 54 55 56 |
# File 'lib/bankid.rb', line 53 def generate_authentication(ip:, id_number: nil) response = request("auth", auth_data(ip, id_number)) Authentication.new(**camelize(JSON.parse(response))) end |
#generate_qr(start_token:, start_secret:, seconds:) ⇒ Object
42 43 44 45 46 |
# File 'lib/bankid.rb', line 42 def generate_qr(start_token:, start_secret:, seconds:) RQRCode::QRCode.new( qr_auth_code(start_token, start_secret, seconds) ) end |