import { ApiResponse , RequestOptions } from '../core' ; import { ObtainTokenRequest , obtainTokenRequestSchema , } from '../models/obtainTokenRequest' ; import { ObtainTokenResponse , obtainTokenResponseSchema , } from '../models/obtainTokenResponse' ; import { RenewTokenRequest , renewTokenRequestSchema , } from '../models/renewTokenRequest' ; import { RenewTokenResponse , renewTokenResponseSchema , } from '../models/renewTokenResponse' ; import { RevokeTokenRequest , revokeTokenRequestSchema , } from '../models/revokeTokenRequest' ; import { RevokeTokenResponse , revokeTokenResponseSchema , } from '../models/revokeTokenResponse' ; import { string } from '../schema' ; import { BaseApi } from './baseApi' ; export class OAuthApi extends BaseApi { param clientId param body param authorization return deprecated async renewToken ( clientId , body , authorization , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { clientId : [ clientId , string ( ) ] , body : [ body , renewTokenRequestSchema ] , authorization : [ authorization , string ( ) ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . header ( 'Authorization' , mapped . authorization ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/oauth2/clients/${ mapped . clientId }/access-token/renew` ; req . deprecated ( 'OAuthApi.renewToken' ) ; req . authenticate ( false ) ; return req . callAsJson ( renewTokenResponseSchema , requestOptions ) ; } param body param authorization return async revokeToken ( body , authorization , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/oauth2/revoke' ) ; const mapped = req . prepareArgs ( { body : [ body , revokeTokenRequestSchema ] , authorization : [ authorization , string ( ) ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . header ( 'Authorization' , mapped . authorization ) ; req . json ( mapped . body ) ; req . authenticate ( false ) ; return req . callAsJson ( revokeTokenResponseSchema , requestOptions ) ; } param body return async obtainToken ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/oauth2/token' ) ; const mapped = req . prepareArgs ( { body : [ body , obtainTokenRequestSchema ] } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . authenticate ( false ) ; return req . callAsJson ( obtainTokenResponseSchema , requestOptions ) ; } }