diff --git a/components/paazl/actions/create-checkout-token/create-checkout-token.mjs b/components/paazl/actions/create-checkout-token/create-checkout-token.mjs new file mode 100644 index 0000000000000..03836a22e7f9e --- /dev/null +++ b/components/paazl/actions/create-checkout-token/create-checkout-token.mjs @@ -0,0 +1,35 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-create-checkout-token", + name: "Create Checkout Access Token", + description: "Returns an access token for a checkout session. This enables the Paazl checkout widget to access Paazl resources. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Checkout/createTokenUsingPOST)", + version: "0.0.1", + type: "action", + props: { + app, + reference: { + propDefinition: [ + app, + "reference", + ], + description: "Your reference for the checkout session. If the reference value provided already exists, the existing session will be replaced with a new session.", + }, + }, + async run({ $ }) { + const { + app, + reference, + } = this; + + const response = await app.createCheckoutToken({ + $, + data: { + reference, + }, + }); + + $.export("$summary", "Successfully created checkout token"); + return response; + }, +}; diff --git a/components/paazl/actions/create-shipment/create-shipment.mjs b/components/paazl/actions/create-shipment/create-shipment.mjs new file mode 100644 index 0000000000000..3539ea520abc4 --- /dev/null +++ b/components/paazl/actions/create-shipment/create-shipment.mjs @@ -0,0 +1,196 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-create-shipment", + name: "Create Shipment For Order", + description: "Generates a shipment at the carrier for the shipping option specified in POST order. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/createShipmentUsingPOST)", + version: "0.0.1", + type: "action", + props: { + app, + orderReference: { + propDefinition: [ + app, + "reference", + ], + }, + type: { + optional: false, + propDefinition: [ + app, + "labelType", + ], + }, + size: { + optional: false, + propDefinition: [ + app, + "labelSize", + ], + }, + quantity: { + propDefinition: [ + app, + "quantity", + ], + }, + enableParcels: { + propDefinition: [ + app, + "enableParcels", + ], + }, + parcelWeight: { + propDefinition: [ + app, + "parcelWeight", + ], + }, + parcelLength: { + propDefinition: [ + app, + "parcelLength", + ], + }, + parcelWidth: { + propDefinition: [ + app, + "parcelWidth", + ], + }, + parcelHeight: { + propDefinition: [ + app, + "parcelHeight", + ], + }, + parcelVolume: { + propDefinition: [ + app, + "parcelVolume", + ], + }, + parcelReference: { + propDefinition: [ + app, + "parcelReference", + ], + }, + parcelDescription: { + propDefinition: [ + app, + "parcelDescription", + ], + }, + parcelCodValue: { + propDefinition: [ + app, + "parcelCodValue", + ], + }, + parcelCodCurrency: { + propDefinition: [ + app, + "parcelCodCurrency", + ], + }, + parcelInsuredValue: { + propDefinition: [ + app, + "parcelInsuredValue", + ], + }, + parcelInsuredCurrency: { + propDefinition: [ + app, + "parcelInsuredCurrency", + ], + }, + }, + async run({ $ }) { + const { + app, + orderReference, + type, + size, + quantity, + enableParcels, + parcelWeight, + parcelLength, + parcelWidth, + parcelHeight, + parcelVolume, + parcelReference, + parcelDescription, + parcelCodValue, + parcelCodCurrency, + parcelInsuredValue, + parcelInsuredCurrency, + } = this; + + const response = await app.createShipment({ + $, + orderReference, + data: { + type, + size, + quantity, + ...(enableParcels && parcelWeight + ? { + parcels: [ + { + weight: parseFloat(parcelWeight), + ...(parcelLength && parcelWidth && parcelHeight + ? { + dimensions: { + length: parcelLength, + width: parcelWidth, + height: parcelHeight, + ...(parcelVolume + ? { + volume: parseFloat(parcelVolume), + } + : {} + ), + }, + } + : parcelVolume + ? { + dimensions: { + volume: parseFloat(parcelVolume), + }, + } + : {} + ), + reference: parcelReference, + description: parcelDescription, + ...(parcelCodValue + ? { + codValue: { + value: parseFloat(parcelCodValue), + currency: parcelCodCurrency || "EUR", + }, + } + : {} + ), + ...(parcelInsuredValue + ? { + insuredValue: { + value: parseFloat(parcelInsuredValue), + currency: parcelInsuredCurrency || "EUR", + }, + } + : {} + ), + }, + ], + } + : {} + ), + }, + }); + + $.export("$summary", `Successfully created shipment for order: ${orderReference}`); + return response; + }, +}; diff --git a/components/paazl/actions/delete-order/delete-order.mjs b/components/paazl/actions/delete-order/delete-order.mjs new file mode 100644 index 0000000000000..0069ac09aa980 --- /dev/null +++ b/components/paazl/actions/delete-order/delete-order.mjs @@ -0,0 +1,33 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-delete-order", + name: "Delete Order", + description: "Deletes an order. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Order/saveOrderUsingPOST)", + version: "0.0.1", + type: "action", + props: { + app, + reference: { + propDefinition: [ + app, + "reference", + ], + description: "Your reference for the order you want to delete", + }, + }, + async run({ $ }) { + const { + app, + reference, + } = this; + + const response = await app.deleteOrder({ + $, + reference, + }); + + $.export("$summary", `Successfully deleted order with reference: ${reference}`); + return response; + }, +}; diff --git a/components/paazl/actions/get-checkout-session/get-checkout-session.mjs b/components/paazl/actions/get-checkout-session/get-checkout-session.mjs new file mode 100644 index 0000000000000..d32f53cf9e168 --- /dev/null +++ b/components/paazl/actions/get-checkout-session/get-checkout-session.mjs @@ -0,0 +1,35 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-checkout-session", + name: "Get Checkout Session Data", + description: "Gets your reference for a checkout session. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Checkout/getCheckoutUsingGET)", + version: "0.0.1", + type: "action", + props: { + app, + reference: { + propDefinition: [ + app, + "reference", + ], + description: "Your reference for the checkout session whose details you want to retrieve. The reference is the one you used when you created an access token with the token endpoint.", + }, + }, + async run({ $ }) { + const { + app, + reference, + } = this; + + const response = await app.getCheckoutSession({ + $, + params: { + reference, + }, + }); + + $.export("$summary", "Successfully retrieved checkout session data"); + return response; + }, +}; diff --git a/components/paazl/actions/get-order-labels/get-order-labels.mjs b/components/paazl/actions/get-order-labels/get-order-labels.mjs new file mode 100644 index 0000000000000..e7a8a44f5330d --- /dev/null +++ b/components/paazl/actions/get-order-labels/get-order-labels.mjs @@ -0,0 +1,52 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-order-labels", + name: "Get Order Shipping Labels", + description: "Retrieves an order's labels. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getOrderLabelsUsingGet)", + version: "0.0.1", + type: "action", + props: { + app, + orderReference: { + propDefinition: [ + app, + "reference", + ], + }, + type: { + propDefinition: [ + app, + "labelType", + ], + description: "Format of the labels", + }, + size: { + propDefinition: [ + app, + "labelSize", + ], + description: "Size of the labels", + }, + }, + async run({ $ }) { + const { + app, + orderReference, + type, + size, + } = this; + + const response = await app.getOrderLabels({ + $, + orderReference, + params: { + type, + size, + }, + }); + + $.export("$summary", `Successfully retrieved labels for order: ${orderReference}`); + return response; + }, +}; diff --git a/components/paazl/actions/get-order-shipments/get-order-shipments.mjs b/components/paazl/actions/get-order-shipments/get-order-shipments.mjs new file mode 100644 index 0000000000000..94468b517987e --- /dev/null +++ b/components/paazl/actions/get-order-shipments/get-order-shipments.mjs @@ -0,0 +1,32 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-order-shipments", + name: "Get Order Shipment Details", + description: "Retrieves an order's shipments details. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getShipmentsUsingGET)", + version: "0.0.1", + type: "action", + props: { + app, + orderReference: { + propDefinition: [ + app, + "reference", + ], + }, + }, + async run({ $ }) { + const { + app, + orderReference, + } = this; + + const response = await app.getOrderShipments({ + $, + orderReference, + }); + + $.export("$summary", "Successfully retrieved shipment details for order"); + return response; + }, +}; diff --git a/components/paazl/actions/get-parcel-label/get-parcel-label.mjs b/components/paazl/actions/get-parcel-label/get-parcel-label.mjs new file mode 100644 index 0000000000000..6b54991ec83a1 --- /dev/null +++ b/components/paazl/actions/get-parcel-label/get-parcel-label.mjs @@ -0,0 +1,71 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-parcel-label", + name: "Get Specific Parcel Label", + description: "Retrieves a specific parcel's label. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getParcelLabelUsingGet)", + version: "0.0.1", + type: "action", + props: { + app, + orderReference: { + propDefinition: [ + app, + "reference", + ], + }, + shipmentId: { + propDefinition: [ + app, + "shipmentId", + ({ orderReference }) => ({ + orderReference, + }), + ], + }, + parcelId: { + propDefinition: [ + app, + "parcelId", + ], + }, + type: { + propDefinition: [ + app, + "labelType", + ], + description: "Format of the label", + }, + size: { + propDefinition: [ + app, + "labelSize", + ], + description: "Size of the label", + }, + }, + async run({ $ }) { + const { + app, + orderReference, + shipmentId, + parcelId, + type, + size, + } = this; + + const response = await app.getParcelLabel({ + $, + orderReference, + shipmentId, + parcelId, + params: { + type, + size, + }, + }); + + $.export("$summary", `Successfully retrieved label for parcel: ${parcelId} in shipment: ${shipmentId} of order: ${orderReference}`); + return response; + }, +}; diff --git a/components/paazl/actions/get-pickup-location-options/get-pickup-location-options.mjs b/components/paazl/actions/get-pickup-location-options/get-pickup-location-options.mjs new file mode 100644 index 0000000000000..faaeca9aaf884 --- /dev/null +++ b/components/paazl/actions/get-pickup-location-options/get-pickup-location-options.mjs @@ -0,0 +1,228 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-pickup-location-options", + name: "Get Pickup Location Shipping Options", + description: "Contains pickup locations for your checkout page. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipping%20options/getPickupLocationsUsingPOST)", + version: "0.0.1", + type: "action", + props: { + app, + consigneeCountryCode: { + propDefinition: [ + app, + "consigneeCountryCode", + ], + }, + consigneePostalCode: { + optional: false, + propDefinition: [ + app, + "consigneePostalCode", + ], + }, + consignorCountryCode: { + propDefinition: [ + app, + "consignorCountryCode", + ], + }, + consignorPostalCode: { + propDefinition: [ + app, + "consignorPostalCode", + ], + }, + locale: { + propDefinition: [ + app, + "locale", + ], + }, + timeZone: { + propDefinition: [ + app, + "timeZone", + ], + }, + limit: { + propDefinition: [ + app, + "limit", + ], + }, + numberOfProcessingDays: { + propDefinition: [ + app, + "numberOfProcessingDays", + ], + }, + includeExternalDeliveryDates: { + propDefinition: [ + app, + "includeExternalDeliveryDates", + ], + }, + deliveryDateStartDate: { + propDefinition: [ + app, + "deliveryDateStartDate", + ], + }, + deliveryDateNumberOfDays: { + propDefinition: [ + app, + "deliveryDateNumberOfDays", + ], + }, + token: { + propDefinition: [ + app, + "token", + ], + }, + network: { + propDefinition: [ + app, + "network", + ], + }, + crossBorderStores: { + propDefinition: [ + app, + "crossBorderStores", + ], + }, + excludeLockers: { + propDefinition: [ + app, + "excludeLockers", + ], + }, + lockersOnly: { + propDefinition: [ + app, + "lockersOnly", + ], + }, + tags: { + propDefinition: [ + app, + "tags", + ], + }, + totalWeight: { + propDefinition: [ + app, + "totalWeight", + ], + }, + totalPrice: { + propDefinition: [ + app, + "totalPrice", + ], + }, + totalVolume: { + propDefinition: [ + app, + "totalVolume", + ], + }, + numberOfGoods: { + propDefinition: [ + app, + "numberOfGoods", + ], + }, + startMatrix: { + propDefinition: [ + app, + "startMatrix", + ], + }, + }, + async run({ $ }) { + const { + app, + consigneeCountryCode, + consigneePostalCode, + consignorCountryCode, + consignorPostalCode, + locale, + timeZone, + limit, + numberOfProcessingDays, + includeExternalDeliveryDates, + token, + network, + crossBorderStores, + excludeLockers, + lockersOnly, + tags, + totalWeight, + totalPrice, + totalVolume, + numberOfGoods, + startMatrix, + deliveryDateStartDate, + deliveryDateNumberOfDays, + } = this; + + const response = await app.getPickupLocationOptions({ + $, + data: { + consigneeCountryCode, + consigneePostalCode, + consignorCountryCode, + consignorPostalCode, + locale, + timeZone, + limit, + numberOfProcessingDays, + includeExternalDeliveryDates, + token, + network, + crossBorderStores, + excludeLockers, + lockersOnly, + tags, + ...(deliveryDateStartDate + || deliveryDateNumberOfDays + ? { + deliveryDateOptions: { + startDate: deliveryDateStartDate, + numberOfDays: deliveryDateNumberOfDays, + }, + } + : {} + ), + ...(totalWeight + || totalPrice + || totalVolume + || numberOfGoods + || startMatrix + ? { + shipmentParameters: { + totalWeight: totalWeight + ? parseFloat(totalWeight) + : undefined, + totalPrice: totalPrice + ? parseFloat(totalPrice) + : undefined, + totalVolume: totalVolume + ? parseFloat(totalVolume) + : undefined, + numberOfGoods, + startMatrix, + }, + } + : {} + ), + }, + }); + + $.export("$summary", `Successfully retrieved \`${response.pickupLocations?.length || 0}\` pickup location options`); + return response; + }, +}; diff --git a/components/paazl/actions/get-return-shipments/get-return-shipments.mjs b/components/paazl/actions/get-return-shipments/get-return-shipments.mjs new file mode 100644 index 0000000000000..a74ae6d1609e2 --- /dev/null +++ b/components/paazl/actions/get-return-shipments/get-return-shipments.mjs @@ -0,0 +1,32 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-return-shipments", + name: "Get Return Shipment Details", + description: "Retrieves an order's return shipments details. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getReturnShipmentsUsingGET)", + version: "0.0.1", + type: "action", + props: { + app, + orderReference: { + propDefinition: [ + app, + "reference", + ], + }, + }, + async run({ $ }) { + const { + app, + orderReference, + } = this; + + const response = await app.getReturnShipments({ + $, + orderReference, + }); + + $.export("$summary", `Successfully retrieved return shipment details for order: ${orderReference}`); + return response; + }, +}; diff --git a/components/paazl/actions/get-shipment-labels/get-shipment-labels.mjs b/components/paazl/actions/get-shipment-labels/get-shipment-labels.mjs new file mode 100644 index 0000000000000..211f6416f2682 --- /dev/null +++ b/components/paazl/actions/get-shipment-labels/get-shipment-labels.mjs @@ -0,0 +1,63 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-shipment-labels", + name: "Get Specific Shipment Label", + description: "Retrieves a specific shipment's labels. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getShipmentLabelsUsingGet)", + version: "0.0.1", + type: "action", + props: { + app, + orderReference: { + propDefinition: [ + app, + "reference", + ], + }, + shipmentId: { + propDefinition: [ + app, + "shipmentId", + ({ orderReference }) => ({ + orderReference, + }), + ], + }, + type: { + propDefinition: [ + app, + "labelType", + ], + description: "Format of the labels", + }, + size: { + propDefinition: [ + app, + "labelSize", + ], + description: "Size of the labels", + }, + }, + async run({ $ }) { + const { + app, + orderReference, + shipmentId, + type, + size, + } = this; + + const response = await app.getShipmentLabels({ + $, + orderReference, + shipmentId, + params: { + type, + size, + }, + }); + + $.export("$summary", `Successfully retrieved labels for shipment: ${shipmentId} in order: ${orderReference}`); + return response; + }, +}; diff --git a/components/paazl/actions/get-shipment-tracking/get-shipment-tracking.mjs b/components/paazl/actions/get-shipment-tracking/get-shipment-tracking.mjs new file mode 100644 index 0000000000000..479cc2447a01c --- /dev/null +++ b/components/paazl/actions/get-shipment-tracking/get-shipment-tracking.mjs @@ -0,0 +1,43 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-shipment-tracking", + name: "Get Specific Shipment Tracking", + description: "Retrieves a specific shipment's tracking number details. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getShipmentByShipmentIdUsingGET)", + version: "0.0.1", + type: "action", + props: { + app, + orderReference: { + propDefinition: [ + app, + "reference", + ], + }, + shipmentId: { + propDefinition: [ + app, + "shipmentId", + ({ orderReference }) => ({ + orderReference, + }), + ], + }, + }, + async run({ $ }) { + const { + app, + orderReference, + shipmentId, + } = this; + + const response = await app.getShipmentById({ + $, + orderReference, + shipmentId, + }); + + $.export("$summary", `Successfully retrieved tracking details for shipment: ${shipmentId} in order: ${orderReference}`); + return response; + }, +}; diff --git a/components/paazl/actions/get-shipping-options/get-shipping-options.mjs b/components/paazl/actions/get-shipping-options/get-shipping-options.mjs new file mode 100644 index 0000000000000..90f50898807af --- /dev/null +++ b/components/paazl/actions/get-shipping-options/get-shipping-options.mjs @@ -0,0 +1,228 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-get-shipping-options", + name: "Get Home Delivery Shipping Options", + description: "Contains shipping options for your checkout page. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipping%20options/shippingOptionsUsingPOST)", + version: "0.0.1", + type: "action", + props: { + app, + consigneeCountryCode: { + propDefinition: [ + app, + "consigneeCountryCode", + ], + }, + consigneePostalCode: { + propDefinition: [ + app, + "consigneePostalCode", + ], + }, + consignorCountryCode: { + propDefinition: [ + app, + "consignorCountryCode", + ], + }, + consignorPostalCode: { + propDefinition: [ + app, + "consignorPostalCode", + ], + }, + locale: { + propDefinition: [ + app, + "locale", + ], + }, + timeZone: { + propDefinition: [ + app, + "timeZone", + ], + }, + limit: { + propDefinition: [ + app, + "limit", + ], + }, + numberOfProcessingDays: { + propDefinition: [ + app, + "numberOfProcessingDays", + ], + }, + includeExternalDeliveryDates: { + propDefinition: [ + app, + "includeExternalDeliveryDates", + ], + }, + deliveryDateStartDate: { + propDefinition: [ + app, + "deliveryDateStartDate", + ], + }, + deliveryDateNumberOfDays: { + propDefinition: [ + app, + "deliveryDateNumberOfDays", + ], + }, + token: { + propDefinition: [ + app, + "token", + ], + }, + tags: { + propDefinition: [ + app, + "tags", + ], + }, + sortOrderBy: { + propDefinition: [ + app, + "sortOrderBy", + ], + }, + sortOrder: { + propDefinition: [ + app, + "sortOrder", + ], + }, + sortDistributor: { + propDefinition: [ + app, + "sortDistributor", + ], + }, + totalWeight: { + propDefinition: [ + app, + "totalWeight", + ], + }, + totalPrice: { + propDefinition: [ + app, + "totalPrice", + ], + }, + totalVolume: { + propDefinition: [ + app, + "totalVolume", + ], + }, + numberOfGoods: { + propDefinition: [ + app, + "numberOfGoods", + ], + }, + startMatrix: { + propDefinition: [ + app, + "startMatrix", + ], + }, + }, + async run({ $ }) { + const { + app, + consigneeCountryCode, + consigneePostalCode, + consignorCountryCode, + consignorPostalCode, + locale, + timeZone, + limit, + numberOfProcessingDays, + includeExternalDeliveryDates, + token, + tags, + sortOrderBy, + sortOrder, + sortDistributor, + totalWeight, + totalPrice, + totalVolume, + numberOfGoods, + startMatrix, + deliveryDateStartDate, + deliveryDateNumberOfDays, + } = this; + + const response = await app.getShippingOptions({ + $, + data: { + consigneeCountryCode, + consigneePostalCode, + consignorCountryCode, + consignorPostalCode, + locale, + timeZone, + limit, + numberOfProcessingDays, + includeExternalDeliveryDates, + token, + tags, + ...(deliveryDateStartDate + || deliveryDateNumberOfDays + ? { + deliveryDateOptions: { + startDate: deliveryDateStartDate, + numberOfDays: deliveryDateNumberOfDays, + }, + } + : {} + ), + ...(sortOrderBy + || sortOrder + || sortDistributor + ? { + sortingModel: { + orderBy: sortOrderBy, + sortOrder: sortOrder, + distributor: sortDistributor, + }, + } + : {} + ), + ...(totalWeight + || totalPrice + || totalVolume + || numberOfGoods + || startMatrix + ? { + shipmentParameters: { + totalWeight: totalWeight + ? parseFloat(totalWeight) + : undefined, + totalPrice: totalPrice + ? parseFloat(totalPrice) + : undefined, + totalVolume: totalVolume + ? parseFloat(totalVolume) + : undefined, + numberOfGoods, + startMatrix: startMatrix, + }, + } + : {} + ), + }, + }); + + $.export("$summary", `Successfully retrieved \`${response.shippingOptions?.length || 0}\` shipping options`); + return response; + }, +}; diff --git a/components/paazl/actions/modify-order/modify-order.mjs b/components/paazl/actions/modify-order/modify-order.mjs new file mode 100644 index 0000000000000..20a7c4692b6e3 --- /dev/null +++ b/components/paazl/actions/modify-order/modify-order.mjs @@ -0,0 +1,153 @@ +import app from "../../paazl.app.mjs"; +import utils from "../../common/utils.mjs"; + +export default { + key: "paazl-modify-order", + name: "Modify Order", + description: "Modifies the information of an order with a specific reference in the Paazl database. The method overwrites the order. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Order/editOrderUsingPUT)", + version: "0.0.1", + type: "action", + props: { + app, + reference: { + propDefinition: [ + app, + "reference", + ], + label: "Order Reference", + description: "Your own order reference for a purchase transaction. Must be unique within the webshop.", + }, + consignee: { + propDefinition: [ + app, + "consignee", + ], + }, + customsValue: { + propDefinition: [ + app, + "customsValue", + ], + }, + insuredValue: { + propDefinition: [ + app, + "insuredValue", + ], + }, + codValue: { + propDefinition: [ + app, + "codValue", + ], + }, + description: { + propDefinition: [ + app, + "orderDescription", + ], + }, + requestedDeliveryDate: { + propDefinition: [ + app, + "requestedDeliveryDate", + ], + }, + products: { + propDefinition: [ + app, + "products", + ], + }, + invoiceNumber: { + propDefinition: [ + app, + "invoiceNumber", + ], + }, + invoiceDate: { + propDefinition: [ + app, + "invoiceDate", + ], + }, + returnProp: { + propDefinition: [ + app, + "returnProp", + ], + }, + sender: { + propDefinition: [ + app, + "sender", + ], + }, + shipping: { + propDefinition: [ + app, + "shipping", + ], + }, + weight: { + propDefinition: [ + app, + "orderWeight", + ], + }, + additionalInstruction: { + propDefinition: [ + app, + "additionalInstruction", + ], + }, + }, + async run({ $ }) { + const { + app, + reference, + consignee, + customsValue, + insuredValue, + codValue, + description, + requestedDeliveryDate, + products, + invoiceNumber, + invoiceDate, + returnProp, + sender, + shipping, + weight, + additionalInstruction, + } = this; + + const response = await app.modifyOrder({ + $, + data: { + reference, + consignee: utils.parseJson(consignee), + customsValue: utils.parseJson(customsValue), + insuredValue: utils.parseJson(insuredValue), + codValue: utils.parseJson(codValue), + description, + requestedDeliveryDate, + products: utils.parseArray(products), + invoiceNumber, + invoiceDate, + return: utils.parseJson(returnProp), + sender: utils.parseJson(sender), + shipping: utils.parseJson(shipping), + weight: weight + ? parseFloat(weight) + : undefined, + additionalInstruction, + }, + }); + + $.export("$summary", `Successfully modified order information for reference: ${reference}`); + return response || { + success: true, + }; + }, +}; diff --git a/components/paazl/actions/save-checkout-session/save-checkout-session.mjs b/components/paazl/actions/save-checkout-session/save-checkout-session.mjs new file mode 100644 index 0000000000000..10d4224d6e8ca --- /dev/null +++ b/components/paazl/actions/save-checkout-session/save-checkout-session.mjs @@ -0,0 +1,88 @@ +import app from "../../paazl.app.mjs"; + +export default { + key: "paazl-save-checkout-session", + name: "Save Checkout Session Data", + description: "Saves the most important information of a specific checkout session to the Paazl database. The information will be kept for 30 days. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Checkout/saveCheckoutUsingPOST)", + version: "0.0.1", + type: "action", + props: { + app, + token: { + type: "string", + label: "Token", + description: "The access token returned by the token endpoint", + }, + consigneeCountryCode: { + propDefinition: [ + app, + "consigneeCountryCode", + ], + }, + shippingOptionIdentifier: { + optional: false, + propDefinition: [ + app, + "shippingOptionId", + ({ + token, consigneeCountryCode, + }) => ({ + token, + consigneeCountryCode, + }), + ], + }, + pickupLocationCode: { + propDefinition: [ + app, + "pickupLocationCode", + ], + }, + pickupLocationAccountNumber: { + type: "string", + label: "Pickup Location Account Number", + description: "An account number that a carrier can issue to customers for managing delivery of their parcel to a collection point", + optional: true, + }, + preferredDeliveryDate: { + type: "string", + label: "Preferred Delivery Date", + description: "The day on which customers want their order delivered (format: `YYYY-MM-DD`)", + optional: true, + }, + }, + async run({ $ }) { + const { + app, + token, + shippingOptionIdentifier, + pickupLocationCode, + pickupLocationAccountNumber, + preferredDeliveryDate, + } = this; + + const response = await app.saveCheckoutSession({ + $, + data: { + token, + shippingOption: { + identifier: shippingOptionIdentifier, + }, + preferredDeliveryDate, + ...(pickupLocationCode + || pickupLocationAccountNumber + ? { + pickupLocation: { + code: pickupLocationCode, + accountNumber: pickupLocationAccountNumber, + }, + } + : {} + ), + }, + }); + + $.export("$summary", "Successfully saved checkout session data"); + return response; + }, +}; diff --git a/components/paazl/actions/save-order/save-order.mjs b/components/paazl/actions/save-order/save-order.mjs new file mode 100644 index 0000000000000..554c28b345c82 --- /dev/null +++ b/components/paazl/actions/save-order/save-order.mjs @@ -0,0 +1,153 @@ +import app from "../../paazl.app.mjs"; +import utils from "../../common/utils.mjs"; + +export default { + key: "paazl-save-order", + name: "Save Order", + description: "Saves an order's most important information to the Paazl database once a customer has paid for their purchase. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Order/saveOrderUsingPOST)", + version: "0.0.1", + type: "action", + props: { + app, + reference: { + propDefinition: [ + app, + "reference", + ], + label: "Order Reference", + description: "Your own order reference for a purchase transaction. Must be unique within the webshop.", + }, + consignee: { + propDefinition: [ + app, + "consignee", + ], + }, + customsValue: { + propDefinition: [ + app, + "customsValue", + ], + }, + insuredValue: { + propDefinition: [ + app, + "insuredValue", + ], + }, + codValue: { + propDefinition: [ + app, + "codValue", + ], + }, + description: { + propDefinition: [ + app, + "orderDescription", + ], + }, + requestedDeliveryDate: { + propDefinition: [ + app, + "requestedDeliveryDate", + ], + }, + products: { + propDefinition: [ + app, + "products", + ], + }, + invoiceNumber: { + propDefinition: [ + app, + "invoiceNumber", + ], + }, + invoiceDate: { + propDefinition: [ + app, + "invoiceDate", + ], + }, + returnProp: { + propDefinition: [ + app, + "returnProp", + ], + }, + sender: { + propDefinition: [ + app, + "sender", + ], + }, + shipping: { + propDefinition: [ + app, + "shipping", + ], + }, + weight: { + propDefinition: [ + app, + "orderWeight", + ], + }, + additionalInstruction: { + propDefinition: [ + app, + "additionalInstruction", + ], + }, + }, + async run({ $ }) { + const { + app, + reference, + consignee, + customsValue, + insuredValue, + codValue, + description, + requestedDeliveryDate, + products, + invoiceNumber, + invoiceDate, + returnProp, + sender, + shipping, + weight, + additionalInstruction, + } = this; + + const response = await app.saveOrder({ + $, + data: { + reference, + consignee: utils.parseJson(consignee), + customsValue: utils.parseJson(customsValue), + insuredValue: utils.parseJson(insuredValue), + codValue: utils.parseJson(codValue), + description, + requestedDeliveryDate, + products: utils.parseArray(products), + invoiceNumber, + invoiceDate, + return: utils.parseJson(returnProp), + sender: utils.parseJson(sender), + shipping: utils.parseJson(shipping), + weight: weight + ? parseFloat(weight) + : undefined, + additionalInstruction, + }, + }); + + $.export("$summary", `Successfully saved order information for reference: ${reference}`); + return response || { + success: true, + }; + }, +}; diff --git a/components/paazl/common/utils.mjs b/components/paazl/common/utils.mjs new file mode 100644 index 0000000000000..4101f481bbacc --- /dev/null +++ b/components/paazl/common/utils.mjs @@ -0,0 +1,68 @@ +const parseJson = (input, maxDepth = 100) => { + const seen = new WeakSet(); + const parse = (value) => { + if (maxDepth <= 0) { + return value; + } + if (typeof(value) === "string") { + // Only parse if the string looks like a JSON object or array + const trimmed = value.trim(); + if ( + (trimmed.startsWith("{") && trimmed.endsWith("}")) || + (trimmed.startsWith("[") && trimmed.endsWith("]")) + ) { + try { + return parseJson(JSON.parse(value), maxDepth - 1); + } catch (e) { + return value; + } + } + return value; + } else if (typeof(value) === "object" && value !== null && !Array.isArray(value)) { + if (seen.has(value)) { + return value; + } + seen.add(value); + return Object.entries(value) + .reduce((acc, [ + key, + val, + ]) => Object.assign(acc, { + [key]: parse(val), + }), {}); + } else if (Array.isArray(value)) { + return value.map((item) => parse(item)); + } + return value; + }; + + return parse(input); +}; + +function parseArray (input, maxDepth = 100) { + if (typeof input === "string") { + const trimmed = input.trim(); + if (trimmed.startsWith("[") && trimmed.endsWith("]")) { + try { + const parsed = JSON.parse(trimmed); + if (Array.isArray(parsed)) { + return parsed.map((item) => parseArray(item, maxDepth - 1)); + } + } catch (e) { + throw new Error(`Invalid JSON array format: ${e.message}`); + } + } + return parseJson(input, maxDepth); + } + + if (Array.isArray(input)) { + return input.map((item) => parseArray(item, maxDepth)); + } + + return input; +} + +export default { + parseJson, + parseArray, +}; diff --git a/components/paazl/paazl.app.mjs b/components/paazl/paazl.app.mjs index bb36a60897dd3..ad733d1393745 100644 --- a/components/paazl/paazl.app.mjs +++ b/components/paazl/paazl.app.mjs @@ -1,11 +1,934 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "paazl", - propDefinitions: {}, + propDefinitions: { + reference: { + type: "string", + label: "Reference", + description: "Your reference for the order", + }, + consigneeCountryCode: { + type: "string", + label: "Consignee Country Code", + description: "The [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) code for the country to which an order is shipped (e.g., `NL`, `DE`)", + }, + consigneePostalCode: { + type: "string", + label: "Consignee Postal Code", + description: "The postal code of the address to which an order is shipped", + optional: true, + }, + consignorCountryCode: { + type: "string", + label: "Consignor Country Code", + description: "The [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) code for the country the shipment is being sent from", + optional: true, + }, + consignorPostalCode: { + type: "string", + label: "Consignor Postal Code", + description: "The postal code of the address from which an order is shipped", + optional: true, + }, + shipmentId: { + type: "string", + label: "Shipment ID", + description: "The shipment identifier", + async options({ orderReference }) { + if (!orderReference) { + return []; + } + const { shipments } = await this.getOrderShipments({ + orderReference, + }); + return shipments.map(({ trackingNumber: value }) => value); + }, + }, + parcelId: { + type: "string", + label: "Parcel ID", + description: "The parcel identifier", + }, + shippingOptionId: { + type: "string", + label: "Shipping Option ID", + description: "The shipping option identifier", + optional: true, + async options({ + token, consigneeCountryCode, + }) { + const response = await this.getShippingOptions({ + data: { + token, + consigneeCountryCode, + }, + }); + return response?.shippingOptions?.map(({ + identifier: value, name: label, + }) => ({ + label, + value, + })) || []; + }, + }, + pickupLocationCode: { + type: "string", + label: "Pickup Location Code", + description: "A carrier's unique code for a pickup location (required if delivering to pickup location)", + optional: true, + async options() { + const { pickupLocations } = await this.getPickupLocationOptions(); + return pickupLocations.map(({ + code: value, name: label, + }) => ({ + label, + value, + })); + }, + }, + locale: { + type: "string", + label: "Locale", + description: "Specifies the language in which the widget is displayed. It is specified using the format `{language}_{country}`, where `{language}` is an [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code and `{country}` is an [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) country code (e.g., `en_US`)", + optional: true, + }, + timeZone: { + type: "string", + label: "Time Zone", + description: "Specifies the time zone for which the delivery days should be calculated (e.g., `Europe/Amsterdam`, `UTC`)", + optional: true, + }, + limit: { + type: "integer", + label: "Limit", + description: "The maximum number of shipping options that Paazl must return (min: `1`, max: `99`)", + optional: true, + min: 1, + max: 99, + }, + numberOfProcessingDays: { + type: "integer", + label: "Number of Processing Days", + description: "The number of days a warehouse needs to get an order ready for pick-up by a carrier (min: `0`, max: `99`)", + optional: true, + min: 0, + max: 99, + }, + includeExternalDeliveryDates: { + type: "boolean", + label: "Include External Delivery Dates", + description: "Gets delivery dates directly from the carrier if the carrier supplies them", + optional: true, + }, + deliveryDateStartDate: { + type: "string", + label: "Delivery Date Start Date", + description: "The starting point of a range of possible delivery dates (format: `YYYY-MM-DD`)", + optional: true, + }, + deliveryDateNumberOfDays: { + type: "integer", + label: "Delivery Date Number of Days", + description: "The length of time in days after start date for which shipping options are supplied", + optional: true, + }, + token: { + type: "string", + label: "Token", + description: "The access token returned by the token endpoint", + optional: true, + }, + tags: { + type: "string[]", + label: "Tags", + description: "Codes that are used to filter returned shipping options for display", + optional: true, + options: [ + "PARCEL_LOCKER", + "SAME_DAY", + "FLEX_DELIVERY", + "CASH_ON_DELIVERY", + "INSURANCE", + "SIGNATURE_REQUIRED", + "AT_NEIGHBOURS", + "NOT_AT_NEIGHBOURS", + "RETURN_ON_FAILURE", + "DATE_PREFERENCE", + "TWENTYFOUR_SEVEN", + "NOTIFY_RECEIVER", + "SUNDAY_SORTING", + "AGE_CHECK", + "ID_CHECK", + "CLIMATE_COMPENSATION", + "DANGEROUS_GOODS", + "RETURN_TO_SENDER", + "NO_PROOF_OF_DELIVERY", + "PERISHABLE", + ], + }, + totalWeight: { + type: "string", + label: "Total Weight", + description: "The total weight in kilograms (kg) of the shipment, including packaging", + optional: true, + }, + totalPrice: { + type: "string", + label: "Total Price", + description: "The total price of a shipment", + optional: true, + }, + totalVolume: { + type: "string", + label: "Total Volume", + description: "The total volume of a shipment, including packaging, in cubic meters", + optional: true, + }, + numberOfGoods: { + type: "integer", + label: "Number of Goods", + description: "The total number of packages or individual goods in a shipment", + optional: true, + }, + startMatrix: { + type: "string", + label: "Start Matrix", + description: "A one- or two-letter code identifying the delivery matrix column to start with", + optional: true, + }, + network: { + type: "string", + label: "Network", + description: "Specifies what type(s) of pickup locations you want Paazl to send you", + optional: true, + options: [ + "CARRIER", + "STORE", + "ALL", + ], + }, + crossBorderStores: { + type: "boolean", + label: "Cross Border Stores", + description: "Shows stores from different countries", + optional: true, + }, + excludeLockers: { + type: "boolean", + label: "Exclude Lockers", + description: "Get all shipping options except those that have parcel locker support", + optional: true, + }, + lockersOnly: { + type: "boolean", + label: "Lockers Only", + description: "Get only shipping options with parcel locker support", + optional: true, + }, + sortOrderBy: { + type: "string", + label: "Sort Order By", + description: "Indicates the field by which to sort the shipping options returned", + optional: true, + options: [ + "PRICE", + "DATE", + "CARRIER", + ], + }, + sortOrder: { + type: "string", + label: "Sort Order", + description: "Indicates the order in which shipping options should be sorted", + optional: true, + options: [ + "ASC", + "DESC", + ], + }, + sortDistributor: { + type: "string", + label: "Sort Distributor", + description: "Indicates which carrier's shipping options should appear at the top (required if orderBy is CARRIER)", + optional: true, + options: [ + "SELEKTVRACHT", + "TNT", + "TNT_EXPRESS", + "DPD", + "FEDEX", + "DYNALOGIC", + "KIALA", + "DHL_EXPRESS", + "DHL_DE", + "UPS", + "BPOST", + "GLS", + "TSN", + "MONDIALRELAY", + "B2C_EUROPE", + "B2C_EUROPE_LAB", + "DE_BUREN", + "CARGOOFFICE", + "VAN_SPREUWEL", + "PACKS", + "COLISSIMO", + "BRT", + "CORREOS", + "TRANSMISSION", + "HERMES", + "FADELLO", + "AUS_POST", + "SAGAWA", + "ASENDIA", + "MENDRIX", + "FEDEX_ZA", + "RJP", + "YUNDA_EXPRESS", + "HERMES_UK", + "POSTNORD", + "BLANK", + "GENERIC", + ], + }, + pickupLocationAccountNumber: { + type: "string", + label: "Pickup Location Account Number", + description: "An account number that a carrier can issue to customers", + optional: true, + }, + orderDescription: { + type: "string", + label: "Description", + description: "A general description of the contents of a shipment", + optional: true, + }, + orderWeight: { + type: "string", + label: "Weight", + description: "The total weight in kilograms (kg) of an order, including packaging", + optional: true, + }, + requestedDeliveryDate: { + type: "string", + label: "Requested Delivery Date", + description: "The date on which a customer has requested that an order be delivered (format: `YYYY-MM-DD`)", + optional: true, + }, + additionalInstruction: { + type: "string", + label: "Additional Instructions", + description: "Additional instructions for the delivery of an order", + optional: true, + }, + invoiceNumber: { + type: "string", + label: "Invoice Number", + description: "The invoice number of an order (sometimes required for international shipments)", + optional: true, + }, + invoiceDate: { + type: "string", + label: "Invoice Date", + description: "The invoice date of an order (format: `YYYY-MM-DD`)", + optional: true, + }, + labelType: { + type: "string", + label: "Label Type", + description: "Format of the generated label(s)", + optional: true, + options: [ + "PNG", + "PDF", + "ZPL", + ], + }, + labelSize: { + type: "string", + label: "Label Size", + description: "Size of the generated label(s)", + optional: true, + options: [ + "10x15", + "10x21", + "a4", + "laser", + ], + }, + quantity: { + type: "integer", + label: "Quantity", + description: "Optional. If Quantity is `1` then one extra label is generated. If Quantity is greater than `1`, extra labels are generated. Mutually exclusive with parcels.", + optional: true, + min: 1, + }, + enableParcels: { + type: "boolean", + label: "Enable Custom Parcels", + description: "Enable to specify custom parcel details (mutually exclusive with quantity)", + optional: true, + }, + parcelWeight: { + type: "string", + label: "Parcel Weight", + description: "The gross weight of the parcel in kilograms (required if enabling parcels)", + optional: true, + }, + parcelLength: { + type: "integer", + label: "Parcel Length", + description: "The length of the parcel in centimeters", + optional: true, + }, + parcelWidth: { + type: "integer", + label: "Parcel Width", + description: "The width of the parcel in centimeters", + optional: true, + }, + parcelHeight: { + type: "integer", + label: "Parcel Height", + description: "The height of the parcel in centimeters", + optional: true, + }, + parcelVolume: { + type: "string", + label: "Parcel Volume", + description: "The volume of the parcel, including packaging, in cubic meters", + optional: true, + }, + parcelReference: { + type: "string", + label: "Parcel Reference", + description: "A reference for the parcel", + optional: true, + }, + parcelDescription: { + type: "string", + label: "Parcel Description", + description: "A general description of the contents of the parcel", + optional: true, + }, + parcelCodValue: { + type: "string", + label: "Parcel COD Value", + description: "The amount that has to be paid by receiver before receiving the goods", + optional: true, + }, + parcelCodCurrency: { + type: "string", + label: "Parcel COD Currency", + description: "The ISO 4217 code for the currency (default: `EUR`)", + optional: true, + default: "EUR", + }, + parcelInsuredValue: { + type: "string", + label: "Parcel Insured Value", + description: "The amount for which this is insured by the carrier", + optional: true, + }, + parcelInsuredCurrency: { + type: "string", + label: "Parcel Insured Currency", + description: "The ISO 4217 code for the currency (default: `EUR`)", + optional: true, + default: "EUR", + }, + consignee: { + type: "object", + label: "Consignee", + description: `Contains details of the party to which an order is shipped. + +**Fields:** +- \`companyName\` (string): The name of a company to which an order is shipped. + _Example:_ \`"Bonn Mac Tosch"\` +- \`vatNumber\` (string): The VAT number of the receiver. + _Example:_ \`"vat-123456789"\` +- \`email\` (string): The email address of the person to whom an order is shipped. + _Example:_ \`"freddie.kwiksilver@konningin.org"\` +- \`name\` (string): The name of the person to whom an order is shipped. + _Example:_ \`"Friederich Feuerstein"\` +- \`other\` (string): Additional details used to identify the person to whom an order is shipped. + _Example:_ \`"Logistik Manager"\` +- \`phone\` (string): The phone number of the person to whom an order is shipped. + _Example:_ \`"+31-20-7736303"\` +- \`locale\` (string): Specifies the language of the email templates used for track & trace notifications. + Format: \`{language}_{country}\` (e.g., \`fr_FR\`) +- \`address\` (object): Contains details of the address to which an order is shipped. + **Address Fields:** + - \`city\` (string): The city or town. _Example:_ \`"Bonn"\` + - \`country\` (string): ISO 3166-2 code. _Example:_ \`"DE"\` + - \`postalCode\` (string): Postal code. _Example:_ \`"53111"\` + - \`province\` (string): Province/state code. _Example:_ \`"NW"\` + - \`street\` (string): Street name. _Example:_ \`"Am Hauptbahnhof"\` + - \`streetLines\` (array): Additional street lines. + - \`houseNumber\` (integer): House number. _Example:_ \`9\` + - \`houseNumberExtension\` (string): House number extension. _Example:_ \`"-A"\` + +**Example:** +\`\`\`json +{ + "companyName": "Bonn Mac Tosch", + "vatNumber": "vat-123456789", + "email": "freddie.kwiksilver@konningin.org", + "name": "Friederich Feuerstein", + "other": "Logistik Manager", + "phone": "+31-20-7736303", + "locale": "fr_FR", + "address": { + "city": "Bonn", + "country": "DE", + "postalCode": "53111", + "province": "NW", + "street": "Am Hauptbahnhof", + "streetLines": ["Am Hauptbahnhof 9"], + "houseNumber": 9, + "houseNumberExtension": "-A" + } +} +\`\`\` +`, + }, + customsValue: { + type: "object", + label: "Customs Value", + description: `The total monetary value for customs purposes. + +**Fields:** +- \`value\` (number): The monetary value of an order for customs purposes. + _Example:_ \`40.2\` +- \`currency\` (string): The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the currency. + The default code is \`"EUR"\`. + _Example:_ \`"USD"\` +- \`description\` (string): The description of the customs value. + _Example:_ \`"Customs value description"\` + +**Example:** +\`\`\`json +{ + "value": 40.2, + "currency": "USD", + "description": "Customs value description" +} +\`\`\` +`, + optional: true, + }, + insuredValue: { + type: "object", + label: "Insured Value", + description: `The amount for which this order is insured by the carrier against loss, damage, or accident during transport. + +**Fields:** +- \`value\` (number): The amount of insurance coverage requested from the carrier. + _Example:_ \`500.0\` +- \`currency\` (string): The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the currency. + The default code is \`"EUR"\`. + _Example:_ \`"USD"\` +- \`description\` (string): The description of the insured value. + _Example:_ \`"Insured value description"\` + +**Example:** +\`\`\`json +{ + "value": 500.0, + "currency": "USD", + "description": "Insured value description" +} +\`\`\` +`, + optional: true, + }, + codValue: { + type: "object", + label: "COD Value", + description: `The amount that a consignee has to pay before receiving the "Cash On Delivery" consignment. + +**Fields:** +- \`value\` (number): The amount that has to be paid by receiver before receiving the goods. + _Example:_ \`40.2\` +- \`currency\` (string): The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the currency. + The default code is \`"EUR"\`. + _Example:_ \`"USD"\` +- \`description\` (string): The description of the COD value. + _Example:_ \`"COD value description"\` + +**Example:** +\`\`\`json +{ + "value": 40.2, + "currency": "USD", + "description": "COD value description" +} +\`\`\` +`, + optional: true, + }, + products: { + type: "string[]", + label: "Products", + description: `Contains objects representing the products making up an order. + +**Fields:** +- \`height\` (integer): The height of a product, in centimeters (cm). + _Example:_ \`10\` +- \`length\` (integer): The length of a product, in centimeters (cm). + _Example:_ \`30\` +- \`unitPrice\` (object): The value of a product. + - \`value\` (number): The monetary value of a product. _Example:_ \`40.2\` + - \`currency\` (string): The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the currency. Default: \`"EUR"\`. _Example:_ \`"USD"\` + - \`description\` (string): The description of the product. _Example:_ \`"Zhitomir socks"\` +- \`quantity\` (integer, required): The number of items of a product in a shipment. + _Example:_ \`7\` +- \`volume\` (number): The volume of a product, including packaging, in cubic meters (m³). + _Example:_ \`0.015625\` +- \`weight\` (number): The weight of a product, in kilograms (kg). + _Example:_ \`100\` +- \`width\` (integer): The width of a product, in centimeters (cm). + _Example:_ \`20\` +- \`countryOfManufacture\` (string): The [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) code for the country in which a product was manufactured. + _Example:_ \`"DE"\` +- \`description\` (string): A description of the contents of a specific product. + _Example:_ \`"Zhitomir socks"\` +- \`hsTariffCode\` (string): The import Harmonized System code of a product. + _Example:_ \`"62034231"\` +- \`skuCode\` (string): The SKU code of a product. + _Example:_ \`"8754-124-990"\` or \`"KS944RUR"\` + +**Example:** +\`\`\`json +[ + { + "height": 10, + "length": 30, + "unitPrice": { + "value": 40.2, + "currency": "USD", + "description": "Zhitomir socks" + }, + "quantity": 7, + "volume": 0.015625, + "weight": 100, + "width": 20, + "countryOfManufacture": "DE", + "description": "Zhitomir socks", + "hsTariffCode": "62034231", + "skuCode": "8754-124-990" + } +] +\`\`\` +`, + optional: true, + }, + returnProp: { + type: "object", + label: "Return Address", + description: `Contains the details of an address to which an order is returned. + +**Fields:** +- \`description\` *(string)*: The description of the return address. + Example: \`"Return address description"\` +- \`name\` *(string)*: The name of the party to which an order is returned. + Example: \`"A'dam Mac Tosch"\` +- \`address\` *(object)*: Contains details of the address to which an order is returned. + - \`city\` *(string, required if address is provided)*: The city or town. + Example: \`"Bonn"\` + - \`country\` *(string)*: ISO 3166-2 code for the country. + Example: \`"DE"\` + - \`postalCode\` *(string)*: Postal code. + Example: \`"53111"\` + - \`province\` *(string)*: Last 2 letters of the ISO 3166-2 code for the province/state. + Example: \`"NW"\` + - \`street\` *(string)*: Name of the street. + Example: \`"Jacob Bontousplaats"\` + - \`streetLines\` *(array of strings)*: Street name and house number, one or more strings. + Example: \`["Jacob Bontiusplaats 9", "Unit 580"]\` + - \`houseNumber\` *(integer)*: House number. + Example: \`9\` + - \`houseNumberExtension\` *(string)*: House number extension (e.g., "-A"). + Example: \`"-A"\` + +**Example:** +\`\`\`json +{ + "description": "Return address description", + "name": "A'dam Mac Tosch", + "address": { + "city": "Bonn", + "country": "DE", + "postalCode": "53111", + "province": "NW", + "street": "Jacob Bontiusplaats", + "streetLines": ["Jacob Bontiusplaats 9", "Unit 580"], + "houseNumber": 9, + "houseNumberExtension": "-A" + } +} +\`\`\` +`, + optional: true, + }, + sender: { + type: "object", + label: "Sender", + description: `Contains the details of the address from which an order is shipped. + +**Fields:** +- \`description\` *(string)*: The description of the sender address. + Example: \`"Sender address description"\` +- \`name\` *(string)*: The name of the party that shipped an order. + Example: \`"A'dam Mac Tosch"\` +- \`address\` *(object, required if provided)*: Contains details of the address from which an order is shipped. + - \`city\` *(string, required if address is provided)*: The city or town from which an order is shipped. + Example: \`"Bonn"\` + - \`country\` *(string)*: ISO 3166-2 code for the country. + Example: \`"DE"\` + - \`postalCode\` *(string)*: Postal code. + Example: \`"53111"\` + - \`province\` *(string)*: Last 2 letters of the ISO 3166-2 code for the province/state. + Example: \`"NW"\` + - \`street\` *(string)*: Name of the street. + Example: \`"John Plagis Avenue"\` + - \`streetLines\` *(array of strings)*: Street name and house number, one or more strings. + Example: \`["6 John Plagis Avenue", "Around the corner"]\` + - \`houseNumber\` *(integer)*: House number. + Example: \`6\` + - \`houseNumberExtension\` *(string)*: House number extension (e.g., "-A"). + Example: \`"-A"\` + +**Note:** +If not provided, the default value is the address specified in your web app account under **Settings > Account > My address book > Sender address**. + +**Example:** +\`\`\`json +{ + "description": "Sender address description", + "name": "A'dam Mac Tosch", + "address": { + "city": "Bonn", + "country": "DE", + "postalCode": "53111", + "province": "NW", + "street": "John Plagis Avenue", + "streetLines": ["6 John Plagis Avenue", "Around the corner"], + "houseNumber": 6, + "houseNumberExtension": "-A" + } +} +\`\`\` +`, + optional: true, + }, + shipping: { + type: "object", + label: "Shipping", + description: `Contains information on the shipping option selected by a customer. + +**Fields:** +- \`option\` *(string, required)*: A shipping option's Paazl identifier. + Example: \`"AVG"\` + +- \`pickupLocation\` *(object, optional)*: If your customer selected a pickup location at checkout, this object contains information on that location. + - \`description\` *(string, optional)*: The description of the pickup location. + Example: \`"Pickup location description"\` + - \`accountNumber\` *(string, optional)*: An account number that a carrier can issue to customers for managing delivery of their parcel to a collection point. + - \`code\` *(string, required if pickupLocation is provided)*: A carrier's unique code for a pickup location. + Example: \`"NOP12345"\` + +- \`contract\` *(string, optional)*: The identification code of your carrier contract for an outbound shipment. + Example: \`"XYZ123"\` + +- \`returnContract\` *(string, optional)*: The identification code of your carrier contract for a return shipment. + Example: \`"321ZYX"\` + +- \`packageCount\` *(integer, optional)*: The number of packages in a shipment. + Example: \`3\` + +- \`multiPackageShipment\` *(boolean, optional)*: If true, Paazl will treat the shipment as consolidated. + Example: \`false\` + +**Example:** +\`\`\`json +{ + "option": "AVG", + "pickupLocation": { + "description": "Pickup location description", + "accountNumber": "123456789", + "code": "NOP12345" + }, + "contract": "XYZ123", + "returnContract": "321ZYX", + "packageCount": 3, + "multiPackageShipment": false +} +\`\`\` +`, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + const { environment: baseUrl } = this.$auth; + return `${baseUrl}/v1${path}`; + }, + getHeaders(isPublic = false) { + const { + api_key: apiKey, + api_secret: apiSecret, + } = this.$auth; + + const authToken = isPublic + ? `Bearer ${apiKey}` + : `Bearer ${apiKey}:${apiSecret}`; + + return { + "Authorization": authToken, + "Content-Type": "application/json", + "Accept": "application/json", + }; + }, + makeRequest({ + $ = this, path, headers = {}, isPublic = false, ...args + }) { + return axios($, { + url: this.getUrl(path), + headers: { + ...this.getHeaders(isPublic), + ...headers, + }, + ...args, + }); + }, + post(args = {}) { + return this.makeRequest({ + method: "post", + ...args, + }); + }, + put(args = {}) { + return this.makeRequest({ + method: "put", + ...args, + }); + }, + delete(args = {}) { + return this.makeRequest({ + method: "delete", + ...args, + }); + }, + createCheckoutToken(args = {}) { + return this.post({ + path: "/checkout/token", + ...args, + }); + }, + saveCheckoutSession(args = {}) { + return this.post({ + isPublic: true, + path: "/checkout", + ...args, + }); + }, + getCheckoutSession(args = {}) { + return this.makeRequest({ + path: "/checkout", + ...args, + }); + }, + saveOrder(args = {}) { + return this.post({ + path: "/order", + ...args, + }); + }, + modifyOrder(args = {}) { + return this.put({ + path: "/order", + ...args, + }); + }, + deleteOrder({ + reference, ...args + } = {}) { + return this.delete({ + path: `/order/${reference}`, + ...args, + }); + }, + getPickupLocationOptions(args = {}) { + return this.post({ + path: "/pickuplocations", + isPublic: true, + ...args, + }); + }, + getShippingOptions(args = {}) { + return this.post({ + path: "/shippingoptions", + isPublic: true, + ...args, + }); + }, + createShipment({ + orderReference, ...args + } = {}) { + return this.post({ + path: `/orders/${orderReference}/shipments`, + ...args, + }); + }, + getOrderShipments({ + orderReference, ...args + } = {}) { + return this.makeRequest({ + path: `/orders/${orderReference}/shipments`, + ...args, + }); + }, + getShipmentById({ + orderReference, shipmentId, ...args + } = {}) { + return this.makeRequest({ + path: `/orders/${orderReference}/shipments/${shipmentId}`, + ...args, + }); + }, + getOrderLabels({ + orderReference, ...args + } = {}) { + return this.makeRequest({ + path: `/orders/${orderReference}/labels`, + ...args, + }); + }, + getShipmentLabels({ + orderReference, shipmentId, ...args + } = {}) { + return this.makeRequest({ + path: `/orders/${orderReference}/shipments/${shipmentId}/labels`, + ...args, + }); + }, + getParcelLabel({ + orderReference, shipmentId, parcelId, ...args + } = {}) { + return this.makeRequest({ + path: `/orders/${orderReference}/shipments/${shipmentId}/parcels/${parcelId}/labels`, + ...args, + }); + }, + getReturnShipments({ + orderReference, ...args + } = {}) { + return this.makeRequest({ + path: `/orders/${orderReference}/returnShipments`, + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/paazl/package.json b/components/paazl/package.json index b65f780294e92..25fd793bc670a 100644 --- a/components/paazl/package.json +++ b/components/paazl/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/paazl", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Paazl Components", "main": "paazl.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index afd66a8a07874..5af2957913771 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10196,7 +10196,11 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/paazl: {} + components/paazl: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/paddle: {} @@ -38898,8 +38902,6 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) - transitivePeerDependencies: - - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: