/** * Sparks OpenAPI * Generated documentation for the Logicdrop Sparks API and OpenAPI clients. Logicdrop Sparks lets users build rules, analyze data, and automate documents. Use it to make decisions faster, generate documents better, and learn from your data. ### Documentation - [User Documentation](https://docs.logicdrop.com) ### Modules - [Sparks Compute](https://docs.logicdrop.com/rules/introduction) - [Sparks Decision Tables](https://docs.logicdrop.com/rules/authoring-decision-tables) - [Sparks Documents](https://docs.logicdrop.com/documents/introduction) ### Clients - [OpenAPI Clients](https://docs.logicdrop.com/development/sample-clients) ### Security - [Authorizing API Requests](https://docs.logicdrop.com/development/authorization) * * The version of the OpenAPI document: v_VERSION_, build# _BUILD_ * Contact: support@logicdrop.com * * 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 = require('request'); import http = require('http'); /* tslint:disable:no-unused-locals */ import { FileResult } from '../model/fileResult'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models'; import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'https://api.staging.com'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export enum ContentServicesApiApiKeys { api, } export class ContentServicesApi { protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; protected authentications = { 'default': new VoidAuth(), 'jwt': new HttpBasicAuth(), 'api': new ApiKeyAuth('header', 'X-Logicdrop-ApiKey'), 'oauth2': new OAuth(), } constructor(oAuth?: OAuth); constructor(oAuth: OAuth, basePath?: string) { if (oAuth) { this.oAuth = oAuth; } if (basePath) { this.basePath = basePath; } } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } get basePath() { return this._basePath; } public setDefaultAuthentication(auth: Authentication) { this.authentications.default = auth; } public setApiKey(key: ContentServicesApiApiKeys, value: string) { (this.authentications as any)[ContentServicesApiApiKeys[key]].apiKey = value; } set oAuth(oAuth: OAuth) { this.authentications.oauth2 = oAuth; } set tokenUrl(tokenUrl: string) { this.authentications.oauth2.tokenUrl = tokenUrl; } set clientId(clientId: string) { this.authentications.oauth2.clientId = clientId; } set clientSecret(clientSecret: string) { this.authentications.oauth2.clientSecret = clientSecret; } /** * Delete a file in content * @summary Delete content * @param client Client name * @param folders Folders * @param filename Filename * @param extension Extension */ public async deleteContent (client: string, folders: string, filename: string, extension: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/content/{client}/{folders}/{filename}.{extension}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))) .replace('{' + 'filename' + '}', encodeURIComponent(String(filename))) .replace('{' + 'extension' + '}', encodeURIComponent(String(extension))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling deleteContent.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling deleteContent.'); } // verify required parameter 'filename' is not null or undefined if (filename === null || filename === undefined) { throw new Error('Required parameter filename was null or undefined when calling deleteContent.'); } // verify required parameter 'extension' is not null or undefined if (extension === null || extension === undefined) { throw new Error('Required parameter extension was null or undefined when calling deleteContent.'); } (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(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Array"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Delete a private file in content * @summary Delete private content * @param client Client name * @param folders Folders * @param filename Filename * @param extension Extension */ public async deletePrivateContent (client: string, folders: string, filename: string, extension: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/content/{client}/private/{folders}/{filename}.{extension}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))) .replace('{' + 'filename' + '}', encodeURIComponent(String(filename))) .replace('{' + 'extension' + '}', encodeURIComponent(String(extension))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling deletePrivateContent.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling deletePrivateContent.'); } // verify required parameter 'filename' is not null or undefined if (filename === null || filename === undefined) { throw new Error('Required parameter filename was null or undefined when calling deletePrivateContent.'); } // verify required parameter 'extension' is not null or undefined if (extension === null || extension === undefined) { throw new Error('Required parameter extension was null or undefined when calling deletePrivateContent.'); } (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(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Array"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Get a file in content * @summary Get content * @param client Client name * @param folders Folders * @param filename Filename * @param extension Extension */ public async getContent (client: string, folders: string, filename: string, extension: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: string; }> { const localVarPath = this.basePath + '/content/{client}/{folders}/{filename}.{extension}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))) .replace('{' + 'filename' + '}', encodeURIComponent(String(filename))) .replace('{' + 'extension' + '}', encodeURIComponent(String(extension))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/octet-stream']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling getContent.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling getContent.'); } // verify required parameter 'filename' is not null or undefined if (filename === null || filename === undefined) { throw new Error('Required parameter filename was null or undefined when calling getContent.'); } // verify required parameter 'extension' is not null or undefined if (extension === null || extension === undefined) { throw new Error('Required parameter extension was null or undefined when calling getContent.'); } (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(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: string; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "string"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Get a private file in content * @summary Get private content * @param client Client name * @param folders Folders * @param filename Filename * @param extension Extension */ public async getPrivateContent (client: string, folders: string, filename: string, extension: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: string; }> { const localVarPath = this.basePath + '/content/{client}/private/{folders}/{filename}.{extension}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))) .replace('{' + 'filename' + '}', encodeURIComponent(String(filename))) .replace('{' + 'extension' + '}', encodeURIComponent(String(extension))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/octet-stream']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling getPrivateContent.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling getPrivateContent.'); } // verify required parameter 'filename' is not null or undefined if (filename === null || filename === undefined) { throw new Error('Required parameter filename was null or undefined when calling getPrivateContent.'); } // verify required parameter 'extension' is not null or undefined if (extension === null || extension === undefined) { throw new Error('Required parameter extension was null or undefined when calling getPrivateContent.'); } (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(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: string; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "string"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Get a signed token for uploading or downloading directly * @summary Get signed token * @param client Client name * @param folders Folders * @param filename Filename * @param extension Extension * @param expires Expiration * @param _public Private or public origin (default false) * @param upload URL for uploading */ public async getSignedToken (client: string, folders: string, filename: string, extension: string, expires?: string, _public?: string, upload?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: FileResult; }> { const localVarPath = this.basePath + '/content/{client}/signed/{folders}/{filename}.{extension}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))) .replace('{' + 'filename' + '}', encodeURIComponent(String(filename))) .replace('{' + 'extension' + '}', encodeURIComponent(String(extension))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling getSignedToken.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling getSignedToken.'); } // verify required parameter 'filename' is not null or undefined if (filename === null || filename === undefined) { throw new Error('Required parameter filename was null or undefined when calling getSignedToken.'); } // verify required parameter 'extension' is not null or undefined if (extension === null || extension === undefined) { throw new Error('Required parameter extension was null or undefined when calling getSignedToken.'); } if (expires !== undefined) { localVarQueryParameters['expires'] = ObjectSerializer.serialize(expires, "string"); } if (_public !== undefined) { localVarQueryParameters['public'] = ObjectSerializer.serialize(_public, "string"); } if (upload !== undefined) { localVarQueryParameters['upload'] = ObjectSerializer.serialize(upload, "string"); } (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(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: FileResult; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "FileResult"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * List files in content * @summary List contents * @param client Client name * @param folders Folders */ public async listContent (client: string, folders: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/content/{client}/{folders}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling listContent.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling listContent.'); } (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(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Array"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * List private files in content * @summary List private contents * @param client Client name * @param folders Folders * @param recursive Include subfolders */ public async listPrivateContent (client: string, folders: string, recursive?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/content/{client}/private/{folders}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling listPrivateContent.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling listPrivateContent.'); } if (recursive !== undefined) { localVarQueryParameters['recursive'] = ObjectSerializer.serialize(recursive, "string"); } (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(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Array"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Upload file(s) to content * @summary Upload content * @param client Client name * @param folders Folders * @param explode If a zip or folder, explode * @param unique Use unique names * @param file File */ public async uploadContent (client: string, folders: string, explode?: string, unique?: string, file?: RequestFile, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/content/{client}/{folders}/upload' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling uploadContent.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling uploadContent.'); } if (explode !== undefined) { localVarQueryParameters['explode'] = ObjectSerializer.serialize(explode, "string"); } if (unique !== undefined) { localVarQueryParameters['unique'] = ObjectSerializer.serialize(unique, "string"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; if (file !== undefined) { const newfile: any = file; localVarFormParams['file'] = { value: newfile.buffer, options: { filename: newfile.originalname, contentType: newfile.mimetype, encoding: newfile.encoding } }; } localVarUseFormData = true; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Array"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Upload file(s) to content * @summary Upload private content * @param client Client name * @param folders Folders * @param explode If a zip or folder, explode * @param unique Use unique names * @param file File */ public async uploadPrivateContent (client: string, folders: string, explode?: string, unique?: string, file?: RequestFile, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/content/{client}/private/{folders}/upload' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'folders' + '}', encodeURIComponent(String(folders))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // 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 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling uploadPrivateContent.'); } // verify required parameter 'folders' is not null or undefined if (folders === null || folders === undefined) { throw new Error('Required parameter folders was null or undefined when calling uploadPrivateContent.'); } if (explode !== undefined) { localVarQueryParameters['explode'] = ObjectSerializer.serialize(explode, "string"); } if (unique !== undefined) { localVarQueryParameters['unique'] = ObjectSerializer.serialize(unique, "string"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; if (file !== undefined) { const newfile: any = file; localVarFormParams['file'] = { value: newfile.buffer, options: { filename: newfile.originalname, contentType: newfile.mimetype, encoding: newfile.encoding } }; } localVarUseFormData = true; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Array"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } }