Skip to content

Commit a844abe

Browse files
authored
17945 trusted shops (#18417)
* Add eTrusted actions and utilities - Introduced new actions for managing reviews, including creating, deleting, and replying to reviews, as well as retrieving review details and statistics. - Added utility functions for parsing objects to enhance parameter handling. - Updated eTrusted app version to 0.1.0 and included a new constants file for configuration limits. - Enhanced prop definitions for better user input handling in actions. * pnpm update * Refactor eTrusted module structure - Updated import path for constants to reflect new file location. - Added a new constants file defining the LIMIT value for configuration. * Refactor parameter handling in eTrusted review actions - Updated parameter assignments in get-list-of-reviews and get-total-reviews actions to use optional chaining for improved safety and readability. - Simplified the logic for parsing channel, rating, status, type, additional information, and SKU parameters. * pnpm update * Update parseObject function to return an empty array for undefined input * Remove optional flag from Veto Reporter Email and add error handling in get-review-veto-by-review-id action
1 parent d439499 commit a844abe

File tree

17 files changed

+899
-10
lines changed

17 files changed

+899
-10
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import etrusted from "../../etrusted.app.mjs";
2+
3+
export default {
4+
key: "etrusted-create-veto-for-review",
5+
name: "Create A Veto For A Review",
6+
description: "Creates a veto for a specific review. [See the documentation](https://developers.etrusted.com/reference/createveto)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
etrusted,
11+
reviewId: {
12+
propDefinition: [
13+
etrusted,
14+
"reviewId",
15+
],
16+
},
17+
comment: {
18+
type: "string",
19+
label: "Comment",
20+
description: "The veto comment. Provide additional information on the review or your veto here.",
21+
},
22+
reason: {
23+
type: "string",
24+
label: "Reason",
25+
description: "The reason for the veto.",
26+
options: [
27+
"UNTRUTHFUL",
28+
"ABUSIVE",
29+
"VIOLATES_THE_TERMS_OF_USE",
30+
"INAPPROPRIATE_IMAGE",
31+
],
32+
},
33+
vetoReporterEmail: {
34+
type: "string",
35+
label: "Veto Reporter Email",
36+
description: "The E-Mail address of the veto reporter.",
37+
},
38+
},
39+
async run({ $ }) {
40+
const response = await this.etrusted.createVetoForReview({
41+
$,
42+
reviewId: this.reviewId,
43+
data: {
44+
comment: this.comment,
45+
reason: this.reason,
46+
vetoReporterEmail: this.vetoReporterEmail,
47+
},
48+
});
49+
50+
$.export("$summary", `Successfully created veto with ID ${response.id} for review ${this.reviewId}`);
51+
return response;
52+
},
53+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import etrusted from "../../etrusted.app.mjs";
2+
3+
export default {
4+
key: "etrusted-delete-review-reply",
5+
name: "Delete Review Reply",
6+
description: "Reply to a review. [See the documentation](https://developers.etrusted.com/reference/deletereviewreply)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
etrusted,
11+
reviewId: {
12+
propDefinition: [
13+
etrusted,
14+
"reviewId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.etrusted.deleteReviewReply({
20+
$,
21+
reviewId: this.reviewId,
22+
});
23+
24+
$.export("$summary", `Successfully deleted review reply for review ${this.reviewId}`);
25+
return response;
26+
},
27+
};
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import etrusted from "../../etrusted.app.mjs";
3+
4+
export default {
5+
key: "etrusted-get-list-of-reviews-with-fewer-properties",
6+
name: "Get List of Reviews with Fewer Properties",
7+
description: "Retrieves a list of reviews with fewer properties. [See the documentation](https://developers.etrusted.com/reference/getminimalreviews)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
etrusted,
12+
channelId: {
13+
propDefinition: [
14+
etrusted,
15+
"channelId",
16+
],
17+
type: "string[]",
18+
optional: true,
19+
},
20+
after: {
21+
propDefinition: [
22+
etrusted,
23+
"reviewId",
24+
],
25+
label: "After",
26+
description: "`After` is a review ID. The list of reviews in the response will only contain reviews submitted earlier than the review with this ID.",
27+
optional: true,
28+
},
29+
before: {
30+
propDefinition: [
31+
etrusted,
32+
"reviewId",
33+
],
34+
label: "Before",
35+
description: "`Before` is a review ID. The list of reviews in the response will only contain reviews submitted later than the review with this ID.",
36+
optional: true,
37+
},
38+
submittedAfter: {
39+
propDefinition: [
40+
etrusted,
41+
"submittedAfter",
42+
],
43+
optional: true,
44+
},
45+
submittedBefore: {
46+
propDefinition: [
47+
etrusted,
48+
"submittedBefore",
49+
],
50+
optional: true,
51+
},
52+
rating: {
53+
propDefinition: [
54+
etrusted,
55+
"rating",
56+
],
57+
optional: true,
58+
},
59+
status: {
60+
propDefinition: [
61+
etrusted,
62+
"status",
63+
],
64+
optional: true,
65+
},
66+
type: {
67+
propDefinition: [
68+
etrusted,
69+
"type",
70+
],
71+
optional: true,
72+
},
73+
hasReply: {
74+
propDefinition: [
75+
etrusted,
76+
"hasReply",
77+
],
78+
optional: true,
79+
},
80+
ignoreStatements: {
81+
propDefinition: [
82+
etrusted,
83+
"ignoreStatements",
84+
],
85+
optional: true,
86+
},
87+
query: {
88+
propDefinition: [
89+
etrusted,
90+
"query",
91+
],
92+
optional: true,
93+
},
94+
sku: {
95+
propDefinition: [
96+
etrusted,
97+
"sku",
98+
],
99+
optional: true,
100+
},
101+
orderBy: {
102+
propDefinition: [
103+
etrusted,
104+
"orderBy",
105+
],
106+
optional: true,
107+
},
108+
maxResults: {
109+
propDefinition: [
110+
etrusted,
111+
"maxResults",
112+
],
113+
optional: true,
114+
},
115+
},
116+
async run({ $ }) {
117+
const response = await this.etrusted.paginate({
118+
$,
119+
fn: this.etrusted.getListOfReviewsWithFewerProperties,
120+
params: {
121+
channels: this.channelId && parseObject(this.channelId).join(","),
122+
after: this.after,
123+
before: this.before,
124+
submittedAfter: this.submittedAfter,
125+
submittedBefore: this.submittedBefore,
126+
rating: this.rating && parseObject(this.rating).join(","),
127+
status: this.status && parseObject(this.status).join(","),
128+
type: this.type && parseObject(this.type).join(","),
129+
hasReply: this.hasReply,
130+
ignoreStatements: this.ignoreStatements,
131+
query: this.query,
132+
sku: this.sku,
133+
orderBy: this.orderBy,
134+
maxResults: this.maxResults,
135+
},
136+
maxResults: this.maxResults,
137+
});
138+
139+
const reviews = [];
140+
for await (const review of response) {
141+
reviews.push(review);
142+
}
143+
144+
$.export("$summary", `Successfully retrieved ${reviews.length} review${reviews.length === 1
145+
? ""
146+
: "s"} with fewer properties`);
147+
return reviews;
148+
},
149+
};
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import etrusted from "../../etrusted.app.mjs";
3+
4+
export default {
5+
key: "etrusted-get-list-of-reviews",
6+
name: "Get List of Reviews",
7+
description: "Get a list of reviews for a specific channel, a set of channels or for your entire account. [See the documentation](https://developers.etrusted.com/reference/getreviews)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
etrusted,
12+
channelId: {
13+
propDefinition: [
14+
etrusted,
15+
"channelId",
16+
],
17+
type: "string[]",
18+
optional: true,
19+
},
20+
after: {
21+
propDefinition: [
22+
etrusted,
23+
"reviewId",
24+
],
25+
label: "After",
26+
description: "`After` is a review ID. The list of reviews in the response will only contain reviews submitted earlier than the review with this ID.",
27+
optional: true,
28+
},
29+
before: {
30+
propDefinition: [
31+
etrusted,
32+
"reviewId",
33+
],
34+
label: "Before",
35+
description: "`Before` is a review ID. The list of reviews in the response will only contain reviews submitted later than the review with this ID.",
36+
optional: true,
37+
},
38+
submittedAfter: {
39+
propDefinition: [
40+
etrusted,
41+
"submittedAfter",
42+
],
43+
optional: true,
44+
},
45+
submittedBefore: {
46+
propDefinition: [
47+
etrusted,
48+
"submittedBefore",
49+
],
50+
optional: true,
51+
},
52+
rating: {
53+
propDefinition: [
54+
etrusted,
55+
"rating",
56+
],
57+
optional: true,
58+
},
59+
status: {
60+
propDefinition: [
61+
etrusted,
62+
"status",
63+
],
64+
optional: true,
65+
},
66+
type: {
67+
propDefinition: [
68+
etrusted,
69+
"type",
70+
],
71+
optional: true,
72+
},
73+
hasReply: {
74+
propDefinition: [
75+
etrusted,
76+
"hasReply",
77+
],
78+
optional: true,
79+
},
80+
additionalInformation: {
81+
type: "string[]",
82+
label: "Additional Information",
83+
description: "A list of additional pieces of information to be retrieved with the review. If this property is not set, none of the of additional information are included in the review.",
84+
options: [
85+
"VETO",
86+
"ATTACHMENTS",
87+
],
88+
optional: true,
89+
},
90+
ignoreStatements: {
91+
propDefinition: [
92+
etrusted,
93+
"ignoreStatements",
94+
],
95+
optional: true,
96+
},
97+
query: {
98+
propDefinition: [
99+
etrusted,
100+
"query",
101+
],
102+
optional: true,
103+
},
104+
sku: {
105+
propDefinition: [
106+
etrusted,
107+
"sku",
108+
],
109+
optional: true,
110+
},
111+
orderBy: {
112+
propDefinition: [
113+
etrusted,
114+
"orderBy",
115+
],
116+
optional: true,
117+
},
118+
maxResults: {
119+
propDefinition: [
120+
etrusted,
121+
"maxResults",
122+
],
123+
optional: true,
124+
},
125+
},
126+
async run({ $ }) {
127+
const response = this.etrusted.paginate({
128+
$,
129+
fn: this.etrusted.getListOfReviews,
130+
params: {
131+
channels: parseObject(this.channelId)?.join(","),
132+
after: this.after,
133+
before: this.before,
134+
submittedAfter: this.submittedAfter,
135+
submittedBefore: this.submittedBefore,
136+
rating: parseObject(this.rating)?.join(","),
137+
status: parseObject(this.status)?.join(","),
138+
type: parseObject(this.type)?.join(","),
139+
hasReply: this.hasReply,
140+
additionalInformation: parseObject(this.additionalInformation)?.join(","),
141+
ignoreStatements: this.ignoreStatements,
142+
query: this.query,
143+
sku: parseObject(this.sku)?.join(","),
144+
orderBy: this.orderBy,
145+
},
146+
maxResults: this.maxResults,
147+
});
148+
149+
const reviews = [];
150+
for await (const review of response) {
151+
reviews.push(review);
152+
}
153+
154+
$.export("$summary", `Successfully retrieved ${reviews.length} review${reviews.length === 1
155+
? ""
156+
: "s"}`);
157+
return reviews;
158+
},
159+
};

0 commit comments

Comments
 (0)