feat: customer bulk endpoint form managing customer groups (#9761)

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Frane Polić
2024-10-25 11:55:57 +02:00
committed by GitHub
parent bb6d7c6641
commit 259d050e53
12 changed files with 271 additions and 32 deletions

View File

@@ -210,4 +210,38 @@ export class Customer {
}
)
}
/**
* This method manages customer groups for a customer.
* It sends a request to the [Manage Customers](https://docs.medusajs.com/api/admin#customers_postcustomersidcustomergroups)
* API route.
*
* @param id - The customer's ID.
* @param body - The groups to add customer to or remove customer from.
* @param headers - Headers to pass in the request
* @returns The customers details.
*
* @example
* sdk.admin.customer.batchCustomerGroups("cus_123", {
* add: ["cusgroup_123"],
* remove: ["cusgroup_321"]
* })
* .then(({ customer }) => {
* console.log(customer)
* })
*/
async batchCustomerGroups(
id: string,
body: HttpTypes.AdminBatchLink,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminCustomerResponse>(
`/admin/customers/${id}/customer-groups`,
{
method: "POST",
headers,
body,
}
)
}
}