Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -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;
},
};
196 changes: 196 additions & 0 deletions components/paazl/actions/create-shipment/create-shipment.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
33 changes: 33 additions & 0 deletions components/paazl/actions/delete-order/delete-order.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
Original file line number Diff line number Diff line change
@@ -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;
},
};
52 changes: 52 additions & 0 deletions components/paazl/actions/get-order-labels/get-order-labels.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
Original file line number Diff line number Diff line change
@@ -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;
},
};
Loading
Loading