From 47168e4f9edd7a021e768c9d65b1986f8c098749 Mon Sep 17 00:00:00 2001 From: CryptoCompiler <72892531+peepopoggers@users.noreply.github.com> Date: Fri, 22 Jan 2021 00:14:22 +0000 Subject: [PATCH] Made if/else for public check a function --- src/util/requestWrapper.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/util/requestWrapper.ts b/src/util/requestWrapper.ts index 4987ef5..d32395f 100644 --- a/src/util/requestWrapper.ts +++ b/src/util/requestWrapper.ts @@ -69,15 +69,17 @@ export default class RequestUtil { * @private Make a HTTP request to a specific endpoint. Private endpoints are automatically signed. */ async _call(method: Method, endpoint: string, params?: any): GenericAPIResponse { - let publicEndpoint = false; - if(endpoint.startsWith('v2/public')){ - publicEndpoint = true; - } - else if(endpoint.startsWith('public/linear/')){ - publicEndpoint = true; + const isPublicEndpoint = (endpoint: string): boolean { + if (endpoint.startsWith('v2/public')) { + return true; + } + if (endpoint.startsWith('public/linear')) { + return true; + } + return false; } - if (publicEndpoint == false) { + if (isPublicEndpoint(endpoint) === false) { if (!this.key || !this.secret) { throw new Error('Private endpoints require api and private keys set'); }