Class: Bankid::Result
- Inherits:
-
Object
- Object
- Bankid::Result
- Defined in:
- lib/bankid/result.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
-
#hint_code ⇒ Object
Returns the value of attribute hint_code.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(result_json:) ⇒ Result
constructor
A new instance of Result.
- #pending? ⇒ Boolean
- #set_device_and_user ⇒ Object
- #set_hint_code ⇒ Object
- #started? ⇒ Boolean
- #success? ⇒ Boolean
- #user_sign? ⇒ Boolean
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
#device ⇒ Object
Returns the value of attribute device.
30 31 32 |
# File 'lib/bankid/result.rb', line 30 def device @device end |
#hint_code ⇒ Object
Returns the value of attribute hint_code.
30 31 32 |
# File 'lib/bankid/result.rb', line 30 def hint_code @hint_code end |
#user ⇒ Object
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
59 60 61 |
# File 'lib/bankid/result.rb', line 59 def failure? @result_json["status"] == "failed" end |
#pending? ⇒ Boolean
63 64 65 |
# File 'lib/bankid/result.rb', line 63 def pending? @result_json["status"] == "pending" end |
#set_device_and_user ⇒ Object
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_code ⇒ Object
51 52 53 |
# File 'lib/bankid/result.rb', line 51 def set_hint_code @hint_code = @result_json["hintCode"] end |
#started? ⇒ Boolean
71 72 73 |
# File 'lib/bankid/result.rb', line 71 def started? @result_json["status"] == "started" end |
#success? ⇒ Boolean
55 56 57 |
# File 'lib/bankid/result.rb', line 55 def success? @result_json["status"] == "complete" end |
#user_sign? ⇒ Boolean
67 68 69 |
# File 'lib/bankid/result.rb', line 67 def user_sign? @result_json["status"] == "userSign" end |