Class: ShopifyApp::WebhooksManager
- Inherits:
-
Object
- Object
- ShopifyApp::WebhooksManager
- Defined in:
- lib/shopify_app/managers/webhooks_manager.rb
Class Method Summary collapse
- .add_registrations ⇒ Object
- .create_webhooks(session:) ⇒ Object
- .destroy_webhooks(session:) ⇒ Object
- .queue(shop_domain, shop_token) ⇒ Object
- .recreate_webhooks!(session:) ⇒ Object
Class Method Details
.add_registrations ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/shopify_app/managers/webhooks_manager.rb', line 40 def add_registrations return unless ShopifyApp.configuration.has_webhooks? ShopifyApp::Logger.debug("Adding registrations to webhooks") ShopifyApp.configuration.webhooks.each do |attributes| webhook_path = path(attributes) ShopifyAPI::Webhooks::Registry.add_registration( topic: attributes[:topic], delivery_method: attributes[:delivery_method] || :http, path: webhook_path, handler: webhook_job_klass(webhook_path), fields: attributes[:fields], ) end end |
.create_webhooks(session:) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/shopify_app/managers/webhooks_manager.rb', line 15 def create_webhooks(session:) return unless ShopifyApp.configuration.has_webhooks? ShopifyApp::Logger.debug("Creating webhooks #{ShopifyApp.configuration.webhooks}") ShopifyAPI::Webhooks::Registry.register_all(session: session) end |
.destroy_webhooks(session:) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/shopify_app/managers/webhooks_manager.rb', line 31 def destroy_webhooks(session:) return unless ShopifyApp.configuration.has_webhooks? ShopifyApp::Logger.debug("Destroying webhooks") ShopifyApp.configuration.webhooks.each do |attributes| ShopifyAPI::Webhooks::Registry.unregister(topic: attributes[:topic], session: session) end end |
.queue(shop_domain, shop_token) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/shopify_app/managers/webhooks_manager.rb', line 8 def queue(shop_domain, shop_token) ShopifyApp::WebhooksManagerJob.perform_later( shop_domain: shop_domain, shop_token: shop_token, ) end |
.recreate_webhooks!(session:) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/shopify_app/managers/webhooks_manager.rb', line 23 def recreate_webhooks!(session:) destroy_webhooks(session: session) return unless ShopifyApp.configuration.has_webhooks? ShopifyApp::Logger.debug("Recreating webhooks") add_registrations end |