feat: customer group customers client endpoints (#1221)
* feat: add `listCustomers` (by group) to `medusa-js` * feat: add `useAdminCustomerGroupCustomers` hook * fix: remove log * fix: import/export * fix: change query keys * wip: sublist query keys * fix: revert query factory changes * fix: add query as a param when building the "detail" key * fix: revert keys logic, use special case * fix: query path, change batch keys * change admin customer groups cache key generation * spread query params Co-authored-by: fPolic <frane@medusajs.com>
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
||||
AdminPostCustomerGroupsGroupCustomersBatchReq,
|
||||
AdminDeleteCustomerGroupsGroupCustomerBatchReq,
|
||||
AdminGetCustomerGroupsGroupParams,
|
||||
AdminCustomersListRes,
|
||||
AdminGetCustomersParams,
|
||||
} from "@medusajs/medusa"
|
||||
import qs from "qs"
|
||||
|
||||
@@ -131,6 +133,28 @@ class AdminCustomerGroupsResource extends BaseResource {
|
||||
const path = `/admin/customer-groups/${id}/customers/batch`
|
||||
return this.client.request("DELETE", path, payload, {}, customHeaders)
|
||||
}
|
||||
|
||||
/**
|
||||
* List and count customers that belong to provided customer groups.
|
||||
*
|
||||
* @param id - customer group id
|
||||
* @param query - params for filtering customers
|
||||
* @param customHeaders
|
||||
*/
|
||||
listCustomers(
|
||||
id: string,
|
||||
query?: AdminGetCustomersParams,
|
||||
customHeaders: Record<string, any> = {}
|
||||
): ResponsePromise<AdminCustomersListRes> {
|
||||
let path = `/admin/customer-groups/${id}/customers`
|
||||
|
||||
if (query) {
|
||||
const queryString = qs.stringify(query)
|
||||
path += `?${queryString}`
|
||||
}
|
||||
|
||||
return this.client.request("GET", path, {}, {}, customHeaders)
|
||||
}
|
||||
}
|
||||
|
||||
export default AdminCustomerGroupsResource
|
||||
|
||||
Reference in New Issue
Block a user