Class: ShopifyGraphql::WebhooksManager
- Inherits:
-
Object
- Object
- ShopifyGraphql::WebhooksManager
- Defined in:
- lib/shopify_graphql/managers/webhooks_manager.rb
Instance Attribute Summary collapse
-
#required_webhooks ⇒ Object
readonly
Returns the value of attribute required_webhooks.
Class Method Summary collapse
- .queue_create(shop_domain, shop_token) ⇒ Object
- .queue_destroy(shop_domain, shop_token) ⇒ Object
- .queue_update(shop_domain, shop_token) ⇒ Object
Instance Method Summary collapse
- #create_webhooks ⇒ Object
- #destroy_webhooks ⇒ Object
-
#initialize(webhooks) ⇒ WebhooksManager
constructor
A new instance of WebhooksManager.
- #recreate_webhooks! ⇒ Object
Constructor Details
#initialize(webhooks) ⇒ WebhooksManager
Returns a new instance of WebhooksManager.
28 29 30 |
# File 'lib/shopify_graphql/managers/webhooks_manager.rb', line 28 def initialize(webhooks) @required_webhooks = webhooks end |
Instance Attribute Details
#required_webhooks ⇒ Object (readonly)
Returns the value of attribute required_webhooks.
26 27 28 |
# File 'lib/shopify_graphql/managers/webhooks_manager.rb', line 26 def required_webhooks @required_webhooks end |
Class Method Details
.queue_create(shop_domain, shop_token) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/shopify_graphql/managers/webhooks_manager.rb', line 4 def queue_create(shop_domain, shop_token) ShopifyGraphql::CreateWebhooksJob.perform_later( shop_domain: shop_domain, shop_token: shop_token, ) end |
.queue_destroy(shop_domain, shop_token) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/shopify_graphql/managers/webhooks_manager.rb', line 11 def queue_destroy(shop_domain, shop_token) ShopifyGraphql::DestroyWebhooksJob.perform_later( shop_domain: shop_domain, shop_token: shop_token, ) end |
.queue_update(shop_domain, shop_token) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/shopify_graphql/managers/webhooks_manager.rb', line 18 def queue_update(shop_domain, shop_token) ShopifyGraphql::UpdateWebhooksJob.perform_later( shop_domain: shop_domain, shop_token: shop_token, ) end |
Instance Method Details
#create_webhooks ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/shopify_graphql/managers/webhooks_manager.rb', line 37 def create_webhooks return unless webhooks_enabled? return unless required_webhooks.present? required_webhooks.each do |webhook| create_webhook(webhook) unless webhook_exists?(webhook[:topic]) end end |
#destroy_webhooks ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/shopify_graphql/managers/webhooks_manager.rb', line 46 def destroy_webhooks return unless webhooks_enabled? current_webhooks.each do |webhook| ShopifyGraphql::Webhook.delete(webhook.id) end @current_webhooks = nil end |
#recreate_webhooks! ⇒ Object
32 33 34 35 |
# File 'lib/shopify_graphql/managers/webhooks_manager.rb', line 32 def recreate_webhooks! destroy_webhooks create_webhooks end |