Sms & Email
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// Day-end owner report settings: recipients, schedule, preview, test send and send log
|
||||
// (docs/DAY_END_OWNER_REPORT_PLAN.md §3.5). Singleton settings — no id; saves need the ETag.
|
||||
import { apiRequest, apiRequestWithETag, buildQuery } from "@/lib/api-client"
|
||||
import { ApiResult, PagedResponse } from "@/types/common"
|
||||
import {
|
||||
OwnerReportConfig,
|
||||
OwnerReportDispatch,
|
||||
OwnerReportPreview,
|
||||
OwnerReportSendResult,
|
||||
UpdateOwnerReportConfigRequest,
|
||||
} from "@/types/owner-report"
|
||||
|
||||
const BASE = "/settings/owner-report"
|
||||
|
||||
export const ownerReportApi = {
|
||||
get(): Promise<ApiResult<OwnerReportConfig>> {
|
||||
return apiRequestWithETag<OwnerReportConfig>(BASE)
|
||||
},
|
||||
|
||||
update(request: UpdateOwnerReportConfigRequest, ifMatch: string): Promise<ApiResult<OwnerReportConfig>> {
|
||||
return apiRequestWithETag<OwnerReportConfig>(BASE, { method: "PUT", body: request, ifMatch })
|
||||
},
|
||||
|
||||
/** The report as it would be sent for `date` (yyyy-MM-dd; default today) — nothing is sent. */
|
||||
preview(date?: string): Promise<OwnerReportPreview> {
|
||||
return apiRequest<OwnerReportPreview>(`${BASE}/preview${buildQuery({ date })}`)
|
||||
},
|
||||
|
||||
/** Sends the report now to every active recipient (logged as a test). One per minute. */
|
||||
sendTest(date?: string): Promise<OwnerReportSendResult[]> {
|
||||
return apiRequest<OwnerReportSendResult[]>(`${BASE}/test`, { method: "POST", body: { date: date || null } })
|
||||
},
|
||||
|
||||
dispatches(params: { page?: number; pageSize?: number } = {}): Promise<PagedResponse<OwnerReportDispatch>> {
|
||||
return apiRequest<PagedResponse<OwnerReportDispatch>>(`${BASE}/dispatches${buildQuery(params)}`)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user