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 { 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 { await APIClient.exec({ uri: `/inbox`, method: "POST", jsonData: entry, }); } /** * Get the list of inbox entries */ static async GetList(includeAttached: boolean): Promise { return ( await APIClient.exec({ uri: `/inbox?include_attached=${includeAttached ? "true" : "false"}`, method: "GET", }) ).data; } /** * Update inbox entry */ static async Update( inbox: InboxEntry & InboxEntryUpdate ): Promise { return ( await APIClient.exec({ uri: `/inbox/${inbox.id}`, method: "PUT", jsonData: inbox, }) ).data; } /** * Delete an inbox entry */ static async Delete(movement: InboxEntry): Promise { await APIClient.exec({ uri: `/inbox/${movement.id}`, method: "DELETE", }); } }