83 lines
1.6 KiB
TypeScript
83 lines
1.6 KiB
TypeScript
import { APIClient } from "./ApiClient";
|
|
|
|
export interface InboxEntry {
|
|
id: number;
|
|
file_id: number;
|
|
user_id: number;
|
|
movement_id?: number;
|
|
time: number;
|
|
label?: string;
|
|
amount?: number;
|
|
time_create: number;
|
|
time_update: number;
|
|
}
|
|
|
|
export interface InboxEntryUpdate {
|
|
file_id: number;
|
|
movement_id?: number;
|
|
time: number;
|
|
label?: string;
|
|
amount?: number;
|
|
}
|
|
|
|
export class InboxApi {
|
|
/**
|
|
* Get the number of unmatched entries
|
|
*/
|
|
static async CountUnmatched(): Promise<number> {
|
|
return (
|
|
await APIClient.exec({
|
|
uri: `/inbox/count?include_attached=false`,
|
|
method: "GET",
|
|
})
|
|
).data.count;
|
|
}
|
|
/**
|
|
* Create a new inbox entry
|
|
*/
|
|
static async Create(entry: InboxEntryUpdate): Promise<void> {
|
|
await APIClient.exec({
|
|
uri: `/inbox`,
|
|
method: "POST",
|
|
jsonData: entry,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get the list of inbox entries
|
|
*/
|
|
static async GetList(includeAttached: boolean): Promise<InboxEntry[]> {
|
|
return (
|
|
await APIClient.exec({
|
|
uri: `/inbox?include_attached=${includeAttached ? "true" : "false"}`,
|
|
method: "GET",
|
|
})
|
|
).data;
|
|
}
|
|
|
|
/**
|
|
* Update inbox entry
|
|
*/
|
|
static async Update(
|
|
inbox: InboxEntry & InboxEntryUpdate
|
|
): Promise<InboxEntry> {
|
|
return (
|
|
await APIClient.exec({
|
|
uri: `/inbox/${inbox.id}`,
|
|
method: "PUT",
|
|
jsonData: inbox,
|
|
})
|
|
).data;
|
|
}
|
|
|
|
/**
|
|
* Delete an inbox entry
|
|
*/
|
|
static async Delete(movement: InboxEntry): Promise<void> {
|
|
await APIClient.exec({
|
|
uri: `/inbox/${movement.id}`,
|
|
method: "DELETE",
|
|
});
|
|
}
|
|
}
|