feat: Admin Returns API (#8117)

* feat: Add request item + add shipping APIs

* wip

* finalize workflow

* move steps

* add returns to js-sdk

* few chores

* fix test

* fix another test :)
This commit is contained in:
Oli Juhl
2024-07-15 15:57:06 +02:00
committed by GitHub
parent 53ddea717c
commit 00c7900337
23 changed files with 845 additions and 77 deletions

View File

@@ -14,6 +14,7 @@ import { ProductCollection } from "./product-collection"
import { ProductTag } from "./product-tag"
import { ProductType } from "./product-type"
import { Region } from "./region"
import { Return } from "./return"
import { SalesChannel } from "./sales-channel"
import { ShippingOption } from "./shipping-option"
import { ShippingProfile } from "./shipping-profile"
@@ -47,6 +48,7 @@ export class Admin {
public taxRegion: TaxRegion
public store: Store
public productTag: ProductTag
public return: Return
constructor(client: Client) {
this.invite = new Invite(client)
@@ -72,5 +74,6 @@ export class Admin {
this.taxRegion = new TaxRegion(client)
this.store = new Store(client)
this.productTag = new ProductTag(client)
this.return = new Return(client)
}
}

View File

@@ -0,0 +1,77 @@
import { HttpTypes } from "@medusajs/types"
import { Client } from "../client"
import { ClientHeaders } from "../types"
export class Return {
private client: Client
constructor(client: Client) {
this.client = client
}
async initiateRequest(
body: HttpTypes.AdminInitiateReturnRequest,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
`/admin/returns`,
{
method: "POST",
headers,
body,
query,
}
)
}
async addReturnItem(
id: string,
body: HttpTypes.AdminAddReturnItems,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
`/admin/returns/${id}/request-items`,
{
method: "POST",
headers,
body,
query,
}
)
}
async addReturnShipping(
id: string,
body: HttpTypes.AdminAddReturnShipping,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
`/admin/returns/${id}/shipping-method`,
{
method: "POST",
headers,
body,
query,
}
)
}
async confirmRequest(
id: string,
body: HttpTypes.AdminConfirmReturnRequest,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
`/admin/returns/${id}/request`,
{
method: "POST",
headers,
body,
query,
}
)
}
}