import { FetchFn } from "./types.js"; import { components, paths } from "./schemas/nutripatrol.js"; import * as _$openapi_fetch0 from "openapi-fetch"; import createClient from "openapi-fetch"; //#region src/nutripatrol.d.ts type FlagCreate = components["schemas"]["FlagCreate"]; type Flag = components["schemas"]["Flag"]; type Ticket = components["schemas"]["Ticket"]; type TicketStatus = components["schemas"]["TicketStatus"]; type StatsResponse = components["schemas"]["StatsResponse"]; type IssueType = components["schemas"]["IssueType"]; type ReasonType = components["schemas"]["ReasonType"]; declare class NutriPatrol { private readonly fetch; private readonly baseUrl; readonly client: ReturnType>; constructor(fetch: FetchFn, options?: { baseUrl: string; }); /** * List all flags. * * @returns - A promise that resolves with the list of flag data or error. * @example * const { data, error } = await nutripatrol.getFlags(); * if (error) console.error("Error fetching flags:", error); * else console.log("Flags:", data); */ getFlags(): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query?: never; header?: never; path?: never; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["GetFlagsResponse"]; }; }; }; }, _$openapi_fetch0.FetchOptions<{ parameters: { query?: never; header?: never; path?: never; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["GetFlagsResponse"]; }; }; }; }> | undefined, `${string}/${string}`>>; /** * Retrieves a specific flag by its ID from the NutriPatrol API. * * @param {number} flagId - The ID of the flag to fetch. * @returns A promise that resolves with the flag data if found or error. * @example * const { data, error } = await nutripatrol.getFlagById(123); */ getFlagById(flagId: number): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query?: never; header?: never; path: { flag_id: number; }; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["Flag"]; }; }; 422: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["HTTPValidationError"]; }; }; }; }, { params: { path: { flag_id: number; }; }; }, `${string}/${string}`>>; /** * Create a flag in the NutriPatrol API. * * @param flag - Data for the flag to create. */ createFlag(flag: components["schemas"]["FlagCreate"]): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query?: never; header?: never; path?: never; cookie?: never; }; requestBody: { content: { "application/json": components["schemas"]["FlagCreate"]; }; }; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["Flag"]; }; }; 422: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["HTTPValidationError"]; }; }; }; }, { body: { barcode?: string | null; type: components["schemas"]["IssueType"]; url: string; user_id: string; source: components["schemas"]["SourceType"]; confidence?: number | null; image_id?: string | null; flavor: components["schemas"]["Flavor"]; reason?: string | null; comment?: string | null; created_at?: string; }; }, `${string}/${string}`>>; /** * Get flags by ticket batch. * * @param {number[]} ticketIds - Ids of ticket to get flags from. * @returns A promise that resolves with the flags data or error. * @example * const { data, error } = await nutripatrol.getFlagsByTicketBatch([123, 456]); */ getFlagsByTicketBatch(ticketIds: number[]): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query?: never; header?: never; path?: never; cookie?: never; }; requestBody: { content: { "application/json": components["schemas"]["FlagsByTicketIdRequest"]; }; }; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": unknown; }; }; 422: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["HTTPValidationError"]; }; }; }; }, { body: { ticket_ids: number[]; }; }, `${string}/${string}`>>; /** * List all tickets. * * @param {object} query - Parameters to filter the tickets. * @returns A promise that resolves with the list of tickets or error. * @example * const { data, error } = await nutripatrol.getTickets({ * barcode: "3017620422003", * status: "open", * type: "product", * reason: ["inappropriate", "human"], * page: 1, * page_size: 20, * }); */ getTickets(query: { barcode?: string; status?: components["schemas"]["TicketStatus"]; type?: components["schemas"]["IssueType"]; reason?: components["schemas"]["ReasonType"][]; page?: number; page_size?: number; }): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query?: { barcode?: string | null; status?: components["schemas"]["TicketStatus"] | null; type_?: components["schemas"]["IssueType"] | null; reason?: components["schemas"]["ReasonType"][] | null; page?: number; page_size?: number; }; header?: never; path?: never; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["GetTicketsResponse"]; }; }; 422: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["HTTPValidationError"]; }; }; }; }, { params: { query: { type_: "search" | "image" | "product" | undefined; barcode?: string; status?: components["schemas"]["TicketStatus"]; reason?: components["schemas"]["ReasonType"][]; page?: number; page_size?: number; }; }; }, `${string}/${string}`>>; /** * Retrieves a specific ticket by its ID from the NutriPatrol API. * * @param {number} ticketId - The ID of the ticket to fetch. * @example * const { data, error } = await nutripatrol.getTicketById(123); * if (!data) console.error("Error fetching ticket:", error); */ getTicketById(ticketId: number): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query?: never; header?: never; path: { ticket_id: number; }; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": unknown; }; }; 422: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["HTTPValidationError"]; }; }; }; }, { params: { path: { ticket_id: number; }; }; }, `${string}/${string}`>>; /** * Update a ticket status in the NutriPatrol API. * * @param {number} ticketId - The ID of the ticket to update. * @param {"open" | "closed"} status - The new status of the ticket. * @example * const { data, error } = await nutripatrol.updateTicketStatus(123, "closed"); * if (!data) console.error("Error updating ticket status:", error); */ updateTicketStatus(ticketId: number, status: "open" | "closed"): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query: { status: components["schemas"]["TicketStatus"]; }; header?: never; path: { ticket_id: number; }; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["Ticket"]; }; }; 422: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["HTTPValidationError"]; }; }; }; }, { params: { path: { ticket_id: number; }; query: { status: "open" | "closed"; }; }; }, `${string}/${string}`>>; /** * Get ticket statistics for the last N days. * * Returns the total number of tickets, broken down by status, flavor, and type, * along with the date range of the data. * * @param {number} [nDays] - Number of days to fetch stats for (defaults to 31 on the server). * @returns A promise that resolves with the stats data or error. * @example * const { data, error } = await nutripatrol.getStats(); * if (data) console.log("Total tickets:", data.total_tickets); * * @example * // Get stats for the last 7 days * const { data } = await nutripatrol.getStats(7); */ getStats(nDays?: number): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query?: { n_days?: number; }; header?: never; path?: never; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["StatsResponse"]; }; }; 422: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["HTTPValidationError"]; }; }; }; }, { params: { query: { n_days: number | undefined; }; }; }, `${string}/${string}`>>; /** * Get the status of the NutriPatrol API. * * If the returned `status.data` is undefined, it indicates that * the API is down or unreachable. * * @example * const { data } = await nutripatrol.getApiStatus(); * if (!data) throw new Error("API is down or unreachable"); */ getApiStatus(): Promise<_$openapi_fetch0.FetchResponse<{ parameters: { query?: never; header?: never; path?: never; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["StatusResponse"]; }; }; }; }, _$openapi_fetch0.FetchOptions<{ parameters: { query?: never; header?: never; path?: never; cookie?: never; }; requestBody?: never; responses: { 200: { headers: { [name: string]: unknown; }; content: { "application/json": components["schemas"]["StatusResponse"]; }; }; }; }> | undefined, `${string}/${string}`>>; } //#endregion export { Flag, FlagCreate, IssueType, NutriPatrol, ReasonType, StatsResponse, Ticket, TicketStatus }; //# sourceMappingURL=nutripatrol.d.ts.map