/**
 * Onshape REST API
 * The Onshape REST API consumed by all clients.
 *
 * OpenAPI spec version: 1.93
 * Contact: api-support@onshape.zendesk.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');
import Promise = require('bluebird');

/* tslint:disable:no-unused-locals */
import { BTAppElementCommitTransactionParams } from '../model/bTAppElementCommitTransactionParams';
import { BTAppElementContentInfo } from '../model/bTAppElementContentInfo';
import { BTAppElementHistoryInfo } from '../model/bTAppElementHistoryInfo';
import { BTAppElementModifyInfo } from '../model/bTAppElementModifyInfo';
import { BTAppElementParams } from '../model/bTAppElementParams';
import { BTAppElementReferenceInfo } from '../model/bTAppElementReferenceInfo';
import { BTAppElementReferenceParams } from '../model/bTAppElementReferenceParams';
import { BTAppElementReferenceResolveInfo } from '../model/bTAppElementReferenceResolveInfo';
import { BTAppElementStartTransactionParams } from '../model/bTAppElementStartTransactionParams';
import { BTAppElementUpdateParams } from '../model/bTAppElementUpdateParams';

import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models';

let defaultBasePath = 'http://localhost';

// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================

export enum AppElementsApiApiKeys {
}

export class AppElementsApi {
    protected _basePath = defaultBasePath;
    protected defaultHeaders : any = {};
    protected _useQuerystring : boolean = false;

    protected authentications = {
        'default': <Authentication>new VoidAuth(),
        'OAuth2': new OAuth(),
    }

    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;
    }

    get basePath() {
        return this._basePath;
    }

    public setDefaultAuthentication(auth: Authentication) {
        this.authentications.default = auth;
    }

    public setApiKey(key: AppElementsApiApiKeys, value: string) {
        (this.authentications as any)[AppElementsApiApiKeys[key]].apiKey = value;
    }

    set accessToken(token: string) {
        this.authentications.OAuth2.accessToken = token;
    }

    /**
     * 
     * @summary Commit Transaction
     * @param did 
     * @param eid 
     * @param wid 
     * @param tid 
     * @param bTAppElementCommitTransactionParams 
     */
    public commitTransaction (did: string, eid: string, wid: string, tid: string, bTAppElementCommitTransactionParams: BTAppElementCommitTransactionParams) : Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/w/{wid}/e/{eid}/transactions/{tid}'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wid' + '}', encodeURIComponent(String(wid)))
            .replace('{' + 'tid' + '}', encodeURIComponent(String(tid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling commitTransaction.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling commitTransaction.');
        }

        // verify required parameter 'wid' is not null or undefined
        if (wid === null || wid === undefined) {
            throw new Error('Required parameter wid was null or undefined when calling commitTransaction.');
        }

        // verify required parameter 'tid' is not null or undefined
        if (tid === null || tid === undefined) {
            throw new Error('Required parameter tid was null or undefined when calling commitTransaction.');
        }

        // verify required parameter 'bTAppElementCommitTransactionParams' is not null or undefined
        if (bTAppElementCommitTransactionParams === null || bTAppElementCommitTransactionParams === undefined) {
            throw new Error('Required parameter bTAppElementCommitTransactionParams was null or undefined when calling commitTransaction.');
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'POST',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
            body: ObjectSerializer.serialize(bTAppElementCommitTransactionParams, "BTAppElementCommitTransactionParams")
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementModifyInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Create Element.
     * @param did 
     * @param wid 
     * @param bTAppElementParams 
     */
    public create7 (did: string, wid: string, bTAppElementParams: BTAppElementParams) : Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/w/{wid}'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'wid' + '}', encodeURIComponent(String(wid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling create7.');
        }

        // verify required parameter 'wid' is not null or undefined
        if (wid === null || wid === undefined) {
            throw new Error('Required parameter wid was null or undefined when calling create7.');
        }

        // verify required parameter 'bTAppElementParams' is not null or undefined
        if (bTAppElementParams === null || bTAppElementParams === undefined) {
            throw new Error('Required parameter bTAppElementParams was null or undefined when calling create7.');
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'POST',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
            body: ObjectSerializer.serialize(bTAppElementParams, "BTAppElementParams")
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementModifyInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Create Reference
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     * @param bTAppElementReferenceParams 
     */
    public createReference1 (did: string, eid: string, wvm: string, wvmid: string, bTAppElementReferenceParams: BTAppElementReferenceParams) : Promise<{ response: http.ClientResponse; body: BTAppElementReferenceInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/references'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling createReference1.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling createReference1.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling createReference1.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling createReference1.');
        }

        // verify required parameter 'bTAppElementReferenceParams' is not null or undefined
        if (bTAppElementReferenceParams === null || bTAppElementReferenceParams === undefined) {
            throw new Error('Required parameter bTAppElementReferenceParams was null or undefined when calling createReference1.');
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'POST',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
            body: ObjectSerializer.serialize(bTAppElementReferenceParams, "BTAppElementReferenceParams")
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementReferenceInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementReferenceInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Delete a Sub-element
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     * @param sid 
     * @param transactionId 
     * @param parentChangeId 
     * @param description 
     */
    public deleteContent1 (did: string, eid: string, wvm: string, wvmid: string, sid: string, transactionId?: string, parentChangeId?: string, description?: string) : Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/content/subelements/{sid}'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)))
            .replace('{' + 'sid' + '}', encodeURIComponent(String(sid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling deleteContent1.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling deleteContent1.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling deleteContent1.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling deleteContent1.');
        }

        // verify required parameter 'sid' is not null or undefined
        if (sid === null || sid === undefined) {
            throw new Error('Required parameter sid was null or undefined when calling deleteContent1.');
        }

        if (transactionId !== undefined) {
            localVarQueryParameters['transactionId'] = ObjectSerializer.serialize(transactionId, "string");
        }

        if (parentChangeId !== undefined) {
            localVarQueryParameters['parentChangeId'] = ObjectSerializer.serialize(parentChangeId, "string");
        }

        if (description !== undefined) {
            localVarQueryParameters['description'] = ObjectSerializer.serialize(description, "string");
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'DELETE',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementModifyInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Delete Reference
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     * @param rid 
     * @param transactionId 
     * @param parentChangeId 
     * @param description 
     */
    public deleteReference1 (did: string, eid: string, wvm: string, wvmid: string, rid: string, transactionId?: string, parentChangeId?: string, description?: string) : Promise<{ response: http.ClientResponse; body: BTAppElementReferenceInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/references/{rid}'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)))
            .replace('{' + 'rid' + '}', encodeURIComponent(String(rid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling deleteReference1.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling deleteReference1.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling deleteReference1.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling deleteReference1.');
        }

        // verify required parameter 'rid' is not null or undefined
        if (rid === null || rid === undefined) {
            throw new Error('Required parameter rid was null or undefined when calling deleteReference1.');
        }

        if (transactionId !== undefined) {
            localVarQueryParameters['transactionId'] = ObjectSerializer.serialize(transactionId, "string");
        }

        if (parentChangeId !== undefined) {
            localVarQueryParameters['parentChangeId'] = ObjectSerializer.serialize(parentChangeId, "string");
        }

        if (description !== undefined) {
            localVarQueryParameters['description'] = ObjectSerializer.serialize(description, "string");
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'DELETE',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementReferenceInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementReferenceInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Get History
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     */
    public getHistory (did: string, eid: string, wvm: string, wvmid: string) : Promise<{ response: http.ClientResponse; body: BTAppElementHistoryInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/content/history'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling getHistory.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling getHistory.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling getHistory.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling getHistory.');
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'GET',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementHistoryInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementHistoryInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Get Content
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     * @param transactionId 
     * @param changeId 
     * @param baseChangeId 
     * @param subelementId 
     * @param linkDocumentId 
     */
    public getSubElementContent (did: string, eid: string, wvm: string, wvmid: string, transactionId?: string, changeId?: string, baseChangeId?: string, subelementId?: string, linkDocumentId?: string) : Promise<{ response: http.ClientResponse; body: BTAppElementContentInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/content'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling getSubElementContent.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling getSubElementContent.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling getSubElementContent.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling getSubElementContent.');
        }

        if (transactionId !== undefined) {
            localVarQueryParameters['transactionId'] = ObjectSerializer.serialize(transactionId, "string");
        }

        if (changeId !== undefined) {
            localVarQueryParameters['changeId'] = ObjectSerializer.serialize(changeId, "string");
        }

        if (baseChangeId !== undefined) {
            localVarQueryParameters['baseChangeId'] = ObjectSerializer.serialize(baseChangeId, "string");
        }

        if (subelementId !== undefined) {
            localVarQueryParameters['subelementId'] = ObjectSerializer.serialize(subelementId, "string");
        }

        if (linkDocumentId !== undefined) {
            localVarQueryParameters['linkDocumentId'] = ObjectSerializer.serialize(linkDocumentId, "string");
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'GET',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementContentInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementContentInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Get Sub-element IDs
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     * @param transactionId 
     * @param changeId 
     */
    public getSubelementIds (did: string, eid: string, wvm: string, wvmid: string, transactionId?: string, changeId?: string) : Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/content/ids'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling getSubelementIds.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling getSubelementIds.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling getSubelementIds.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling getSubelementIds.');
        }

        if (transactionId !== undefined) {
            localVarQueryParameters['transactionId'] = ObjectSerializer.serialize(transactionId, "string");
        }

        if (changeId !== undefined) {
            localVarQueryParameters['changeId'] = ObjectSerializer.serialize(changeId, "string");
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'GET',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementModifyInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Resolve Reference
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     * @param rid 
     * @param transactionId 
     * @param parentChangeId 
     * @param includeInternal 
     * @param linkDocumentId 
     */
    public resolveReference1 (did: string, eid: string, wvm: string, wvmid: string, rid: string, transactionId?: string, parentChangeId?: string, includeInternal?: boolean, linkDocumentId?: string) : Promise<{ response: http.ClientResponse; body: BTAppElementReferenceResolveInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/references/{rid}'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)))
            .replace('{' + 'rid' + '}', encodeURIComponent(String(rid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling resolveReference1.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling resolveReference1.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling resolveReference1.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling resolveReference1.');
        }

        // verify required parameter 'rid' is not null or undefined
        if (rid === null || rid === undefined) {
            throw new Error('Required parameter rid was null or undefined when calling resolveReference1.');
        }

        if (transactionId !== undefined) {
            localVarQueryParameters['transactionId'] = ObjectSerializer.serialize(transactionId, "string");
        }

        if (parentChangeId !== undefined) {
            localVarQueryParameters['parentChangeId'] = ObjectSerializer.serialize(parentChangeId, "string");
        }

        if (includeInternal !== undefined) {
            localVarQueryParameters['includeInternal'] = ObjectSerializer.serialize(includeInternal, "boolean");
        }

        if (linkDocumentId !== undefined) {
            localVarQueryParameters['linkDocumentId'] = ObjectSerializer.serialize(linkDocumentId, "string");
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'GET',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementReferenceResolveInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementReferenceResolveInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Start Transaction
     * @param did 
     * @param eid 
     * @param wid 
     * @param bTAppElementStartTransactionParams 
     */
    public startTransaction (did: string, eid: string, wid: string, bTAppElementStartTransactionParams: BTAppElementStartTransactionParams) : Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/w/{wid}/e/{eid}/transactions'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wid' + '}', encodeURIComponent(String(wid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling startTransaction.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling startTransaction.');
        }

        // verify required parameter 'wid' is not null or undefined
        if (wid === null || wid === undefined) {
            throw new Error('Required parameter wid was null or undefined when calling startTransaction.');
        }

        // verify required parameter 'bTAppElementStartTransactionParams' is not null or undefined
        if (bTAppElementStartTransactionParams === null || bTAppElementStartTransactionParams === undefined) {
            throw new Error('Required parameter bTAppElementStartTransactionParams was null or undefined when calling startTransaction.');
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'POST',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
            body: ObjectSerializer.serialize(bTAppElementStartTransactionParams, "BTAppElementStartTransactionParams")
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementModifyInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Update Element
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     * @param bTAppElementUpdateParams 
     */
    public update5 (did: string, eid: string, wvm: string, wvmid: string, bTAppElementUpdateParams: BTAppElementUpdateParams) : Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/content'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling update5.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling update5.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling update5.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling update5.');
        }

        // verify required parameter 'bTAppElementUpdateParams' is not null or undefined
        if (bTAppElementUpdateParams === null || bTAppElementUpdateParams === undefined) {
            throw new Error('Required parameter bTAppElementUpdateParams was null or undefined when calling update5.');
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'POST',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
            body: ObjectSerializer.serialize(bTAppElementUpdateParams, "BTAppElementUpdateParams")
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementModifyInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementModifyInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
    /**
     * 
     * @summary Update Reference
     * @param did 
     * @param eid 
     * @param wvm 
     * @param wvmid 
     * @param rid 
     * @param bTAppElementReferenceParams 
     */
    public updateReference1 (did: string, eid: string, wvm: string, wvmid: string, rid: string, bTAppElementReferenceParams: BTAppElementReferenceParams) : Promise<{ response: http.ClientResponse; body: BTAppElementReferenceInfo;  }> {
        const localVarPath = this.basePath + '/api/appelements/d/{did}/{wvm}/{wvmid}/e/{eid}/references/{rid}'
            .replace('{' + 'did' + '}', encodeURIComponent(String(did)))
            .replace('{' + 'eid' + '}', encodeURIComponent(String(eid)))
            .replace('{' + 'wvm' + '}', encodeURIComponent(String(wvm)))
            .replace('{' + 'wvmid' + '}', encodeURIComponent(String(wvmid)))
            .replace('{' + 'rid' + '}', encodeURIComponent(String(rid)));
        let localVarQueryParameters: any = {};
        let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
        let localVarFormParams: any = {};

        // verify required parameter 'did' is not null or undefined
        if (did === null || did === undefined) {
            throw new Error('Required parameter did was null or undefined when calling updateReference1.');
        }

        // verify required parameter 'eid' is not null or undefined
        if (eid === null || eid === undefined) {
            throw new Error('Required parameter eid was null or undefined when calling updateReference1.');
        }

        // verify required parameter 'wvm' is not null or undefined
        if (wvm === null || wvm === undefined) {
            throw new Error('Required parameter wvm was null or undefined when calling updateReference1.');
        }

        // verify required parameter 'wvmid' is not null or undefined
        if (wvmid === null || wvmid === undefined) {
            throw new Error('Required parameter wvmid was null or undefined when calling updateReference1.');
        }

        // verify required parameter 'rid' is not null or undefined
        if (rid === null || rid === undefined) {
            throw new Error('Required parameter rid was null or undefined when calling updateReference1.');
        }

        // verify required parameter 'bTAppElementReferenceParams' is not null or undefined
        if (bTAppElementReferenceParams === null || bTAppElementReferenceParams === undefined) {
            throw new Error('Required parameter bTAppElementReferenceParams was null or undefined when calling updateReference1.');
        }


        let localVarUseFormData = false;

        let localVarRequestOptions: localVarRequest.Options = {
            method: 'POST',
            qs: localVarQueryParameters,
            headers: localVarHeaderParams,
            uri: localVarPath,
            useQuerystring: this._useQuerystring,
            json: true,
            body: ObjectSerializer.serialize(bTAppElementReferenceParams, "BTAppElementReferenceParams")
        };

        this.authentications.OAuth2.applyToRequest(localVarRequestOptions);

        this.authentications.default.applyToRequest(localVarRequestOptions);

        if (Object.keys(localVarFormParams).length) {
            if (localVarUseFormData) {
                (<any>localVarRequestOptions).formData = localVarFormParams;
            } else {
                localVarRequestOptions.form = localVarFormParams;
            }
        }
        return new Promise<{ response: http.ClientResponse; body: BTAppElementReferenceInfo;  }>((resolve, reject) => {
            localVarRequest(localVarRequestOptions, (error, response, body) => {
                if (error) {
                    reject(error);
                } else {
                    body = ObjectSerializer.deserialize(body, "BTAppElementReferenceInfo");
                    if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                        resolve({ response: response, body: body });
                    } else {
                        reject({ response: response, body: body });
                    }
                }
            });
        });
    }
}
