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
148 changes: 148 additions & 0 deletions components/orderspace/actions/create-customer/create-customer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import orderspace from "../../orderspace.app.mjs";

export default {
key: "orderspace-create-customer",
name: "Create Customer",
description: "Create a new customer. [See the documentation](https://apidocs.orderspace.com/#create-a-customer)",
type: "action",
version: "0.0.1",
props: {
orderspace,
companyName: {
type: "string",
label: "Company Name",
description: "The name of the customer's company",
},
contactName: {
type: "string",
label: "Contact Name",
description: "The contact name for the customer",
},
email: {
type: "string",
label: "Email",
description: "The email address of the customer",
},
addressLine1: {
type: "string",
label: "Address Line 1",
description: "The first line of the customer's address",
},
addressLine2: {
type: "string",
label: "Address Line 2",
description: "The second line of the customer's address",
optional: true,
},
city: {
type: "string",
label: "City",
description: "The city of the customer's address",
},
state: {
type: "string",
label: "State",
description: "The state of the customer's address",
},
postalCode: {
type: "string",
label: "Postal Code",
description: "The postal code of the customer's address",
},
country: {
type: "string",
label: "Country",
description: "The 2 letter country code of the customer's address",
},
phone: {
type: "string",
label: "Phone",
description: "The phone number of the customer",
optional: true,
},
reference: {
type: "string",
label: "Reference",
description: "Your reference for the customer",
optional: true,
},
internalNote: {
type: "string",
label: "Internal Note",
description: "An internal note for the customer",
optional: true,
},
taxNumber: {
type: "string",
label: "Sales Tax Number",
description: "The sales tax number of the customer",
optional: true,
},
minimumSpend: {
type: "string",
label: "Minimum Spend",
description: "The minimum spend per order for the customer",
optional: true,
},
paymentTermId: {
propDefinition: [
orderspace,
"paymentTermId",
],
},
customerGroupId: {
propDefinition: [
orderspace,
"customerGroupId",
],
},
priceListId: {
propDefinition: [
orderspace,
"priceListId",
],
},
},
async run({ $ }) {
const { customer } = await this.orderspace.createCustomer({
data: {
customer: {
company_name: this.companyName,
reference: this.reference,
internal_note: this.internalNote,
buyers: [
{
name: this.contactName,
email_address: this.email,
},
],
phone: this.phone,
email_addresses: {
orders: this.email,
dispatches: this.email,
invoices: this.email,
},
tax_number: this.taxNumber,
addresses: [
{
company_name: this.companyName,
contact_name: this.contactName,
line1: this.addressLine1,
line2: this.addressLine2,
city: this.city,
state: this.state,
postal_code: this.postalCode,
country: this.country,
},
],
minimum_spend: this.minimumSpend,
payment_terms_id: this.paymentTermId,
customer_group_id: this.customerGroupId,
price_list_id: this.priceListId,
},
},
});
$.export("$summary", `Successfully created customer with ID: ${customer.id}`);
return customer;
},
};
44 changes: 44 additions & 0 deletions components/orderspace/actions/create-dispatch/create-dispatch.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import orderspace from "../../orderspace.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "orderspace-create-dispatch",
name: "Create Dispatch",
description: "Create a new dispatch. [See the documentation](https://apidocs.orderspace.com/#create-a-dispatch)",
type: "action",
version: "0.0.1",
props: {
orderspace,
orderId: {
propDefinition: [
orderspace,
"orderId",
],
},
comments: {
type: "string",
label: "Comments",
description: "The comments to add to the dispatch",
optional: true,
},
dispatchLines: {
type: "string[]",
label: "Dispatch Lines",
description: "The lines of the dispatch. Each line should contain values for `sku` and `quantity`. [See the documentation](https://apidocs.orderspace.com/#create-a-dispatch) for information.",
},
},
async run({ $ }) {
const { dispatch } = await this.orderspace.createDispatch({
$,
data: {
dispatch: {
order_id: this.orderId,
comments: this.comments,
dispatch_lines: parseObject(this.dispatchLines),
},
},
});
$.export("$summary", `Successfully created dispatch ${dispatch.id}`);
return dispatch;
},
};
150 changes: 150 additions & 0 deletions components/orderspace/actions/create-order/create-order.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import orderspace from "../../orderspace.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "orderspace-create-order",
name: "Create Order",
description: "Create a new order. [See the documentation](https://apidocs.orderspace.com/#create-an-order)",
type: "action",
version: "0.0.1",
props: {
orderspace,
customerId: {
propDefinition: [
orderspace,
"customerId",
],
},
shippingAddressLine1: {
type: "string",
label: "Address Line 1",
description: "The first line of the shipping address",
},
shippingAddressLine2: {
type: "string",
label: "Address Line 2",
description: "The second line of the shipping address",
optional: true,
},
shippingCity: {
type: "string",
label: "City",
description: "The city of the shipping address",
},
shippingState: {
type: "string",
label: "State",
description: "The state of the shipping address",
},
shippingPostalCode: {
type: "string",
label: "Postal Code",
description: "The postal code of the shipping address",
},
shippingCountry: {
type: "string",
label: "Country",
description: "The 2 letter country code of the shipping address",
},
billingAddressLine1: {
type: "string",
label: "Address Line 1",
description: "The first line of the billing address",
},
billingAddressLine2: {
type: "string",
label: "Address Line 2",
description: "The second line of the billing address",
optional: true,
},
billingCity: {
type: "string",
label: "City",
description: "The city of the billing address",
},
billingState: {
type: "string",
label: "State",
description: "The state of the billing address",
},
billingPostalCode: {
type: "string",
label: "Postal Code",
description: "The postal code of the billing address",
},
billingCountry: {
type: "string",
label: "Country",
description: "The 2 letter country code of the billing address",
},
orderLines: {
type: "string[]",
label: "Order Lines",
description: "The lines of the order. [See the documentation](https://apidocs.orderspace.com/#create-an-order) for information about line format.",
},
deliveryDate: {
type: "string",
label: "Delivery Date",
description: "The date the order is due (YYYY-MM-DD)",
optional: true,
},
reference: {
type: "string",
label: "Reference",
description: "The reference for the order",
optional: true,
},
internalNote: {
type: "string",
label: "Internal Note",
description: "An internal note for the order",
optional: true,
},
customerPoNumber: {
type: "string",
label: "Customer PO Number",
description: "The customer's purchase order number for this order",
optional: true,
},
customerNote: {
type: "string",
label: "Customer Note",
description: "The customer's note on this order",
optional: true,
},
},
async run({ $ }) {
const { order } = await this.orderspace.createOrder({
$,
data: {
order: {
customer_id: this.customerId,
delivery_date: this.deliveryDate,
reference: this.reference,
internal_note: this.internalNote,
customer_po_number: this.customerPoNumber,
customer_note: this.customerNote,
shipping_address: {
line1: this.shippingAddressLine1,
line2: this.shippingAddressLine2,
city: this.shippingCity,
state: this.shippingState,
postal_code: this.shippingPostalCode,
country: this.shippingCountry,
},
billing_address: {
line1: this.billingAddressLine1,
line2: this.billingAddressLine2,
city: this.billingCity,
state: this.billingState,
postal_code: this.billingPostalCode,
country: this.billingCountry,
},
order_lines: parseObject(this.orderLines),
},
},
});
$.export("$summary", `Successfully created order ${order.id}`);
return order;
},
};
Loading
Loading