notifications client (#949)
This commit is contained in:
@@ -18,6 +18,7 @@ import AdminShippingProfilesResource from "./shipping-profiles"
|
||||
import AdminStoresResource from "./store"
|
||||
import AdminShippingOptionsResource from "./shipping-options"
|
||||
import AdminRegionsResource from "./regions"
|
||||
import AdminNotificationsResource from "./notifications"
|
||||
|
||||
class Admin extends BaseResource {
|
||||
public auth = new AdminAuthResource(this.client)
|
||||
@@ -39,6 +40,7 @@ class Admin extends BaseResource {
|
||||
public store = new AdminStoresResource(this.client)
|
||||
public shippingOptions = new AdminShippingOptionsResource(this.client)
|
||||
public regions = new AdminRegionsResource(this.client)
|
||||
public notifications = new AdminNotificationsResource(this.client)
|
||||
}
|
||||
|
||||
export default Admin
|
||||
|
||||
36
packages/medusa-js/src/resources/admin/notifications.ts
Normal file
36
packages/medusa-js/src/resources/admin/notifications.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
AdminGetNotificationsParams,
|
||||
AdminNotificationsListRes,
|
||||
AdminNotificationsRes,
|
||||
AdminPostNotificationsNotificationResendReq,
|
||||
} from "@medusajs/medusa"
|
||||
import { ResponsePromise } from "../.."
|
||||
import BaseResource from "../base"
|
||||
|
||||
class AdminNotificationsResource extends BaseResource {
|
||||
list(
|
||||
query: AdminGetNotificationsParams
|
||||
): ResponsePromise<AdminNotificationsListRes> {
|
||||
let path = `/admin/notifications`
|
||||
|
||||
if (query) {
|
||||
const queryString = Object.entries(query).map(([key, value]) => {
|
||||
return `${key}=${value}`
|
||||
})
|
||||
|
||||
path = `/admin/notifications?${queryString.join("&")}`
|
||||
}
|
||||
|
||||
return this.client.request("GET", path)
|
||||
}
|
||||
|
||||
resend(
|
||||
id: string,
|
||||
payload: AdminPostNotificationsNotificationResendReq
|
||||
): ResponsePromise<AdminNotificationsRes> {
|
||||
const path = `/admin/notifications/${id}/resend`
|
||||
return this.client.request("POST", path, payload)
|
||||
}
|
||||
}
|
||||
|
||||
export default AdminNotificationsResource
|
||||
@@ -53,6 +53,9 @@ export type AdminNotificationsListRes = {
|
||||
notifications: Notification[]
|
||||
}
|
||||
|
||||
export type AdminNotificationsRes = PaginatedResponse & {
|
||||
export type AdminNotificationsRes = {
|
||||
notification: Notification
|
||||
}
|
||||
|
||||
export * from "./list-notifications"
|
||||
export * from "./resend-notification"
|
||||
|
||||
Reference in New Issue
Block a user