Class: SmartId::Api::Authentication::ConfirmationPoller
- Inherits:
-
Object
- Object
- SmartId::Api::Authentication::ConfirmationPoller
- Defined in:
- lib/smart_id/api/authentication/confirmation_poller.rb
Constant Summary collapse
- BASE_URI =
"session/"
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(session_id, authentication_hash, poll) ⇒ ConfirmationPoller
constructor
A new instance of ConfirmationPoller.
Constructor Details
#initialize(session_id, authentication_hash, poll) ⇒ ConfirmationPoller
Returns a new instance of ConfirmationPoller.
11 12 13 14 15 |
# File 'lib/smart_id/api/authentication/confirmation_poller.rb', line 11 def initialize(session_id, authentication_hash, poll) @session_id = session_id @authentication_hash = authentication_hash @poll = poll end |
Class Method Details
.confirm(session_id:, authentication_hash:, poll: true) ⇒ Object
6 7 8 9 |
# File 'lib/smart_id/api/authentication/confirmation_poller.rb', line 6 def self.confirm(session_id:, authentication_hash:, poll: true) new(session_id, authentication_hash, poll).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/smart_id/api/authentication/confirmation_poller.rb', line 17 def call params = { timeoutMs: SmartId.poller_timeout_seconds * 1000 } uri = BASE_URI + @session_id raw_response = SmartId::Api::Request.execute(method: :get, uri: uri, params: params) response = SmartId::Api::ConfirmationResponse.new( JSON.parse(raw_response.body), @authentication_hash.hash_data ) # repeat request if confirmation is still running if response.confirmation_running? && @poll call else response end end |