Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineAction({
key: "google_my_business-create-post",
name: "Create Post",
description: `Create a new local post associated with a location. [See the documentation](${DOCS_LINK})`,
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineAction({
key: "google_my_business-create-update-reply-to-review",
name: "Create or Update Reply to Review",
description: `Create or update a reply to the specified review. [See the documentation](${DOCS_LINK})`,
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineAction({
key: "google_my_business-get-reviews-multiple-locations",
name: "Get Reviews from Multiple Locations",
description: `Get reviews from multiple locations at once. [See the documentation](${DOCS_LINK})`,
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineAction({
key: "google_my_business-get-specific-review",
name: "Get a Specific Review",
description: `Return a specific review by name. [See the documentation](${DOCS_LINK})`,
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineAction({
key: "google_my_business-list-all-reviews",
name: "List All Reviews",
description: `List all reviews of a location to audit reviews in bulk. [See the documentation](${DOCS_LINK})`,
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineAction({
key: "google_my_business-list-posts",
name: "List Posts",
description: `List local posts associated with a location. [See the documentation](${DOCS_LINK})`,
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
app,
Expand Down
116 changes: 80 additions & 36 deletions components/google_my_business/app/google_my_business.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineApp } from "@pipedream/types";
import { axios } from "@pipedream/platform";
import {
CreatePostParams,
HttpRequestParams, ListPostsParams, ListReviewsParams, PaginatedRequestParams, UpdateReplyParams, GetReviewParams, BatchGetReviewsParams,
HttpRequestParams, ListPostsParams, PaginatedRequestParams, UpdateReplyParams, GetReviewParams, BatchGetReviewsParams,
} from "../common/requestParams";
import {
Account, LocalPost, Location, Review,
Expand All @@ -16,14 +16,31 @@ export default defineApp({
type: "string",
label: "Account Name",
description: "Select an **Account** or provide a custom *Account Name*.",
async options() {
const accounts: Account[] = await this.listAccounts();
return accounts.map(({
async options({ prevContext: { pageToken } }: {
prevContext: { pageToken: string | null; };
}) {
if (pageToken === null) {
return [];
}
const response = await this.listAccounts({
params: {
pageSize: 50,
pageToken,
},
});
const accounts: Account[] = response?.accounts ?? [];
const options = accounts?.map?.(({
name, accountName, type,
}) => ({
}: Account) => ({
label: `${accountName ?? name} (${type})`,
value: this.getCleanName(name) as string,
}));
})) ?? [];
return {
options,
context: {
pageToken: response?.nextPageToken ?? null,
},
};
},
},
location: {
Expand All @@ -32,43 +49,76 @@ export default defineApp({
description: "The location whose local posts will be listed. [See the documentation](https://developers.google.com/my-business/content/location-data#filter_results_when_you_list_locations) on how to filter locations.",
useQuery: true,
async options({
account, query,
}: Record<string, string>) {
account, query, prevContext: { pageToken },
}: Record<string, string> & {
prevContext: { pageToken: string | null; };
}) {
if (pageToken === null) {
return [];
}
const filter = query
? (query.match(/[=:]/)
? query
: `title="${query}"`).replace(/ /g, "+").replace(/"/g, "%22")
: undefined;

const locations: Location[] = await this.listLocations({
const response = await this.listLocations({
account,
filter,
params: {
pageSize: 50,
pageToken,
filter,
readMask: "name,title",
},
});
return locations?.map?.(({
const locations: Location[] = response?.locations ?? [];
const options = locations?.map?.(({
name, title,
}: Location) => ({
label: title,
value: this.getCleanName(name) as string,
})) ?? [];
return {
options,
context: {
pageToken: response?.nextPageToken ?? null,
},
};
},
},
review: {
type: "string",
label: "Review",
description: "Select a **Review** or provide a custom *Review Name*.",
async options({
account, location,
}: Record<string, string>) {
const reviews: Review[] = await this.listReviews({
account, location, prevContext: { pageToken },
}: Record<string, string> & {
prevContext: { pageToken: string | null; };
}) {
if (pageToken === null) {
return [];
}
const response = await this.listReviews({
account,
location,
params: {
pageSize: 50,
pageToken,
},
});
return reviews?.map?.(({
const reviews: Review[] = response?.reviews ?? [];
const options = reviews?.map?.(({
name, title,
}: Location) => ({
}: Review) => ({
label: title,
value: this.getCleanName(name) as string,
}));
})) ?? [];
return {
options,
context: {
pageToken: response?.nextPageToken ?? null,
},
};
},
},
},
Expand Down Expand Up @@ -123,33 +173,27 @@ export default defineApp({

return result;
},
async listAccounts(): Promise<Account[]> {
const response = await this._httpRequest({
listAccounts(args: object = {}): Promise<unknown> {
return this._httpRequest({
url: "https://mybusinessaccountmanagement.googleapis.com/v1/accounts",
...args,
});
return response?.accounts ?? [];
},
async listLocations({
account, filter,
}: Record<string, string>): Promise<Location[]> {
const response = await this._httpRequest({
listLocations({
account, ...args
}: Record<string, string> & { args: object }): Promise<unknown> {
return this._httpRequest({
url: `https://mybusinessbusinessinformation.googleapis.com/v1/accounts/${account}/locations`,
pageSize: 100,
params: {
filter,
readMask: "name,title",
},
...args,
});
return response?.locations ?? [];
},
async listReviews({
account, location,
}: ListReviewsParams): Promise<Review[]> {
const response = await this._httpRequest({
listReviews({
account, location, ...args
}: Record<string, string> & { args: object }): Promise<unknown> {
return this._httpRequest({
url: `https://mybusiness.googleapis.com/v4/accounts/${account}/locations/${location}/reviews`,
pageSize: 50,
...args,
});
return response?.reviews ?? [];
},
async listPosts({
account, location, ...args
Expand Down
2 changes: 1 addition & 1 deletion components/google_my_business/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/google_my_business",
"version": "0.2.0",
"version": "0.2.1",
"description": "Pipedream Google My Business Components",
"main": "dist/app/google_my_business.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineSource({
key: "google_my_business-new-post-created",
name: "New Post Created",
description: `Emit new event for each new local post on a location [See the documentation](${DOCS_LINK})`,
version: "0.0.4",
version: "0.0.5",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineSource({
key: "google_my_business-new-review-created-multiple-locations",
name: "New Review Created (Multiple Locations)",
description: `Emit new event for each new review on any of the selected locations [See the documentation](${DOCS_LINK})`,
version: "0.0.1",
version: "0.0.2",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineSource({
key: "google_my_business-new-review-created",
name: "New Review Created",
description: `Emit new event for each new review on a location [See the documentation](${DOCS_LINK})`,
version: "0.0.4",
version: "0.0.5",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Loading