@reservation-studio/electron-types
Version:
TypeScript типове за ReservationStudioElectron
220 lines (219 loc) • 12.7 kB
TypeScript
import { CertificateInfo } from './certificate-info.interface';
import { HttpOptions, HttpResponse } from './http.interface';
import { EnvironmentEnum } from '../enums/envirovment.enum';
import { DeviceInfo, FiscalDeviceResponse, FiscalDeviceStatus, FiscalMemoryRecord, FiscalReceipt, FiscalResponse, ReversalReceipt } from './fiscal-device.interface';
export interface ApiInterface {
/**
* An object representing operations related to certificates.
*/
certificates: {
/**
* Retrieves a list of certificate information.
*
* @return {Promise<CertificateInfo[]>} A promise that resolves to an array of CertificateInfo objects.
*/
list(): Promise<CertificateInfo[]>;
/**
* Validates a PIN against a specific slot.
*
* @param {number} slot - The numerical identifier of the slot to validate the PIN against.
* @param {string} pin - The PIN to be validated.
* @return {Promise<boolean>} A promise that resolves to true if the PIN is valid, otherwise false.
*/
isValidPin(slot: number, pin: string): Promise<boolean>;
};
/**
* Object representing XML-related operations.
*/
xml: {
/**
* Signs the provided XML data using the specified cryptographic token slot and PIN.
*
* @param {string} xml - The XML string to be digitally signed.
* @param {number} slot - The slot number of the cryptographic token to be used for signing.
* @param {string} pin - The personal identification number (PIN) for accessing the cryptographic token.
* @return {Promise<string>} - A promise that resolves to the signed XML string.
*/
sign(xml: string, slot: number, pin: string): Promise<string>;
};
/**
* A utility object for making HTTP requests, providing methods for sending GET and POST requests.
* Supports configuration options such as headers, query parameters, and response handling.
*/
http: {
/**
* Sends an HTTP POST request to the specified URL with the provided data and options.
*
* @param {string} url - The URL to which the POST request is sent.
* @param {any} data - The payload to be sent in the body of the POST request.
* @param {HttpOptions} [options] - Optional configuration for the HTTP request, such as headers and parameters.
* @return {Promise<HttpResponse>} A promise that resolves to the HTTP response object containing status, headers, and data.
*/
post(url: string, data: any, options?: HttpOptions): Promise<HttpResponse>;
/**
* Sends an HTTP GET request to the specified URL with optional configuration settings.
*
* @param {string} url - The target URL to which the GET request will be sent.
* @param {HttpOptions} [options] - Optional settings to configure the HTTP request, such as headers, query parameters, and other request options.
* @return {Promise<HttpResponse>} A promise that resolves to the HTTP response containing the status, headers, and data of the response.
*/
get(url: string, options?: HttpOptions): Promise<HttpResponse>;
};
/**
* Retrieves the current version of the application.
*
* @return {Promise<string>} A promise that resolves to a string representing the version.
*/
version(): Promise<string>;
/**
* Triggers a reload operation. This method is generally used to refresh or reset
* the state of a system, component, or application. The specific behavior of the
* reload operation may vary based on the implementation.
*
* @return {Promise<void>} A promise that resolves when the reload operation is complete.
*/
reload(): Promise<void>;
/**
* Retrieves the current application environment.
*
* @return {Promise<EnvironmentEnum>} A promise that resolves to the enumeration representing the current environment.
*/
environment(): Promise<EnvironmentEnum>;
/**
* An object representing operations related to fiscal devices.
* All methods automatically initialize fiscal devices when needed.
*/
fiscalDevices: {
/**
* Retrieves a list of fiscal devices.
*
* @return {Promise<FiscalDeviceResponse[]>} A promise that resolves to an array of fiscal device responses.
*/
list(): Promise<FiscalDeviceResponse[]>;
/**
* Sets the active fiscal device.
*
* @param {string} serialNumber - The serial number of the device to set as active.
* @return {Promise<void>} A promise that resolves when the device is successfully set as active.
* @throws {Error} If the device with the specified serial number is not found.
*/
setActiveDevice(serialNumber: string): Promise<void>;
/**
* Gets the active fiscal device.
*
* @return {Promise<FiscalDeviceResponse>} A promise that resolves to the active fiscal device information.
* @throws {Error} If no active device is set.
*/
getActiveDevice(): Promise<FiscalDeviceResponse>;
/**
* Gets detailed information about a fiscal device.
*
* @param {string} [serial] - Optional serial number of the device to get information for. If not provided, uses the active device.
* @return {Promise<DeviceInfo>} A promise that resolves to the detailed device information.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
getDeviceInfo(serial?: string): Promise<DeviceInfo>;
/**
* Prints a fiscal receipt using a fiscal device.
*
* @param {FiscalReceipt} receipt - The receipt to print.
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<FiscalResponse>} A promise that resolves to the fiscal response.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
printReceipt(receipt: FiscalReceipt, serial?: string): Promise<FiscalResponse>;
/**
* Prints a non-fiscal receipt using a fiscal device.
*
* @param {FiscalReceipt} receipt - The receipt object containing details to be printed as a non-fiscal receipt.
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<FiscalResponse>} A promise that resolves to a FiscalResponse object indicating the result of the operation.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
printNonFiscalReceipt(receipt: FiscalReceipt, serial?: string): Promise<FiscalResponse>;
/**
* Prints a reversal receipt using a fiscal device.
*
* @param {ReversalReceipt} receipt - The reversal receipt to print.
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<FiscalResponse>} A promise that resolves to the fiscal response.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
printReversalReceipt(receipt: ReversalReceipt, serial?: string): Promise<FiscalResponse>;
/**
* Gets the last fiscal memory record from a fiscal device.
*
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<FiscalMemoryRecord>} A promise that resolves to the last fiscal memory record.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
getLastFiscalRecord(serial?: string): Promise<FiscalMemoryRecord>;
/**
* Gets the status of a fiscal device.
*
* @param {string} [serial] - Optional serial number of the device to get status for. If not provided, uses the active device.
* @return {Promise<FiscalDeviceStatus>} A promise that resolves to the status of the device.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
getStatus(serial?: string): Promise<FiscalDeviceStatus>;
/**
* Prints an X report (daily financial report without reset) using a fiscal device.
*
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<boolean>} A promise that resolves to true if printing was successful.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
printXReport(serial?: string): Promise<boolean>;
/**
* Prints a Z report (daily financial report with reset) using a fiscal device.
*
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<boolean>} A promise that resolves to true if printing was successful.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
printZReport(serial?: string): Promise<boolean>;
/**
* Deposits money into the cash register using a fiscal device.
*
* @param {number} amount - The amount to deposit.
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<boolean>} A promise that resolves to true if the deposit was successful.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
depositMoney(amount: number, serial?: string): Promise<boolean>;
/**
* Withdraws money from the cash register using a fiscal device.
*
* @param {number} amount - The amount to withdraw.
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<boolean>} A promise that resolves to true if the withdrawal was successful.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
withdrawMoney(amount: number, serial?: string): Promise<boolean>;
/**
* Gets the current cash amount in the register using a fiscal device.
*
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<number>} A promise that resolves to the current cash amount.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
getCashAmount(serial?: string): Promise<number>;
/**
* Sets the date and time on a fiscal device.
*
* @param {Date} dateTime - The date and time to set.
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<boolean>} A promise that resolves to true if setting was successful.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
setDateTime(dateTime: Date, serial?: string): Promise<boolean>;
/**
* Prints a duplicate of the last receipt using a fiscal device.
*
* @param {string} [serial] - Optional serial number of the device to use. If not provided, uses the active device.
* @return {Promise<boolean>} A promise that resolves to true if printing was successful.
* @throws {Error} If no active device is set and no serial is provided, or if the device with the specified serial is not found.
*/
printDuplicate(serial?: string): Promise<boolean>;
};
}