From d5d386a67130b17ba3ca05503ed0f9ae5eacc138 Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Mon, 3 Jul 2023 13:22:45 -0400 Subject: [PATCH 1/2] Shopify: Add sources for accepting and rejecting a fulfillment request. --- .../shopify/sources/common/constants.mjs | 16 ++++++++++++ .../fulfillment-request-accepted.mjs | 25 +++++++++++++++++++ .../fulfillment-request-rejected.mjs | 25 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 components/shopify/sources/fulfillment-request-accepted/fulfillment-request-accepted.mjs create mode 100644 components/shopify/sources/fulfillment-request-rejected/fulfillment-request-rejected.mjs diff --git a/components/shopify/sources/common/constants.mjs b/components/shopify/sources/common/constants.mjs index 8d4c43b10c657..1ec41c84b1b46 100644 --- a/components/shopify/sources/common/constants.mjs +++ b/components/shopify/sources/common/constants.mjs @@ -44,6 +44,22 @@ const EVENT_TOPIC = { FULFILLMENT_EVENTS_DELETE: "fulfillment_events/delete", FULFILLMENTS_CREATE: "fulfillments/create", FULFILLMENTS_UPDATE: "fulfillments/update", + FULFILLMENT_ORDERS_CANCELLATION_REQUEST_ACCEPTED: "fulfillment_orders/cancellation_request_accepted", + FULFILLMENT_ORDERS_CANCELLATION_REQUEST_REJECTED: "fulfillment_orders/cancellation_request_rejected", + FULFILLMENT_ORDERS_CANCELLATION_REQUEST_SUBMITTED: "fulfillment_orders/cancellation_request_submitted", + FULFILLMENT_ORDERS_CANCELLED: "fulfillment_orders/cancelled", + FULFILLMENT_ORDERS_FULFILLMENT_REQUEST_ACCEPTED: "fulfillment_orders/fulfillment_request_accepted", + FULFILLMENT_ORDERS_FULFILLMENT_REQUEST_REJECTED: "fulfillment_orders/fulfillment_request_rejected", + FULFILLMENT_ORDERS_FULFILLMENT_REQUEST_SUBMITTED: "fulfillment_orders/fulfillment_request_submitted", + FULFILLMENT_ORDERS_FULFILLMENT_SERVICE_FAILED_TO_COMPLETE: "fulfillment_orders/fulfillment_service_failed_to_complete", + FULFILLMENT_ORDERS_HOLD_RELEASED: "fulfillment_orders/hold_released", + FULFILLMENT_ORDERS_LINE_ITEMS_PREPARED_FOR_LOCAL_DELIVERY: "fulfillment_orders/line_items_prepared_for_local_delivery", + FULFILLMENT_ORDERS_LINE_ITEMS_PREPARED_FOR_PICKUP: "fulfillment_orders/line_items_prepared_for_pickup", + FULFILLMENT_ORDERS_MOVED: "fulfillment_orders/moved", + FULFILLMENT_ORDERS_ORDER_ROUTING_COMPLETE: "fulfillment_orders/order_routing_complete", + FULFILLMENT_ORDERS_PLACED_ON_HOLD: "fulfillment_orders/placed_on_hold", + FULFILLMENT_ORDERS_RESCHEDULED: "fulfillment_orders/rescheduled", + FULFILLMENT_ORDERS_SCHEDULED_FULFILLMENT_ORDER_READY: "fulfillment_orders/scheduled_fulfillment_order_ready", INVENTORY_ITEMS_CREATE: "inventory_items/create", INVENTORY_ITEMS_DELETE: "inventory_items/delete", INVENTORY_ITEMS_UPDATE: "inventory_items/update", diff --git a/components/shopify/sources/fulfillment-request-accepted/fulfillment-request-accepted.mjs b/components/shopify/sources/fulfillment-request-accepted/fulfillment-request-accepted.mjs new file mode 100644 index 0000000000000..8c4dd3560068e --- /dev/null +++ b/components/shopify/sources/fulfillment-request-accepted/fulfillment-request-accepted.mjs @@ -0,0 +1,25 @@ +import common from "../common/webhook.mjs"; +import constants from "../common/constants.mjs"; + +export default { + ...common, + key: "shopify-fulfillment-request-accepted", + name: "Fulfillment Request Accepted", + type: "source", + description: "Occurs when a fulfillment service accepts a fulfillment request that was sent by a merchant.", + version: "0.0.7", + dedupe: "unique", + methods: { + ...common.methods, + getTopic() { + return constants.EVENT_TOPIC.FULFILLMENT_ORDERS_FULFILLMENT_REQUEST_ACCEPTED; + }, + generateMeta(resource) { + return { + id: fulfillment_order.id, + summary: `Fulfillment request accepted for fulfillment order.`, + ts: Date.now(), + }; + }, + }, +}; \ No newline at end of file diff --git a/components/shopify/sources/fulfillment-request-rejected/fulfillment-request-rejected.mjs b/components/shopify/sources/fulfillment-request-rejected/fulfillment-request-rejected.mjs new file mode 100644 index 0000000000000..e369c51614cbc --- /dev/null +++ b/components/shopify/sources/fulfillment-request-rejected/fulfillment-request-rejected.mjs @@ -0,0 +1,25 @@ +import common from "../common/webhook.mjs"; +import constants from "../common/constants.mjs"; + +export default { + ...common, + key: "shopify-fulfillment-request-rejected", + name: "Fulfillment Request Rejected", + type: "source", + description: "Occurs when a fulfillment service rejects a fulfillment request that was sent by a merchant.", + version: "0.0.7", + dedupe: "unique", + methods: { + ...common.methods, + getTopic() { + return constants.EVENT_TOPIC.FULFILLMENT_ORDERS_FULFILLMENT_REQUEST_REJECTED; + }, + generateMeta(resource) { + return { + id: fulfillment_order.id, + summary: `Fulfillment request rejected for fulfillment order.`, + ts: Date.now(), + }; + }, + }, +}; \ No newline at end of file From 300a4718f56b8fb247545329d3e98b4bcfeca134 Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Mon, 3 Jul 2023 13:41:02 -0400 Subject: [PATCH 2/2] Fixups --- .../fulfillment-request-accepted.mjs | 10 +++++----- .../fulfillment-request-rejected.mjs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/shopify/sources/fulfillment-request-accepted/fulfillment-request-accepted.mjs b/components/shopify/sources/fulfillment-request-accepted/fulfillment-request-accepted.mjs index 8c4dd3560068e..3e86054a40ca2 100644 --- a/components/shopify/sources/fulfillment-request-accepted/fulfillment-request-accepted.mjs +++ b/components/shopify/sources/fulfillment-request-accepted/fulfillment-request-accepted.mjs @@ -4,10 +4,10 @@ import constants from "../common/constants.mjs"; export default { ...common, key: "shopify-fulfillment-request-accepted", - name: "Fulfillment Request Accepted", + name: "Fulfillment Request Accepted (Instant)", type: "source", - description: "Occurs when a fulfillment service accepts a fulfillment request that was sent by a merchant.", - version: "0.0.7", + description: "Emit when a fulfillment service accepts a fulfillment request that was sent by a merchant.", + version: "0.0.1", dedupe: "unique", methods: { ...common.methods, @@ -16,8 +16,8 @@ export default { }, generateMeta(resource) { return { - id: fulfillment_order.id, - summary: `Fulfillment request accepted for fulfillment order.`, + id: resource.fulfillment_order.id, + summary: `Fulfillment request accepted for fulfillment order ${resource.fulfillment_order.id}`, ts: Date.now(), }; }, diff --git a/components/shopify/sources/fulfillment-request-rejected/fulfillment-request-rejected.mjs b/components/shopify/sources/fulfillment-request-rejected/fulfillment-request-rejected.mjs index e369c51614cbc..b4c05475e49c8 100644 --- a/components/shopify/sources/fulfillment-request-rejected/fulfillment-request-rejected.mjs +++ b/components/shopify/sources/fulfillment-request-rejected/fulfillment-request-rejected.mjs @@ -4,10 +4,10 @@ import constants from "../common/constants.mjs"; export default { ...common, key: "shopify-fulfillment-request-rejected", - name: "Fulfillment Request Rejected", + name: "Fulfillment Request Rejected (Instant)", type: "source", - description: "Occurs when a fulfillment service rejects a fulfillment request that was sent by a merchant.", - version: "0.0.7", + description: "Emit when a fulfillment service rejects a fulfillment request that was sent by a merchant.", + version: "0.0.1", dedupe: "unique", methods: { ...common.methods, @@ -16,8 +16,8 @@ export default { }, generateMeta(resource) { return { - id: fulfillment_order.id, - summary: `Fulfillment request rejected for fulfillment order.`, + id: resource.fulfillment_order.id, + summary: `Fulfillment request rejected for fulfillment order ${resource.fulfillment_order.id}`, ts: Date.now(), }; },