/*
 * The version of the OpenAPI document: v1
 * Contact: developer-experience@adyen.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit this class manually.
 */


import getJsonResponse from "../../helpers/getJsonResponse";
import Service from "../../service";
/* tslint:disable:no-unused-locals */
import { AllowedOrigin } from '../../typings/management/models';
import { AllowedOriginsResponse } from '../../typings/management/models';
import { IRequest } from "../../typings/requestOptions";
import ManagementResource from "../resource/management/managementResource";
import { ObjectSerializer } from "../../typings/management/models";


export default class AllowedOriginsCompanyLevelApi extends Service {
    /**
     * @summary Delete an allowed origin
     * @param companyId The unique identifier of the company account.
     * @param apiCredentialId Unique identifier of the API credential.
     * @param originId Unique identifier of the allowed origin.
     */
    public async deleteAllowedOrigin(companyId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise<void> {
        const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
            .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)))
            .replace('{' + 'originId' + '}', encodeURIComponent(String(originId)));
        const resource = new ManagementResource(this, localVarPath);
        await getJsonResponse<string, void>(
            resource,
            "",
            { ...requestOptions, method: "DELETE" }
        );
    }
    /**
     * @summary Get a list of allowed origins
     * @param companyId The unique identifier of the company account.
     * @param apiCredentialId Unique identifier of the API credential.
     */
    public async listAllowedOrigins(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
        const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
            .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
        const resource = new ManagementResource(this, localVarPath);
        const response = await getJsonResponse<string, AllowedOriginsResponse>(
            resource,
            "",
            { ...requestOptions, method: "GET" }
        );
        return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
    }
    /**
     * @summary Get an allowed origin
     * @param companyId The unique identifier of the company account.
     * @param apiCredentialId Unique identifier of the API credential.
     * @param originId Unique identifier of the allowed origin.
     */
    public async getAllowedOrigin(companyId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise<AllowedOrigin> {
        const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
            .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)))
            .replace('{' + 'originId' + '}', encodeURIComponent(String(originId)));
        const resource = new ManagementResource(this, localVarPath);
        const response = await getJsonResponse<string, AllowedOrigin>(
            resource,
            "",
            { ...requestOptions, method: "GET" }
        );
        return ObjectSerializer.deserialize(response, "AllowedOrigin");
    }
    /**
     * @summary Create an allowed origin
     * @param companyId The unique identifier of the company account.
     * @param apiCredentialId Unique identifier of the API credential.
     * @param allowedOrigin 
     */
    public async createAllowedOrigin(companyId: string, apiCredentialId: string, allowedOrigin: AllowedOrigin, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
        const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
            .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
        const resource = new ManagementResource(this, localVarPath);
        const request: AllowedOrigin = ObjectSerializer.serialize(allowedOrigin, "AllowedOrigin");
        const response = await getJsonResponse<AllowedOrigin, AllowedOriginsResponse>(
            resource,
            request,
            { ...requestOptions, method: "POST" }
        );
        return ObjectSerializer.deserialize(response, "AllowedOriginsResponse");
    }
}
