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:
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": ["../../../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# pieces-zoho-invoice
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
|
||||
## Building
|
||||
|
||||
Run `nx build pieces-zoho-invoice` to build the library.
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "@activepieces/piece-zoho-invoice",
|
||||
"version": "0.0.13"
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "pieces-zoho-invoice",
|
||||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "packages/pieces/community/zoho-invoice/src",
|
||||
"projectType": "library",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"outputs": [
|
||||
"{options.outputPath}"
|
||||
],
|
||||
"options": {
|
||||
"outputPath": "dist/packages/pieces/community/zoho-invoice",
|
||||
"tsConfig": "packages/pieces/community/zoho-invoice/tsconfig.lib.json",
|
||||
"packageJson": "packages/pieces/community/zoho-invoice/package.json",
|
||||
"main": "packages/pieces/community/zoho-invoice/src/index.ts",
|
||||
"assets": [
|
||||
"packages/pieces/community/zoho-invoice/*.md",
|
||||
{
|
||||
"input": "packages/pieces/community/zoho-invoice/src/i18n",
|
||||
"output": "./src/i18n",
|
||||
"glob": "**/!(i18n.json)"
|
||||
}
|
||||
],
|
||||
"buildableProjectDepsInPackageJsonType": "dependencies",
|
||||
"updateBuildableProjectDepsInPackageJson": true
|
||||
},
|
||||
"dependsOn": [
|
||||
"^build",
|
||||
"prebuild"
|
||||
]
|
||||
},
|
||||
"publish": {
|
||||
"command": "node tools/scripts/publish.mjs pieces-zoho-invoice {args.ver} {args.tag}",
|
||||
"dependsOn": [
|
||||
"build"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": [
|
||||
"{options.outputFile}"
|
||||
]
|
||||
},
|
||||
"prebuild": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/pieces/community/zoho-invoice",
|
||||
"command": "bun install --no-save --silent"
|
||||
},
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Online invoicing software for businesses": "Online-Rechnungssoftware für Unternehmen",
|
||||
"Region": "Region",
|
||||
"Select your account region": "Wählen Sie Ihre Kontoregion",
|
||||
"US (.com)": "US (.com)",
|
||||
"Europe (.eu)": "Europa (.eu)",
|
||||
"India (.in)": "Indien (.in)",
|
||||
"Australia (.com.au)": "Australien (.com.au)",
|
||||
"Japan (.jp)": "Japan (.jp)",
|
||||
"Custom API Call": "Eigener API-Aufruf",
|
||||
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
|
||||
"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)",
|
||||
"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 Invoice": "Neue Rechnung",
|
||||
"Trigger when a new invoice is received.": "Auslösen wenn eine neue Rechnung empfangen wird."
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Online invoicing software for businesses": "Software de facturación online para empresas",
|
||||
"Region": "Región",
|
||||
"Select your account region": "Seleccione la región de su cuenta",
|
||||
"US (.com)": "EEUU (.com)",
|
||||
"Europe (.eu)": "Europa (.eu)",
|
||||
"India (.in)": "India (.in)",
|
||||
"Australia (.com.au)": "Australia (.com.au)",
|
||||
"Japan (.jp)": "Japón (.jp)",
|
||||
"Custom API Call": "Llamada API personalizada",
|
||||
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
|
||||
"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)",
|
||||
"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 Invoice": "Nueva factura",
|
||||
"Trigger when a new invoice is received.": "Activar cuando se recibe una nueva factura."
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Online invoicing software for businesses": "Logiciel de facturation en ligne pour les entreprises",
|
||||
"Region": "Région",
|
||||
"Select your account region": "Sélectionnez la région de votre compte",
|
||||
"US (.com)": "US (.com)",
|
||||
"Europe (.eu)": "Europe (.eu)",
|
||||
"India (.in)": "Inde (.in)",
|
||||
"Australia (.com.au)": "Australie (.com.au)",
|
||||
"Japan (.jp)": "Japon (.jp)",
|
||||
"Custom API Call": "Appel d'API personnalisé",
|
||||
"Make a custom API call to a specific endpoint": "Passer un appel API personnalisé à un endpoint spécifique",
|
||||
"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'expiration (en secondes)",
|
||||
"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": "GET",
|
||||
"POST": "POST",
|
||||
"PATCH": "PATCH",
|
||||
"PUT": "PUT",
|
||||
"DELETE": "DELETE",
|
||||
"HEAD": "HEAD",
|
||||
"New Invoice": "Nouvelle facture",
|
||||
"Trigger when a new invoice is received.": "Déclencher quand une nouvelle facture est reçue."
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Online invoicing software for businesses": "企業向けオンライン請求書発行ソフトウェア",
|
||||
"Region": "地域",
|
||||
"Select your account region": "アカウントの地域を選択してください",
|
||||
"US (.com)": "米国 (.com)",
|
||||
"Europe (.eu)": "ヨーロッパ (.eu)",
|
||||
"India (.in)": "インド (.in)",
|
||||
"Australia (.com.au)": "オーストラリア (.com.au)",
|
||||
"Japan (.jp)": "日本 (.jp)",
|
||||
"Custom API Call": "カスタムAPI通話",
|
||||
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
|
||||
"Method": "方法",
|
||||
"Headers": "ヘッダー",
|
||||
"Query Parameters": "クエリパラメータ",
|
||||
"Body": "本文",
|
||||
"Response is Binary ?": "応答はバイナリですか?",
|
||||
"No Error on Failure": "失敗時にエラーはありません",
|
||||
"Timeout (in seconds)": "タイムアウト(秒)",
|
||||
"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 Invoice": "新しい請求書",
|
||||
"Trigger when a new invoice is received.": "新しい請求書を受信したときにトリガーします。"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Online invoicing software for businesses": "Online factureringssoftware voor bedrijven",
|
||||
"Region": "Regio",
|
||||
"Select your account region": "Selecteer uw accountregio",
|
||||
"US (.com)": "VS (.com)",
|
||||
"Europe (.eu)": "Europa (.eu)",
|
||||
"India (.in)": "India (.in)",
|
||||
"Australia (.com.au)": "Australië (.com.au)",
|
||||
"Japan (.jp)": "Japan (.jp)",
|
||||
"Custom API Call": "Custom API Call",
|
||||
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
|
||||
"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)",
|
||||
"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 Invoice": "Nieuwe factuur",
|
||||
"Trigger when a new invoice is received.": "Trigger wanneer een nieuwe factuur is ontvangen."
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Online invoicing software for businesses": "Software de faturação on-line para empresas",
|
||||
"Region": "Região",
|
||||
"Select your account region": "Selecione a região de sua conta",
|
||||
"US (.com)": "EUA (.com)",
|
||||
"Europe (.eu)": "Europa (.eu)",
|
||||
"India (.in)": "Índia (.in)",
|
||||
"Australia (.com.au)": "Austrália (.com.au)",
|
||||
"Japan (.jp)": "Japão (.jp)",
|
||||
"Custom API Call": "Chamada de API personalizada",
|
||||
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
|
||||
"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)",
|
||||
"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 Invoice": "Nova fatura",
|
||||
"Trigger when a new invoice is received.": "Acionar quando uma nova fatura for recebida."
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"Zoho Invoice": "Счет Zoho",
|
||||
"Online invoicing software for businesses": "Программное обеспечение для предприятий в режиме онлайн выставления счетов",
|
||||
"Region": "Регион",
|
||||
"Select your account region": "Выберите регион вашего аккаунта",
|
||||
"US (.com)": "США (.com)",
|
||||
"Europe (.eu)": "Европа (.eu)",
|
||||
"India (.in)": "Индия (.н)",
|
||||
"Australia (.com.au)": "Австралия (.com.au)",
|
||||
"Japan (.jp)": "Япония (.jp)",
|
||||
"Custom API Call": "Пользовательский вызов API",
|
||||
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
|
||||
"Method": "Метод",
|
||||
"Headers": "Заголовки",
|
||||
"Query Parameters": "Параметры запроса",
|
||||
"Body": "Тело",
|
||||
"No Error on Failure": "Нет ошибок при ошибке",
|
||||
"Timeout (in seconds)": "Таймаут (в секундах)",
|
||||
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
|
||||
"GET": "ПОЛУЧИТЬ",
|
||||
"POST": "ПОСТ",
|
||||
"PATCH": "ПАТЧ",
|
||||
"PUT": "ПОКУПИТЬ",
|
||||
"DELETE": "УДАЛИТЬ",
|
||||
"HEAD": "HEAD",
|
||||
"New Invoice": "Новый счет",
|
||||
"Trigger when a new invoice is received.": "Срабатывать при получении нового счета."
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Online invoicing software for businesses": "Online invoicing software for businesses",
|
||||
"Region": "Region",
|
||||
"Select your account region": "Select your account region",
|
||||
"US (.com)": "US (.com)",
|
||||
"Europe (.eu)": "Europe (.eu)",
|
||||
"India (.in)": "India (.in)",
|
||||
"Australia (.com.au)": "Australia (.com.au)",
|
||||
"Japan (.jp)": "Japan (.jp)",
|
||||
"Custom API Call": "Custom API Call",
|
||||
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
|
||||
"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)",
|
||||
"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 Invoice": "New Invoice",
|
||||
"Trigger when a new invoice is received.": "Trigger when a new invoice is received."
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"Zoho Invoice": "Zoho Invoice",
|
||||
"Online invoicing software for businesses": "Online invoicing software for businesses",
|
||||
"Region": "Region",
|
||||
"Select your account region": "Select your account region",
|
||||
"US (.com)": "US (.com)",
|
||||
"Europe (.eu)": "Europe (.eu)",
|
||||
"India (.in)": "India (.in)",
|
||||
"Australia (.com.au)": "Australia (.com.au)",
|
||||
"Japan (.jp)": "Japan (.jp)",
|
||||
"Custom API Call": "Custom API Call",
|
||||
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
|
||||
"Method": "Method",
|
||||
"Headers": "Headers",
|
||||
"Query Parameters": "Query Parameters",
|
||||
"Body": "Body",
|
||||
"No Error on Failure": "No Error on Failure",
|
||||
"Timeout (in seconds)": "Timeout (in seconds)",
|
||||
"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 Invoice": "New Invoice",
|
||||
"Trigger when a new invoice is received.": "Trigger when a new invoice is received."
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Online invoicing software for businesses": "Online invoicing software for businesses",
|
||||
"Region": "Region",
|
||||
"Select your account region": "Select your account region",
|
||||
"US (.com)": "US (.com)",
|
||||
"Europe (.eu)": "Europe (.eu)",
|
||||
"India (.in)": "India (.in)",
|
||||
"Australia (.com.au)": "Australia (.com.au)",
|
||||
"Japan (.jp)": "Japan (.jp)",
|
||||
"Custom API Call": "自定义 API 呼叫",
|
||||
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
|
||||
"Method": "方法",
|
||||
"Headers": "信头",
|
||||
"Query Parameters": "查询参数",
|
||||
"Body": "正文内容",
|
||||
"Response is Binary ?": "Response is Binary ?",
|
||||
"No Error on Failure": "失败时没有错误",
|
||||
"Timeout (in seconds)": "超时(秒)",
|
||||
"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 Invoice": "New Invoice",
|
||||
"Trigger when a new invoice is received.": "Trigger when a new invoice is received."
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { createCustomApiCallAction } from '@activepieces/pieces-common';
|
||||
import {
|
||||
createPiece,
|
||||
OAuth2PropertyValue,
|
||||
PieceAuth,
|
||||
Property,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import { PieceCategory } from '@activepieces/shared';
|
||||
import { common } from './lib/common';
|
||||
import { newInvoice } from './lib/triggers/new-invoice';
|
||||
|
||||
export const zohoAuth = PieceAuth.OAuth2({
|
||||
required: true,
|
||||
authUrl: 'https://accounts.zoho.{region}/oauth/v2/auth',
|
||||
tokenUrl: 'https://accounts.zoho.{region}/oauth/v2/token',
|
||||
scope: ['ZohoInvoice.invoices.READ'],
|
||||
props: {
|
||||
region: Property.StaticDropdown({
|
||||
displayName: 'Region',
|
||||
description: 'Select your account region',
|
||||
required: true,
|
||||
options: {
|
||||
options: [
|
||||
{
|
||||
label: 'US (.com)',
|
||||
value: 'com',
|
||||
},
|
||||
{
|
||||
label: 'Europe (.eu)',
|
||||
value: 'eu',
|
||||
},
|
||||
{
|
||||
label: 'India (.in)',
|
||||
value: 'in',
|
||||
},
|
||||
{
|
||||
label: 'Australia (.com.au)',
|
||||
value: 'com.au',
|
||||
},
|
||||
{
|
||||
label: 'Japan (.jp)',
|
||||
value: 'jp',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
export const zohoInvoice = createPiece({
|
||||
displayName: 'Zoho Invoice',
|
||||
description: 'Online invoicing software for businesses',
|
||||
|
||||
auth: zohoAuth,
|
||||
minimumSupportedRelease: '0.30.0',
|
||||
logoUrl: 'https://cdn.activepieces.com/pieces/zoho-invoice.png',
|
||||
categories: [PieceCategory.ACCOUNTING],
|
||||
authors: ["kishanprmr","MoShizzle","abuaboud"],
|
||||
actions: [
|
||||
createCustomApiCallAction({
|
||||
baseUrl: (auth) =>
|
||||
common.baseUrl((auth as OAuth2PropertyValue).props!['region']),
|
||||
auth: zohoAuth,
|
||||
authMapping: async (auth) =>
|
||||
common.authHeaders((auth as OAuth2PropertyValue).access_token),
|
||||
}),
|
||||
],
|
||||
triggers: [newInvoice],
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
|
||||
import { OAuth2PropertyValue } from '@activepieces/pieces-framework';
|
||||
|
||||
export const common = {
|
||||
baseUrl: (region: string) => {
|
||||
return `https://www.zohoapis.${region}/invoice/v3`;
|
||||
},
|
||||
authHeaders: (accessToken: string) => {
|
||||
return {
|
||||
Authorization: `Zoho-oauthtoken ${accessToken}`,
|
||||
};
|
||||
},
|
||||
|
||||
async getInvoices(
|
||||
auth: OAuth2PropertyValue,
|
||||
search?: {
|
||||
createdSince?: string;
|
||||
}
|
||||
) {
|
||||
const q: {
|
||||
last_modified_at?: string;
|
||||
} = {};
|
||||
if (search?.createdSince) q.last_modified_at = search.createdSince;
|
||||
|
||||
const response = await httpClient.sendRequest({
|
||||
url: `${common.baseUrl(auth.props!['region'])}/invoices`,
|
||||
method: HttpMethod.GET,
|
||||
headers: common.authHeaders(auth.access_token),
|
||||
queryParams: q,
|
||||
});
|
||||
|
||||
return response.body['invoices'];
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
import {
|
||||
AppConnectionValueForAuthProperty,
|
||||
PiecePropValueSchema,
|
||||
TriggerStrategy,
|
||||
createTrigger,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import {
|
||||
DedupeStrategy,
|
||||
Polling,
|
||||
pollingHelper,
|
||||
} from '@activepieces/pieces-common';
|
||||
|
||||
import { common } from '../common';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { zohoAuth } from '../..';
|
||||
|
||||
const polling: Polling<
|
||||
AppConnectionValueForAuthProperty<typeof zohoAuth>,
|
||||
Record<string, never>
|
||||
> = {
|
||||
strategy: DedupeStrategy.TIMEBASED,
|
||||
items: async ({ auth, lastFetchEpochMS }) => {
|
||||
const currentValues =
|
||||
(await common.getInvoices(auth, {
|
||||
createdSince: dayjs(lastFetchEpochMS).format('YYYY-MM-DD'),
|
||||
})) ?? [];
|
||||
const items = (currentValues as any[]).map(
|
||||
(item: { created_time: string }) => ({
|
||||
epochMilliSeconds: dayjs(item.created_time).valueOf(),
|
||||
data: item,
|
||||
})
|
||||
);
|
||||
return items;
|
||||
},
|
||||
};
|
||||
|
||||
export const newInvoice = createTrigger({
|
||||
auth: zohoAuth,
|
||||
name: 'new_invoice',
|
||||
displayName: 'New Invoice',
|
||||
description: 'Trigger when a new invoice is received.',
|
||||
props: {},
|
||||
type: TriggerStrategy.POLLING,
|
||||
onEnable: async (context) => {
|
||||
await pollingHelper.onEnable(polling, {
|
||||
auth: context.auth,
|
||||
store: context.store,
|
||||
propsValue: context.propsValue,
|
||||
});
|
||||
},
|
||||
onDisable: async (context) => {
|
||||
await pollingHelper.onDisable(polling, {
|
||||
auth: context.auth,
|
||||
store: context.store,
|
||||
propsValue: context.propsValue,
|
||||
});
|
||||
},
|
||||
run: async (context) => {
|
||||
return await pollingHelper.poll(polling, {
|
||||
auth: context.auth,
|
||||
store: context.store,
|
||||
propsValue: context.propsValue,
|
||||
files: context.files,
|
||||
});
|
||||
},
|
||||
test: async (context) => {
|
||||
return await pollingHelper.test(polling, {
|
||||
auth: context.auth,
|
||||
store: context.store,
|
||||
propsValue: context.propsValue,
|
||||
files: context.files,
|
||||
});
|
||||
},
|
||||
|
||||
sampleData: {},
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"outDir": "../../../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user