creates webhook and cron job to update inventory

This commit is contained in:
Sebastian Rindom
2020-08-03 14:05:56 +02:00
parent c18677d5f2
commit e69c3aba01
10 changed files with 317 additions and 22 deletions
@@ -10,6 +10,7 @@ class BrightpearlClient {
},
})
this.webhooks = this.buildWebhookEndpoints()
this.payments = this.buildPaymentEndpoints()
this.warehouses = this.buildWarehouseEndpoints()
this.orders = this.buildOrderEndpoints()
@@ -31,6 +32,25 @@ class BrightpearlClient {
})
}
buildWebhookEndpoints = () => {
return {
list: () => {
return this.client_.request({
url: `/integration-service/webhook`,
method: "GET",
})
.then(({ data }) => data.response)
},
create: (data) => {
return this.client_.request({
url: `/integration-service/webhook`,
method: "POST",
data
})
}
}
}
buildPaymentEndpoints = () => {
return {
create: (payment) => {
@@ -128,6 +148,18 @@ class BrightpearlClient {
buildProductEndpoints = () => {
return {
retrieveAvailability: productId => {
return this.client_.request({
url: `/warehouse-service/product-availability/${productId}`,
})
.then(({ data }) => data.response && data.response)
},
retrieve: (productId) => {
return this.client_.request({
url: `/product-service/product/${productId}`,
})
.then(({ data }) => data.response && data.response[0])
},
retrieveBySKU: (sku) => {
return this.client_.request({
url: `/product-service/product-search?SKU=${sku}`,