/*
 * 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 { CompanyApiCredential } from '../../typings/management/models';
import { CreateCompanyApiCredentialRequest } from '../../typings/management/models';
import { CreateCompanyApiCredentialResponse } from '../../typings/management/models';
import { ListCompanyApiCredentialsResponse } from '../../typings/management/models';
import { UpdateCompanyApiCredentialRequest } from '../../typings/management/models';
import { IRequest } from "../../typings/requestOptions";
import ManagementResource from "../resource/management/managementResource";
import { ObjectSerializer } from "../../typings/management/models";


export default class APICredentialsCompanyLevelApi extends Service {
    /**
     * @summary Get a list of API credentials
     * @param companyId The unique identifier of the company 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(companyId: string, requestOptions?: IRequest.Options): Promise<ListCompanyApiCredentialsResponse> {
        const localVarPath = "/companies/{companyId}/apiCredentials"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
        const resource = new ManagementResource(this, localVarPath);
        const response = await getJsonResponse<string, ListCompanyApiCredentialsResponse>(
            resource,
            "",
            { ...requestOptions, method: "GET" }
        );
        return ObjectSerializer.deserialize(response, "ListCompanyApiCredentialsResponse");
    }
    /**
     * @summary Get an API credential
     * @param companyId The unique identifier of the company account.
     * @param apiCredentialId Unique identifier of the API credential.
     */
    public async getApiCredential(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise<CompanyApiCredential> {
        const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
            .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
        const resource = new ManagementResource(this, localVarPath);
        const response = await getJsonResponse<string, CompanyApiCredential>(
            resource,
            "",
            { ...requestOptions, method: "GET" }
        );
        return ObjectSerializer.deserialize(response, "CompanyApiCredential");
    }
    /**
     * @summary Update an API credential.
     * @param companyId The unique identifier of the company account.
     * @param apiCredentialId Unique identifier of the API credential.
     * @param updateCompanyApiCredentialRequest 
     */
    public async updateApiCredential(companyId: string, apiCredentialId: string, updateCompanyApiCredentialRequest: UpdateCompanyApiCredentialRequest, requestOptions?: IRequest.Options): Promise<CompanyApiCredential> {
        const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
            .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId)));
        const resource = new ManagementResource(this, localVarPath);
        const request: UpdateCompanyApiCredentialRequest = ObjectSerializer.serialize(updateCompanyApiCredentialRequest, "UpdateCompanyApiCredentialRequest");
        const response = await getJsonResponse<UpdateCompanyApiCredentialRequest, CompanyApiCredential>(
            resource,
            request,
            { ...requestOptions, method: "PATCH" }
        );
        return ObjectSerializer.deserialize(response, "CompanyApiCredential");
    }
    /**
     * @summary Create an API credential.
     * @param companyId The unique identifier of the company account.
     * @param createCompanyApiCredentialRequest 
     */
    public async createApiCredential(companyId: string, createCompanyApiCredentialRequest: CreateCompanyApiCredentialRequest, requestOptions?: IRequest.Options): Promise<CreateCompanyApiCredentialResponse> {
        const localVarPath = "/companies/{companyId}/apiCredentials"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
        const resource = new ManagementResource(this, localVarPath);
        const request: CreateCompanyApiCredentialRequest = ObjectSerializer.serialize(createCompanyApiCredentialRequest, "CreateCompanyApiCredentialRequest");
        const response = await getJsonResponse<CreateCompanyApiCredentialRequest, CreateCompanyApiCredentialResponse>(
            resource,
            request,
            { ...requestOptions, method: "POST" }
        );
        return ObjectSerializer.deserialize(response, "CreateCompanyApiCredentialResponse");
    }
}
