From 1fc88ad63a0840e391031a51189896d082e91cef Mon Sep 17 00:00:00 2001 From: Pavel Baluev Date: Wed, 30 Oct 2024 14:38:29 +0100 Subject: [PATCH] Humaans integration: update "getCustomValue" method --- src/integrations/humaans/index.ts | 13 +++++++------ src/integrations/humaans/types.ts | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/integrations/humaans/index.ts b/src/integrations/humaans/index.ts index 6b37328d..ea8e108e 100644 --- a/src/integrations/humaans/index.ts +++ b/src/integrations/humaans/index.ts @@ -113,12 +113,13 @@ class Humaans extends Integration { personId: string, customFieldId: string ): Promise { - return ( - (await this.makePaginatedRequest('/custom-values', { - personId, - customFieldId, - }).then(fp.first)) || null - ) + return await this.makePaginatedRequest('/custom-values', { + personId, + customFieldId, + }).then((xs) => { + if (!xs.length) return null + return xs.sort(fp.sortBy('updatedAt', 'desc'))[0] + }) } } diff --git a/src/integrations/humaans/types.ts b/src/integrations/humaans/types.ts index 858aecb2..92d60346 100644 --- a/src/integrations/humaans/types.ts +++ b/src/integrations/humaans/types.ts @@ -77,4 +77,6 @@ export type CustomValue = { value: string personId: string customFieldId: string + createdAt: Date + updatedAt: Date }