UNPKG

@novo-learning/novo-sdk

Version:

SDK for the Novolanguage Speech Analysis API

40 lines (35 loc) 1.46 kB
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import { LanguageCodeMapper } from '../../mappers/language-code.mapper'; import { Configuration, MetadataApi as GeneratedMetadataApi, MetadataDtoV1, MetadataRequestDtoV1, PronunciationMetadataRequestDtoV1, } from './generated'; export class MetadataApi { private readonly api: GeneratedMetadataApi; private readonly languageCodeMapper: LanguageCodeMapper; constructor(configuration?: Configuration | undefined, basePath?: string, axios?: AxiosInstance) { this.api = new GeneratedMetadataApi(configuration, basePath, axios); this.languageCodeMapper = new LanguageCodeMapper(); } public async getMetadataV1( { phrase, targetLanguage, secret, userData }: MetadataRequestDtoV1, options?: AxiosRequestConfig<unknown> | undefined, ): Promise<AxiosResponse<Array<MetadataDtoV1>>> { return this.api.getMetadataV1( { phrase, targetLanguage: this.languageCodeMapper.mapFromGenerated(targetLanguage), secret, userData }, options, ); } public async getPronunciationMetadataV1( { words, language, secret, userData }: PronunciationMetadataRequestDtoV1, options?: AxiosRequestConfig<unknown> | undefined, ): Promise<AxiosResponse<Array<MetadataDtoV1>>> { return this.api.getPronunciationMetadataV1( { words, language: this.languageCodeMapper.mapFromGenerated(language), secret, userData }, options, ); } }