Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 193 additions & 0 deletions components/paazl/actions/create-order/create-order.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
import { ConfigurationError } from "@pipedream/platform";
import { COUNTRY_OPTIONS } from "../../common/constants.mjs";
import { parseObject } from "../../common/utils.mjs";
import paazl from "../../paazl.app.mjs";

export default {
key: "paazl-create-order",
name: "Create Order",
description: "Create a new order in Paazl. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Order/saveOrderUsingPOST)",
version: "0.0.1",
type: "action",
props: {
paazl,
additionalInstruction: {
type: "string",
label: "Additional Instruction",
description: "Additional instructions for the delivery of an order. E.g. `Call before delivery`.",
optional: true,
},
consigneeCompanyName: {
type: "string",
label: "Consignee - Company Name",
description: "The name of a company to which an order is shipped.",
optional: true,
},
consigneeVatNumber: {
type: "string",
label: "Consignee - VAT Number",
description: "The VAT number of the receiver. This is the tax identification number of the receiver, that can be used by B2B international shipments for customs, for some carriers.",
optional: true,
},
consigneeEmail: {
type: "string",
label: "Consignee - Email",
description: "The email address of the person to whom an order is shipped.",
optional: true,
},
consigneeName: {
type: "string",
label: "Consignee - Name",
description: "The name of the person to whom an order is shipped.",
optional: true,
},
consigneeOther: {
type: "object",
label: "Consignee - Other",
description: "Additional details used to identify the person to whom an order is shipped.",
optional: true,
},
consigneePhone: {
type: "string",
label: "Consignee - Phone",
description: "The phone number of the person to whom an order is shipped.",
optional: true,
},
consigneeLocale: {
type: "string",
label: "Consignee - Locale",
description: "Specifies the language of the email templates used for track & trace notifications. `locale` 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. Example: `fr_FR`",
optional: true,
},
consigneeAddressCity: {
type: "string",
label: "Consignee - Address - City",
description: "The city or town to which an order is shipped.",
},
consigneeAddressCountry: {
type: "string",
label: "Consignee - Address - Country",
description: "The [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) code for the country to which an order is shipped.",
options: COUNTRY_OPTIONS,
optional: true,
},
consigneeAddressPostalCode: {
type: "string",
label: "Consignee - Address - Postal Code",
description: "The postal code of the address to which an order is shipped. The code is used to get a more precise list of available shipping options.",
optional: true,
},
consigneeAddressProvince: {
type: "string",
label: "Consignee - Address - Province",
description: "The last 2 letters of the [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) code for the province or state to which an order is shipped.",
optional: true,
},
consigneeAddressStreet: {
type: "string",
label: "Consignee - Address - Street",
description: "The name of the street to which an order is shipped. See the note in the \"order\" endpoint description. Note If you provide \"street\" with a value, \"houseNumber\" is required.",
optional: true,
},
consigneeAddressStreetLines: {
type: "string[]",
label: "Consignee - Address - Street Lines",
description: "The street name and house number of the address to which an order is shipped, specified as one or more strings. See the note in the \"order\" endpoint description. Note! Paazl does not parse the string to perform validation with any values that may be provided for the other parameters of a consignee address.",
optional: true,
},
consigneeAddressHouseNumber: {
type: "string",
label: "Consignee - Address - House Number",
description: "The house number of the address to which an order is shipped. See the note in the order endpoint description.",
optional: true,
},
consigneeAddressHouseNumberExtension: {
type: "string",
label: "Consignee - Address - House Number Extension",
description: "The house number extension (such as the \"-A\" in \"12-A\") of the address to which an order is shipped.",
optional: true,
},
reference: {
type: "string",
label: "Reference",
description: "Your own order reference for a purchase transaction. For security reasons, the following special characters are not allowed: \\ and /. Note! The order reference must be unique within the webshop.",
},
shippingOption: {
type: "string",
label: "Shipping - Option",
description: "A shipping option's Paazl identifier. You will find a list of the identifiers of the shipping options available to your webshop in your webshop account under **Settings>Account>Overview of shipping options**. **Note!** If you have used [custom shipping option identifiers](https://support.paazl.com/hc/en-us/articles/360021787374-Customizing-shipping-option-identifiers%22), these will be returned instead of their Paazl equivalents.",
},
shippingPickupLocationCode: {
type: "string",
label: "Shipping - Pickup Location Code",
description: "A carrier's unique code for a pickup location.",
},
shippingContract: {
type: "string",
label: "Shipping - Contract",
description: "The identification code of your carrier contract for an outbound shipment. **Note!** If you don't have this code, contact [Paazl Customer Support]([email protected]).",
optional: true,
},
shippingReturnContract: {
type: "string",
label: "Shipping - Return Contract",
description: "The identification code of your carrier contract for a return shipment. **Note!** If you don't have this code, contact [Paazl Customer Support]([email protected]).",
optional: true,
},
shippingPackageCount: {
type: "integer",
label: "Shipping - Package Count",
description: "The number of packages in a shipment. **Note!** If `multiPackageShipment` is set to `true`, the default value of `packageCount` will be `2`.",
optional: true,
},
shippingMultiPackageShipment: {
type: "boolean",
label: "Shipping - Multi Package Shipment",
description: "If `true`, Paazl will treat the shipment as consolidated. This setting affects how the packages in the shipment are numbered on its labels. The number of packages in a shipment is indicated by `packageCount`. So, for example, if `multiPackageShipment` is `true` and `packageCount` is `3`, then the labels will be numbered 1/3, 2/3, 3/3. **Note!** If `packageCount` > `1`, then the default value of `multiPackageShipment` will be `true`. If you don't want Paazl to treat a multi-package shipment as consolidated, you have to set `multiPackageShipment` to `false`.",
optional: true,
},
},
async run({ $ }) {
if (!this.consigneeAddressStreet && !this.consigneeAddressStreetLines) {
throw new ConfigurationError("**Consignee Address Street** or **Consignee Address Street Lines** is required.");
}

const response = await this.paazl.createOrder({
$,
data: {
additionalInstruction: this.additionalInstruction,
consignee: {
companyName: parseObject(this.consigneeCompanyName),
vatNumber: this.consigneeVatNumber,
email: this.consigneeEmail,
name: this.consigneeName,
other: parseObject(this.consigneeOther),
phone: this.consigneePhone,
locale: this.consigneeLocale,
address: {
city: this.consigneeAddressCity,
country: this.consigneeAddressCountry,
postalCode: this.consigneeAddressPostalCode,
province: this.consigneeAddressProvince,
street: this.consigneeAddressStreet,
streetLines: parseObject(this.consigneeAddressStreetLines),
houseNumber: this.consigneeAddressHouseNumber,
houseNumberExtension: this.consigneeAddressHouseNumberExtension,
},
},
reference: this.reference,
shipping: {
option: this.shippingOption,
pickupLocation: {
code: this.shippingPickupLocationCode,
},
contract: this.shippingContract,
returnContract: this.shippingReturnContract,
packageCount: this.shippingPackageCount,
multiPackageShipment: this.shippingMultiPackageShipment,
},
},
});
return response;
},
};
73 changes: 73 additions & 0 deletions components/paazl/actions/create-shipment/create-shipment.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { ConfigurationError } from "@pipedream/platform";
import { parseObject } from "../../common/utils.mjs";
import paazl from "../../paazl.app.mjs";

export default {
key: "paazl-create-shipment",
name: "Create Shipment",
description: "Create a new shipment in Paazl. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/createShipmentUsingPOST)",
version: "0.0.1",
type: "action",
props: {
paazl,
orderId: {
propDefinition: [
paazl,
"orderId",
],
},
type: {
type: "string",
label: "Type",
description: "Format of the generated label(s).",
options: [
"PNG",
"PDF",
"ZPL",
],
optional: true,
},
size: {
type: "string",
label: "Size",
description: "Size of the generated label(s).",
options: [
"10x15",
"10x21",
"a4",
"laser",
],
optional: true,
},
quantity: {
type: "integer",
label: "Quantity",
description: "If quantity == 1 -> one extra label is generated. The default quantity value == 1. If quantity > 1 , extra labels are generated. It replaces packageCount in the POST order, if set. Extra labels are generated under 1 new shipment for each label. Mutually exclusive with `parcels`.",
optional: true,
},
parcels: {
type: "string[]",
label: "Parcels",
description: "Array of one or more parcels in the requested shipment. Mutually exclusive with `quantity`. E.g. **[{ \"name\": \"parcels\", \"attribute\": false, \"wrapped\": true }]**. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/createShipmentUsingPOST) for more information.",
optional: true,
},
},
async run({ $ }) {
if (this.quantity && this.parcels) {
throw new ConfigurationError("The 'quantity' and 'parcels' parameters are mutually exclusive. Please provide only one.");
}
const response = await this.paazl.createShipment({
$,
orderId: this.orderId,
data: {
type: this.type,
size: this.size,
quantity: this.quantity,
parcels: parseObject(this.parcels),
},
});

$.export("$summary", "Created shipment successfully");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { COUNTRY_OPTIONS } from "../../common/constants.mjs";
import paazl from "../../paazl.app.mjs";

export default {
key: "paazl-get-pickup-locations",
name: "Get Pickup Locations",
description: "Retrieve available pickup locations from Paazl. [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: {
paazl,
consigneeCountryCode: {
type: "string",
label: "Consignee Country Code",
description: "The ISO 3166-2 code for the country to which an order is shipped.",
options: COUNTRY_OPTIONS,
},
consigneePostalCode: {
type: "string",
label: "Consignee Postal Code",
description: "The postal code of the address to which an order is shipped. The code is used to get a more precise list of available shipping options.",
},
consignorCountryCode: {
type: "string",
label: "Consignor Country Code",
description: "The ISO 3166-2 code for the country the shipment is being sent from. If left empty, Paazl will use the default setting in your Paazl web app account.",
optional: true,
options: COUNTRY_OPTIONS,
},
consignorPostalCode: {
type: "string",
label: "Consignor Postal Code",
description: "The postal code of the address from which an order is shipped. The code is used to get delivery dates from carriers if they offer this service. The default value is the value in your Paazl web app account.",
optional: true,
},
deliveryDateNumberOfDays: {
type: "integer",
label: "Delivery Date - Number of Days",
description: "The length of time in days after startDate for which shipping options are supplied. The default value is `7`.",
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\" The default value is today's date. Note! When calculating the start date for a delivery date range, Paazl adds the number of delivery days and processing days you have configured in your webshop's [delivery matrix](https://support.paazl.com/hc/en-us/articles/360007580074-Configuring-your-delivery-matrix-).",
optional: true,
},
includeExternalDeliveryDates: {
type: "boolean",
label: "Include External Delivery Dates",
description: "Gets delivery dates directly from the carrier if the carrier supplies them.",
default: false,
},
limit: {
type: "integer",
label: "Limit",
description: "The maximum number of shipping options that Paazl must return.",
min: 1,
max: 99,
optional: true,
},
locale: {
type: "string",
label: "Locale",
description: "Specifies the language in which the widget is displayed as well as the localized shipping option names you have configured in your web app account (under **Settings>Paazl Perfect>Shipping options**). locale 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. Example: `fr_FR`",
optional: true,
},
timeZone: {
type: "string",
label: "Time Zone",
description: "Specifies the time zone for which the delivery days should be calculated. If not specified, the default time zone Europe/Amsterdam is used. Example: timeZone:\"Europe/Amsterdam\", timeZone:\"UTC\", timeZone:\"GMT+3\", timeZone:\"UTC+01:30\"",
optional: true,
},
},
async run({ $ }) {
const response = await this.paazl.getPickupLocations({
$,
data: {
consigneeCountryCode: this.consigneeCountryCode,
consigneePostalCode: this.consigneePostalCode,
consignorCountryCode: this.consignorCountryCode,
consignorPostalCode: this.consignorPostalCode,
deliveryDateNumberOfDays: this.deliveryDateNumberOfDays,
deliveryDateStartDate: this.deliveryDateStartDate,
includeExternalDeliveryDates: this.includeExternalDeliveryDates,
limit: this.limit,
locale: this.locale,
timeZone: this.timeZone,
},
});
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import paazl from "../../paazl.app.mjs";

export default {
key: "paazl-get-shipment-details",
name: "Get Shipment Details",
description: "Retrieve detailed information about a specific shipment from Paazl. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getShipmentByShipmentIdUsingGET)",
version: "0.0.1",
type: "action",
props: {
paazl,
orderId: {
propDefinition: [
paazl,
"orderId",
],
},
shipmentId: {
propDefinition: [
paazl,
"shipmentId",
({ orderId }) => ({
orderId,
}),
],
},
},
async run({ $ }) {
const response = await this.paazl.getOrderShipmentDetails({
$,
orderId: this.orderId,
shipmentId: this.shipmentId,
});

$.export("$summary", `Successfully retrieved shipment details for ${this.orderId}`);
return response;
},
};
Loading
Loading