Class: Bankid::Poll
- Inherits:
-
Object
- Object
- Bankid::Poll
- Defined in:
- lib/bankid/poll.rb
Constant Summary collapse
- ATTRS =
%i[order_ref status hint_code completion_data error_code details].freeze
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#completed? ⇒ Boolean
rubocop:enable Metrics/ParameterLists.
- #failed? ⇒ Boolean
-
#initialize(order_ref: nil, status: nil, hint_code: nil, completion_data: {}, error_code: nil, details: nil) ⇒ Poll
constructor
rubocop:disable Metrics/ParameterLists.
- #pending? ⇒ Boolean
- #timed_out? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(order_ref: nil, status: nil, hint_code: nil, completion_data: {}, error_code: nil, details: nil) ⇒ Poll
rubocop:disable Metrics/ParameterLists
9 10 11 12 13 14 15 16 |
# File 'lib/bankid/poll.rb', line 9 def initialize(order_ref: nil, status: nil, hint_code: nil, completion_data: {}, error_code: nil, details: nil) @order_ref = order_ref @status = status @hint_code = hint_code @completion_data = completion_data @error_code = error_code @details = details end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 |
# File 'lib/bankid/poll.rb', line 39 def ==(other) ATTRS.all? { |a| send(a) == other.send(a) } end |
#completed? ⇒ Boolean
rubocop:enable Metrics/ParameterLists
19 20 21 |
# File 'lib/bankid/poll.rb', line 19 def completed? status == "complete" end |
#failed? ⇒ Boolean
23 24 25 |
# File 'lib/bankid/poll.rb', line 23 def failed? status == "failed" || error_code end |
#pending? ⇒ Boolean
27 28 29 |
# File 'lib/bankid/poll.rb', line 27 def pending? status == "pending" end |
#timed_out? ⇒ Boolean
31 32 33 |
# File 'lib/bankid/poll.rb', line 31 def timed_out? hint_code == "startFailed" end |
#to_h ⇒ Object
35 36 37 |
# File 'lib/bankid/poll.rb', line 35 def to_h ATTRS.to_h { |a| [a, send(a)] } end |