feat(dashboard,types,js-sdk): Cleanup collection domain (#7502)

**What**
- Adds missing collection HttpTypes
- Adds missing sdk functions
- Adds usage of sdk to collection domain.
This commit is contained in:
Kasper Fabricius Kristensen
2024-05-28 18:53:55 +00:00
committed by GitHub
parent 75791f2cbd
commit 5a9922916a
23 changed files with 359 additions and 446 deletions
+82 -1
View File
@@ -203,7 +203,10 @@ export class Admin {
}
)
},
list: async (queryParams?: FindParams, headers?: ClientHeaders) => {
list: async (
queryParams?: FindParams & HttpTypes.AdminCollectionFilters,
headers?: ClientHeaders
) => {
return this.client.fetch<
PaginatedResponse<{ customers: HttpTypes.AdminCustomer[] }>
>(`/admin/customers`, {
@@ -234,4 +237,82 @@ export class Admin {
)
},
}
public collection = {
create: async (
body: HttpTypes.AdminCreateCollection,
query?: SelectParams,
headers?: ClientHeaders
) => {
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
`/admin/collections`,
{
method: "POST",
headers,
body,
query,
}
)
},
update: async (
id: string,
body: HttpTypes.AdminUpdateCollection,
query?: SelectParams,
headers?: ClientHeaders
) => {
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
`/admin/collections/${id}`,
{
method: "POST",
headers,
body,
query,
}
)
},
list: async (queryParams?: FindParams, headers?: ClientHeaders) => {
return this.client.fetch<
PaginatedResponse<{ collections: HttpTypes.AdminCollection[] }>
>(`/admin/collections`, {
headers,
query: queryParams,
})
},
retrieve: async (
id: string,
query?: SelectParams,
headers?: ClientHeaders
) => {
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
`/admin/collections/${id}`,
{
query,
headers,
}
)
},
delete: async (id: string, headers?: ClientHeaders) => {
return this.client.fetch<DeleteResponse<"collection">>(
`/admin/collections/${id}`,
{
method: "DELETE",
headers,
}
)
},
updateProducts: async (
id: string,
body: HttpTypes.AdminUpdateCollectionProducts,
headers?: ClientHeaders
) => {
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
`/admin/collections/${id}/products`,
{
method: "POST",
headers,
body,
}
)
},
}
}