/*
 * 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 { CompanyUser } from '../../typings/management/models';
import { CreateCompanyUserRequest } from '../../typings/management/models';
import { CreateCompanyUserResponse } from '../../typings/management/models';
import { ListCompanyUsersResponse } from '../../typings/management/models';
import { UpdateCompanyUserRequest } from '../../typings/management/models';
import { IRequest } from "../../typings/requestOptions";
import ManagementResource from "../resource/management/managementResource";
import { ObjectSerializer } from "../../typings/management/models";


export default class UsersCompanyLevelApi extends Service {
    /**
     * @summary Get a list of users
     * @param companyId The unique identifier of the company account.
     * @param pageNumber The number of the page to return.
     * @param pageSize The number of items to have on a page. Maximum value is **100**. The default is **10** items on a page.
     */
    public async listUsers(companyId: string, requestOptions?: IRequest.Options): Promise<ListCompanyUsersResponse> {
        const localVarPath = "/companies/{companyId}/users"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
        const resource = new ManagementResource(this, localVarPath);
        const response = await getJsonResponse<string, ListCompanyUsersResponse>(
            resource,
            "",
            { ...requestOptions, method: "GET" }
        );
        return ObjectSerializer.deserialize(response, "ListCompanyUsersResponse");
    }
    /**
     * @summary Get user details
     * @param companyId The unique identifier of the company account.
     * @param userId The unique identifier of the user.
     */
    public async getUserDetails(companyId: string, userId: string, requestOptions?: IRequest.Options): Promise<CompanyUser> {
        const localVarPath = "/companies/{companyId}/users/{userId}"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
            .replace('{' + 'userId' + '}', encodeURIComponent(String(userId)));
        const resource = new ManagementResource(this, localVarPath);
        const response = await getJsonResponse<string, CompanyUser>(
            resource,
            "",
            { ...requestOptions, method: "GET" }
        );
        return ObjectSerializer.deserialize(response, "CompanyUser");
    }
    /**
     * @summary Update user details
     * @param companyId The unique identifier of the company account.
     * @param userId The unique identifier of the user.
     * @param updateCompanyUserRequest 
     */
    public async updateUserDetails(companyId: string, userId: string, updateCompanyUserRequest: UpdateCompanyUserRequest, requestOptions?: IRequest.Options): Promise<CompanyUser> {
        const localVarPath = "/companies/{companyId}/users/{userId}"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)))
            .replace('{' + 'userId' + '}', encodeURIComponent(String(userId)));
        const resource = new ManagementResource(this, localVarPath);
        const request: UpdateCompanyUserRequest = ObjectSerializer.serialize(updateCompanyUserRequest, "UpdateCompanyUserRequest");
        const response = await getJsonResponse<UpdateCompanyUserRequest, CompanyUser>(
            resource,
            request,
            { ...requestOptions, method: "PATCH" }
        );
        return ObjectSerializer.deserialize(response, "CompanyUser");
    }
    /**
     * @summary Create a new user
     * @param companyId The unique identifier of the company account.
     * @param createCompanyUserRequest 
     */
    public async createNewUser(companyId: string, createCompanyUserRequest: CreateCompanyUserRequest, requestOptions?: IRequest.Options): Promise<CreateCompanyUserResponse> {
        const localVarPath = "/companies/{companyId}/users"
            .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId)));
        const resource = new ManagementResource(this, localVarPath);
        const request: CreateCompanyUserRequest = ObjectSerializer.serialize(createCompanyUserRequest, "CreateCompanyUserRequest");
        const response = await getJsonResponse<CreateCompanyUserRequest, CreateCompanyUserResponse>(
            resource,
            request,
            { ...requestOptions, method: "POST" }
        );
        return ObjectSerializer.deserialize(response, "CreateCompanyUserResponse");
    }
}
