Class: Bankid::Poll

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (Boolean)


19
20
21
# File 'lib/bankid/poll.rb', line 19

def completed?
  status == "complete"
end

#failed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/bankid/poll.rb', line 23

def failed?
  status == "failed" || error_code
end

#pending?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/bankid/poll.rb', line 27

def pending?
  status == "pending"
end

#timed_out?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/bankid/poll.rb', line 31

def timed_out?
  hint_code == "startFailed"
end

#to_hObject



35
36
37
# File 'lib/bankid/poll.rb', line 35

def to_h
  ATTRS.to_h { |a| [a, send(a)] }
end