From 66ffd6fa41347a593fdefaf80a88ce4a1fef873e Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Tue, 30 Jul 2024 14:17:09 +0100 Subject: [PATCH] simplify person creation (#22) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: update flake.lock Flake lock file updates: • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/f4f322d1424aa547eba9cb092f905f5ceb9b639c' (2024-07-29) → 'github:NixOS/nixpkgs/3563397b2f10ffa1891e1a6ce99d13d960d73acd' (2024-07-30) * feat: improve persons creation API * fix: mixin for undefined cases --- src/v1/persons.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/v1/persons.ts b/src/v1/persons.ts index f9bbf88..f70ca92 100644 --- a/src/v1/persons.ts +++ b/src/v1/persons.ts @@ -145,7 +145,7 @@ export type CreatePersonRequest = { /** * The email addresses of the person. If there are no email addresses, please specify an empty array. */ - emails: string[] + emails?: string[] /** * An array of unique identifiers of organizations that the person is associated with. */ @@ -349,7 +349,10 @@ export class Persons { ): Promise { const response = await this.axios.post( personsUrl(), - data, + { + ...data, + emails: data.emails ?? [], // the API requires this field to be present + }, ) return response.data }