From 810d5dd2856ac389065858f5c1294de93510e676 Mon Sep 17 00:00:00 2001 From: Branko Gvoka Date: Wed, 15 Mar 2023 11:45:33 +0100 Subject: [PATCH] chore: code reorg and clean up --- grid/crm/contacts/maps/pipedrive.suma | 94 +++++++++++++-------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/grid/crm/contacts/maps/pipedrive.suma b/grid/crm/contacts/maps/pipedrive.suma index 3a9bcbca..c1699fe5 100644 --- a/grid/crm/contacts/maps/pipedrive.suma +++ b/grid/crm/contacts/maps/pipedrive.suma @@ -92,53 +92,6 @@ map Search { } } -// Pipedrive rate limits docs: https://pipedrive.readme.io/docs/core-api-concepts-rate-limiting -// -// Last checked 14th March 2023 -// Essential - Enterprise plans - between 20 - 120 requests per 2 seconds per api_token - -// -// Status codes docs: https://pipedrive.readme.io/docs/core-api-concepts-http-status-codes -operation MapError { - statusCode = args.statusCode - detail = args.body.error - - return if (statusCode === 400) { - title = "Bad request" - detail = detail - } - - return if (statusCode === 401) { - title = "Unauthenticated" - detail = detail - } - - return if (statusCode === 402) { - title = "Payment required" - detail = detail - } - - return if (statusCode === 403) { - title = "Unauthorized" - detail = detail - } - - return if (statusCode === 404) { - title = "Not found" - detail = detail - } - - return if (statusCode === 429) { - title = "Too many requests" - detail = detail - } - - return { - title = "Unknown error" - detail = `Unknown error occurred. Status: ${statusCode}. IPData provider error info: ${detail}.` - } -} - operation UpsertOrganization { data = call GetOrganizationByName(input = args.input) @@ -195,3 +148,50 @@ operation GetOrganizationByName { } } + +// Pipedrive rate limits docs: https://pipedrive.readme.io/docs/core-api-concepts-rate-limiting +// +// Last checked 14th March 2023 +// Essential - Enterprise plans - between 20 - 120 requests per 2 seconds per api_token + +// +// Status codes docs: https://pipedrive.readme.io/docs/core-api-concepts-http-status-codes +operation MapError { + statusCode = args.statusCode + detail = args.body.error + + return if (statusCode === 400) { + title = "Bad request" + detail = detail + } + + return if (statusCode === 401) { + title = "Unauthenticated" + detail = detail + } + + return if (statusCode === 402) { + title = "Payment required" + detail = detail + } + + return if (statusCode === 403) { + title = "Unauthorized" + detail = detail + } + + return if (statusCode === 404) { + title = "Not found" + detail = detail + } + + return if (statusCode === 429) { + title = "Too many requests" + detail = detail + } + + return { + title = "Unknown error" + detail = `Unknown error occurred. Status: ${statusCode}. IPData provider error info: ${detail}.` + } +} \ No newline at end of file