chore: Replace reservation customer group client with JS-SDK + clean up (#8857)
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
export class CustomerGroup {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminGetCustomerGroupParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupResponse>(
|
||||
`/admin/customer-groups/${id}`,
|
||||
{
|
||||
method: "GET",
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminGetCustomerGroupsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupListResponse>(
|
||||
`/admin/customer-groups`,
|
||||
{
|
||||
method: "GET",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateCustomerGroup,
|
||||
query?: HttpTypes.AdminGetCustomerGroupsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupResponse>(
|
||||
`/admin/customer-groups`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateCustomerGroup,
|
||||
query?: HttpTypes.AdminGetCustomerGroupsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupResponse>(
|
||||
`/admin/customer-groups/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.DeleteResponse<"customer_group">>(
|
||||
`/admin/customer-groups/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async batchCustomers(
|
||||
id: string,
|
||||
body: HttpTypes.AdminBatchLink,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupResponse>(
|
||||
`/admin/customer-groups/${id}/customers`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { ApiKey } from "./api-key"
|
||||
import { Claim } from "./claim"
|
||||
import { Currency } from "./currency"
|
||||
import { Customer } from "./customer"
|
||||
import { CustomerGroup } from "./customer-group"
|
||||
import { Exchange } from "./exchange"
|
||||
import { Fulfillment } from "./fulfillment"
|
||||
import { FulfillmentProvider } from "./fulfillment-provider"
|
||||
@@ -24,6 +25,7 @@ import { ProductType } from "./product-type"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { RefundReason } from "./refund-reasons"
|
||||
import { Region } from "./region"
|
||||
import Reservation from "./reservation"
|
||||
import { Return } from "./return"
|
||||
import { ReturnReason } from "./return-reason"
|
||||
import { SalesChannel } from "./sales-channel"
|
||||
@@ -73,6 +75,8 @@ export class Admin {
|
||||
public refundReason: RefundReason
|
||||
public paymentCollection: PaymentCollection
|
||||
public apiKey: ApiKey
|
||||
public reservation: Reservation
|
||||
public customerGroup: CustomerGroup
|
||||
|
||||
constructor(client: Client) {
|
||||
this.invite = new Invite(client)
|
||||
@@ -111,5 +115,7 @@ export class Admin {
|
||||
this.exchange = new Exchange(client)
|
||||
this.paymentCollection = new PaymentCollection(client)
|
||||
this.apiKey = new ApiKey(client)
|
||||
this.reservation = new Reservation(client)
|
||||
this.customerGroup = new CustomerGroup(client)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
class Reservation {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminReservationParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationResponse>(
|
||||
`/admin/reservations/${id}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationListResponse>(
|
||||
"/admin/reservations",
|
||||
{
|
||||
method: "GET",
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateReservation,
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationResponse>(
|
||||
"/admin/reservations",
|
||||
{
|
||||
method: "POST",
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateReservation,
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationResponse>(
|
||||
`/admin/reservations/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.DeleteResponse<"reservation">>(
|
||||
`/admin/reservations/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Reservation
|
||||
Reference in New Issue
Block a user