Sha256: b3777f4565830f46c91169913245d474fcaefd6e1bf57be9937e3d9969698810
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
module DiscoApp::Concerns::SynchroniseCarrierServiceJob extend ActiveSupport::Concern # Ensure that any carrier service required by our app is registered. def perform(shopify_domain) # Don't proceed unless we have a name and callback url. return unless carrier_service_name and callback_url # Registered the carrier service if it hasn't been registered yet. unless current_carrier_service_names.include?(carrier_service_name) ShopifyAPI::CarrierService.create( name: carrier_service_name, callback_url: callback_url, service_discovery: true, format: :json ) end # Ensure any existing carrier services (with the correct name) are active # and have a current callback URL. current_carrier_services.each do |carrier_service| if carrier_service.name == carrier_service_name carrier_service.callback_url = callback_url carrier_service.active = true carrier_service.save end end end protected def carrier_service_name Rails.application.config.x.shopify_app_name end def callback_url nil end private # Return a list of currently registered carrier service names. def current_carrier_service_names current_carrier_services.map(&:name) end # Return a list of currently registered carrier services. def current_carrier_services @current_carrier_service ||= ShopifyAPI::CarrierService.find(:all) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
disco_app-0.8.2 | app/jobs/disco_app/concerns/synchronise_carrier_service_job.rb |
disco_app-0.8.3 | app/jobs/disco_app/concerns/synchronise_carrier_service_job.rb |