Initial commit
This commit is contained in:
25
api/hooks/webhook/delete_delete.js
Normal file
25
api/hooks/webhook/delete_delete.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { bigcommerceApiOAuth, serverBaseURL, bigcommerceStoreHash } = require("../config.js")
|
||||
const { deletePrintfulWebhook } = require("../lib/printfulRestAPI.js")
|
||||
;(function () {
|
||||
const data = context.data
|
||||
if (context?.user?.auth()?.id) {
|
||||
const webhook = context.db.find("webhook", {
|
||||
filter: {
|
||||
_id: context.request().param("id"),
|
||||
},
|
||||
})[0]
|
||||
|
||||
if (webhook.type === "printful") {
|
||||
deletePrintfulWebhook(webhook.scope)
|
||||
} else {
|
||||
let url = `https://api.bigcommerce.com/stores/${bigcommerceStoreHash}/v3/hooks/${webhook.webhookId}`
|
||||
|
||||
let options = {
|
||||
method: "DELETE",
|
||||
headers: { "Content-Type": "application/json", "X-Auth-Token": bigcommerceApiOAuth },
|
||||
}
|
||||
|
||||
const response = context.http.fetch(url, options).body.json()
|
||||
}
|
||||
}
|
||||
})()
|
||||
Reference in New Issue
Block a user