Skip to content

Commit 2ff8179

Browse files
committed
[Components] Mews
1 parent 6989cbc commit 2ff8179

File tree

18 files changed

+1173
-18
lines changed

18 files changed

+1173
-18
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import app from "../../mews.app.mjs";
2+
3+
export default {
4+
name: "Cancel Reservation",
5+
description: "Cancel a reservation in Mews.",
6+
key: "mews-cancel-reservation",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
reservationId: {
12+
propDefinition: [
13+
app,
14+
"reservationId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const {
20+
app,
21+
reservationId,
22+
} = this;
23+
const response = await app.reservationsCancel({
24+
$,
25+
data: {
26+
ReservationIds: [
27+
reservationId,
28+
],
29+
},
30+
});
31+
$.export("summary", "Successfully cancelled reservation");
32+
return response;
33+
},
34+
};
35+
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
import app from "../../mews.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
name: "Create Reservation",
6+
description: "Create a reservation in Mews. See reservation parameters in the docs. [See the documentation](https://mews-systems.gitbook.io/connector-api/operations/reservations#add-reservations)",
7+
key: "mews-create-reservation",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
serviceId: {
13+
propDefinition: [
14+
app,
15+
"serviceId",
16+
],
17+
},
18+
customerId: {
19+
propDefinition: [
20+
app,
21+
"customerId",
22+
],
23+
},
24+
startUtc: {
25+
propDefinition: [
26+
app,
27+
"startUtc",
28+
],
29+
},
30+
endUtc: {
31+
propDefinition: [
32+
app,
33+
"endUtc",
34+
],
35+
},
36+
state: {
37+
propDefinition: [
38+
app,
39+
"state",
40+
],
41+
optional: true,
42+
},
43+
resourceId: {
44+
propDefinition: [
45+
app,
46+
"resourceId",
47+
],
48+
optional: true,
49+
},
50+
number: {
51+
propDefinition: [
52+
app,
53+
"number",
54+
],
55+
optional: true,
56+
},
57+
notes: {
58+
propDefinition: [
59+
app,
60+
"notes",
61+
],
62+
optional: true,
63+
},
64+
rateId: {
65+
propDefinition: [
66+
app,
67+
"rateId",
68+
],
69+
optional: true,
70+
},
71+
companyId: {
72+
propDefinition: [
73+
app,
74+
"companyId",
75+
],
76+
optional: true,
77+
},
78+
travelAgencyId: {
79+
propDefinition: [
80+
app,
81+
"travelAgencyId",
82+
],
83+
optional: true,
84+
},
85+
businessSegmentId: {
86+
propDefinition: [
87+
app,
88+
"businessSegmentId",
89+
],
90+
optional: true,
91+
},
92+
additionalFields: {
93+
propDefinition: [
94+
app,
95+
"additionalFields",
96+
],
97+
optional: true,
98+
},
99+
},
100+
async run({ $ }) {
101+
const {
102+
app,
103+
serviceId,
104+
customerId,
105+
startUtc,
106+
endUtc,
107+
state,
108+
resourceId,
109+
number,
110+
notes,
111+
rateId,
112+
companyId,
113+
travelAgencyId,
114+
businessSegmentId,
115+
additionalFields,
116+
} = this;
117+
118+
const response = await app.reservationsCreate({
119+
data: {
120+
Reservations: [
121+
{
122+
ServiceId: serviceId,
123+
CustomerId: customerId,
124+
StartUtc: startUtc,
125+
EndUtc: endUtc,
126+
...(state && {
127+
State: state,
128+
}),
129+
...(resourceId && {
130+
ResourceId: resourceId,
131+
}),
132+
...(number && {
133+
Number: number,
134+
}),
135+
...(notes && {
136+
Notes: notes,
137+
}),
138+
...(rateId && {
139+
RateId: rateId,
140+
}),
141+
...(companyId && {
142+
CompanyId: companyId,
143+
}),
144+
...(travelAgencyId && {
145+
TravelAgencyId: travelAgencyId,
146+
}),
147+
...(businessSegmentId && {
148+
BusinessSegmentId: businessSegmentId,
149+
}),
150+
...(additionalFields && {
151+
...utils.parseJson(additionalFields),
152+
}),
153+
},
154+
],
155+
},
156+
$,
157+
});
158+
$.export("summary", "Successfully created reservation");
159+
return response;
160+
},
161+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../mews.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
name: "Fetch Customers",
6+
description: "Retrieve customers using Mews Connector API. [See the documentation](https://mews-systems.gitbook.io/connector-api/operations/customers#get-all-customers)",
7+
key: "mews-fetch-customers",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
additionalFields: {
13+
propDefinition: [
14+
app,
15+
"additionalFields",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
app,
22+
additionalFields,
23+
} = this;
24+
25+
const items = await app.paginate({
26+
requester: app.customersGetAll,
27+
requesterArgs: {
28+
$,
29+
data: utils.parseJson(additionalFields),
30+
},
31+
resultKey: "Customers",
32+
});
33+
$.export("summary", `Successfully fetched ${items.length} customers`);
34+
return items;
35+
},
36+
};
37+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../mews.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
name: "Fetch Order Items",
6+
description: "Retrieve order items using Mews Connector API. [See the documentation](https://mews-systems.gitbook.io/connector-api/operations/orderitems#get-all-order-items)",
7+
key: "mews-fetch-order-items",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
additionalFields: {
13+
propDefinition: [
14+
app,
15+
"additionalFields",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
app,
22+
additionalFields,
23+
} = this;
24+
25+
const items = await app.paginate({
26+
requester: app.orderItemsGetAll,
27+
requesterArgs: {
28+
$,
29+
data: utils.parseJson(additionalFields),
30+
},
31+
resultKey: "OrderItems",
32+
});
33+
$.export("summary", `Successfully fetched ${items.length} order items`);
34+
return items;
35+
},
36+
};
37+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../mews.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
name: "Fetch Products",
6+
description: "Retrieve products using Mews Connector API. [See the documentation](https://mews-systems.gitbook.io/connector-api/operations/products#get-all-products)",
7+
key: "mews-fetch-products",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
additionalFields: {
13+
propDefinition: [
14+
app,
15+
"additionalFields",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
app,
22+
additionalFields,
23+
} = this;
24+
25+
const items = await app.paginate({
26+
requester: app.productsGetAll,
27+
requesterArgs: {
28+
$,
29+
data: utils.parseJson(additionalFields),
30+
},
31+
resultKey: "Products",
32+
});
33+
$.export("summary", `Successfully fetched ${items.length} products`);
34+
return items;
35+
},
36+
};
37+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import app from "../../mews.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
name: "Fetch Reservations",
6+
description: "Retrieve reservations using Mews Connector API. [See the documentation](https://mews-systems.gitbook.io/connector-api/operations/reservations#get-all-reservations-ver-2023-06-06)",
7+
key: "mews-fetch-reservations",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
additionalFields: {
13+
propDefinition: [
14+
app,
15+
"additionalFields",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
app,
22+
additionalFields,
23+
} = this;
24+
25+
const items = await app.paginate({
26+
requester: app.reservationsGetAll,
27+
requesterArgs: {
28+
$,
29+
data: utils.parseJson(additionalFields),
30+
},
31+
resultKey: "Reservations",
32+
});
33+
34+
$.export("summary", `Successfully fetched ${items.length} reservations`);
35+
return items;
36+
},
37+
};
38+

0 commit comments

Comments
 (0)