Made if/else for public check a function
This commit is contained in:
@@ -69,15 +69,17 @@ export default class RequestUtil {
|
|||||||
* @private Make a HTTP request to a specific endpoint. Private endpoints are automatically signed.
|
* @private Make a HTTP request to a specific endpoint. Private endpoints are automatically signed.
|
||||||
*/
|
*/
|
||||||
async _call(method: Method, endpoint: string, params?: any): GenericAPIResponse {
|
async _call(method: Method, endpoint: string, params?: any): GenericAPIResponse {
|
||||||
let publicEndpoint = false;
|
const isPublicEndpoint = (endpoint: string): boolean {
|
||||||
if(endpoint.startsWith('v2/public')){
|
if (endpoint.startsWith('v2/public')) {
|
||||||
publicEndpoint = true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(endpoint.startsWith('public/linear/')){
|
if (endpoint.startsWith('public/linear')) {
|
||||||
publicEndpoint = true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publicEndpoint == false) {
|
if (isPublicEndpoint(endpoint) === false) {
|
||||||
if (!this.key || !this.secret) {
|
if (!this.key || !this.secret) {
|
||||||
throw new Error('Private endpoints require api and private keys set');
|
throw new Error('Private endpoints require api and private keys set');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user