feat: add store admin endpoints to medusa-js (#938)
* add: store admin endpoint to medusa-js * add: resource to admin class Co-authored-by: Sebastian Rindom <seb@medusajs.com> Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import AdminReturnReasonsResource from "./return-reasons"
|
||||
import AdminVariantsResource from "./variants"
|
||||
import AdminSwapsResource from "./swaps"
|
||||
import AdminShippingProfilesResource from "./shipping-profiles"
|
||||
import AdminStoresResource from "./store"
|
||||
import AdminShippingOptionsResource from "./shipping-options"
|
||||
import AdminRegionsResource from "./regions"
|
||||
|
||||
@@ -31,6 +32,7 @@ class Admin extends BaseResource {
|
||||
public variants = new AdminVariantsResource(this.client)
|
||||
public swaps = new AdminSwapsResource(this.client)
|
||||
public shippingProfiles = new AdminShippingProfilesResource(this.client)
|
||||
public store = new AdminStoresResource(this.client)
|
||||
public shippingOptions = new AdminShippingOptionsResource(this.client)
|
||||
public regions = new AdminRegionsResource(this.client)
|
||||
}
|
||||
|
||||
59
packages/medusa-js/src/resources/admin/store.ts
Normal file
59
packages/medusa-js/src/resources/admin/store.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import {
|
||||
AdminPaymentProvidersList,
|
||||
AdminPostStoreReq,
|
||||
AdminStoresRes,
|
||||
} from "@medusajs/medusa"
|
||||
import { ResponsePromise } from "../../typings"
|
||||
import BaseResource from "../base"
|
||||
|
||||
class AdminStoresResource extends BaseResource {
|
||||
/**
|
||||
* @description Updates the store
|
||||
* @param payload update to apply to the store.
|
||||
* @returns the updated store.
|
||||
*/
|
||||
update(payload: AdminPostStoreReq): ResponsePromise<AdminStoresRes> {
|
||||
const path = `/admin/store/`
|
||||
return this.client.request("POST", path, payload)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description adds a currency to the store.
|
||||
* @param currency_code code of the currency to add
|
||||
* @returns updated store.
|
||||
*/
|
||||
addCurrency(currency_code: string): ResponsePromise<AdminStoresRes> {
|
||||
const path = `/admin/store/${currency_code}`
|
||||
return this.client.request("POST", path)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description deletes a currency from the available store currencies
|
||||
* @param currency_code currency code of the currency to delete from the store.
|
||||
* @returns updated store
|
||||
*/
|
||||
deleteCurrency(currency_code: string): ResponsePromise<AdminStoresRes> {
|
||||
const path = `/admin/store/currencies/${currency_code}`
|
||||
return this.client.request("DELETE", path)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description gets a medusa store
|
||||
* @returns a medusa store
|
||||
*/
|
||||
retrieve(): ResponsePromise<AdminStoresRes> {
|
||||
const path = `/admin/store/`
|
||||
return this.client.request("GET", path)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Lists the store's payment providers
|
||||
* @returns a list of payment providers configured on the store
|
||||
*/
|
||||
listPaymentProviders(): ResponsePromise<AdminPaymentProvidersList> {
|
||||
const path = `/admin/store/payment-providers`
|
||||
return this.client.request("GET", path)
|
||||
}
|
||||
}
|
||||
|
||||
export default AdminStoresResource
|
||||
@@ -31,6 +31,7 @@ export * from "./routes/admin/orders"
|
||||
export * from "./routes/admin/variants"
|
||||
export * from "./routes/admin/return-reasons"
|
||||
export * from "./routes/admin/swaps"
|
||||
export * from "./routes/admin/store"
|
||||
export * from "./routes/admin/returns"
|
||||
export * from "./routes/admin/shipping-options"
|
||||
export * from "./routes/admin/regions"
|
||||
|
||||
@@ -32,3 +32,5 @@ export type AdminStoresRes = {
|
||||
export type AdminPaymentProvidersList = {
|
||||
payment_providers: PaymentProvider[]
|
||||
}
|
||||
|
||||
export * from "./update-store"
|
||||
|
||||
@@ -3,7 +3,7 @@ import { StoreService } from "../../../../services"
|
||||
/**
|
||||
* @oas [delete] /store/currencies/{code}
|
||||
* operationId: "DeleteStoreCurrenciesCode"
|
||||
* summary: "Remvoe a Currency Code"
|
||||
* summary: "Remove a Currency Code"
|
||||
* description: "Removes a Currency Code from the available currencies."
|
||||
* x-authenticated: true
|
||||
* parameters:
|
||||
|
||||
Reference in New Issue
Block a user