diff --git a/packages/medusa-js/src/resources/admin/index.ts b/packages/medusa-js/src/resources/admin/index.ts index 7a990ad5cc..b22261cce2 100644 --- a/packages/medusa-js/src/resources/admin/index.ts +++ b/packages/medusa-js/src/resources/admin/index.ts @@ -2,11 +2,13 @@ import BaseResource from "../base" import AdminAuthResource from "./auth" import AdminCustomersResource from "./customers" import AdminDiscountsResource from "./discounts" +import AdminNotesResource from "./notes" class Admin extends BaseResource { public auth = new AdminAuthResource(this.client) public customers = new AdminCustomersResource(this.client) public discounts = new AdminDiscountsResource(this.client) + public notes = new AdminNotesResource(this.client) } export default Admin diff --git a/packages/medusa-js/src/resources/admin/notes.ts b/packages/medusa-js/src/resources/admin/notes.ts new file mode 100644 index 0000000000..ca55d37b76 --- /dev/null +++ b/packages/medusa-js/src/resources/admin/notes.ts @@ -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 { + const path = `/admin/notes` + return this.client.request("POST", path, payload) + } + + update( + id: string, + payload: AdminPostNotesNoteReq + ): ResponsePromise { + const path = `/admin/notes/${id}` + return this.client.request("POST", path, payload) + } + + delete(id: string): ResponsePromise { + const path = `/admin/notes/${id}` + return this.client.request("DELETE", path) + } + + retrieve(id: string): ResponsePromise { + const path = `/admin/notes/${id}` + return this.client.request("GET", path) + } + + list(query: AdminGetNotesParams): ResponsePromise { + 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 diff --git a/packages/medusa/src/api/index.js b/packages/medusa/src/api/index.js index bdc7e62fcf..a7fc2f6b85 100644 --- a/packages/medusa/src/api/index.js +++ b/packages/medusa/src/api/index.js @@ -17,8 +17,9 @@ export default (container, config) => { export * from "./routes/admin/auth" export * from "./routes/admin/customers" -export * from "./routes/admin/draft-orders" 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/store" export * from "./routes/admin/variants"