Files
bybit-api/test/response.util.ts
2022-09-08 16:48:33 +01:00

50 lines
1.0 KiB
TypeScript

import { API_ERROR_CODE } from '../src';
export function successResponseList(successMsg: string | null = 'OK') {
return {
result: expect.any(Array),
ret_code: API_ERROR_CODE.SUCCESS,
ret_msg: successMsg,
};
}
export function successResponseObject(successMsg: string | null = 'OK') {
return {
result: expect.any(Object),
ret_code: API_ERROR_CODE.SUCCESS,
ret_msg: successMsg,
};
}
export function successUSDCResponseObject() {
return {
result: expect.any(Object),
...successUSDCEmptyResponseObject(),
};
}
export function successUSDCEmptyResponseObject() {
return {
retCode: API_ERROR_CODE.SUCCESS,
retMsg: expect.stringMatching(
/OK|SUCCESS|success|success\.|Request accepted|/gim
),
};
}
export function errorResponseObject(
result: null | any = null,
ret_code: number,
ret_msg: string
) {
return {
result,
ret_code,
ret_msg,
};
}
export function notAuthenticatedError() {
return new Error('Private endpoints require api and private keys set');
}