UNPKG

@novo-learning/novo-sdk

Version:

SDK for the Novolanguage Speech Analysis API

470 lines (432 loc) 16.9 kB
/* tslint:disable */ /* eslint-disable */ /** * Authentication API * The authentication API is used to get signed JWT tokens to access other APIs * * The version of the OpenAPI document: 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 { Configuration } from './configuration'; import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; /** * * @export * @interface AuthenticateSsoRequestDtoV1 */ export interface AuthenticateSsoRequestDtoV1 { /** * Identifier of the publisher who authenticates a session * @type {string} * @memberof AuthenticateSsoRequestDtoV1 */ 'publisherId': string; /** * Details of the user being authenticated * @type {UserDataDtoV1} * @memberof AuthenticateSsoRequestDtoV1 */ 'userData': UserDataDtoV1; /** * Secret key of the publisher * @type {string} * @memberof AuthenticateSsoRequestDtoV1 */ 'publisherToken': string; } /** * * @export * @interface AuthenticationDataDtoV1 */ export interface AuthenticationDataDtoV1 { /** * User data * @type {UserDataDtoV1} * @memberof AuthenticationDataDtoV1 */ 'user': UserDataDtoV1; /** * JWT payload * @type {AuthenticationPayloadDtoV1} * @memberof AuthenticationDataDtoV1 */ 'payload': AuthenticationPayloadDtoV1; } /** * * @export * @interface AuthenticationPayloadDtoV1 */ export interface AuthenticationPayloadDtoV1 { /** * Type * @type {string} * @memberof AuthenticationPayloadDtoV1 */ 'type': string; /** * JWT access token * @type {string} * @memberof AuthenticationPayloadDtoV1 */ 'token': string; /** * JWT refresh token * @type {string} * @memberof AuthenticationPayloadDtoV1 */ 'refresh_token'?: string; /** * expiration time in milliseconds * @type {number} * @memberof AuthenticationPayloadDtoV1 */ 'access_token_expires_in': number; /** * expiration time in milliseconds * @type {number} * @memberof AuthenticationPayloadDtoV1 */ 'refresh_token_expires_in': number; } /** * * @export * @interface AuthenticationResponseDtoV1 */ export interface AuthenticationResponseDtoV1 { /** * Status of the authentication request * @type {string} * @memberof AuthenticationResponseDtoV1 */ 'status': string; /** * Authentication data * @type {AuthenticationDataDtoV1} * @memberof AuthenticationResponseDtoV1 */ 'data': AuthenticationDataDtoV1; } /** * The permissions the user has for the group. A user can always send audio and retrieve its own recording / asr_result. * @export * @enum {string} */ export const PermissionType = { attempt_read_result: 'attempt_read_result', attempt_read_audio: 'attempt_read_audio', attempt_read_group_result: 'attempt_read_group_result', attempt_read_group_audio: 'attempt_read_group_audio', attempt_edit: 'attempt_edit', attempt_delete: 'attempt_delete', attempt_maintenance: 'attempt_maintenance', exercise_edit: 'exercise_edit', exercise_delete: 'exercise_delete', exercise_maintenance: 'exercise_maintenance', publisher_edit: 'publisher_edit', publisher_read: 'publisher_read', publisher_maintenance: 'publisher_maintenance', publisher_configuration_read: 'publisher_configuration_read', publisher_configuration_edit: 'publisher_configuration_edit', pronunciation_edit: 'pronunciation_edit' } as const; export type PermissionType = typeof PermissionType[keyof typeof PermissionType]; /** * * @export * @interface RefreshRequestDtoV1 */ export interface RefreshRequestDtoV1 { /** * * @type {string} * @memberof RefreshRequestDtoV1 */ 'refresh_token': string; } /** * The retention policy for this user: \'all\' (default), \'attempt\' or \'none\'. Audio and attempts should be retained for the publisher * @export * @enum {string} */ export const RetentionType = { all: 'all', attempt: 'attempt', none: 'none' } as const; export type RetentionType = typeof RetentionType[keyof typeof RetentionType]; /** * * @export * @interface SsoRequestDtoV1 */ export interface SsoRequestDtoV1 { /** * Identifier of the publisher who authenticates a session * @type {string} * @memberof SsoRequestDtoV1 */ 'publisherId': string; /** * Details of the user being authenticated * @type {UserDataDtoV1} * @memberof SsoRequestDtoV1 */ 'userData': UserDataDtoV1; } /** * * @export * @interface UserDataDtoV1 */ export interface UserDataDtoV1 { /** * Identifier for a user * @type {string} * @memberof UserDataDtoV1 */ 'userId': string; /** * Identifier of a group to whom the user belongs. * @type {string} * @memberof UserDataDtoV1 */ 'groupId'?: string; /** * * @type {Array<PermissionType>} * @memberof UserDataDtoV1 */ 'permissions'?: Array<PermissionType>; /** * * @type {RetentionType} * @memberof UserDataDtoV1 */ 'retention'?: RetentionType; /** * Dictionary with meta data about the user, for instance native language or type of browser. Do not include any data which could be used to identify a user. The metadata is stored along the attempts made by the user in this session. * @type {object} * @memberof UserDataDtoV1 */ 'metadata'?: object; } /** * AuthApi - axios parameter creator * @export */ export const AuthApiAxiosParamCreator = function (configuration?: Configuration) { return { /** * Refresh an authentication token * @param {RefreshRequestDtoV1} refreshRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ refresh: async (refreshRequestDtoV1: RefreshRequestDtoV1, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'refreshRequestDtoV1' is not null or undefined assertParamExists('refresh', 'refreshRequestDtoV1', refreshRequestDtoV1) const localVarPath = `/v1/auth/refresh`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(refreshRequestDtoV1, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Authenticate using SSO * @param {AuthenticateSsoRequestDtoV1} authenticateSsoRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ sso: async (authenticateSsoRequestDtoV1: AuthenticateSsoRequestDtoV1, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'authenticateSsoRequestDtoV1' is not null or undefined assertParamExists('sso', 'authenticateSsoRequestDtoV1', authenticateSsoRequestDtoV1) const localVarPath = `/v1/auth/sso`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(authenticateSsoRequestDtoV1, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Authenticate using SSO with an anonymous user * @param {SsoRequestDtoV1} ssoRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ ssoAnonymous: async (ssoRequestDtoV1: SsoRequestDtoV1, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'ssoRequestDtoV1' is not null or undefined assertParamExists('ssoAnonymous', 'ssoRequestDtoV1', ssoRequestDtoV1) const localVarPath = `/v1/auth/sso/anonymous`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(ssoRequestDtoV1, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, } }; /** * AuthApi - functional programming interface * @export */ export const AuthApiFp = function(configuration?: Configuration) { const localVarAxiosParamCreator = AuthApiAxiosParamCreator(configuration) return { /** * Refresh an authentication token * @param {RefreshRequestDtoV1} refreshRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ async refresh(refreshRequestDtoV1: RefreshRequestDtoV1, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthenticationResponseDtoV1>> { const localVarAxiosArgs = await localVarAxiosParamCreator.refresh(refreshRequestDtoV1, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** * Authenticate using SSO * @param {AuthenticateSsoRequestDtoV1} authenticateSsoRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ async sso(authenticateSsoRequestDtoV1: AuthenticateSsoRequestDtoV1, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthenticationResponseDtoV1>> { const localVarAxiosArgs = await localVarAxiosParamCreator.sso(authenticateSsoRequestDtoV1, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** * Authenticate using SSO with an anonymous user * @param {SsoRequestDtoV1} ssoRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ async ssoAnonymous(ssoRequestDtoV1: SsoRequestDtoV1, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthenticationResponseDtoV1>> { const localVarAxiosArgs = await localVarAxiosParamCreator.ssoAnonymous(ssoRequestDtoV1, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, } }; /** * AuthApi - factory interface * @export */ export const AuthApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { const localVarFp = AuthApiFp(configuration) return { /** * Refresh an authentication token * @param {RefreshRequestDtoV1} refreshRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ refresh(refreshRequestDtoV1: RefreshRequestDtoV1, options?: any): AxiosPromise<AuthenticationResponseDtoV1> { return localVarFp.refresh(refreshRequestDtoV1, options).then((request) => request(axios, basePath)); }, /** * Authenticate using SSO * @param {AuthenticateSsoRequestDtoV1} authenticateSsoRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ sso(authenticateSsoRequestDtoV1: AuthenticateSsoRequestDtoV1, options?: any): AxiosPromise<AuthenticationResponseDtoV1> { return localVarFp.sso(authenticateSsoRequestDtoV1, options).then((request) => request(axios, basePath)); }, /** * Authenticate using SSO with an anonymous user * @param {SsoRequestDtoV1} ssoRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} */ ssoAnonymous(ssoRequestDtoV1: SsoRequestDtoV1, options?: any): AxiosPromise<AuthenticationResponseDtoV1> { return localVarFp.ssoAnonymous(ssoRequestDtoV1, options).then((request) => request(axios, basePath)); }, }; }; /** * AuthApi - object-oriented interface * @export * @class AuthApi * @extends {BaseAPI} */ export class AuthApi extends BaseAPI { /** * Refresh an authentication token * @param {RefreshRequestDtoV1} refreshRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AuthApi */ public refresh(refreshRequestDtoV1: RefreshRequestDtoV1, options?: AxiosRequestConfig) { return AuthApiFp(this.configuration).refresh(refreshRequestDtoV1, options).then((request) => request(this.axios, this.basePath)); } /** * Authenticate using SSO * @param {AuthenticateSsoRequestDtoV1} authenticateSsoRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AuthApi */ public sso(authenticateSsoRequestDtoV1: AuthenticateSsoRequestDtoV1, options?: AxiosRequestConfig) { return AuthApiFp(this.configuration).sso(authenticateSsoRequestDtoV1, options).then((request) => request(this.axios, this.basePath)); } /** * Authenticate using SSO with an anonymous user * @param {SsoRequestDtoV1} ssoRequestDtoV1 * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AuthApi */ public ssoAnonymous(ssoRequestDtoV1: SsoRequestDtoV1, options?: AxiosRequestConfig) { return AuthApiFp(this.configuration).ssoAnonymous(ssoRequestDtoV1, options).then((request) => request(this.axios, this.basePath)); } }