Skip to content

Commit 375b4db

Browse files
committed
Update getJsonResponse signature to match async method
1 parent d3c16b3 commit 375b4db

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/helpers/getJsonResponse.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,36 @@
1919

2020
import Resource from "../services/resource";
2121
import { IRequest } from "../typings/requestOptions";
22+
import { TerminalApiResponse } from "../typings/terminal/models";
2223

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+
*/
2452
async function getJsonResponse<T, R>(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise<R>;
2553

2654
/**

0 commit comments

Comments
 (0)