/* tslint:disable */
/* eslint-disable */
/**
 * Synapse REST API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v1
 *
 *
 * 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 { AsyncJobIdFromJSON, DoiAssociationFromJSON, DoiRequestToJSON, DoiResponseFromJSON, V2DoiFromJSON, } from '../models/index';
/**
 *
 */
export class DOIServicesApi extends runtime.BaseAPI {
    /**
     */
    async getRepoV1DoiRaw(requestParameters, initOverrides) {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling getRepoV1Doi().');
        }
        if (requestParameters['type'] == null) {
            throw new runtime.RequiredError('type', 'Required parameter "type" was null or undefined when calling getRepoV1Doi().');
        }
        const queryParameters = {};
        if (requestParameters['portalId'] != null) {
            queryParameters['portalId'] = requestParameters['portalId'];
        }
        if (requestParameters['id'] != null) {
            queryParameters['id'] = requestParameters['id'];
        }
        if (requestParameters['type'] != null) {
            queryParameters['type'] = requestParameters['type'];
        }
        if (requestParameters['version'] != null) {
            queryParameters['version'] = requestParameters['version'];
        }
        const headerParameters = {};
        let urlPath = `/repo/v1/doi`;
        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => V2DoiFromJSON(jsonValue));
    }
    /**
     */
    async getRepoV1Doi(requestParameters, initOverrides) {
        const response = await this.getRepoV1DoiRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async getRepoV1DoiAssociationRaw(requestParameters, initOverrides) {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling getRepoV1DoiAssociation().');
        }
        if (requestParameters['type'] == null) {
            throw new runtime.RequiredError('type', 'Required parameter "type" was null or undefined when calling getRepoV1DoiAssociation().');
        }
        const queryParameters = {};
        if (requestParameters['portalId'] != null) {
            queryParameters['portalId'] = requestParameters['portalId'];
        }
        if (requestParameters['id'] != null) {
            queryParameters['id'] = requestParameters['id'];
        }
        if (requestParameters['type'] != null) {
            queryParameters['type'] = requestParameters['type'];
        }
        if (requestParameters['version'] != null) {
            queryParameters['version'] = requestParameters['version'];
        }
        const headerParameters = {};
        let urlPath = `/repo/v1/doi/association`;
        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => DoiAssociationFromJSON(jsonValue));
    }
    /**
     */
    async getRepoV1DoiAssociation(requestParameters, initOverrides) {
        const response = await this.getRepoV1DoiAssociationRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async getRepoV1DoiAsyncGetAsyncTokenRaw(requestParameters, initOverrides) {
        if (requestParameters['asyncToken'] == null) {
            throw new runtime.RequiredError('asyncToken', 'Required parameter "asyncToken" was null or undefined when calling getRepoV1DoiAsyncGetAsyncToken().');
        }
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearerAuth", []);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        let urlPath = `/repo/v1/doi/async/get/{asyncToken}`;
        urlPath = urlPath.replace(`{${"asyncToken"}}`, encodeURIComponent(String(requestParameters['asyncToken'])));
        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => DoiResponseFromJSON(jsonValue));
    }
    /**
     */
    async getRepoV1DoiAsyncGetAsyncToken(requestParameters, initOverrides) {
        const response = await this.getRepoV1DoiAsyncGetAsyncTokenRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async getRepoV1DoiLocateRaw(requestParameters, initOverrides) {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling getRepoV1DoiLocate().');
        }
        if (requestParameters['type'] == null) {
            throw new runtime.RequiredError('type', 'Required parameter "type" was null or undefined when calling getRepoV1DoiLocate().');
        }
        const queryParameters = {};
        if (requestParameters['portalId'] != null) {
            queryParameters['portalId'] = requestParameters['portalId'];
        }
        if (requestParameters['id'] != null) {
            queryParameters['id'] = requestParameters['id'];
        }
        if (requestParameters['type'] != null) {
            queryParameters['type'] = requestParameters['type'];
        }
        if (requestParameters['version'] != null) {
            queryParameters['version'] = requestParameters['version'];
        }
        if (requestParameters['redirect'] != null) {
            queryParameters['redirect'] = requestParameters['redirect'];
        }
        const headerParameters = {};
        let urlPath = `/repo/v1/doi/locate`;
        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse(response);
        }
        else {
            return new runtime.TextApiResponse(response);
        }
    }
    /**
     */
    async getRepoV1DoiLocate(requestParameters, initOverrides) {
        const response = await this.getRepoV1DoiLocateRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async postRepoV1DoiAsyncStartRaw(requestParameters, initOverrides) {
        if (requestParameters['doiRequest'] == null) {
            throw new runtime.RequiredError('doiRequest', 'Required parameter "doiRequest" was null or undefined when calling postRepoV1DoiAsyncStart().');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearerAuth", []);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        let urlPath = `/repo/v1/doi/async/start`;
        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: DoiRequestToJSON(requestParameters['doiRequest']),
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => AsyncJobIdFromJSON(jsonValue));
    }
    /**
     */
    async postRepoV1DoiAsyncStart(requestParameters, initOverrides) {
        const response = await this.postRepoV1DoiAsyncStartRaw(requestParameters, initOverrides);
        return await response.value();
    }
}
//# sourceMappingURL=DOIServicesApi.js.map