From c76283bca6417fc96e1457b15e076f62f5ac6a0c Mon Sep 17 00:00:00 2001 From: Nevo David Date: Fri, 1 Aug 2025 12:43:00 +0700 Subject: [PATCH] feat: handle pinterest errors --- .../integrations/social/pinterest.provider.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts b/libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts index 8bfc048a..ef9814ba 100644 --- a/libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts @@ -30,6 +30,24 @@ export class PinterestProvider editor = 'normal' as const; + public override handleErrors(body: string): + | { + type: 'refresh-token' | 'bad-body'; + value: string; + } + | undefined { + + if (body.indexOf('cover_image_url or cover_image_content_type') > -1) { + return { + type: 'bad-body' as const, + value: + 'When uploading a video, you must add also an image to be used as a cover image.', + }; + } + + return undefined; + } + async refreshToken(refreshToken: string): Promise { const { access_token, expires_in } = await ( await this.fetch('https://api.pinterest.com/v5/oauth/token', {