/** * Jellyfin API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 10.8.9 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import localVarRequest from 'request'; import http from 'http'; /* tslint:disable:no-unused-locals */ import { PluginInfo } from '../model/pluginInfo'; import { ProblemDetails } from '../model/problemDetails'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://localhost'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export enum PluginsApiApiKeys { CustomAuthentication, } export class PluginsApi { protected _basePath = defaultBasePath; protected _defaultHeaders : any = {}; protected _useQuerystring : boolean = false; protected authentications = { 'default': new VoidAuth(), 'CustomAuthentication': new ApiKeyAuth('header', 'Authorization'), } protected interceptors: Interceptor[] = []; constructor(basePath?: string); constructor(basePathOrUsername: string, password?: string, basePath?: string) { if (password) { if (basePath) { this.basePath = basePath; } } else { if (basePathOrUsername) { this.basePath = basePathOrUsername } } } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } set defaultHeaders(defaultHeaders: any) { this._defaultHeaders = defaultHeaders; } get defaultHeaders() { return this._defaultHeaders; } get basePath() { return this._basePath; } public setDefaultAuthentication(auth: Authentication) { this.authentications.default = auth; } public setApiKey(key: PluginsApiApiKeys, value: string) { (this.authentications as any)[PluginsApiApiKeys[key]].apiKey = value; } public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } /** * * @summary Disable a plugin. * @param pluginId Plugin id. * @param version Plugin version. */ public async disablePlugin (pluginId: string, version: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Plugins/{pluginId}/{version}/Disable' .replace('{' + 'pluginId' + '}', encodeURIComponent(String(pluginId))) .replace('{' + 'version' + '}', encodeURIComponent(String(version))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'pluginId' is not null or undefined if (pluginId === null || pluginId === undefined) { throw new Error('Required parameter pluginId was null or undefined when calling disablePlugin.'); } // verify required parameter 'version' is not null or undefined if (version === null || version === undefined) { throw new Error('Required parameter version was null or undefined when calling disablePlugin.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Enables a disabled plugin. * @param pluginId Plugin id. * @param version Plugin version. */ public async enablePlugin (pluginId: string, version: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Plugins/{pluginId}/{version}/Enable' .replace('{' + 'pluginId' + '}', encodeURIComponent(String(pluginId))) .replace('{' + 'version' + '}', encodeURIComponent(String(version))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'pluginId' is not null or undefined if (pluginId === null || pluginId === undefined) { throw new Error('Required parameter pluginId was null or undefined when calling enablePlugin.'); } // verify required parameter 'version' is not null or undefined if (version === null || version === undefined) { throw new Error('Required parameter version was null or undefined when calling enablePlugin.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Gets plugin configuration. * @param pluginId Plugin id. */ public async getPluginConfiguration (pluginId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: object; }> { const localVarPath = this.basePath + '/Plugins/{pluginId}/Configuration' .replace('{' + 'pluginId' + '}', encodeURIComponent(String(pluginId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'pluginId' is not null or undefined if (pluginId === null || pluginId === undefined) { throw new Error('Required parameter pluginId was null or undefined when calling getPluginConfiguration.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: object; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "object"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Gets a plugin\'s image. * @param pluginId Plugin id. * @param version Plugin version. */ public async getPluginImage (pluginId: string, version: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { const localVarPath = this.basePath + '/Plugins/{pluginId}/{version}/Image' .replace('{' + 'pluginId' + '}', encodeURIComponent(String(pluginId))) .replace('{' + 'version' + '}', encodeURIComponent(String(version))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['image/*', 'application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'pluginId' is not null or undefined if (pluginId === null || pluginId === undefined) { throw new Error('Required parameter pluginId was null or undefined when calling getPluginImage.'); } // verify required parameter 'version' is not null or undefined if (version === null || version === undefined) { throw new Error('Required parameter version was null or undefined when calling getPluginImage.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, encoding: null, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: Buffer; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "Buffer"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Gets a plugin\'s manifest. * @param pluginId Plugin id. */ public async getPluginManifest (pluginId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Plugins/{pluginId}/Manifest' .replace('{' + 'pluginId' + '}', encodeURIComponent(String(pluginId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'pluginId' is not null or undefined if (pluginId === null || pluginId === undefined) { throw new Error('Required parameter pluginId was null or undefined when calling getPluginManifest.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Gets a list of currently installed plugins. */ public async getPlugins (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { const localVarPath = this.basePath + '/Plugins'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: Array; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "Array"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Uninstalls a plugin. * @param pluginId Plugin id. */ public async uninstallPlugin (pluginId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Plugins/{pluginId}' .replace('{' + 'pluginId' + '}', encodeURIComponent(String(pluginId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'pluginId' is not null or undefined if (pluginId === null || pluginId === undefined) { throw new Error('Required parameter pluginId was null or undefined when calling uninstallPlugin.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'DELETE', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Uninstalls a plugin by version. * @param pluginId Plugin id. * @param version Plugin version. */ public async uninstallPluginByVersion (pluginId: string, version: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Plugins/{pluginId}/{version}' .replace('{' + 'pluginId' + '}', encodeURIComponent(String(pluginId))) .replace('{' + 'version' + '}', encodeURIComponent(String(version))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'pluginId' is not null or undefined if (pluginId === null || pluginId === undefined) { throw new Error('Required parameter pluginId was null or undefined when calling uninstallPluginByVersion.'); } // verify required parameter 'version' is not null or undefined if (version === null || version === undefined) { throw new Error('Required parameter version was null or undefined when calling uninstallPluginByVersion.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'DELETE', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Accepts plugin configuration as JSON body. * @summary Updates plugin configuration. * @param pluginId Plugin id. */ public async updatePluginConfiguration (pluginId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/Plugins/{pluginId}/Configuration' .replace('{' + 'pluginId' + '}', encodeURIComponent(String(pluginId))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'pluginId' is not null or undefined if (pluginId === null || pluginId === undefined) { throw new Error('Required parameter pluginId was null or undefined when calling updatePluginConfiguration.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.CustomAuthentication.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } }