Add Activepieces integration for workflow automation

- Add Activepieces fork with SmoothSchedule custom piece
- Create integrations app with Activepieces service layer
- Add embed token endpoint for iframe integration
- Create Automations page with embedded workflow builder
- Add sidebar visibility fix for embed mode
- Add list inactive customers endpoint to Public API
- Include SmoothSchedule triggers: event created/updated/cancelled
- Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,29 @@
{
"Google My Business": "Google My Business",
"Manage your business on Google": "Manage your business on Google",
"Create or Update Reply": "Create or Update Reply",
"Custom API Call": "Custom API Call",
"Create or update a reply to a review if it already exists": "Create or update a reply to a review if it already exists",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Review Name": "Review Name",
"Comment": "Comment",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"You can find the review name from new review trigger": "You can find the review name from new review trigger",
"Comment to be added to the review": "Comment to be added to the review",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Review": "New Review",
"Triggers when there is new review": "Triggers when there is new review",
"Account": "Account",
"Location": "Location"
}

View File

@@ -0,0 +1,30 @@
{
"Manage your business on Google": "Verwalten Sie Ihr Geschäft auf Google",
"Create or Update Reply": "Antwort erstellen oder aktualisieren",
"Custom API Call": "Eigener API-Aufruf",
"Create or update a reply to a review if it already exists": "Erstelle oder aktualisiere eine Antwort auf eine Überprüfung, falls sie bereits existiert",
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
"Review Name": "Bewertungsname",
"Comment": "Kommentar",
"Method": "Methode",
"Headers": "Kopfzeilen",
"Query Parameters": "Abfrageparameter",
"Body": "Körper",
"Response is Binary ?": "Antwort ist binär?",
"No Error on Failure": "Kein Fehler bei Fehler",
"Timeout (in seconds)": "Timeout (in Sekunden)",
"You can find the review name from new review trigger": "Sie können den Rezensionsnamen vom neuen Rezensionstrigger finden",
"Comment to be added to the review": "Kommentar zur Bewertung hinzugefügt werden",
"Authorization headers are injected automatically from your connection.": "Autorisierungs-Header werden automatisch von Ihrer Verbindung injiziert.",
"Enable for files like PDFs, images, etc..": "Aktivieren für Dateien wie PDFs, Bilder, etc..",
"GET": "ERHALTEN",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "LÖSCHEN",
"HEAD": "HEAD",
"New Review": "Neue Bewertung",
"Triggers when there is new review": "Wird ausgelöst, wenn neue Rezension vorhanden ist",
"Account": "Konto",
"Location": "Standort"
}

View File

@@ -0,0 +1,30 @@
{
"Manage your business on Google": "Administrar tu negocio en Google",
"Create or Update Reply": "Crear o actualizar respuesta",
"Custom API Call": "Llamada API personalizada",
"Create or update a reply to a review if it already exists": "Crear o actualizar una respuesta a una revisión si ya existe",
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
"Review Name": "Revisar nombre",
"Comment": "Comentario",
"Method": "Método",
"Headers": "Encabezados",
"Query Parameters": "Parámetros de consulta",
"Body": "Cuerpo",
"Response is Binary ?": "¿Respuesta es binaria?",
"No Error on Failure": "No hay ningún error en fallo",
"Timeout (in seconds)": "Tiempo de espera (en segundos)",
"You can find the review name from new review trigger": "Puede encontrar el nombre de la reseña del nuevo disparador de reseñas",
"Comment to be added to the review": "Comentario para ser añadido a la revisión",
"Authorization headers are injected automatically from your connection.": "Las cabeceras de autorización se inyectan automáticamente desde tu conexión.",
"Enable for files like PDFs, images, etc..": "Activar para archivos como PDFs, imágenes, etc.",
"GET": "RECOGER",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "BORRAR",
"HEAD": "LIMPIO",
"New Review": "Nueva reseña",
"Triggers when there is new review": "Dispara cuando hay una nueva revisión",
"Account": "Cuenta",
"Location": "Ubicación"
}

View File

@@ -0,0 +1,30 @@
{
"Manage your business on Google": "Gérez votre entreprise sur Google",
"Create or Update Reply": "Créer ou mettre à jour la réponse",
"Custom API Call": "Appel API personnalisé",
"Create or update a reply to a review if it already exists": "Créer ou mettre à jour une réponse à une revue si elle existe déjà",
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
"Review Name": "Nom de la revue",
"Comment": "Commenter",
"Method": "Méthode",
"Headers": "En-têtes",
"Query Parameters": "Paramètres de requête",
"Body": "Corps",
"Response is Binary ?": "La réponse est Binaire ?",
"No Error on Failure": "Aucune erreur en cas d'échec",
"Timeout (in seconds)": "Délai d'attente (en secondes)",
"You can find the review name from new review trigger": "Vous pouvez trouver le nom de la revue à partir d'un nouveau déclencheur de révision",
"Comment to be added to the review": "Commentaire à ajouter à la revue",
"Authorization headers are injected automatically from your connection.": "Les en-têtes d'autorisation sont injectés automatiquement à partir de votre connexion.",
"Enable for files like PDFs, images, etc..": "Activer pour les fichiers comme les PDFs, les images, etc.",
"GET": "OBTENIR",
"POST": "POSTER",
"PATCH": "PATCH",
"PUT": "EFFACER",
"DELETE": "SUPPRIMER",
"HEAD": "HEAD",
"New Review": "Nouveau commentaire",
"Triggers when there is new review": "Déclenche quand il y a une nouvelle revue",
"Account": "Compte client",
"Location": "Localisation"
}

View File

@@ -0,0 +1,29 @@
{
"Google My Business": "Google My Business",
"Manage your business on Google": "Manage your business on Google",
"Create or Update Reply": "Create or Update Reply",
"Custom API Call": "Custom API Call",
"Create or update a reply to a review if it already exists": "Create or update a reply to a review if it already exists",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Review Name": "Review Name",
"Comment": "Comment",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"You can find the review name from new review trigger": "You can find the review name from new review trigger",
"Comment to be added to the review": "Comment to be added to the review",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Review": "New Review",
"Triggers when there is new review": "Triggers when there is new review",
"Account": "Account",
"Location": "Location"
}

View File

@@ -0,0 +1,29 @@
{
"Google My Business": "Google My Business",
"Manage your business on Google": "Manage your business on Google",
"Create or Update Reply": "Create or Update Reply",
"Custom API Call": "Custom API Call",
"Create or update a reply to a review if it already exists": "Create or update a reply to a review if it already exists",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Review Name": "Review Name",
"Comment": "Comment",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"You can find the review name from new review trigger": "You can find the review name from new review trigger",
"Comment to be added to the review": "Comment to be added to the review",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Review": "New Review",
"Triggers when there is new review": "Triggers when there is new review",
"Account": "Account",
"Location": "Location"
}

View File

@@ -0,0 +1,30 @@
{
"Manage your business on Google": "Googleでビジネスを管理する",
"Create or Update Reply": "返信を作成または更新",
"Custom API Call": "カスタムAPI通話",
"Create or update a reply to a review if it already exists": "すでに存在する場合は、レビューに返信を作成または更新",
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
"Review Name": "レビュー名",
"Comment": "コメント",
"Method": "方法",
"Headers": "ヘッダー",
"Query Parameters": "クエリパラメータ",
"Body": "本文",
"Response is Binary ?": "応答はバイナリですか?",
"No Error on Failure": "失敗時にエラーはありません",
"Timeout (in seconds)": "タイムアウト(秒)",
"You can find the review name from new review trigger": "新しいレビュートリガーからレビュー名を見つけることができます",
"Comment to be added to the review": "レビューに追加されるコメント",
"Authorization headers are injected automatically from your connection.": "認証ヘッダは接続から自動的に注入されます。",
"Enable for files like PDFs, images, etc..": "PDF、画像などのファイルを有効にします。",
"GET": "取得",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "削除",
"HEAD": "頭",
"New Review": "新しいレビュー",
"Triggers when there is new review": "新しいレビューがある場合にトリガー",
"Account": "アカウント",
"Location": "場所"
}

View File

@@ -0,0 +1,30 @@
{
"Manage your business on Google": "Beheer uw bedrijf op Google",
"Create or Update Reply": "Maken of bijwerken antwoord",
"Custom API Call": "Custom API Call",
"Create or update a reply to a review if it already exists": "Een reactie op een beoordeling maken of bijwerken als deze al bestaat",
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
"Review Name": "Naam review",
"Comment": "Opmerking",
"Method": "Methode",
"Headers": "Kopteksten",
"Query Parameters": "Query parameters",
"Body": "Lichaam",
"Response is Binary ?": "Antwoord is binair?",
"No Error on Failure": "Geen fout bij fout",
"Timeout (in seconds)": "Time-out (in seconden)",
"You can find the review name from new review trigger": "U vindt de naam van de review op de nieuwe beoordeling trigger",
"Comment to be added to the review": "Opmerking om toe te voegen aan de review",
"Authorization headers are injected automatically from your connection.": "Autorisatie headers worden automatisch geïnjecteerd vanuit uw verbinding.",
"Enable for files like PDFs, images, etc..": "Inschakelen voor bestanden zoals PDF's, afbeeldingen etc..",
"GET": "KRIJG",
"POST": "POSTE",
"PATCH": "BEKIJK",
"PUT": "PUT",
"DELETE": "VERWIJDEREN",
"HEAD": "HOOFD",
"New Review": "Nieuwe review",
"Triggers when there is new review": "Triggert wanneer er nieuwe review is",
"Account": "Rekening",
"Location": "Locatie"
}

View File

@@ -0,0 +1,30 @@
{
"Manage your business on Google": "Gerencie seu negócio no Google",
"Create or Update Reply": "Criar ou Atualizar Resposta",
"Custom API Call": "Chamada de API personalizada",
"Create or update a reply to a review if it already exists": "Criar ou atualizar uma resposta a uma revisão, se ela já existir",
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
"Review Name": "Nome da Revisão",
"Comment": "Comentar",
"Method": "Método",
"Headers": "Cabeçalhos",
"Query Parameters": "Parâmetros da consulta",
"Body": "Conteúdo",
"Response is Binary ?": "A resposta é binária ?",
"No Error on Failure": "Nenhum erro no Failure",
"Timeout (in seconds)": "Tempo limite (em segundos)",
"You can find the review name from new review trigger": "Você pode encontrar o nome da revisão a partir do novo gatilho de revisão",
"Comment to be added to the review": "Comentário para ser adicionado à avaliação",
"Authorization headers are injected automatically from your connection.": "Os cabeçalhos de autorização são inseridos automaticamente a partir da sua conexão.",
"Enable for files like PDFs, images, etc..": "Habilitar para arquivos como PDFs, imagens, etc..",
"GET": "OBTER",
"POST": "POSTAR",
"PATCH": "COMPRAR",
"PUT": "COLOCAR",
"DELETE": "EXCLUIR",
"HEAD": "CABEÇA",
"New Review": "Nova Revisão",
"Triggers when there is new review": "Dispara quando houver uma nova revisão",
"Account": "conta",
"Location": "Local:"
}

View File

@@ -0,0 +1,29 @@
{
"Google My Business": "Google Мой бизнес",
"Manage your business on Google": "Управление бизнесом в Google",
"Create or Update Reply": "Создать или обновить ответ",
"Custom API Call": "Пользовательский вызов API",
"Create or update a reply to a review if it already exists": "Создать или обновить ответ на отзыв, если он уже существует",
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
"Review Name": "Название отзыва",
"Comment": "Комментарий",
"Method": "Метод",
"Headers": "Заголовки",
"Query Parameters": "Параметры запроса",
"Body": "Тело",
"No Error on Failure": "Нет ошибок при ошибке",
"Timeout (in seconds)": "Таймаут (в секундах)",
"You can find the review name from new review trigger": "Вы можете найти имя отзыва из нового триггера",
"Comment to be added to the review": "Комментарий для добавления к отзыву",
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
"GET": "ПОЛУЧИТЬ",
"POST": "ПОСТ",
"PATCH": "ПАТЧ",
"PUT": "ПОКУПИТЬ",
"DELETE": "УДАЛИТЬ",
"HEAD": "HEAD",
"New Review": "Новый отзыв",
"Triggers when there is new review": "Триггеры, когда есть новый отзыв",
"Account": "Аккаунт",
"Location": "Местоположение"
}

View File

@@ -0,0 +1,30 @@
{
"Manage your business on Google": "Manage your business on Google",
"Create or Update Reply": "Create or Update Reply",
"Custom API Call": "Custom API Call",
"Create or update a reply to a review if it already exists": "Create or update a reply to a review if it already exists",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Review Name": "Review Name",
"Comment": "Comment",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"You can find the review name from new review trigger": "You can find the review name from new review trigger",
"Comment to be added to the review": "Comment to be added to the review",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Review": "New Review",
"Triggers when there is new review": "Triggers when there is new review",
"Account": "Account",
"Location": "Location"
}

View File

@@ -0,0 +1,29 @@
{
"Google My Business": "Google My Business",
"Manage your business on Google": "Manage your business on Google",
"Create or Update Reply": "Create or Update Reply",
"Custom API Call": "Custom API Call",
"Create or update a reply to a review if it already exists": "Create or update a reply to a review if it already exists",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Review Name": "Review Name",
"Comment": "Comment",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"You can find the review name from new review trigger": "You can find the review name from new review trigger",
"Comment to be added to the review": "Comment to be added to the review",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Review": "New Review",
"Triggers when there is new review": "Triggers when there is new review",
"Account": "Account",
"Location": "Location"
}

View File

@@ -0,0 +1,30 @@
{
"Manage your business on Google": "Manage your business on Google",
"Create or Update Reply": "Create or Update Reply",
"Custom API Call": "自定义 API 呼叫",
"Create or update a reply to a review if it already exists": "Create or update a reply to a review if it already exists",
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
"Review Name": "Review Name",
"Comment": "Comment",
"Method": "方法",
"Headers": "信头",
"Query Parameters": "查询参数",
"Body": "正文内容",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "失败时没有错误",
"Timeout (in seconds)": "超时(秒)",
"You can find the review name from new review trigger": "You can find the review name from new review trigger",
"Comment to be added to the review": "Comment to be added to the review",
"Authorization headers are injected automatically from your connection.": "授权头自动从您的连接中注入。",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"GET": "获取",
"POST": "帖子",
"PATCH": "PATCH",
"PUT": "弹出",
"DELETE": "删除",
"HEAD": "黑色",
"New Review": "New Review",
"Triggers when there is new review": "Triggers when there is new review",
"Account": "Account",
"Location": "Location"
}

View File

@@ -0,0 +1,39 @@
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import {
OAuth2PropertyValue,
PieceAuth,
createPiece,
} from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/shared';
import { createReply } from './lib/actions/create-reply';
import { newReview } from './lib/triggers/new-review';
export const googleAuth = PieceAuth.OAuth2({
authUrl: 'https://accounts.google.com/o/oauth2/auth',
tokenUrl: 'https://oauth2.googleapis.com/token',
required: true,
scope: ['https://www.googleapis.com/auth/business.manage'],
});
export const googleBusiness = createPiece({
auth: googleAuth,
displayName: 'Google My Business',
description: 'Manage your business on Google',
logoUrl: 'https://cdn.activepieces.com/pieces/google-business.png',
authors: ["kishanprmr","MoShizzle","abuaboud"],
categories: [PieceCategory.MARKETING],
actions: [
createReply,
createCustomApiCallAction({
baseUrl: () => {
return 'https://www.googleapis.com/business/v4';
},
auth: googleAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,
}),
}),
],
triggers: [newReview],
});

View File

@@ -0,0 +1,45 @@
import {
Property,
createAction,
} from '@activepieces/pieces-framework';
import { googleAuth } from '../..';
import { HttpMethod, httpClient, propsValidation } from '@activepieces/pieces-common';
import { z } from 'zod';
export const createReply = createAction({
name: 'create-reply',
displayName: 'Create or Update Reply',
description: 'Create or update a reply to a review if it already exists',
props: {
reviewName: Property.ShortText({
displayName: 'Review Name',
description: 'You can find the review name from new review trigger',
required: true,
}),
comment: Property.LongText({
displayName: 'Comment',
description: 'Comment to be added to the review',
required: true,
}),
},
auth: googleAuth,
async run(ctx) {
const { reviewName, comment } = ctx.propsValue;
await propsValidation.validateZod(ctx.propsValue, {
reviewName: z.string().regex(/accounts\/.*\/locations\/.*\/reviews\/.*/),
});
const response = await httpClient.sendRequest({
url: ` https://mybusiness.googleapis.com/v4/${reviewName}/reply`,
method: HttpMethod.PUT,
headers: {
Authorization: `Bearer ${ctx.auth.access_token}`,
},
body: {
comment,
},
});
return response;
},
});

View File

@@ -0,0 +1,118 @@
import {
Property,
OAuth2PropertyValue,
DropdownOption,
} from '@activepieces/pieces-framework';
import {
httpClient,
HttpMethod,
AuthenticationType,
QueryParams,
} from '@activepieces/pieces-common';
import { googleAuth } from '../..';
export const googleBusinessCommon = {
account: Property.Dropdown({
displayName: 'Account',
required: true,
auth: googleAuth,
refreshers: [],
options: async (propsValue) => {
if (!propsValue['auth']) {
return {
disabled: true,
options: [],
placeholder: 'Please authenticate first',
};
}
const authProp: OAuth2PropertyValue = propsValue[
'auth'
] as OAuth2PropertyValue;
const response = await httpClient.sendRequest<{
accounts: { accountName: string; name: string }[];
}>({
url: 'https://mybusinessbusinessinformation.googleapis.com/v1/accounts',
method: HttpMethod.GET,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: authProp.access_token,
},
});
return {
disabled: false,
options: response.body.accounts.map(
(location: { accountName: string; name: string }) => {
return {
label: location.accountName,
value: location.name,
};
}
),
};
},
}),
location: Property.Dropdown({
displayName: 'Location',
auth: googleAuth,
required: true,
refreshers: ['account'],
options: async (propsValue) => {
if (!propsValue['auth'] || !propsValue['account']) {
return {
disabled: true,
options: [],
placeholder: 'Please select account first',
};
}
const account = propsValue['account'];
const authProp: OAuth2PropertyValue = propsValue[
'auth'
] as OAuth2PropertyValue;
const options: DropdownOption<string>[] = [];
let nextPageToken: string | undefined;
do {
const qs: QueryParams = {
pageSize: '100',
read_mask: 'title,name',
};
if (nextPageToken) {
qs.pageToken = nextPageToken;
}
const response = await httpClient.sendRequest<{
locations: { title: string; name: string }[];
nextPageToken?: string;
}>({
url: `https://mybusinessbusinessinformation.googleapis.com/v1/${account}/locations`,
queryParams: qs,
method: HttpMethod.GET,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: authProp.access_token,
},
});
nextPageToken = response.body.nextPageToken;
if (response.body.locations && Array.isArray(response.body.locations)) {
for (const location of response.body.locations) {
options.push({
label: location.title,
value: location.name,
});
}
}
} while (nextPageToken);
return {
disabled: false,
options,
};
},
}),
};

View File

@@ -0,0 +1,88 @@
import {
DedupeStrategy,
httpClient,
HttpMethod,
Polling,
pollingHelper,
} from '@activepieces/pieces-common';
import {
AppConnectionValueForAuthProperty,
createTrigger,
OAuth2PropertyValue,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import dayjs from 'dayjs';
import { googleBusinessCommon } from '../common/common';
import { googleAuth } from '../..';
export const newReview = createTrigger({
name: 'new_review',
displayName: 'New Review',
description: 'Triggers when there is new review',
auth: googleAuth,
props: {
account: googleBusinessCommon.account,
location: googleBusinessCommon.location,
},
sampleData: {},
type: TriggerStrategy.POLLING,
async test(ctx) {
return await pollingHelper.test(polling, ctx);
},
async onEnable(ctx) {
await pollingHelper.onEnable(polling, {
auth: ctx.auth,
store: ctx.store,
propsValue: ctx.propsValue,
});
},
async onDisable(ctx) {
await pollingHelper.onDisable(polling, {
auth: ctx.auth,
store: ctx.store,
propsValue: ctx.propsValue,
});
},
async run(ctx) {
return await pollingHelper.poll(polling, ctx);
},
});
const polling: Polling<
AppConnectionValueForAuthProperty<typeof googleAuth>,
{ location: string; account: string }
> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ propsValue, lastFetchEpochMS, auth }) => {
const items = await getResponse(
auth,
propsValue.location,
propsValue.account
);
return items.map((item) => ({
epochMilliSeconds: dayjs(item.createTime).valueOf(),
data: item,
}));
},
};
const getResponse = async (
authentication: OAuth2PropertyValue,
location: string,
account: string
) => {
const response = await httpClient.sendRequest<{
reviews: { createTime: string }[];
}>({
url: ` https://mybusiness.googleapis.com/v4/${account}/${location}/reviews`,
method: HttpMethod.GET,
headers: {
Authorization: `Bearer ${authentication.access_token}`,
},
queryParams: {
pageSize: '100',
orderBy: 'updateTime desc',
},
});
return response.body['reviews'] ?? [];
};