2013-10-17 124 views
0

我已經檢查了以下網址:ShopifyAPI網絡掛接去除

How to delete Shopify Webhooks made thru Shopify API?

Deleting Webhooks

但無論似乎真的解釋如何通過一個應用程序內刪除它們。

我有例如超過100個商店與遺留webhooks,我想刪除他們使用API​​。

@legacyhooks = ShopifyAPI::Webhook.find(:all, :params => {:limit => 15, :created_at_max => '2013-09-02', :order => "created_at DESC" }) 

這很好用。但是如何刪除它們?

我曾嘗試:

ShopifyAPI::Webhook.destroy ShopifyAPI::Webhook.delete ShopifyAPI::Webhook.remove 

和無那些似乎工作。

編輯: 我曾嘗試:ShopifyAPI::Webhook.delete({ :id => h.id })

凡PKID h.id是在一個循環中。但我得到一個404錯誤。

ShopifyAPI::Webhook.createShopifyAPI::Webhook.find的文檔,但在此之後,什麼也沒有。

我不希望使用CLI或運行爲每一個捲曲的命令(例如可能是成千上萬)

我只是想創建它自己的應用程序中自動執行。

回答

1

簡單。嘗試這個。作品完美的每一次我...

@legacyhooks = ShopifyAPI::Webhook.find(:all, :params => {:limit => 15, :created_at_max => '2013-09-02', :order => "created_at DESC" }) 
@legacyhooks.each {|wh| wh.destroy } 

你可以去瘋了將這一概念擴展...

例如..我耙任務之一......是:

def remove_webhooks 
    ShopifyAPI::Webhook.all.each {|wh| wh.destroy if wh.topic == 'products/update'} 
end 

'Nuff說?