/* tslint:disable */ /* eslint-disable */ /** * DocRaptor * A native client library for the DocRaptor HTML to PDF/XLS service. * * The version of the OpenAPI document: 2.0.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 * as runtime from '../runtime'; import type { AsyncDoc, Doc, DocStatus, } from '../models/index'; import { AsyncDocFromJSON, AsyncDocToJSON, DocFromJSON, DocToJSON, DocStatusFromJSON, DocStatusToJSON, } from '../models/index'; export interface CreateAsyncDocRequest { doc: Doc; } export interface CreateDocRequest { doc: Doc; } export interface CreateHostedAsyncDocRequest { doc: Doc; } export interface CreateHostedDocRequest { doc: Doc; } export interface ExpireRequest { id: string; } export interface GetAsyncDocRequest { id: string; } export interface GetAsyncDocStatusRequest { id: string; } /** * */ export class DocApi extends runtime.BaseAPI { /** * Creates a document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document. */ async createAsyncDocRaw(requestParameters: CreateAsyncDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.doc === null || requestParameters.doc === undefined) { throw new runtime.RequiredError('doc','Required parameter requestParameters.doc was null or undefined when calling createAsyncDoc.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } const response = await this.request({ path: `/async_docs`, method: 'POST', headers: headerParameters, query: queryParameters, body: DocToJSON(requestParameters.doc), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => AsyncDocFromJSON(jsonValue)); } /** * Creates a document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document. */ async createAsyncDoc(requestParameters: CreateAsyncDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createAsyncDocRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates a document synchronously. */ async createDocRaw(requestParameters: CreateDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.doc === null || requestParameters.doc === undefined) { throw new runtime.RequiredError('doc','Required parameter requestParameters.doc was null or undefined when calling createDoc.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } const response = await this.request({ path: `/docs`, method: 'POST', headers: headerParameters, query: queryParameters, body: DocToJSON(requestParameters.doc), }, initOverrides); return new runtime.BlobApiResponse(response); } /** * Creates a document synchronously. */ async createDoc(requestParameters: CreateDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createDocRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates a hosted document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document. */ async createHostedAsyncDocRaw(requestParameters: CreateHostedAsyncDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.doc === null || requestParameters.doc === undefined) { throw new runtime.RequiredError('doc','Required parameter requestParameters.doc was null or undefined when calling createHostedAsyncDoc.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } const response = await this.request({ path: `/hosted_async_docs`, method: 'POST', headers: headerParameters, query: queryParameters, body: DocToJSON(requestParameters.doc), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => AsyncDocFromJSON(jsonValue)); } /** * Creates a hosted document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document. */ async createHostedAsyncDoc(requestParameters: CreateHostedAsyncDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createHostedAsyncDocRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates a hosted document synchronously. */ async createHostedDocRaw(requestParameters: CreateHostedDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.doc === null || requestParameters.doc === undefined) { throw new runtime.RequiredError('doc','Required parameter requestParameters.doc was null or undefined when calling createHostedDoc.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } const response = await this.request({ path: `/hosted_docs`, method: 'POST', headers: headerParameters, query: queryParameters, body: DocToJSON(requestParameters.doc), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DocStatusFromJSON(jsonValue)); } /** * Creates a hosted document synchronously. */ async createHostedDoc(requestParameters: CreateHostedDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createHostedDocRaw(requestParameters, initOverrides); return await response.value(); } /** * Expires a previously created hosted doc. */ async expireRaw(requestParameters: ExpireRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.id === null || requestParameters.id === undefined) { throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling expire.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } const response = await this.request({ path: `/expire/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))), method: 'PATCH', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Expires a previously created hosted doc. */ async expire(requestParameters: ExpireRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.expireRaw(requestParameters, initOverrides); } /** * Downloads a finished document. */ async getAsyncDocRaw(requestParameters: GetAsyncDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.id === null || requestParameters.id === undefined) { throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling getAsyncDoc.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } const response = await this.request({ path: `/download/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.BlobApiResponse(response); } /** * Downloads a finished document. */ async getAsyncDoc(requestParameters: GetAsyncDocRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getAsyncDocRaw(requestParameters, initOverrides); return await response.value(); } /** * Check on the status of an asynchronously created document. */ async getAsyncDocStatusRaw(requestParameters: GetAsyncDocStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.id === null || requestParameters.id === undefined) { throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling getAsyncDocStatus.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } const response = await this.request({ path: `/status/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DocStatusFromJSON(jsonValue)); } /** * Check on the status of an asynchronously created document. */ async getAsyncDocStatus(requestParameters: GetAsyncDocStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getAsyncDocStatusRaw(requestParameters, initOverrides); return await response.value(); } }