Class: Bankid::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/bankid/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result_json:) ⇒ Result

Returns a new instance of Result.



32
33
34
35
36
37
38
39
# File 'lib/bankid/result.rb', line 32

def initialize(result_json:)
  @result_json = result_json
  if result_json["status"] == "complete"
    set_device_and_user
  else
    set_hint_code
  end
end

Instance Attribute Details

#deviceObject

Returns the value of attribute device.



30
31
32
# File 'lib/bankid/result.rb', line 30

def device
  @device
end

#hint_codeObject

Returns the value of attribute hint_code.



30
31
32
# File 'lib/bankid/result.rb', line 30

def hint_code
  @hint_code
end

#userObject

Returns the value of attribute user.



30
31
32
# File 'lib/bankid/result.rb', line 30

def user
  @user
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/bankid/result.rb', line 59

def failure?
  @result_json["status"] == "failed"
end

#pending?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/bankid/result.rb', line 63

def pending?
  @result_json["status"] == "pending"
end

#set_device_and_userObject



41
42
43
44
45
46
47
48
49
# File 'lib/bankid/result.rb', line 41

def set_device_and_user
  @user = User.new(**@result_json.dig("completionData", "user").symbolize_keys)
  @result_json["completionData"].symbolize_keys => {
    device:,
    signature:,
    ocspResponse:
  }
  @device = Device.new(device:, signature:, ocspResponse:)
end

#set_hint_codeObject



51
52
53
# File 'lib/bankid/result.rb', line 51

def set_hint_code
  @hint_code = @result_json["hintCode"]
end

#started?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/bankid/result.rb', line 71

def started?
  @result_json["status"] == "started"
end

#success?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/bankid/result.rb', line 55

def success?
  @result_json["status"] == "complete"
end

#user_sign?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/bankid/result.rb', line 67

def user_sign?
  @result_json["status"] == "userSign"
end