Class: Spree::BankPayments::Reconcilers::Base
- Inherits:
-
Object
- Object
- Spree::BankPayments::Reconcilers::Base
- Defined in:
- app/models/spree/bank_payments/reconcilers/base.rb
Direct Known Subclasses
Defined Under Namespace
Classes: NotConfiguredError
Instance Attribute Summary collapse
-
#payment_method ⇒ Object
readonly
Returns the value of attribute payment_method.
Class Method Summary collapse
Instance Method Summary collapse
-
#configured? ⇒ Boolean
Whether credentials and settings are complete.
-
#healthy? ⇒ Boolean
False means the expiry job must not cancel anything.
-
#initialize(payment_method:) ⇒ Base
constructor
A new instance of Base.
-
#parse_webhook(raw_body, headers) ⇒ Spree::BankPayments::TransferData?
Nil for unsupported events.
- #poll(since:) ⇒ Array<Spree::BankPayments::TransferData>
-
#sync_accounts ⇒ Array<Spree::BankPayments::AccountData>
Accounts this provider can see, for the admin sync flow.
Constructor Details
#initialize(payment_method:) ⇒ Base
Returns a new instance of Base.
28 29 30 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 28 def initialize(payment_method:) @payment_method = payment_method end |
Instance Attribute Details
#payment_method ⇒ Object (readonly)
Returns the value of attribute payment_method.
26 27 28 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 26 def payment_method @payment_method end |
Class Method Details
.build(payment_method:) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 16 def build(payment_method:) key = payment_method.preferred_reconciler.to_s klass = registry.fetch(key) do raise ArgumentError, "unknown reconciler #{key.inspect}" end klass.new(payment_method: payment_method) end |
.register(key, klass) ⇒ Object
12 13 14 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 12 def register(key, klass) registry[key.to_s] = klass end |
.registry ⇒ Object
8 9 10 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 8 def registry @registry ||= {} end |
Instance Method Details
#configured? ⇒ Boolean
Returns whether credentials and settings are complete.
50 51 52 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 50 def configured? raise NotImplementedError, "#{self.class} must implement #configured?" end |
#healthy? ⇒ Boolean
Returns false means the expiry job must not cancel anything.
45 46 47 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 45 def healthy? raise NotImplementedError, "#{self.class} must implement #healthy?" end |
#parse_webhook(raw_body, headers) ⇒ Spree::BankPayments::TransferData?
Returns nil for unsupported events.
40 41 42 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 40 def parse_webhook(raw_body, headers) raise NotImplementedError, "#{self.class} must implement #parse_webhook" end |
#poll(since:) ⇒ Array<Spree::BankPayments::TransferData>
34 35 36 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 34 def poll(since:) raise NotImplementedError, "#{self.class} must implement #poll" end |
#sync_accounts ⇒ Array<Spree::BankPayments::AccountData>
Accounts this provider can see, for the admin sync flow. Providers that cannot enumerate accounts return [].
58 59 60 |
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 58 def sync_accounts [] end |