Adds admin notes API to medusa-js (#923)
This commit is contained in:
@@ -2,11 +2,13 @@ import BaseResource from "../base"
|
|||||||
import AdminAuthResource from "./auth"
|
import AdminAuthResource from "./auth"
|
||||||
import AdminCustomersResource from "./customers"
|
import AdminCustomersResource from "./customers"
|
||||||
import AdminDiscountsResource from "./discounts"
|
import AdminDiscountsResource from "./discounts"
|
||||||
|
import AdminNotesResource from "./notes"
|
||||||
|
|
||||||
class Admin extends BaseResource {
|
class Admin extends BaseResource {
|
||||||
public auth = new AdminAuthResource(this.client)
|
public auth = new AdminAuthResource(this.client)
|
||||||
public customers = new AdminCustomersResource(this.client)
|
public customers = new AdminCustomersResource(this.client)
|
||||||
public discounts = new AdminDiscountsResource(this.client)
|
public discounts = new AdminDiscountsResource(this.client)
|
||||||
|
public notes = new AdminNotesResource(this.client)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Admin
|
export default Admin
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import {
|
||||||
|
AdminGetNotesParams,
|
||||||
|
AdminNotesDeleteRes,
|
||||||
|
AdminNotesListRes,
|
||||||
|
AdminNotesRes,
|
||||||
|
AdminPostNotesNoteReq,
|
||||||
|
AdminPostNotesReq,
|
||||||
|
} from "@medusajs/medusa"
|
||||||
|
import { ResponsePromise } from "../../typings"
|
||||||
|
import BaseResource from "../base"
|
||||||
|
|
||||||
|
class AdminNotesResource extends BaseResource {
|
||||||
|
create(payload: AdminPostNotesReq): ResponsePromise<AdminNotesRes> {
|
||||||
|
const path = `/admin/notes`
|
||||||
|
return this.client.request("POST", path, payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
update(
|
||||||
|
id: string,
|
||||||
|
payload: AdminPostNotesNoteReq
|
||||||
|
): ResponsePromise<AdminNotesRes> {
|
||||||
|
const path = `/admin/notes/${id}`
|
||||||
|
return this.client.request("POST", path, payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(id: string): ResponsePromise<AdminNotesDeleteRes> {
|
||||||
|
const path = `/admin/notes/${id}`
|
||||||
|
return this.client.request("DELETE", path)
|
||||||
|
}
|
||||||
|
|
||||||
|
retrieve(id: string): ResponsePromise<AdminNotesRes> {
|
||||||
|
const path = `/admin/notes/${id}`
|
||||||
|
return this.client.request("GET", path)
|
||||||
|
}
|
||||||
|
|
||||||
|
list(query: AdminGetNotesParams): ResponsePromise<AdminNotesListRes> {
|
||||||
|
let path = `/admin/notes/`
|
||||||
|
|
||||||
|
if (query) {
|
||||||
|
const queryString = Object.entries(query).map(([key, value]) => {
|
||||||
|
return `${key}=${value}`
|
||||||
|
})
|
||||||
|
|
||||||
|
path = `/admin/notes?${queryString.join("&")}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.client.request("GET", path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AdminNotesResource
|
||||||
@@ -17,8 +17,9 @@ export default (container, config) => {
|
|||||||
|
|
||||||
export * from "./routes/admin/auth"
|
export * from "./routes/admin/auth"
|
||||||
export * from "./routes/admin/customers"
|
export * from "./routes/admin/customers"
|
||||||
export * from "./routes/admin/draft-orders"
|
|
||||||
export * from "./routes/admin/discounts"
|
export * from "./routes/admin/discounts"
|
||||||
|
export * from "./routes/admin/draft-orders"
|
||||||
|
export * from "./routes/admin/notes"
|
||||||
export * from "./routes/admin/notifications"
|
export * from "./routes/admin/notifications"
|
||||||
export * from "./routes/admin/store"
|
export * from "./routes/admin/store"
|
||||||
export * from "./routes/admin/variants"
|
export * from "./routes/admin/variants"
|
||||||
|
|||||||
Reference in New Issue
Block a user