UNPKG

@ringer-tel/ivy

Version:
128 lines (106 loc) 5.61 kB
/* tslint:disable */ /* eslint-disable */ /** * Ringer Business API * This API provides comprehensive endpoints for the Ringer Business system. It includes functionality for managing customer accounts, addresses, sites, phone numbers, payments, users, and other business resources. Operations typically require authentication and appropriate permissions. * * The version of the OpenAPI document: 1.0.6 * Contact: support@ringer.tel * * 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 { OauthComponentsSchemasError, RevokeRequest, TokenRequest, TokenResponse, } from '../models/index'; import { OauthComponentsSchemasErrorFromJSON, OauthComponentsSchemasErrorToJSON, RevokeRequestFromJSON, RevokeRequestToJSON, TokenRequestFromJSON, TokenRequestToJSON, TokenResponseFromJSON, TokenResponseToJSON, } from '../models/index'; export interface FetchAccessTokenRequest { tokenRequest: TokenRequest; } export interface RevokeAccessTokenRequest { revokeRequest: RevokeRequest; } /** * */ export class AuthenticationApi extends runtime.BaseAPI { /** * Requests an access token using one of the supported OAuth 2.0 grant types. The specific parameters required in the request body depend on the `grant_type` used. - For `password` grant: include `username`, `password`, `client_id`, and `client_secret`. - For `refresh_token` grant: include `refresh_token`, `client_id`, and `client_secret`. Successful authentication returns an access token, its type, expiration time, and a refresh token (if applicable for the grant type). * Obtain an OAuth 2.0 Access Token */ async fetchAccessTokenRaw(requestParameters: FetchAccessTokenRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TokenResponse>> { if (requestParameters['tokenRequest'] == null) { throw new runtime.RequiredError( 'tokenRequest', 'Required parameter "tokenRequest" was null or undefined when calling fetchAccessToken().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ path: `/oauth/token`, method: 'POST', headers: headerParameters, query: queryParameters, body: TokenRequestToJSON(requestParameters['tokenRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => TokenResponseFromJSON(jsonValue)); } /** * Requests an access token using one of the supported OAuth 2.0 grant types. The specific parameters required in the request body depend on the `grant_type` used. - For `password` grant: include `username`, `password`, `client_id`, and `client_secret`. - For `refresh_token` grant: include `refresh_token`, `client_id`, and `client_secret`. Successful authentication returns an access token, its type, expiration time, and a refresh token (if applicable for the grant type). * Obtain an OAuth 2.0 Access Token */ async fetchAccessToken(requestParameters: FetchAccessTokenRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TokenResponse> { const response = await this.fetchAccessTokenRaw(requestParameters, initOverrides); return await response.value(); } /** * Revokes an active access token or refresh token, effectively logging the user or application out. The request must include the token to be revoked and client credentials for authentication of the revocation request itself. * Revoke an OAuth 2.0 Token */ async revokeAccessTokenRaw(requestParameters: RevokeAccessTokenRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> { if (requestParameters['revokeRequest'] == null) { throw new runtime.RequiredError( 'revokeRequest', 'Required parameter "revokeRequest" was null or undefined when calling revokeAccessToken().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { // oauth required headerParameters["Authorization"] = await this.configuration.accessToken("oAuth2", []); } const response = await this.request({ path: `/oauth/revoke`, method: 'POST', headers: headerParameters, query: queryParameters, body: RevokeRequestToJSON(requestParameters['revokeRequest']), }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Revokes an active access token or refresh token, effectively logging the user or application out. The request must include the token to be revoked and client credentials for authentication of the revocation request itself. * Revoke an OAuth 2.0 Token */ async revokeAccessToken(requestParameters: RevokeAccessTokenRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> { await this.revokeAccessTokenRaw(requestParameters, initOverrides); } }