Skip to content

Commit 470a821

Browse files
committed
updates
1 parent 662e775 commit 470a821

File tree

2 files changed

+40
-24
lines changed

2 files changed

+40
-24
lines changed

components/returnless/actions/create-return-order/create-return-order.mjs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import returnless from "../../returnless.app.mjs";
22
import { parseObject } from "../../common/utils.mjs";
3+
import { ConfigurationError } from "@pipedream/platform";
34

45
export default {
56
key: "returnless-create-return-order",
@@ -16,9 +17,13 @@ export default {
1617
],
1718
},
1819
locale: {
19-
type: "string",
20-
label: "Locale",
21-
description: "The locale of the form to create the return-order intent for",
20+
propDefinition: [
21+
returnless,
22+
"locale",
23+
(c) => ({
24+
formId: c.formId,
25+
}),
26+
],
2227
},
2328
input: {
2429
type: "string",
@@ -84,7 +89,7 @@ export default {
8489
});
8590
for (const item of items) {
8691
props[`item${item.id}Quantity`] = {
87-
type: "string",
92+
type: "integer",
8893
label: `Item ${item.id} Quantity`,
8994
description: `The quantity of item ${item.id} to return`,
9095
};
@@ -120,6 +125,9 @@ export default {
120125
order_number: order.order_number,
121126
},
122127
});
128+
if (intent.status === "failed") {
129+
throw new ConfigurationError(intent.status_message);
130+
}
123131

124132
const { data: returnOrder } = await this.returnless.createReturnOrder({
125133
$,
@@ -128,7 +136,7 @@ export default {
128136
customer: {
129137
house_number: this.customerHouseNumber,
130138
street: this.customerStreet,
131-
postal_code: this.customerPostalCode,
139+
postcode: this.customerPostalCode,
132140
city: this.customerCity,
133141
country_id: this.customerCountryId,
134142
},

components/returnless/returnless.app.mjs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,14 @@ export default {
8383
type: "string",
8484
label: "Country ID",
8585
description: "The ID of the country to use for the return order",
86-
async options({ prevContext }) {
87-
const {
88-
data, meta,
89-
} = await this.listCountries({
90-
params: {
91-
cursor: prevContext?.cursor,
92-
},
93-
});
94-
return {
95-
options: data.map(({
96-
id: value, name: label,
97-
}) => ({
98-
value,
99-
label,
100-
})) || [],
101-
context: {
102-
cursor: meta.next_cursor,
103-
},
104-
};
86+
async options() {
87+
const { data } = await this.listCountries();
88+
return data.map(({
89+
id: value, name: label,
90+
}) => ({
91+
value,
92+
label,
93+
})) || [];
10594
},
10695
},
10796
itemIds: {
@@ -152,6 +141,17 @@ export default {
152141
};
153142
},
154143
},
144+
locale: {
145+
type: "string",
146+
label: "Locale",
147+
description: "The locale of the form to use for the return order",
148+
async options({ formId }) {
149+
const { data } = await this.getForm({
150+
formId,
151+
});
152+
return data.locales.map(({ locale }) => locale);
153+
},
154+
},
155155
maxResults: {
156156
type: "integer",
157157
label: "Max Results",
@@ -200,6 +200,14 @@ export default {
200200
...opts,
201201
});
202202
},
203+
getForm({
204+
formId, ...opts
205+
}) {
206+
return this._makeRequest({
207+
path: `/forms/${formId}`,
208+
...opts,
209+
});
210+
},
203211
listCountries(opts = {}) {
204212
return this._makeRequest({
205213
path: "/countries",

0 commit comments

Comments
 (0)