|
19 | 19 |
|
20 | 20 | import Resource from "../services/resource";
|
21 | 21 | import { IRequest } from "../typings/requestOptions";
|
| 22 | +import { TerminalApiResponse } from "../typings/terminal/models"; |
22 | 23 |
|
23 |
| -async function getJsonResponse<T>(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise<string>; |
| 24 | +/** |
| 25 | + * Sends a JSON request to the given resource and returns a string or a deserialized `TerminalApiResponse`. |
| 26 | + * Used by Terminal API /sync method |
| 27 | + * |
| 28 | + * @template T The request type (usually a model or plain object). |
| 29 | + * @param {Resource} resource - The API resource to which the request is sent. |
| 30 | + * @param {T | string} jsonRequest - The request payload, either as an object or raw JSON string. |
| 31 | + * @param {IRequest.Options} [requestOptions] - Optional HTTP request options. |
| 32 | + * @returns {Promise<string | TerminalApiResponse>} A promise resolving to either a raw response string or a `TerminalApiResponse` object. |
| 33 | + * |
| 34 | + * @example |
| 35 | + * const response = await getJsonResponse<TerminalApiRequest>(terminalApiResource, request); |
| 36 | + */ |
| 37 | +async function getJsonResponse<T>(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise<string | TerminalApiResponse>; |
| 38 | +/** |
| 39 | + * Sends a JSON request to the given resource and returns a deserialized response of the expected type. |
| 40 | + * Used by all APIs and Terminal API sync method |
| 41 | + * |
| 42 | + * @template T The request type. |
| 43 | + * @template R The expected deserialized response type. |
| 44 | + * @param {Resource} resource - The API resource to which the request is sent. |
| 45 | + * @param {T | string} jsonRequest - The request payload, either as an object or raw JSON string. |
| 46 | + * @param {IRequest.Options} [requestOptions] - Optional HTTP request options. |
| 47 | + * @returns {Promise<R>} A promise resolving to the deserialized response object. |
| 48 | + * |
| 49 | + * @example |
| 50 | + * const response = await getJsonResponse<MyRequestType, MyResponseType>(resource, request); |
| 51 | + */ |
24 | 52 | async function getJsonResponse<T, R>(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise<R>;
|
25 | 53 |
|
26 | 54 | /**
|
|
0 commit comments