/** * FastAPI * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 0.1.0 * * * 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 { DubbedOutputInAltFormatRequestPayload } from '../model/dubbedOutputInAltFormatRequestPayload'; import { HTTPValidationError } from '../model/hTTPValidationError'; import { Languages } from '../model/languages'; import { RequestDubbedOutputInAltFormat200Response } from '../model/requestDubbedOutputInAltFormat200Response'; import { TaskStatus } from '../model/taskStatus'; import { TranscriptDataType } from '../model/transcriptDataType'; import { TranscriptFileFormat } from '../model/transcriptFileFormat'; import { ValidationError } from '../model/validationError'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'https://client.camb.ai/apis'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export enum DubApiApiKeys { APIKeyHeader, } export class DubApi { protected _basePath = defaultBasePath; protected _defaultHeaders : any = {}; protected _useQuerystring : boolean = false; protected authentications = { 'default': new VoidAuth(), 'APIKeyHeader': new ApiKeyAuth('header', 'x-api-key'), } 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: DubApiApiKeys, value: string) { (this.authentications as any)[DubApiApiKeys[key]].apiKey = value; } public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } /** * * @summary Get Dubbed Output in Alt Format Status * @param taskId */ public async getDubbedOutputInAltFormatStatusById (taskId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TaskStatus; }> { const localVarPath = this.basePath + '/dub-alt-format/{task_id}' .replace('{' + 'task_id' + '}', encodeURIComponent(String(taskId))); 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 'taskId' is not null or undefined if (taskId === null || taskId === undefined) { throw new Error('Required parameter taskId was null or undefined when calling getDubbedOutputInAltFormatStatusById.'); } (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.APIKeyHeader.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.APIKeyHeader.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: TaskStatus; }>((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, "TaskStatus"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Get Dubbed Run Transcript * @param runId * @param language * @param formatType The format to use for the transcription output. Either `srt`, `vtt` or `txt`. Defaults to `txt`. * @param dataType The data type for the transcription being returned. Returns the raw data of the transcription or a presigned url for the file that contains the transcript contents in the specified format. */ public async getDubbedRunTranscript (runId: number, language: Languages, formatType?: TranscriptFileFormat, dataType?: TranscriptDataType, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/transcript/{run_id}/{language}' .replace('{' + 'run_id' + '}', encodeURIComponent(String(runId))) .replace('{' + 'language' + '}', encodeURIComponent(String(language))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); let localVarFormParams: any = {}; // verify required parameter 'runId' is not null or undefined if (runId === null || runId === undefined) { throw new Error('Required parameter runId was null or undefined when calling getDubbedRunTranscript.'); } // verify required parameter 'language' is not null or undefined if (language === null || language === undefined) { throw new Error('Required parameter language was null or undefined when calling getDubbedRunTranscript.'); } if (formatType !== undefined) { localVarQueryParameters['format_type'] = ObjectSerializer.serialize(formatType, "TranscriptFileFormat"); } if (dataType !== undefined) { localVarQueryParameters['data_type'] = ObjectSerializer.serialize(dataType, "TranscriptDataType"); } (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.APIKeyHeader.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.APIKeyHeader.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 Get Dubbed Output in Alt Format * @param runId * @param language * @param dubbedOutputInAltFormatRequestPayload */ public async requestDubbedOutputInAltFormat (runId: number, language: Languages, dubbedOutputInAltFormatRequestPayload: DubbedOutputInAltFormatRequestPayload, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: RequestDubbedOutputInAltFormat200Response; }> { const localVarPath = this.basePath + '/dub-alt-format/{run_id}/{language}' .replace('{' + 'run_id' + '}', encodeURIComponent(String(runId))) .replace('{' + 'language' + '}', encodeURIComponent(String(language))); 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 'runId' is not null or undefined if (runId === null || runId === undefined) { throw new Error('Required parameter runId was null or undefined when calling requestDubbedOutputInAltFormat.'); } // verify required parameter 'language' is not null or undefined if (language === null || language === undefined) { throw new Error('Required parameter language was null or undefined when calling requestDubbedOutputInAltFormat.'); } // verify required parameter 'dubbedOutputInAltFormatRequestPayload' is not null or undefined if (dubbedOutputInAltFormatRequestPayload === null || dubbedOutputInAltFormatRequestPayload === undefined) { throw new Error('Required parameter dubbedOutputInAltFormatRequestPayload was null or undefined when calling requestDubbedOutputInAltFormat.'); } (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, body: ObjectSerializer.serialize(dubbedOutputInAltFormatRequestPayload, "DubbedOutputInAltFormatRequestPayload") }; let authenticationPromise = Promise.resolve(); if (this.authentications.APIKeyHeader.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.APIKeyHeader.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: RequestDubbedOutputInAltFormat200Response; }>((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, "RequestDubbedOutputInAltFormat200Response"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } }