/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import { authGetTokenFromConfidentialAuthCode } from "../funcs/authGetTokenFromConfidentialAuthCode.js";
import { authGetTokenFromJwtGrant } from "../funcs/authGetTokenFromJwtGrant.js";
import { authGetTokenFromPublicAuthCode } from "../funcs/authGetTokenFromPublicAuthCode.js";
import { authGetTokenFromRefreshToken } from "../funcs/authGetTokenFromRefreshToken.js";
import { authGetUserInfo } from "../funcs/authGetUserInfo.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import * as components from "../models/components/index.js";
import * as operations from "../models/operations/index.js";
import { unwrapAsync } from "../types/fp.js";

export class Auth extends ClientSDK {
  /**
   * Obtains an access token from the Docusign API using an authorization code.
   *
   * @remarks
   * Obtains an access token from the Docusign API using the confidential flow.
   * For the developer environment, the URI is https://account-d.docusign.com/oauth/token
   * For the production environment, the URI is https://account.docusign.com/oauth/token
   * You do not need an integration key to obtain an access token.
   */
  async getTokenFromConfidentialAuthCode(
    security: operations.GetTokenFromConfidentialAuthCodeSecurity,
    request: components.ConfidentialAuthCodeGrantRequestBody,
    options?: RequestOptions,
  ): Promise<components.AuthorizationCodeGrantResponse> {
    return unwrapAsync(authGetTokenFromConfidentialAuthCode(
      this,
      security,
      request,
      options,
    ));
  }

  /**
   * Obtains an access token from the Docusign API using an authorization code.
   *
   * @remarks
   * Obtains an access token from the Docusign API using the confidential flow.
   * For the developer environment, the URI is https://account-d.docusign.com/oauth/token
   * For the production environment, the URI is https://account.docusign.com/oauth/token
   * You do not need an integration key to obtain an access token.
   */
  async getTokenFromPublicAuthCode(
    request: components.PublicAuthCodeGrantRequestBody,
    options?: RequestOptions,
  ): Promise<components.AuthorizationCodeGrantResponse> {
    return unwrapAsync(authGetTokenFromPublicAuthCode(
      this,
      request,
      options,
    ));
  }

  /**
   * Obtains an access token from the Docusign API using a JWT grant.
   *
   * @remarks
   * Obtains an access token from the Docusign API.
   *
   * For the developer environment, the URI is https://account-d.docusign.com/oauth/token
   *
   * For the production environment, the URI is https://account.docusign.com/oauth/token
   *
   * You do not need an integration key to obtain an access token.
   */
  async getTokenFromJwtGrant(
    request: operations.JWTGrant,
    options?: RequestOptions,
  ): Promise<components.JWTGrantResponse> {
    return unwrapAsync(authGetTokenFromJwtGrant(
      this,
      request,
      options,
    ));
  }

  /**
   * Obtains an access token from the Docusign API using an authorization code.
   *
   * @remarks
   * Obtains an access token from the Docusign API.
   * For the developer environment, the URI is https://account-d.docusign.com/oauth/token
   * For the production environment, the URI is https://account.docusign.com/oauth/token
   *
   * You do not need an integration key to obtain an access token.
   */
  async getTokenFromRefreshToken(
    request: operations.AuthorizationCodeGrant,
    security?: operations.GetTokenFromRefreshTokenSecurity | undefined,
    options?: RequestOptions,
  ): Promise<operations.GetTokenFromRefreshTokenResponse> {
    return unwrapAsync(authGetTokenFromRefreshToken(
      this,
      request,
      security,
      options,
    ));
  }

  /**
   * Get user information
   *
   * @remarks
   * This endpoint retrieves user information from the Docusign API using an access token.
   * For the developer environment, the URI is https://account-d.docusign.com/oauth/userinfo
   * For the production environment, the URI is https://account.docusign.com/oauth/userinfo
   */
  async getUserInfo(
    options?: RequestOptions,
  ): Promise<components.UserInfo> {
    return unwrapAsync(authGetUserInfo(
      this,
      options,
    ));
  }
}
