/* 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 { CreateOrUpdateWebhookRequestToJSON, ListUserWebhooksRequestToJSON, ListUserWebhooksResponseFromJSON, VerifyWebhookRequestToJSON, VerifyWebhookResponseFromJSON, WebhookFromJSON, } from '../models/index';
/**
 *
 */
export class WebhookServicesApi extends runtime.BaseAPI {
    /**
     */
    async deleteRepoV1WebhookWebhookIdRaw(requestParameters, initOverrides) {
        if (requestParameters['webhookId'] == null) {
            throw new runtime.RequiredError('webhookId', 'Required parameter "webhookId" was null or undefined when calling deleteRepoV1WebhookWebhookId().');
        }
        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/webhook/{webhookId}`;
        urlPath = urlPath.replace(`{${"webhookId"}}`, encodeURIComponent(String(requestParameters['webhookId'])));
        const response = await this.request({
            path: urlPath,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     */
    async deleteRepoV1WebhookWebhookId(requestParameters, initOverrides) {
        await this.deleteRepoV1WebhookWebhookIdRaw(requestParameters, initOverrides);
    }
    /**
     */
    async getRepoV1WebhookWebhookIdRaw(requestParameters, initOverrides) {
        if (requestParameters['webhookId'] == null) {
            throw new runtime.RequiredError('webhookId', 'Required parameter "webhookId" was null or undefined when calling getRepoV1WebhookWebhookId().');
        }
        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/webhook/{webhookId}`;
        urlPath = urlPath.replace(`{${"webhookId"}}`, encodeURIComponent(String(requestParameters['webhookId'])));
        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => WebhookFromJSON(jsonValue));
    }
    /**
     */
    async getRepoV1WebhookWebhookId(requestParameters, initOverrides) {
        const response = await this.getRepoV1WebhookWebhookIdRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async postRepoV1WebhookRaw(requestParameters, initOverrides) {
        if (requestParameters['createOrUpdateWebhookRequest'] == null) {
            throw new runtime.RequiredError('createOrUpdateWebhookRequest', 'Required parameter "createOrUpdateWebhookRequest" was null or undefined when calling postRepoV1Webhook().');
        }
        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/webhook`;
        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: CreateOrUpdateWebhookRequestToJSON(requestParameters['createOrUpdateWebhookRequest']),
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => WebhookFromJSON(jsonValue));
    }
    /**
     */
    async postRepoV1Webhook(requestParameters, initOverrides) {
        const response = await this.postRepoV1WebhookRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async postRepoV1WebhookListRaw(requestParameters, initOverrides) {
        if (requestParameters['listUserWebhooksRequest'] == null) {
            throw new runtime.RequiredError('listUserWebhooksRequest', 'Required parameter "listUserWebhooksRequest" was null or undefined when calling postRepoV1WebhookList().');
        }
        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/webhook/list`;
        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: ListUserWebhooksRequestToJSON(requestParameters['listUserWebhooksRequest']),
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => ListUserWebhooksResponseFromJSON(jsonValue));
    }
    /**
     */
    async postRepoV1WebhookList(requestParameters, initOverrides) {
        const response = await this.postRepoV1WebhookListRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async postRepoV1WebhookWebhookIdVerifyRaw(requestParameters, initOverrides) {
        if (requestParameters['webhookId'] == null) {
            throw new runtime.RequiredError('webhookId', 'Required parameter "webhookId" was null or undefined when calling postRepoV1WebhookWebhookIdVerify().');
        }
        if (requestParameters['verifyWebhookRequest'] == null) {
            throw new runtime.RequiredError('verifyWebhookRequest', 'Required parameter "verifyWebhookRequest" was null or undefined when calling postRepoV1WebhookWebhookIdVerify().');
        }
        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/webhook/{webhookId}/verify`;
        urlPath = urlPath.replace(`{${"webhookId"}}`, encodeURIComponent(String(requestParameters['webhookId'])));
        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: VerifyWebhookRequestToJSON(requestParameters['verifyWebhookRequest']),
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => VerifyWebhookResponseFromJSON(jsonValue));
    }
    /**
     */
    async postRepoV1WebhookWebhookIdVerify(requestParameters, initOverrides) {
        const response = await this.postRepoV1WebhookWebhookIdVerifyRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async putRepoV1WebhookWebhookIdRaw(requestParameters, initOverrides) {
        if (requestParameters['webhookId'] == null) {
            throw new runtime.RequiredError('webhookId', 'Required parameter "webhookId" was null or undefined when calling putRepoV1WebhookWebhookId().');
        }
        if (requestParameters['createOrUpdateWebhookRequest'] == null) {
            throw new runtime.RequiredError('createOrUpdateWebhookRequest', 'Required parameter "createOrUpdateWebhookRequest" was null or undefined when calling putRepoV1WebhookWebhookId().');
        }
        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/webhook/{webhookId}`;
        urlPath = urlPath.replace(`{${"webhookId"}}`, encodeURIComponent(String(requestParameters['webhookId'])));
        const response = await this.request({
            path: urlPath,
            method: 'PUT',
            headers: headerParameters,
            query: queryParameters,
            body: CreateOrUpdateWebhookRequestToJSON(requestParameters['createOrUpdateWebhookRequest']),
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => WebhookFromJSON(jsonValue));
    }
    /**
     */
    async putRepoV1WebhookWebhookId(requestParameters, initOverrides) {
        const response = await this.putRepoV1WebhookWebhookIdRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     */
    async putRepoV1WebhookWebhookIdVerificationCodeRaw(requestParameters, initOverrides) {
        if (requestParameters['webhookId'] == null) {
            throw new runtime.RequiredError('webhookId', 'Required parameter "webhookId" was null or undefined when calling putRepoV1WebhookWebhookIdVerificationCode().');
        }
        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/webhook/{webhookId}/verificationCode`;
        urlPath = urlPath.replace(`{${"webhookId"}}`, encodeURIComponent(String(requestParameters['webhookId'])));
        const response = await this.request({
            path: urlPath,
            method: 'PUT',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => WebhookFromJSON(jsonValue));
    }
    /**
     */
    async putRepoV1WebhookWebhookIdVerificationCode(requestParameters, initOverrides) {
        const response = await this.putRepoV1WebhookWebhookIdVerificationCodeRaw(requestParameters, initOverrides);
        return await response.value();
    }
}
//# sourceMappingURL=WebhookServicesApi.js.map