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,30 @@
|
||||
{
|
||||
"Please enter the API Key obtained from Lusha.": "Bitte geben Sie den von Lusha erhaltenen API-Schlüssel ein.",
|
||||
"Search Companies": "Unternehmen suchen",
|
||||
"Enrich Companies": "Unternehmen bereichern",
|
||||
"Custom API Call": "Eigener API-Aufruf",
|
||||
"Search for companies with filters and pagination": "Suche nach Firmen mit Filtern und Seiten",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Unternehmensdetails mithilfe von requestId und Firmen-IDs aus Suchergebnissen erweitern",
|
||||
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
|
||||
"Maximum Results": "Maximale Ergebnisse",
|
||||
"Request Body": "Body anfordern",
|
||||
"Search Results": "Suchergebnisse",
|
||||
"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)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "Maximale Anzahl der zurückzugebenden Unternehmen. Das Maximum ist 10000 Ergebnisse.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "Der JSON-Body für die Suchabfrage. Geben Sie keine Seitenangabe (Seiten) ein, wird er automatisch hinzugefügt.",
|
||||
"The results from the Search Companies step": "Die Ergebnisse der Suchfirmen Schritt",
|
||||
"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"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"Please enter the API Key obtained from Lusha.": "Por favor, introduzca la clave de API obtenida de Lusha.",
|
||||
"Search Companies": "Buscar empresas",
|
||||
"Enrich Companies": "Enriquecer empresas",
|
||||
"Custom API Call": "Llamada API personalizada",
|
||||
"Search for companies with filters and pagination": "Buscar empresas con filtros y paginación",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Enriquece los detalles de las empresas usando requestId e identificadores de la empresa de los resultados de búsqueda",
|
||||
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
|
||||
"Maximum Results": "Resultados máximos",
|
||||
"Request Body": "Cuerpo de solicitud",
|
||||
"Search Results": "Resultados de búsqueda",
|
||||
"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)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "El número máximo de empresas a devolver es de 10000 resultados.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "El cuerpo JSON para la solicitud de búsqueda. No incluya paginación (páginas), se añadirá automáticamente.",
|
||||
"The results from the Search Companies step": "Los resultados del paso de las empresas de búsqueda",
|
||||
"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"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"Please enter the API Key obtained from Lusha.": "Veuillez entrer la clé API obtenue de Lusha.",
|
||||
"Search Companies": "Rechercher des entreprises",
|
||||
"Enrich Companies": "Enrichir les entreprises",
|
||||
"Custom API Call": "Appel API personnalisé",
|
||||
"Search for companies with filters and pagination": "Rechercher des entreprises avec des filtres et des paginations",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Enrichissez les détails des entreprises en utilisant requestId et les identifiants de la société à partir des résultats de recherche",
|
||||
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
|
||||
"Maximum Results": "Nombre maximum de résultats",
|
||||
"Request Body": "Corps de la requête",
|
||||
"Search Results": "Résultats de recherche",
|
||||
"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)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "Nombre maximum d'entreprises à retourner. Le maximum est de 10000 résultats.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "Le corps du JSON pour la requête de recherche. Ne pas inclure la pagination (pages), il sera ajouté automatiquement.",
|
||||
"The results from the Search Companies step": "Les résultats de l'étape de recherche des entreprises",
|
||||
"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": "TÊTE"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"Please enter the API Key obtained from Lusha.": "Lusha から取得した API キーを入力してください。",
|
||||
"Search Companies": "企業を検索",
|
||||
"Enrich Companies": "Enrich Companies",
|
||||
"Custom API Call": "カスタムAPI通話",
|
||||
"Search for companies with filters and pagination": "フィルターとページネーションを持つ会社を検索",
|
||||
"Enrich companies details using requestId and company IDs from search results": "検索結果からのリクエストIDと企業IDを使用して会社の詳細を強化",
|
||||
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
|
||||
"Maximum Results": "最大結果",
|
||||
"Request Body": "リクエスト本文",
|
||||
"Search Results": "検索結果",
|
||||
"Method": "方法",
|
||||
"Headers": "ヘッダー",
|
||||
"Query Parameters": "クエリパラメータ",
|
||||
"Body": "本文",
|
||||
"Response is Binary ?": "応答はバイナリですか?",
|
||||
"No Error on Failure": "失敗時にエラーはありません",
|
||||
"Timeout (in seconds)": "タイムアウト(秒)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "返品する企業の最大数は10000件です。",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "検索リクエストの JSON 本文です。ページネーション(ページ)を含めないでください。自動的に追加されます。",
|
||||
"The results from the Search Companies step": "検索会社のステップの結果",
|
||||
"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": "頭"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"Please enter the API Key obtained from Lusha.": "Voer de API-sleutel van Lusha in.",
|
||||
"Search Companies": "Bedrijven zoeken",
|
||||
"Enrich Companies": "Bedrijven verrijken",
|
||||
"Custom API Call": "Custom API Call",
|
||||
"Search for companies with filters and pagination": "Zoek naar bedrijven met filters en paginering",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Verrijk bedrijven details met behulp van requestId en bedrijfs-IDs uit zoekresultaten",
|
||||
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
|
||||
"Maximum Results": "Maximaal aantal resultaten",
|
||||
"Request Body": "Aanvraag body",
|
||||
"Search Results": "Zoek resultaten",
|
||||
"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)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "Maximum aantal bedrijven om terug te sturen. Het maximum is 10000 resultaten.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "De JSON body voor de zoekaanvraag. Voeg geen paginering (pagina's) toe, deze wordt automatisch toegevoegd.",
|
||||
"The results from the Search Companies step": "De resultaten van de zoekbedrijven stap",
|
||||
"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"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"Please enter the API Key obtained from Lusha.": "Digite a chave de API obtida de Lusha.",
|
||||
"Search Companies": "Buscar Empresas",
|
||||
"Enrich Companies": "Enriquecer empresas",
|
||||
"Custom API Call": "Chamada de API personalizada",
|
||||
"Search for companies with filters and pagination": "Pesquise empresas com filtros e paginação",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Enriquecer detalhes das empresas usando requestId e IDs de empresa dos resultados de pesquisa",
|
||||
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
|
||||
"Maximum Results": "Resultados máximos",
|
||||
"Request Body": "Corpo da solicitação",
|
||||
"Search Results": "Resultados da Pesquisa",
|
||||
"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)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "Número máximo de empresas para retornar. O máximo são 10000 resultados.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "O corpo JSON para a solicitação de pesquisa. Não inclua paginação (páginas), ele será adicionado automaticamente.",
|
||||
"The results from the Search Companies step": "Os resultados da etapa das empresas de pesquisa",
|
||||
"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"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Lusha": "Люша",
|
||||
"Please enter the API Key obtained from Lusha.": "Пожалуйста, введите API-ключ, полученный от Луши.",
|
||||
"Search Companies": "Поиск компаний",
|
||||
"Enrich Companies": "Богатые компании",
|
||||
"Custom API Call": "Пользовательский вызов API",
|
||||
"Search for companies with filters and pagination": "Поиск компаний с фильтрами и пагинацией",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Детали компании, используя ID запроса и ID компании из результатов поиска",
|
||||
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
|
||||
"Maximum Results": "Максимальное количество результатов",
|
||||
"Request Body": "Тело запроса",
|
||||
"Search Results": "Результаты поиска",
|
||||
"Method": "Метод",
|
||||
"Headers": "Заголовки",
|
||||
"Query Parameters": "Параметры запроса",
|
||||
"Body": "Тело",
|
||||
"No Error on Failure": "Нет ошибок при ошибке",
|
||||
"Timeout (in seconds)": "Таймаут (в секундах)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "Максимальное количество организаций для возврата. Максимальное количество - 10000 результатов.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "Тело JSON для запроса поиска. Не включайте в себя пагинацию (страницы), она будет добавлена автоматически.",
|
||||
"The results from the Search Companies step": "Результаты этапа поиска компаний",
|
||||
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
|
||||
"GET": "ПОЛУЧИТЬ",
|
||||
"POST": "ПОСТ",
|
||||
"PATCH": "ПАТЧ",
|
||||
"PUT": "ПОКУПИТЬ",
|
||||
"DELETE": "УДАЛИТЬ",
|
||||
"HEAD": "HEAD"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"Please enter the API Key obtained from Lusha.": "Please enter the API Key obtained from Lusha.",
|
||||
"Search Companies": "Search Companies",
|
||||
"Enrich Companies": "Enrich Companies",
|
||||
"Custom API Call": "Custom API Call",
|
||||
"Search for companies with filters and pagination": "Search for companies with filters and pagination",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Enrich companies details using requestId and company IDs from search results",
|
||||
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
|
||||
"Maximum Results": "Maximum Results",
|
||||
"Request Body": "Request Body",
|
||||
"Search Results": "Search Results",
|
||||
"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)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "Maximum number of companies to return. The maximum is 10000 results.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "The JSON body for the search request. Do not include pagination (pages), it will be added automatically.",
|
||||
"The results from the Search Companies step": "The results from the Search Companies step",
|
||||
"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"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Lusha": "Lusha",
|
||||
"Please enter the API Key obtained from Lusha.": "Please enter the API Key obtained from Lusha.",
|
||||
"Search Companies": "Search Companies",
|
||||
"Enrich Companies": "Enrich Companies",
|
||||
"Custom API Call": "Custom API Call",
|
||||
"Search for companies with filters and pagination": "Search for companies with filters and pagination",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Enrich companies details using requestId and company IDs from search results",
|
||||
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
|
||||
"Maximum Results": "Maximum Results",
|
||||
"Request Body": "Request Body",
|
||||
"Search Results": "Search Results",
|
||||
"Method": "Method",
|
||||
"Headers": "Headers",
|
||||
"Query Parameters": "Query Parameters",
|
||||
"Body": "Body",
|
||||
"No Error on Failure": "No Error on Failure",
|
||||
"Timeout (in seconds)": "Timeout (in seconds)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "Maximum number of companies to return. The maximum is 10000 results.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "The JSON body for the search request. Do not include pagination (pages), it will be added automatically.",
|
||||
"The results from the Search Companies step": "The results from the Search Companies step",
|
||||
"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"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"Please enter the API Key obtained from Lusha.": "Please enter the API Key obtained from Lusha.",
|
||||
"Search Companies": "Search Companies",
|
||||
"Enrich Companies": "Enrich Companies",
|
||||
"Custom API Call": "自定义 API 呼叫",
|
||||
"Search for companies with filters and pagination": "Search for companies with filters and pagination",
|
||||
"Enrich companies details using requestId and company IDs from search results": "Enrich companies details using requestId and company IDs from search results",
|
||||
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
|
||||
"Maximum Results": "Maximum Results",
|
||||
"Request Body": "Request Body",
|
||||
"Search Results": "Search Results",
|
||||
"Method": "方法",
|
||||
"Headers": "信头",
|
||||
"Query Parameters": "查询参数",
|
||||
"Body": "正文内容",
|
||||
"Response is Binary ?": "Response is Binary ?",
|
||||
"No Error on Failure": "失败时没有错误",
|
||||
"Timeout (in seconds)": "超时(秒)",
|
||||
"Maximum number of companies to return. The maximum is 10000 results.": "Maximum number of companies to return. The maximum is 10000 results.",
|
||||
"The JSON body for the search request. Do not include pagination (pages), it will be added automatically.": "The JSON body for the search request. Do not include pagination (pages), it will be added automatically.",
|
||||
"The results from the Search Companies step": "The results from the Search Companies step",
|
||||
"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": "黑色"
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createPiece, PieceAuth } from "@activepieces/pieces-framework";
|
||||
import { createCustomApiCallAction } from '@activepieces/pieces-common';
|
||||
import { searchCompanies } from "./lib/actions/companies/search";
|
||||
import { enrichCompanies } from "./lib/actions/companies/enrich";
|
||||
|
||||
export const lushaAuth = PieceAuth.SecretText({
|
||||
displayName: 'API Key',
|
||||
required: true,
|
||||
description: 'Please enter the API Key obtained from Lusha.',
|
||||
});
|
||||
|
||||
export const lusha = createPiece({
|
||||
displayName: "Lusha",
|
||||
auth: lushaAuth,
|
||||
minimumSupportedRelease: '0.36.1',
|
||||
logoUrl: "https://cdn.activepieces.com/pieces/lusha.png",
|
||||
authors: ["Kevinyu-alan"],
|
||||
actions: [
|
||||
searchCompanies,
|
||||
enrichCompanies,
|
||||
createCustomApiCallAction({
|
||||
baseUrl: () => {
|
||||
return 'https://api.lusha.com';
|
||||
},
|
||||
auth: lushaAuth,
|
||||
authMapping: async (auth) => ({
|
||||
'x-app': 'activepieces',
|
||||
'api_key': auth.secret_text,
|
||||
}),
|
||||
})
|
||||
],
|
||||
triggers: [],
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
import { createAction, Property } from "@activepieces/pieces-framework";
|
||||
import { lushaAuth } from "../../..";
|
||||
|
||||
export const enrichCompanies = createAction({
|
||||
name: 'enrich_companies',
|
||||
auth: lushaAuth,
|
||||
displayName: 'Enrich Companies',
|
||||
description: 'Enrich companies details using requestId and company IDs from search results',
|
||||
props: {
|
||||
searchResults: Property.Json({
|
||||
displayName: 'Search Results',
|
||||
description: 'The results from the Search Companies step',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const searchResults = context.propsValue.searchResults as {
|
||||
requestId: string;
|
||||
data: Array<{ id: string }>;
|
||||
};
|
||||
|
||||
const requestId = searchResults.requestId;
|
||||
const companyIds = searchResults.data.map(item => item.id);
|
||||
|
||||
const payload = {
|
||||
requestId: requestId,
|
||||
companiesIds: companyIds
|
||||
};
|
||||
|
||||
const response = await fetch('https://api.lusha.com/prospecting/company/enrich', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'x-app': 'activepieces',
|
||||
'x-api-key': context.auth.secret_text,
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`HTTP error! status: ${response.status}, body: ${errorText}`);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,101 @@
|
||||
import { createAction, Property } from "@activepieces/pieces-framework";
|
||||
import { lushaAuth } from "../../..";
|
||||
|
||||
export const searchCompanies = createAction({
|
||||
name: 'search_companies',
|
||||
auth: lushaAuth,
|
||||
displayName: 'Search Companies',
|
||||
description: 'Search for companies with filters and pagination',
|
||||
props: {
|
||||
resultLimit: Property.Number({
|
||||
displayName: 'Maximum Results',
|
||||
description: 'Maximum number of companies to return. The maximum is 10000 results.',
|
||||
required: true,
|
||||
defaultValue: 10000
|
||||
}),
|
||||
requestBody: Property.Json({
|
||||
displayName: 'Request Body',
|
||||
description: 'The JSON body for the search request. Do not include pagination (pages), it will be added automatically.',
|
||||
required: true,
|
||||
defaultValue: {
|
||||
"filters": {
|
||||
"contacts": {
|
||||
"include": {
|
||||
"countries": ["ES"]
|
||||
}
|
||||
},
|
||||
"companies": {
|
||||
"include": {
|
||||
"sizes": [
|
||||
{
|
||||
"max": 50,
|
||||
"min": 11
|
||||
}
|
||||
],
|
||||
"locations": [
|
||||
{
|
||||
"country": "Spain"
|
||||
}
|
||||
],
|
||||
"mainIndustriesIds": [17, 14]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
async run(context) {
|
||||
const { resultLimit, requestBody } = context.propsValue;
|
||||
|
||||
if (resultLimit > 10000)
|
||||
throw new Error(`The maximum of result is 10000`);
|
||||
|
||||
// the maximum number of result is 10000
|
||||
let allResults: any[] = []
|
||||
let currentPage = 0
|
||||
let hasMorePages = true
|
||||
|
||||
while (hasMorePages && allResults.length < resultLimit) {
|
||||
const payload = {
|
||||
...requestBody,
|
||||
pages: {
|
||||
page: currentPage,
|
||||
size: 40 // the maximum for the Lusha API
|
||||
}
|
||||
};
|
||||
|
||||
const response = await fetch('https://api.lusha.com/prospecting/company/search', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'x-app': 'activepieces',
|
||||
'x-api-key': context.auth.secret_text,
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`HTTP error! status: ${response.status}, body: ${errorText}`);
|
||||
}
|
||||
|
||||
const responseData = await response.json();
|
||||
|
||||
if (!responseData.data || responseData.data.length === 0) {
|
||||
hasMorePages = false;
|
||||
} else {
|
||||
const remainingNeeded = resultLimit - allResults.length;
|
||||
if (remainingNeeded < 40) {
|
||||
allResults = allResults.concat(responseData.data.slice(0, remainingNeeded));
|
||||
} else {
|
||||
allResults = allResults.concat(responseData.data);
|
||||
}
|
||||
}
|
||||
|
||||
currentPage++;
|
||||
}
|
||||
|
||||
return allResults;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user