Skip to content

Commit 3abc3ae

Browse files
authored
Merging pull request #18074
* package version bump * Adding new google my business actions * Fixing entity format * Creating source * pnpm * Version bumps * Adjusting some things * ESLint run
1 parent ce4b889 commit 3abc3ae

File tree

14 files changed

+308
-11
lines changed

14 files changed

+308
-11
lines changed

components/google_my_business/actions/create-post/create-post.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default defineAction({
1212
key: "google_my_business-create-post",
1313
name: "Create Post",
1414
description: `Create a new local post associated with a location. [See the documentation](${DOCS_LINK})`,
15-
version: "0.0.2",
15+
version: "0.0.3",
1616
type: "action",
1717
props: {
1818
app,
@@ -95,7 +95,8 @@ export default defineAction({
9595
? JSON.parse(obj)
9696
: obj;
9797
} catch (err) {
98-
throw new ConfigurationError(`**Invalid JSON string** for object prop: "${obj}"`);
98+
throw new ConfigurationError(`**Invalid JSON string** for object prop: "${obj}"
99+
Error: ${err}`);
99100
}
100101
},
101102
},

components/google_my_business/actions/create-update-reply-to-review/create-update-reply-to-review.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default defineAction({
88
key: "google_my_business-create-update-reply-to-review",
99
name: "Create or Update Reply to Review",
1010
description: `Create or update a reply to the specified review. [See the documentation](${DOCS_LINK})`,
11-
version: "0.0.1",
11+
version: "0.0.2",
1212
type: "action",
1313
props: {
1414
app,
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { defineAction } from "@pipedream/types";
2+
import app from "../../app/google_my_business.app";
3+
import { BatchGetReviewsParams } from "../../common/requestParams";
4+
5+
const DOCS_LINK = "https://developers.google.com/my-business/content/review-data#get_reviews_from_multiple_locations";
6+
7+
export default defineAction({
8+
key: "google_my_business-get-reviews-multiple-locations",
9+
name: "Get Reviews from Multiple Locations",
10+
description: `Get reviews from multiple locations at once. [See the documentation](${DOCS_LINK})`,
11+
version: "0.0.1",
12+
type: "action",
13+
props: {
14+
app,
15+
account: {
16+
propDefinition: [
17+
app,
18+
"account",
19+
],
20+
},
21+
locationNames: {
22+
propDefinition: [
23+
app,
24+
"location",
25+
({ account }: { account: string; }) => ({
26+
account,
27+
}),
28+
],
29+
type: "string[]",
30+
label: "Location Names",
31+
description: "One or more locations to get reviews from",
32+
},
33+
pageSize: {
34+
type: "integer",
35+
label: "Page Size",
36+
description: "The number of reviews to return per location (max 50)",
37+
optional: true,
38+
default: 50,
39+
min: 1,
40+
max: 50,
41+
},
42+
orderBy: {
43+
type: "string",
44+
label: "Order By",
45+
description: "How to order the reviews: by createTime or updateTime, and ascending or descending",
46+
optional: true,
47+
options: [
48+
"createTime desc",
49+
"createTime asc",
50+
"updateTime desc",
51+
"updateTime asc",
52+
],
53+
},
54+
ignoreRatingOnlyReviews: {
55+
type: "boolean",
56+
label: "Ignore Rating Only Reviews",
57+
description: "If true, only return reviews that have textual content",
58+
optional: true,
59+
default: false,
60+
},
61+
},
62+
async run({ $ }) {
63+
const {
64+
account, locationNames, pageSize, orderBy, ignoreRatingOnlyReviews,
65+
} = this;
66+
67+
const params: BatchGetReviewsParams = {
68+
$,
69+
account,
70+
data: {
71+
locationNames: locationNames?.map((locationName: string) => `accounts/${account}/locations/${locationName}`),
72+
pageSize,
73+
orderBy,
74+
ignoreRatingOnlyReviews,
75+
},
76+
};
77+
78+
const response = await this.app.batchGetReviews(params);
79+
80+
$.export("$summary", `Successfully retrieved reviews from ${locationNames.length} locations`);
81+
82+
return response;
83+
},
84+
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { defineAction } from "@pipedream/types";
2+
import app from "../../app/google_my_business.app";
3+
import { GetReviewParams } from "../../common/requestParams";
4+
5+
const DOCS_LINK = "https://developers.google.com/my-business/content/review-data#get_a_specific_review";
6+
7+
export default defineAction({
8+
key: "google_my_business-get-specific-review",
9+
name: "Get a Specific Review",
10+
description: `Return a specific review by name. [See the documentation](${DOCS_LINK})`,
11+
version: "0.0.1",
12+
type: "action",
13+
props: {
14+
app,
15+
account: {
16+
propDefinition: [
17+
app,
18+
"account",
19+
],
20+
},
21+
location: {
22+
propDefinition: [
23+
app,
24+
"location",
25+
({ account }: { account: string; }) => ({
26+
account,
27+
}),
28+
],
29+
},
30+
review: {
31+
propDefinition: [
32+
app,
33+
"review",
34+
({
35+
account, location,
36+
}: Record<string, string>) => ({
37+
account,
38+
location,
39+
}),
40+
],
41+
},
42+
},
43+
async run({ $ }) {
44+
const {
45+
account, location, review,
46+
} = this;
47+
48+
const params: GetReviewParams = {
49+
$,
50+
account,
51+
location,
52+
review,
53+
};
54+
55+
const response = await this.app.getReview(params);
56+
57+
$.export("$summary", `Successfully retrieved review: ${review}`);
58+
59+
return response;
60+
},
61+
});
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { defineAction } from "@pipedream/types";
2+
import app from "../../app/google_my_business.app";
3+
import { ListReviewsParams } from "../../common/requestParams";
4+
5+
const DOCS_LINK = "https://developers.google.com/my-business/content/review-data#list_all_reviews";
6+
7+
export default defineAction({
8+
key: "google_my_business-list-all-reviews",
9+
name: "List All Reviews",
10+
description: `List all reviews of a location to audit reviews in bulk. [See the documentation](${DOCS_LINK})`,
11+
version: "0.0.1",
12+
type: "action",
13+
props: {
14+
app,
15+
account: {
16+
propDefinition: [
17+
app,
18+
"account",
19+
],
20+
},
21+
location: {
22+
propDefinition: [
23+
app,
24+
"location",
25+
({ account }: { account: string; }) => ({
26+
account,
27+
}),
28+
],
29+
},
30+
},
31+
async run({ $ }) {
32+
const {
33+
account, location,
34+
} = this;
35+
36+
const params: ListReviewsParams = {
37+
$,
38+
account,
39+
location,
40+
};
41+
42+
const response = await this.app.listReviews(params);
43+
44+
$.export("$summary", `Successfully listed ${response.length} reviews`);
45+
46+
return response;
47+
},
48+
});

components/google_my_business/actions/list-posts/list-posts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default defineAction({
99
key: "google_my_business-list-posts",
1010
name: "List Posts",
1111
description: `List local posts associated with a location. [See the documentation](${DOCS_LINK})`,
12-
version: "0.0.1",
12+
version: "0.0.2",
1313
type: "action",
1414
props: {
1515
app,

components/google_my_business/app/google_my_business.app.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineApp } from "@pipedream/types";
22
import { axios } from "@pipedream/platform";
33
import {
44
CreatePostParams,
5-
HttpRequestParams, ListPostsParams, ListReviewsParams, PaginatedRequestParams, UpdateReplyParams,
5+
HttpRequestParams, ListPostsParams, ListReviewsParams, PaginatedRequestParams, UpdateReplyParams, GetReviewParams, BatchGetReviewsParams,
66
} from "../common/requestParams";
77
import {
88
Account, LocalPost, Location, Review,
@@ -187,5 +187,22 @@ export default defineApp({
187187
...args,
188188
});
189189
},
190+
async getReview({
191+
account, location, review, ...args
192+
}: GetReviewParams): Promise<Review> {
193+
return this._httpRequest({
194+
url: `https://mybusiness.googleapis.com/v4/accounts/${account}/locations/${location}/reviews/${review}`,
195+
...args,
196+
});
197+
},
198+
async batchGetReviews({
199+
account, ...args
200+
}: BatchGetReviewsParams): Promise<object> {
201+
return this._httpRequest({
202+
method: "POST",
203+
url: `https://mybusiness.googleapis.com/v4/accounts/${account}/locations:batchGetReviews`,
204+
...args,
205+
});
206+
},
190207
},
191208
});

components/google_my_business/common/requestParams.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ export interface UpdateReplyParams extends PdAxiosRequest, AccountLocation {
5050
comment: string;
5151
};
5252
}
53+
54+
export interface GetReviewParams extends PdAxiosRequest, AccountLocation {
55+
review: string;
56+
}
57+
58+
export interface BatchGetReviewsParams extends PdAxiosRequest {
59+
account: string;
60+
data: {
61+
locationNames: string[];
62+
pageSize?: number;
63+
pageToken?: string;
64+
orderBy?: string;
65+
ignoreRatingOnlyReviews?: boolean;
66+
};
67+
}

components/google_my_business/common/responseSchemas.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ export interface Review extends EntityWithCreateTime {
2222
export interface LocalPost extends EntityWithCreateTime {
2323
summary: string;
2424
}
25+
26+
export interface BatchGetReviewsResponse {
27+
locationReviews: {
28+
review: Review
29+
}[];
30+
}

components/google_my_business/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_my_business",
3-
"version": "0.1.4",
3+
"version": "0.2.0",
44
"description": "Pipedream Google My Business Components",
55
"main": "dist/app/google_my_business.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)