Reputation: 299
I have checked the following URLs:
How to delete Shopify Webhooks made thru Shopify API?
But neither seem to really explain how to remove them via inside an app.
I have for example over 100 stores with legacy webhooks that I want to remove for them using the API.
@legacyhooks = ShopifyAPI::Webhook.find(:all, :params => {:limit => 15, :created_at_max => '2013-09-02', :order => "created_at DESC" })
Which this works great. But How do remove them?
I have tried:
ShopifyAPI::Webhook.destroy ShopifyAPI::Webhook.delete ShopifyAPI::Webhook.remove
And none of those seem to work.
EDIT:
I have tried: ShopifyAPI::Webhook.delete({ :id => h.id })
Where the PKID h.id is within a loop. But I get a 404 error.
There is documentation for ShopifyAPI::Webhook.create
and ShopifyAPI::Webhook.find
but after that, nothing.
I DO NOT wish use the CLI or run a cURL command for each one (eg. could be thousands)
I just want to do it automatically within the app that created it itself.
Upvotes: 1
Views: 980
Reputation: 11427
Simple. Try this. Works perfect for me every time...
@legacyhooks = ShopifyAPI::Webhook.find(:all, :params => {:limit => 15, :created_at_max => '2013-09-02', :order => "created_at DESC" })
@legacyhooks.each {|wh| wh.destroy }
You can go crazy extending this concept...
For example.. one of my rake tasks... is:
def remove_webhooks
ShopifyAPI::Webhook.all.each {|wh| wh.destroy if wh.topic == 'products/update'}
end
'Nuff said?
Upvotes: 6