Class: GrandIdSimple

Inherits:
Object
  • Object
show all
Defined in:
lib/grand_id_simple.rb,
lib/grand_id_simple/version.rb

Direct Known Subclasses

FakeGrandIdSimple

Defined Under Namespace

Classes: Error, Login, Person

Constant Summary collapse

DEFAULT_BASE_URL =
'https://client.grandid.com'
VERSION =
'1.0.3'

Instance Method Summary collapse

Constructor Details

#initialize(api_key, service_key, base_url: DEFAULT_BASE_URL) ⇒ GrandIdSimple

Returns a new instance of GrandIdSimple.



40
41
42
43
44
# File 'lib/grand_id_simple.rb', line 40

def initialize(api_key, service_key, base_url: DEFAULT_BASE_URL)
  @api_key = api_key
  @service_key = service_key
  @base_url = base_url
end

Instance Method Details

#federated_login(**options) ⇒ Object

callbackUrl string Optional Where to return end-user after completion. customerURL string Optional Where to return end-user if they press the back button. userVisibleData base64 Optional Visible data for the end-user to sign. userNonVisibleData base64 Optional Hidden data included in the signature. userVisibleDataFormat string Optional Used to format the visible signature data. authMessage base64 Optional Visible data for the end-user to auth. mobileBankId bool Optional Set to true to force usage of a Mobile BankID. desktopBankId bool Optional Set to true to force usage of a Desktop BankID. thisDevice bool Optional Set to true to allow usage of the end-users current device qr bool Optional Set to true to allow authentication/signing using a QR code allowFingerprintAuth string Optional Set whether usage of fingerprint biometrics is allowed with the authentication. allowFingerprintSign string Optional Set whether usage of fingerprint biometrics is allowed with the signature. gui string Optional Set to false to opt out of GrandID’s user interface and build your custom implementation. appRedirect string Optional Can be used to force a redirect to specific application from the BankID application.



61
62
63
64
65
66
67
68
69
70
# File 'lib/grand_id_simple.rb', line 61

def (**options)
  body = call_api(
    :FederatedLogin,
    method: :post,
    body: {
      **options,
    },
  )
  .new(body)
end

#get_session(session_id) ⇒ Object



72
73
74
75
# File 'lib/grand_id_simple.rb', line 72

def get_session(session_id)
  body = call_api(:GetSession, params: {sessionId: session_id})
  Person.new(body[:user_attributes])
end

#logout(session_id) ⇒ Object



77
78
79
80
81
# File 'lib/grand_id_simple.rb', line 77

def logout(session_id)
  call_api(:Logout, params: {sessionId: session_id})
rescue Error => e
  raise(e) unless e.message['User already logged out']
end