Skip to content

Commit 640fb76

Browse files
authored
New Components - orderspace (#17454)
* wip * new components * pnpm-lock.yaml
1 parent 84e06c1 commit 640fb76

File tree

28 files changed

+1553
-7
lines changed

28 files changed

+1553
-7
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
import orderspace from "../../orderspace.app.mjs";
2+
3+
export default {
4+
key: "orderspace-create-customer",
5+
name: "Create Customer",
6+
description: "Create a new customer. [See the documentation](https://apidocs.orderspace.com/#create-a-customer)",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
orderspace,
11+
companyName: {
12+
type: "string",
13+
label: "Company Name",
14+
description: "The name of the customer's company",
15+
},
16+
contactName: {
17+
type: "string",
18+
label: "Contact Name",
19+
description: "The contact name for the customer",
20+
},
21+
email: {
22+
type: "string",
23+
label: "Email",
24+
description: "The email address of the customer",
25+
},
26+
addressLine1: {
27+
type: "string",
28+
label: "Address Line 1",
29+
description: "The first line of the customer's address",
30+
},
31+
addressLine2: {
32+
type: "string",
33+
label: "Address Line 2",
34+
description: "The second line of the customer's address",
35+
optional: true,
36+
},
37+
city: {
38+
type: "string",
39+
label: "City",
40+
description: "The city of the customer's address",
41+
},
42+
state: {
43+
type: "string",
44+
label: "State",
45+
description: "The state of the customer's address",
46+
},
47+
postalCode: {
48+
type: "string",
49+
label: "Postal Code",
50+
description: "The postal code of the customer's address",
51+
},
52+
country: {
53+
type: "string",
54+
label: "Country",
55+
description: "The 2 letter country code of the customer's address",
56+
},
57+
phone: {
58+
type: "string",
59+
label: "Phone",
60+
description: "The phone number of the customer",
61+
optional: true,
62+
},
63+
reference: {
64+
type: "string",
65+
label: "Reference",
66+
description: "Your reference for the customer",
67+
optional: true,
68+
},
69+
internalNote: {
70+
type: "string",
71+
label: "Internal Note",
72+
description: "An internal note for the customer",
73+
optional: true,
74+
},
75+
taxNumber: {
76+
type: "string",
77+
label: "Sales Tax Number",
78+
description: "The sales tax number of the customer",
79+
optional: true,
80+
},
81+
minimumSpend: {
82+
type: "string",
83+
label: "Minimum Spend",
84+
description: "The minimum spend per order for the customer",
85+
optional: true,
86+
},
87+
paymentTermId: {
88+
propDefinition: [
89+
orderspace,
90+
"paymentTermId",
91+
],
92+
},
93+
customerGroupId: {
94+
propDefinition: [
95+
orderspace,
96+
"customerGroupId",
97+
],
98+
},
99+
priceListId: {
100+
propDefinition: [
101+
orderspace,
102+
"priceListId",
103+
],
104+
},
105+
},
106+
async run({ $ }) {
107+
const { customer } = await this.orderspace.createCustomer({
108+
data: {
109+
customer: {
110+
company_name: this.companyName,
111+
reference: this.reference,
112+
internal_note: this.internalNote,
113+
buyers: [
114+
{
115+
name: this.contactName,
116+
email_address: this.email,
117+
},
118+
],
119+
phone: this.phone,
120+
email_addresses: {
121+
orders: this.email,
122+
dispatches: this.email,
123+
invoices: this.email,
124+
},
125+
tax_number: this.taxNumber,
126+
addresses: [
127+
{
128+
company_name: this.companyName,
129+
contact_name: this.contactName,
130+
line1: this.addressLine1,
131+
line2: this.addressLine2,
132+
city: this.city,
133+
state: this.state,
134+
postal_code: this.postalCode,
135+
country: this.country,
136+
},
137+
],
138+
minimum_spend: this.minimumSpend,
139+
payment_terms_id: this.paymentTermId,
140+
customer_group_id: this.customerGroupId,
141+
price_list_id: this.priceListId,
142+
},
143+
},
144+
});
145+
$.export("$summary", `Successfully created customer with ID: ${customer.id}`);
146+
return customer;
147+
},
148+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import orderspace from "../../orderspace.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "orderspace-create-dispatch",
6+
name: "Create Dispatch",
7+
description: "Create a new dispatch. [See the documentation](https://apidocs.orderspace.com/#create-a-dispatch)",
8+
type: "action",
9+
version: "0.0.1",
10+
props: {
11+
orderspace,
12+
orderId: {
13+
propDefinition: [
14+
orderspace,
15+
"orderId",
16+
],
17+
},
18+
comments: {
19+
type: "string",
20+
label: "Comments",
21+
description: "The comments to add to the dispatch",
22+
optional: true,
23+
},
24+
dispatchLines: {
25+
type: "string[]",
26+
label: "Dispatch Lines",
27+
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.",
28+
},
29+
},
30+
async run({ $ }) {
31+
const { dispatch } = await this.orderspace.createDispatch({
32+
$,
33+
data: {
34+
dispatch: {
35+
order_id: this.orderId,
36+
comments: this.comments,
37+
dispatch_lines: parseObject(this.dispatchLines),
38+
},
39+
},
40+
});
41+
$.export("$summary", `Successfully created dispatch ${dispatch.id}`);
42+
return dispatch;
43+
},
44+
};
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import orderspace from "../../orderspace.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "orderspace-create-order",
6+
name: "Create Order",
7+
description: "Create a new order. [See the documentation](https://apidocs.orderspace.com/#create-an-order)",
8+
type: "action",
9+
version: "0.0.1",
10+
props: {
11+
orderspace,
12+
customerId: {
13+
propDefinition: [
14+
orderspace,
15+
"customerId",
16+
],
17+
},
18+
shippingAddressLine1: {
19+
type: "string",
20+
label: "Address Line 1",
21+
description: "The first line of the shipping address",
22+
},
23+
shippingAddressLine2: {
24+
type: "string",
25+
label: "Address Line 2",
26+
description: "The second line of the shipping address",
27+
optional: true,
28+
},
29+
shippingCity: {
30+
type: "string",
31+
label: "City",
32+
description: "The city of the shipping address",
33+
},
34+
shippingState: {
35+
type: "string",
36+
label: "State",
37+
description: "The state of the shipping address",
38+
},
39+
shippingPostalCode: {
40+
type: "string",
41+
label: "Postal Code",
42+
description: "The postal code of the shipping address",
43+
},
44+
shippingCountry: {
45+
type: "string",
46+
label: "Country",
47+
description: "The 2 letter country code of the shipping address",
48+
},
49+
billingAddressLine1: {
50+
type: "string",
51+
label: "Address Line 1",
52+
description: "The first line of the billing address",
53+
},
54+
billingAddressLine2: {
55+
type: "string",
56+
label: "Address Line 2",
57+
description: "The second line of the billing address",
58+
optional: true,
59+
},
60+
billingCity: {
61+
type: "string",
62+
label: "City",
63+
description: "The city of the billing address",
64+
},
65+
billingState: {
66+
type: "string",
67+
label: "State",
68+
description: "The state of the billing address",
69+
},
70+
billingPostalCode: {
71+
type: "string",
72+
label: "Postal Code",
73+
description: "The postal code of the billing address",
74+
},
75+
billingCountry: {
76+
type: "string",
77+
label: "Country",
78+
description: "The 2 letter country code of the billing address",
79+
},
80+
orderLines: {
81+
type: "string[]",
82+
label: "Order Lines",
83+
description: "The lines of the order. [See the documentation](https://apidocs.orderspace.com/#create-an-order) for information about line format.",
84+
},
85+
deliveryDate: {
86+
type: "string",
87+
label: "Delivery Date",
88+
description: "The date the order is due (YYYY-MM-DD)",
89+
optional: true,
90+
},
91+
reference: {
92+
type: "string",
93+
label: "Reference",
94+
description: "The reference for the order",
95+
optional: true,
96+
},
97+
internalNote: {
98+
type: "string",
99+
label: "Internal Note",
100+
description: "An internal note for the order",
101+
optional: true,
102+
},
103+
customerPoNumber: {
104+
type: "string",
105+
label: "Customer PO Number",
106+
description: "The customer's purchase order number for this order",
107+
optional: true,
108+
},
109+
customerNote: {
110+
type: "string",
111+
label: "Customer Note",
112+
description: "The customer's note on this order",
113+
optional: true,
114+
},
115+
},
116+
async run({ $ }) {
117+
const { order } = await this.orderspace.createOrder({
118+
$,
119+
data: {
120+
order: {
121+
customer_id: this.customerId,
122+
delivery_date: this.deliveryDate,
123+
reference: this.reference,
124+
internal_note: this.internalNote,
125+
customer_po_number: this.customerPoNumber,
126+
customer_note: this.customerNote,
127+
shipping_address: {
128+
line1: this.shippingAddressLine1,
129+
line2: this.shippingAddressLine2,
130+
city: this.shippingCity,
131+
state: this.shippingState,
132+
postal_code: this.shippingPostalCode,
133+
country: this.shippingCountry,
134+
},
135+
billing_address: {
136+
line1: this.billingAddressLine1,
137+
line2: this.billingAddressLine2,
138+
city: this.billingCity,
139+
state: this.billingState,
140+
postal_code: this.billingPostalCode,
141+
country: this.billingCountry,
142+
},
143+
order_lines: parseObject(this.orderLines),
144+
},
145+
},
146+
});
147+
$.export("$summary", `Successfully created order ${order.id}`);
148+
return order;
149+
},
150+
};

0 commit comments

Comments
 (0)