/* tslint:disable */
/* eslint-disable */
/**
 * elkar-app
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 0.1.0
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import * as runtime from "../runtime";
import type {
  AgentOutput,
  ApiKeyOutput,
  ApplicationUserOutput,
  CreateAgentInput,
  CreateApiKeyInput,
  CreateTenantInput,
  InviteUserInput,
  IsRegisteredOutput,
  ListApiKeysInput,
  TenantOutput,
  UnpaginatedOutputAgentOutput,
  UnpaginatedOutputApiKeyOutput,
  UnpaginatedOutputApplicationUserOutput,
  UnpaginatedOutputTenantOutput,
} from "../models/index";
import {
  AgentOutputFromJSON,
  AgentOutputToJSON,
  ApiKeyOutputFromJSON,
  ApiKeyOutputToJSON,
  ApplicationUserOutputFromJSON,
  ApplicationUserOutputToJSON,
  CreateAgentInputFromJSON,
  CreateAgentInputToJSON,
  CreateApiKeyInputFromJSON,
  CreateApiKeyInputToJSON,
  CreateTenantInputFromJSON,
  CreateTenantInputToJSON,
  InviteUserInputFromJSON,
  InviteUserInputToJSON,
  IsRegisteredOutputFromJSON,
  IsRegisteredOutputToJSON,
  ListApiKeysInputFromJSON,
  ListApiKeysInputToJSON,
  TenantOutputFromJSON,
  TenantOutputToJSON,
  UnpaginatedOutputAgentOutputFromJSON,
  UnpaginatedOutputAgentOutputToJSON,
  UnpaginatedOutputApiKeyOutputFromJSON,
  UnpaginatedOutputApiKeyOutputToJSON,
  UnpaginatedOutputApplicationUserOutputFromJSON,
  UnpaginatedOutputApplicationUserOutputToJSON,
  UnpaginatedOutputTenantOutputFromJSON,
  UnpaginatedOutputTenantOutputToJSON,
} from "../models/index";

export interface EpCreateAgentRequest {
  createAgentInput: CreateAgentInput;
}

export interface EpCreateApiKeyRequest {
  createApiKeyInput: CreateApiKeyInput;
}

export interface EpCreateTenantRequest {
  createTenantInput: CreateTenantInput;
}

export interface EpDeleteAgentRequest {
  id: string;
}

export interface EpDeleteApiKeyRequest {
  id: string;
}

export interface EpGetApiKeyRequest {
  id: string;
}

export interface EpInviteUserRequest {
  inviteUserInput: InviteUserInput;
}

export interface EpListApiKeysRequest {
  listApiKeysInput: ListApiKeysInput;
}

export interface EpRetrieveAgentRequest {
  id: string;
}

export interface EpRetrieveTenantRequest {
  id: string;
}

/**
 *
 */
export class DefaultApi extends runtime.BaseAPI {
  /**
   */
  async epCreateAgentRaw(
    requestParameters: EpCreateAgentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<AgentOutput>> {
    if (requestParameters["createAgentInput"] == null) {
      throw new runtime.RequiredError(
        "createAgentInput",
        'Required parameter "createAgentInput" was null or undefined when calling epCreateAgent().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    const response = await this.request(
      {
        path: `/agents`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: CreateAgentInputToJSON(requestParameters["createAgentInput"]),
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      AgentOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epCreateAgent(
    requestParameters: EpCreateAgentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<AgentOutput> {
    const response = await this.epCreateAgentRaw(
      requestParameters,
      initOverrides
    );
    return await response.value();
  }

  /**
   */
  async epCreateApiKeyRaw(
    requestParameters: EpCreateApiKeyRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<ApiKeyOutput>> {
    if (requestParameters["createApiKeyInput"] == null) {
      throw new runtime.RequiredError(
        "createApiKeyInput",
        'Required parameter "createApiKeyInput" was null or undefined when calling epCreateApiKey().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    const response = await this.request(
      {
        path: `/api-keys`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: CreateApiKeyInputToJSON(requestParameters["createApiKeyInput"]),
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      ApiKeyOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epCreateApiKey(
    requestParameters: EpCreateApiKeyRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<ApiKeyOutput> {
    const response = await this.epCreateApiKeyRaw(
      requestParameters,
      initOverrides
    );
    return await response.value();
  }

  /**
   */
  async epCreateTenantRaw(
    requestParameters: EpCreateTenantRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<TenantOutput>> {
    if (requestParameters["createTenantInput"] == null) {
      throw new runtime.RequiredError(
        "createTenantInput",
        'Required parameter "createTenantInput" was null or undefined when calling epCreateTenant().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    const response = await this.request(
      {
        path: `/tenants`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: CreateTenantInputToJSON(requestParameters["createTenantInput"]),
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      TenantOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epCreateTenant(
    requestParameters: EpCreateTenantRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<TenantOutput> {
    const response = await this.epCreateTenantRaw(
      requestParameters,
      initOverrides
    );
    return await response.value();
  }

  /**
   */
  async epDeleteAgentRaw(
    requestParameters: EpDeleteAgentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling epDeleteAgent().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/agents/{id}`.replace(
          `{${"id"}}`,
          encodeURIComponent(String(requestParameters["id"]))
        ),
        method: "DELETE",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.VoidApiResponse(response);
  }

  /**
   */
  async epDeleteAgent(
    requestParameters: EpDeleteAgentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.epDeleteAgentRaw(requestParameters, initOverrides);
  }

  /**
   */
  async epDeleteApiKeyRaw(
    requestParameters: EpDeleteApiKeyRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling epDeleteApiKey().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/api-keys/{id}`.replace(
          `{${"id"}}`,
          encodeURIComponent(String(requestParameters["id"]))
        ),
        method: "DELETE",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.VoidApiResponse(response);
  }

  /**
   */
  async epDeleteApiKey(
    requestParameters: EpDeleteApiKeyRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.epDeleteApiKeyRaw(requestParameters, initOverrides);
  }

  /**
   */
  async epGetApiKeyRaw(
    requestParameters: EpGetApiKeyRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<ApiKeyOutput>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling epGetApiKey().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/api-keys/{id}`.replace(
          `{${"id"}}`,
          encodeURIComponent(String(requestParameters["id"]))
        ),
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      ApiKeyOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epGetApiKey(
    requestParameters: EpGetApiKeyRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<ApiKeyOutput> {
    const response = await this.epGetApiKeyRaw(
      requestParameters,
      initOverrides
    );
    return await response.value();
  }

  /**
   */
  async epGetUserMeRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<ApplicationUserOutput>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/users/me`,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      ApplicationUserOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epGetUserMe(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<ApplicationUserOutput> {
    const response = await this.epGetUserMeRaw(initOverrides);
    return await response.value();
  }

  /**
   */
  async epInviteUserRaw(
    requestParameters: EpInviteUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<any>> {
    if (requestParameters["inviteUserInput"] == null) {
      throw new runtime.RequiredError(
        "inviteUserInput",
        'Required parameter "inviteUserInput" was null or undefined when calling epInviteUser().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    const response = await this.request(
      {
        path: `/users/invite`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: InviteUserInputToJSON(requestParameters["inviteUserInput"]),
      },
      initOverrides
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<any>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   */
  async epInviteUser(
    requestParameters: EpInviteUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<any> {
    const response = await this.epInviteUserRaw(
      requestParameters,
      initOverrides
    );
    return await response.value();
  }

  /**
   */
  async epIsRegisteredRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<IsRegisteredOutput>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/users/is-registered`,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      IsRegisteredOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epIsRegistered(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<IsRegisteredOutput> {
    const response = await this.epIsRegisteredRaw(initOverrides);
    return await response.value();
  }

  /**
   */
  async epListApiKeysRaw(
    requestParameters: EpListApiKeysRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<UnpaginatedOutputApiKeyOutput>> {
    if (requestParameters["listApiKeysInput"] == null) {
      throw new runtime.RequiredError(
        "listApiKeysInput",
        'Required parameter "listApiKeysInput" was null or undefined when calling epListApiKeys().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    const response = await this.request(
      {
        path: `/api-keys/list`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: ListApiKeysInputToJSON(requestParameters["listApiKeysInput"]),
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      UnpaginatedOutputApiKeyOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epListApiKeys(
    requestParameters: EpListApiKeysRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<UnpaginatedOutputApiKeyOutput> {
    const response = await this.epListApiKeysRaw(
      requestParameters,
      initOverrides
    );
    return await response.value();
  }

  /**
   */
  async epRegisterUserRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<any>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/users/register`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<any>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   */
  async epRegisterUser(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<any> {
    const response = await this.epRegisterUserRaw(initOverrides);
    return await response.value();
  }

  /**
   */
  async epRetrieveAgentRaw(
    requestParameters: EpRetrieveAgentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<AgentOutput>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling epRetrieveAgent().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/agents/{id}`.replace(
          `{${"id"}}`,
          encodeURIComponent(String(requestParameters["id"]))
        ),
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      AgentOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epRetrieveAgent(
    requestParameters: EpRetrieveAgentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<AgentOutput> {
    const response = await this.epRetrieveAgentRaw(
      requestParameters,
      initOverrides
    );
    return await response.value();
  }

  /**
   */
  async epRetrieveAgentsRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<UnpaginatedOutputAgentOutput>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/agents/list`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      UnpaginatedOutputAgentOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epRetrieveAgents(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<UnpaginatedOutputAgentOutput> {
    const response = await this.epRetrieveAgentsRaw(initOverrides);
    return await response.value();
  }

  /**
   */
  async epRetrieveTenantRaw(
    requestParameters: EpRetrieveTenantRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<TenantOutput>> {
    if (requestParameters["id"] == null) {
      throw new runtime.RequiredError(
        "id",
        'Required parameter "id" was null or undefined when calling epRetrieveTenant().'
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/tenants/{id}`.replace(
          `{${"id"}}`,
          encodeURIComponent(String(requestParameters["id"]))
        ),
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      TenantOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epRetrieveTenant(
    requestParameters: EpRetrieveTenantRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<TenantOutput> {
    const response = await this.epRetrieveTenantRaw(
      requestParameters,
      initOverrides
    );
    return await response.value();
  }

  /**
   */
  async epRetrieveTenantUsersRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<UnpaginatedOutputApplicationUserOutput>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/users`,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      UnpaginatedOutputApplicationUserOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epRetrieveTenantUsers(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<UnpaginatedOutputApplicationUserOutput> {
    const response = await this.epRetrieveTenantUsersRaw(initOverrides);
    return await response.value();
  }

  /**
   */
  async epRetrieveTenantsRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<UnpaginatedOutputTenantOutput>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/tenants`,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      UnpaginatedOutputTenantOutputFromJSON(jsonValue)
    );
  }

  /**
   */
  async epRetrieveTenants(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<UnpaginatedOutputTenantOutput> {
    const response = await this.epRetrieveTenantsRaw(initOverrides);
    return await response.value();
  }
}
