feat(dashboard, order, medusa, types, js-sdk): Request return e2e flow (#7848)
This commit is contained in:
@@ -25,6 +25,7 @@ import { TaxRate } from "./tax-rate"
|
||||
import { TaxRegion } from "./tax-region"
|
||||
import { Upload } from "./upload"
|
||||
import { User } from "./user"
|
||||
import { ReturnReason } from "./return-reason"
|
||||
|
||||
export class Admin {
|
||||
public invite: Invite
|
||||
@@ -37,6 +38,7 @@ export class Admin {
|
||||
public productType: ProductType
|
||||
public upload: Upload
|
||||
public region: Region
|
||||
public returnReason: ReturnReason
|
||||
public stockLocation: StockLocation
|
||||
public salesChannel: SalesChannel
|
||||
public fulfillmentSet: FulfillmentSet
|
||||
@@ -47,12 +49,12 @@ export class Admin {
|
||||
public inventoryItem: InventoryItem
|
||||
public notification: Notification
|
||||
public order: Order
|
||||
public return: Return
|
||||
public taxRate: TaxRate
|
||||
public taxRegion: TaxRegion
|
||||
public store: Store
|
||||
public productTag: ProductTag
|
||||
public user: User
|
||||
public return: Return
|
||||
|
||||
constructor(client: Client) {
|
||||
this.invite = new Invite(client)
|
||||
@@ -65,6 +67,7 @@ export class Admin {
|
||||
this.productType = new ProductType(client)
|
||||
this.upload = new Upload(client)
|
||||
this.region = new Region(client)
|
||||
this.returnReason = new ReturnReason(client)
|
||||
this.stockLocation = new StockLocation(client)
|
||||
this.salesChannel = new SalesChannel(client)
|
||||
this.fulfillmentSet = new FulfillmentSet(client)
|
||||
@@ -75,11 +78,11 @@ export class Admin {
|
||||
this.inventoryItem = new InventoryItem(client)
|
||||
this.notification = new Notification(client)
|
||||
this.order = new Order(client)
|
||||
this.return = new Return(client)
|
||||
this.taxRate = new TaxRate(client)
|
||||
this.taxRegion = new TaxRegion(client)
|
||||
this.store = new Store(client)
|
||||
this.productTag = new ProductTag(client)
|
||||
this.user = new User(client)
|
||||
this.return = new Return(client)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
AdminCreateOrderShipment,
|
||||
FindParams,
|
||||
HttpTypes,
|
||||
PaginatedResponse,
|
||||
@@ -24,6 +23,15 @@ export class Order {
|
||||
)
|
||||
}
|
||||
|
||||
async retrievePreview(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<{ order: HttpTypes.AdminOrder }>(
|
||||
`/admin/orders/${id}/preview`,
|
||||
{
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
queryParams?: FindParams & HttpTypes.AdminOrderFilters,
|
||||
headers?: ClientHeaders
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
export class ReturnReason {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async list(
|
||||
queryParams?: HttpTypes.AdminReturnReasonListParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnReasonsResponse>(
|
||||
"/admin/return-reasons",
|
||||
{
|
||||
headers,
|
||||
query: queryParams,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { FindParams, HttpTypes, SelectParams } from "@medusajs/types"
|
||||
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
@@ -8,6 +9,26 @@ export class Return {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async list(query?: HttpTypes.AdminReturnFilters, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnsResponse>(
|
||||
`/admin/returns`,
|
||||
{
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
|
||||
`/admin/returns/${id}`,
|
||||
{
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async initiateRequest(
|
||||
body: HttpTypes.AdminInitiateReturnRequest,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -24,6 +45,21 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
async cancelRequest(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
|
||||
`/admin/returns/${id}/request`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async addReturnItem(
|
||||
id: string,
|
||||
body: HttpTypes.AdminAddReturnItems,
|
||||
@@ -41,6 +77,40 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
async updateReturnItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
body: HttpTypes.AdminUpdateReturnItems,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
|
||||
`/admin/returns/${id}/request-items/${actionId}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async removeReturnItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
|
||||
`/admin/returns/${id}/request-items/${actionId}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async addReturnShipping(
|
||||
id: string,
|
||||
body: HttpTypes.AdminAddReturnShipping,
|
||||
@@ -58,6 +128,40 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
async updateReturnShipping(
|
||||
id: string,
|
||||
actionId: string,
|
||||
body: HttpTypes.AdminAddReturnShipping,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
|
||||
`/admin/returns/${id}/shipping-method/${actionId}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async deleteReturnShipping(
|
||||
id: string,
|
||||
actionId: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
|
||||
`/admin/returns/${id}/shipping-method/${actionId}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async confirmRequest(
|
||||
id: string,
|
||||
body: HttpTypes.AdminConfirmReturnRequest,
|
||||
|
||||
Reference in New Issue
Block a user