/*
 * 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 AllowedOriginsMerchantLevelApi extends Service {
    /**
     * @summary Delete an allowed origin
     * @param merchantId The unique identifier of the merchant account.
     * @param apiCredentialId Unique identifier of the API credential.
     * @param originId Unique identifier of the allowed origin.
     */
    public async deleteAllowedOrigin(merchantId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise<void> {
        const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}"
            .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
            .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 merchantId The unique identifier of the merchant account.
     * @param apiCredentialId Unique identifier of the API credential.
     */
    public async listAllowedOrigins(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
        const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins"
            .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
            .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 merchantId The unique identifier of the merchant account.
     * @param apiCredentialId Unique identifier of the API credential.
     * @param originId Unique identifier of the allowed origin.
     */
    public async getAllowedOrigin(merchantId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise<AllowedOrigin> {
        const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}"
            .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
            .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 merchantId The unique identifier of the merchant account.
     * @param apiCredentialId Unique identifier of the API credential.
     * @param allowedOrigin 
     */
    public async createAllowedOrigin(merchantId: string, apiCredentialId: string, allowedOrigin: AllowedOrigin, requestOptions?: IRequest.Options): Promise<AllowedOriginsResponse> {
        const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins"
            .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
            .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");
    }
}
