Adds admin notes API to medusa-js (#923)

This commit is contained in:
Oliver Windall Juhl
2021-12-14 15:27:31 +01:00
committed by GitHub
parent 7f4a7cbed0
commit 4ffe50a798
3 changed files with 55 additions and 1 deletions
@@ -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
@@ -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
+2 -1
View File
@@ -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"