import * as Models from "./models";


/**
 * API endpoints for Oauth.
 */
export class Oauth {
  private client: any;

  constructor(client: any) {
    this.client = client;
  }

  /**
   * List OAuth connections
   * 
   * Get all OAuth connections for the current user.
   */
  async accountsOauthConnectionsList(): Promise<any> {
    const response = await this.client.request('GET', "/cfg/accounts/oauth/connections/");
    return (response as any).results || response;
  }

  /**
   * Disconnect OAuth provider
   * 
   * Remove OAuth connection for the specified provider.
   */
  async accountsOauthDisconnectCreate(data: Models.OAuthDisconnectRequestRequest): Promise<any> {
    const response = await this.client.request('POST', "/cfg/accounts/oauth/disconnect/", { body: data });
    return response;
  }

  /**
   * Start GitHub OAuth
   * 
   * Generate GitHub OAuth authorization URL. Redirect user to this URL to
   * start authentication.
   */
  async accountsOauthGithubAuthorizeCreate(data: Models.OAuthAuthorizeRequestRequest): Promise<Models.OAuthAuthorizeResponse> {
    const response = await this.client.request('POST', "/cfg/accounts/oauth/github/authorize/", { body: data });
    return response;
  }

  /**
   * Complete GitHub OAuth
   * 
   * Exchange authorization code for JWT tokens. Call this after GitHub
   * redirects back with code.
   */
  async accountsOauthGithubCallbackCreate(data: Models.OAuthCallbackRequestRequest): Promise<Models.OAuthTokenResponse> {
    const response = await this.client.request('POST', "/cfg/accounts/oauth/github/callback/", { body: data });
    return response;
  }

  /**
   * List OAuth providers
   * 
   * Get list of available OAuth providers for authentication.
   */
  async accountsOauthProvidersRetrieve(): Promise<Models.OAuthProvidersResponse> {
    const response = await this.client.request('GET', "/cfg/accounts/oauth/providers/");
    return response;
  }

}