Module: Vindi::Synchronizable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/vindi/integrations/concerns/synchronizable.rb
Instance Method Summary collapse
- #sync_vindi_customer! ⇒ Object
- #synchronizable? ⇒ Boolean
- #update_vindi_customer! ⇒ Object
- #use_vindi_outbox? ⇒ Boolean
Instance Method Details
#sync_vindi_customer! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vindi/integrations/concerns/synchronizable.rb', line 15 def sync_vindi_customer! return unless synchronizable? return if vindi_customer_id? params = vindi_customer_attributes customer = Vindi::Customer.create(params) update_columns(vindi_customer_id: customer.id.to_s) rescue Vindi::Error => e Rails.logger.error("Failed to sync customer to Vindi: #{e.}") end |
#synchronizable? ⇒ Boolean
41 42 43 |
# File 'lib/vindi/integrations/concerns/synchronizable.rb', line 41 def synchronizable? respond_to?(:vindi_customer_id) && self.class.name != "Vindi::PendingSync" end |
#update_vindi_customer! ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/vindi/integrations/concerns/synchronizable.rb', line 27 def update_vindi_customer! return unless synchronizable? return unless vindi_customer_id? params = vindi_customer_attributes Vindi::Customer.update(vindi_customer_id, params) rescue Vindi::Error => e Rails.logger.error("Failed to update customer in Vindi: #{e.}") end |