/*
 * 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 { ApiCredential } from '../../typings/management/models';
import { CreateApiCredentialResponse } from '../../typings/management/models';
import { CreateMerchantApiCredentialRequest } from '../../typings/management/models';
import { ListMerchantApiCredentialsResponse } from '../../typings/management/models';
import { UpdateMerchantApiCredentialRequest } from '../../typings/management/models';
import { IRequest } from "../../typings/requestOptions";
import ManagementResource from "../resource/management/managementResource";
import { ObjectSerializer } from "../../typings/management/models";


export default class APICredentialsMerchantLevelApi extends Service {
    /**
     * @summary Get a list of API credentials
     * @param merchantId The unique identifier of the merchant account.
     * @param pageNumber The number of the page to fetch.
     * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page.
     */
    public async listApiCredentials(merchantId: string, requestOptions?: IRequest.Options): Promise<ListMerchantApiCredentialsResponse> {
        const localVarPath = "/merchants/{merchantId}/apiCredentials"
            .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
        const resource = new ManagementResource(this, localVarPath);
        const response = await getJsonResponse<string, ListMerchantApiCredentialsResponse>(
            resource,
            "",
            { ...requestOptions, method: "GET" }
        );
        return ObjectSerializer.deserialize(response, "ListMerchantApiCredentialsResponse");
    }
    /**
     * @summary Get an API credential
     * @param merchantId The unique identifier of the merchant account.
     * @param apiCredentialId Unique identifier of the API credential.
     */
    public async getApiCredential(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<ApiCredential> {
        const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}"
            .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
            .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
        const resource = new ManagementResource(this, localVarPath);
        const response = await getJsonResponse<string, ApiCredential>(
            resource,
            "",
            { ...requestOptions, method: "GET" }
        );
        return ObjectSerializer.deserialize(response, "ApiCredential");
    }
    /**
     * @summary Update an API credential
     * @param merchantId The unique identifier of the merchant account.
     * @param apiCredentialId Unique identifier of the API credential.
     * @param updateMerchantApiCredentialRequest 
     */
    public async updateApiCredential(merchantId: string, apiCredentialId: string, updateMerchantApiCredentialRequest: UpdateMerchantApiCredentialRequest, requestOptions?: IRequest.Options): Promise<ApiCredential> {
        const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}"
            .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)))
            .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
        const resource = new ManagementResource(this, localVarPath);
        const request: UpdateMerchantApiCredentialRequest = ObjectSerializer.serialize(updateMerchantApiCredentialRequest, "UpdateMerchantApiCredentialRequest");
        const response = await getJsonResponse<UpdateMerchantApiCredentialRequest, ApiCredential>(
            resource,
            request,
            { ...requestOptions, method: "PATCH" }
        );
        return ObjectSerializer.deserialize(response, "ApiCredential");
    }
    /**
     * @summary Create an API credential
     * @param merchantId The unique identifier of the merchant account.
     * @param createMerchantApiCredentialRequest 
     */
    public async createApiCredential(merchantId: string, createMerchantApiCredentialRequest: CreateMerchantApiCredentialRequest, requestOptions?: IRequest.Options): Promise<CreateApiCredentialResponse> {
        const localVarPath = "/merchants/{merchantId}/apiCredentials"
            .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId)));
        const resource = new ManagementResource(this, localVarPath);
        const request: CreateMerchantApiCredentialRequest = ObjectSerializer.serialize(createMerchantApiCredentialRequest, "CreateMerchantApiCredentialRequest");
        const response = await getJsonResponse<CreateMerchantApiCredentialRequest, CreateApiCredentialResponse>(
            resource,
            request,
            { ...requestOptions, method: "POST" }
        );
        return ObjectSerializer.deserialize(response, "CreateApiCredentialResponse");
    }
}
