From 5812f9e61020f3b54fd9e4b93f80b31aeeb91b39 Mon Sep 17 00:00:00 2001 From: Paul Vaneveld Date: Fri, 19 Jul 2024 15:53:48 +0200 Subject: [PATCH] feat: Add support for customer set custom type --- .changeset/wicked-parents-itch.md | 5 +++++ src/repositories/customer/actions.ts | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .changeset/wicked-parents-itch.md diff --git a/.changeset/wicked-parents-itch.md b/.changeset/wicked-parents-itch.md new file mode 100644 index 00000000..072fd4cb --- /dev/null +++ b/.changeset/wicked-parents-itch.md @@ -0,0 +1,5 @@ +--- +"@labdigital/commercetools-mock": patch +--- + +Add support for customer set custom type diff --git a/src/repositories/customer/actions.ts b/src/repositories/customer/actions.ts index d909c3f5..839fd4b9 100644 --- a/src/repositories/customer/actions.ts +++ b/src/repositories/customer/actions.ts @@ -5,6 +5,7 @@ import type { CustomerSetAuthenticationModeAction, CustomerSetCompanyNameAction, CustomerSetCustomFieldAction, + CustomerSetCustomTypeAction, CustomerSetCustomerNumberAction, CustomerSetExternalIdAction, CustomerSetFirstNameAction, @@ -25,7 +26,7 @@ import { UpdateHandlerInterface, type RepositoryContext, } from "../abstract"; -import { createAddress } from "../helpers"; +import { createAddress, createCustomFields } from "../helpers"; export class CustomerUpdateHandler extends AbstractUpdateHandler @@ -143,6 +144,22 @@ export class CustomerUpdateHandler resource.custom.fields[name] = value; } + setCustomType( + context: RepositoryContext, + resource: Writable, + { type, fields }: CustomerSetCustomTypeAction, + ) { + if (type) { + resource.custom = createCustomFields( + { type, fields }, + context.projectKey, + this._storage, + ); + } else { + resource.custom = undefined; + } + } + setExternalId( _context: RepositoryContext, resource: Writable,