Class: Lucid::Shopify::CreateWebhook
- Inherits:
-
Object
- Object
- Lucid::Shopify::CreateWebhook
- Defined in:
- lib/lucid/shopify/create_webhook.rb
Instance Method Summary collapse
-
#call(credentials, webhook) ⇒ Hash
Response data.
-
#initialize(client: Container[:client]) ⇒ CreateWebhook
constructor
A new instance of CreateWebhook.
Constructor Details
#initialize(client: Container[:client]) ⇒ CreateWebhook
Returns a new instance of CreateWebhook.
9 10 11 |
# File 'lib/lucid/shopify/create_webhook.rb', line 9 def initialize(client: Container[:client]) @client = client end |
Instance Method Details
#call(credentials, webhook) ⇒ Hash
Returns response data.
17 18 19 20 21 22 23 24 25 |
# File 'lib/lucid/shopify/create_webhook.rb', line 17 def call(credentials, webhook) data = {**webhook, address: Shopify.config.webhook_uri} @client.post_json(credentials, 'webhooks', webhook: data) rescue Response::Error => e raise e unless e.response.([ /has already been taken/, ]) end |