diff --git a/src/sdk/v4/audio.ts b/src/sdk/v4/audio.ts index a0d973c..a91c5ba 100644 --- a/src/sdk/v4/audio.ts +++ b/src/sdk/v4/audio.ts @@ -15,33 +15,33 @@ import { decamelize } from 'humps'; import Utils from '../utils'; import { fetcher } from './_fetcher'; -type GetChapterRecitationsOptions = Partial<{ +type GetChapterRecitationOptions = Partial<{ language: Language; }>; -const defaultChapterRecitationsOptions: GetChapterRecitationsOptions = { +const defaultChapterRecitationsOptions: GetChapterRecitationOptions = { language: Language.ARABIC, }; const getChapterRecitationsOptions = ( - options: GetChapterRecitationsOptions = {} + options: GetChapterRecitationOptions = {} ) => { const final: any = { ...defaultChapterRecitationsOptions, ...options }; return final; }; -type GetVerseRecitationsOptions = Partial<{ +type GetVerseRecitationOptions = Partial<{ language: Language; fields: Partial>; }>; -const defaultVerseRecitationsOptions: GetVerseRecitationsOptions = { +const defaultVerseRecitationsOptions: GetVerseRecitationOptions = { language: Language.ARABIC, }; const getVerseRecitationsOptions = ( - options: GetVerseRecitationsOptions = {} + options: GetVerseRecitationOptions = {} ) => { const initial = { ...defaultVerseRecitationsOptions, ...options }; const final: any = { language: initial.language }; @@ -61,13 +61,13 @@ const getVerseRecitationsOptions = ( * Get all chapter recitations for specific reciter * @description https://quran.api-docs.io/v4/audio-recitations/list-of-all-surah-audio-files-for-specific-reciter * @param {string} reciterId - * @param {GetChapterRecitationsOptions} options + * @param {GetChapterRecitationOptions} options * @example * quran.v4.audio.findAllChapterRecitations('2') */ const findAllChapterRecitations = async ( reciterId: string, - options?: GetChapterRecitationsOptions + options?: GetChapterRecitationOptions ) => { const params = getChapterRecitationsOptions(options); const { audioFiles } = await fetcher<{ audioFiles: ChapterRecitation[] }>( @@ -82,14 +82,14 @@ const findAllChapterRecitations = async ( * @description https://quran.api-docs.io/v4/audio-recitations/get-single-surah-audio-for-specific-reciter * @param {ChapterId} chapterId * @param {string} reciterId - * @param {GetChapterRecitationsOptions} options + * @param {GetChapterRecitationOptions} options * @example * quran.v4.audio.findChapterRecitationById('1', '2') // first chapter recitation for reciter 2 */ const findChapterRecitationById = async ( chapterId: ChapterId, reciterId: string, - options?: GetChapterRecitationsOptions + options?: GetChapterRecitationOptions ) => { if (!Utils.isValidChapterId(chapterId)) throw new Error('Invalid chapter id'); @@ -107,14 +107,14 @@ const findChapterRecitationById = async ( * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-surah * @param {ChapterId} chapterId * @param {string} recitationId - * @param {GetVerseRecitationsOptions} options + * @param {GetVerseRecitationOptions} options * @example * quran.v4.audio.findVerseRecitationsByChapter('1', '2') */ const findVerseRecitationsByChapter = async ( chapterId: ChapterId, recitationId: string, - options?: GetVerseRecitationsOptions + options?: GetVerseRecitationOptions ) => { if (!Utils.isValidChapterId(chapterId)) throw new Error('Invalid chapter id'); @@ -139,7 +139,7 @@ const findVerseRecitationsByChapter = async ( const findVerseRecitationsByJuz = async ( juz: JuzNumber, recitationId: string, - options?: GetVerseRecitationsOptions + options?: GetVerseRecitationOptions ) => { if (!Utils.isValidJuz(juz)) throw new Error('Invalid juz'); @@ -157,14 +157,14 @@ const findVerseRecitationsByJuz = async ( * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-madani-mushaf-page * @param {PageNumber} page * @param {string} recitationId - * @param {GetVerseRecitationsOptions} options + * @param {GetVerseRecitationOptions} options * @example * quran.v4.audio.findVerseRecitationsByPage('1', '2') */ const findVerseRecitationsByPage = async ( page: PageNumber, recitationId: string, - options?: GetVerseRecitationsOptions + options?: GetVerseRecitationOptions ) => { if (!Utils.isValidQuranPage(page)) throw new Error('Invalid page'); @@ -182,14 +182,14 @@ const findVerseRecitationsByPage = async ( * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-rub * @param {RubNumber} rub * @param {string} recitationId - * @param {GetVerseRecitationsOptions} options + * @param {GetVerseRecitationOptions} options * @example * quran.v4.audio.findVerseRecitationsByRub('1', '2') */ const findVerseRecitationsByRub = async ( rub: RubNumber, recitationId: string, - options?: GetVerseRecitationsOptions + options?: GetVerseRecitationOptions ) => { if (!Utils.isValidRub(rub)) throw new Error('Invalid rub'); @@ -207,14 +207,14 @@ const findVerseRecitationsByRub = async ( * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-hizb * @param {HizbNumber} hizb * @param {string} recitationId - * @param {GetVerseRecitationsOptions} options + * @param {GetVerseRecitationOptions} options * @example * quran.v4.audio.findVerseRecitationsByHizb('1', '2') */ const findVerseRecitationsByHizb = async ( hizb: HizbNumber, recitationId: string, - options?: GetVerseRecitationsOptions + options?: GetVerseRecitationOptions ) => { if (!Utils.isValidHizb(hizb)) throw new Error('Invalid hizb'); @@ -228,18 +228,18 @@ const findVerseRecitationsByHizb = async ( }; /** - * Get all verse audio files for a specific reciter and a specific hizb + * Get all verse audio files for a specific reciter and a specific verse * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-ayah * @param {VerseKey} key * @param {string} recitationId - * @param {GetVerseRecitationsOptions} options + * @param {GetVerseRecitationOptions} options * @example * quran.v4.audio.findVerseRecitationsByKey('1:1', '2') */ const findVerseRecitationsByKey = async ( key: VerseKey, recitationId: string, - options?: GetVerseRecitationsOptions + options?: GetVerseRecitationOptions ) => { if (!Utils.isValidVerseKey(key)) throw new Error('Invalid verse key'); diff --git a/src/sdk/v4/chapters.ts b/src/sdk/v4/chapters.ts index 4478a0c..2550a77 100644 --- a/src/sdk/v4/chapters.ts +++ b/src/sdk/v4/chapters.ts @@ -2,15 +2,15 @@ import { Chapter, ChapterId, ChapterInfo, Language } from '../../types'; import { fetcher } from './_fetcher'; import Utils from '../utils'; -type Options = Partial<{ +type GetChapterOptions = Partial<{ language: Language; }>; -const defaultOptions: Options = { +const defaultOptions: GetChapterOptions = { language: Language.ARABIC, }; -const getChapterOptions = (options: Options = {}) => { +const getChapterOptions = (options: GetChapterOptions = {}) => { const final: any = { ...defaultOptions, ...options }; return final; }; @@ -18,11 +18,11 @@ const getChapterOptions = (options: Options = {}) => { /** * Get all chapters. * @description https://quran.api-docs.io/v4/chapters/list-chapters - * @param {Options} options + * @param {GetChapterOptions} options * @example * quran.v4.chapters.findAll() */ -const findAll = async (options?: Options) => { +const findAll = async (options?: GetChapterOptions) => { const params = getChapterOptions(options); const { chapters } = await fetcher<{ chapters: Chapter[] }>( '/chapters', @@ -36,12 +36,12 @@ const findAll = async (options?: Options) => { * Get chapter by id. * @description https://quran.api-docs.io/v4/chapters/get-chapter * @param {ChapterId} id chapter id, minimum 1, maximum 114 - * @param {Options} options + * @param {GetChapterOptions} options * @example * quran.v4.chapters.findById('1') * quran.v4.chapters.findById('114') */ -const findById = async (id: ChapterId, options?: Options) => { +const findById = async (id: ChapterId, options?: GetChapterOptions) => { if (!Utils.isValidChapterId(id)) throw new Error('Invalid chapter id'); const params = getChapterOptions(options); @@ -57,12 +57,12 @@ const findById = async (id: ChapterId, options?: Options) => { * Get chapter info by id. * @description https://quran.api-docs.io/v4/chapters/chapter_info * @param {ChapterId} id chapter id, minimum 1, maximum 114 - * @param {Options} options + * @param {GetChapterOptions} options * @example * quran.v4.chapters.findInfoById('1') * quran.v4.chapters.findInfoById('114') */ -const findInfoById = async (id: ChapterId, options?: Options) => { +const findInfoById = async (id: ChapterId, options?: GetChapterOptions) => { if (!Utils.isValidChapterId(id)) throw new Error('Invalid chapter id'); const params = getChapterOptions(options); diff --git a/src/sdk/v4/resources.ts b/src/sdk/v4/resources.ts index cb88b55..7b4e3c2 100644 --- a/src/sdk/v4/resources.ts +++ b/src/sdk/v4/resources.ts @@ -14,15 +14,15 @@ import { } from '../../types'; import { fetcher } from './_fetcher'; -type GetResourcesOptions = Partial<{ +type GetResourceOptions = Partial<{ language: Language; }>; -const defaultOptions: GetResourcesOptions = { +const defaultOptions: GetResourceOptions = { language: Language.ARABIC, }; -const getResourcesOptions = (options: GetResourcesOptions = {}) => { +const getResourcesOptions = (options: GetResourceOptions = {}) => { const final: any = { ...defaultOptions, ...options }; return final; }; @@ -30,11 +30,11 @@ const getResourcesOptions = (options: GetResourcesOptions = {}) => { /** * Get all recitations. * @description https://quran.api-docs.io/v4/resources/recitations - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findAllRecitations() */ -const findAllRecitations = async (options?: GetResourcesOptions) => { +const findAllRecitations = async (options?: GetResourceOptions) => { const params = getResourcesOptions(options); const { recitations } = await fetcher<{ recitations: RecitationResource[]; @@ -48,11 +48,11 @@ const findAllRecitations = async (options?: GetResourcesOptions) => { * Get all recitation info. * @description https://quran.api-docs.io/v4/resources/recitation-info * @param {string} id recitation id - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findRecitationInfo('1') */ -// const findRecitationInfo = async (id: string, options?: GetResourcesOptions) => { +// const findRecitationInfo = async (id: string, options?: GetResourceOptions) => { // const params = getResourcesOptions(options); // const { info } = await fetcher<{ // info: RecitationInfoResource; @@ -64,11 +64,11 @@ const findAllRecitations = async (options?: GetResourcesOptions) => { /** * Get all translations. * @description https://quran.api-docs.io/v4/resources/translations - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findAllTranslations() */ -const findAllTranslations = async (options?: GetResourcesOptions) => { +const findAllTranslations = async (options?: GetResourceOptions) => { const params = getResourcesOptions(options); const { translations } = await fetcher<{ translations: TranslationResource[]; @@ -82,11 +82,11 @@ const findAllTranslations = async (options?: GetResourcesOptions) => { * Get translation info. * @description https://quran.api-docs.io/v4/resources/translation-info * @param {string} id translation id - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findTranslationInfo('169') */ -// const findTranslationInfo = async (id: string, options?: GetResourcesOptions) => { +// const findTranslationInfo = async (id: string, options?: GetResourceOptions) => { // const params = getResourcesOptions(options); // const { info } = await fetcher<{ // info: TranslationInfoResource; @@ -98,11 +98,11 @@ const findAllTranslations = async (options?: GetResourcesOptions) => { /** * Get all tafsirs. * @description https://quran.api-docs.io/v4/resources/tafsirs - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findAllTafsirs() */ -const findAllTafsirs = async (options?: GetResourcesOptions) => { +const findAllTafsirs = async (options?: GetResourceOptions) => { const params = getResourcesOptions(options); const { tafsirs } = await fetcher<{ tafsirs: TafsirResource[]; @@ -116,11 +116,11 @@ const findAllTafsirs = async (options?: GetResourcesOptions) => { * Get tafsir info. * @description https://quran.api-docs.io/v4/resources/tafsirs-info * @param {string} id tafsir id - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findTranslationInfo('1') */ -// const findTafsirInfo = async (id: string, options?: GetResourcesOptions) => { +// const findTafsirInfo = async (id: string, options?: GetResourceOptions) => { // const params = getResourcesOptions(options); // const { info } = await fetcher<{ // info: TafsirInfoResource; @@ -146,11 +146,11 @@ const findAllRecitationStyles = async () => { /** * Get all languages. * @description https://quran.api-docs.io/v4/resources/languages - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findAllLanguages() */ -const findAllLanguages = async (options?: GetResourcesOptions) => { +const findAllLanguages = async (options?: GetResourceOptions) => { const params = getResourcesOptions(options); const { languages } = await fetcher<{ languages: LanguageResource[]; @@ -162,11 +162,11 @@ const findAllLanguages = async (options?: GetResourcesOptions) => { /** * Get all chapter infos. * @description https://quran.api-docs.io/v4/resources/chapter-info - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findAllChapterInfos() */ -const findAllChapterInfos = async (options?: GetResourcesOptions) => { +const findAllChapterInfos = async (options?: GetResourceOptions) => { const params = getResourcesOptions(options); const { chapterInfos } = await fetcher<{ chapterInfos: ChapterInfoResource[]; @@ -178,11 +178,11 @@ const findAllChapterInfos = async (options?: GetResourcesOptions) => { /** * Get verse media. * @description https://quran.api-docs.io/v4/resources/verse_media - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findVerseMedia() */ -const findVerseMedia = async (options?: GetResourcesOptions) => { +const findVerseMedia = async (options?: GetResourceOptions) => { const params = getResourcesOptions(options); const { verseMedia } = await fetcher<{ verseMedia: VerseMediaResource; @@ -194,11 +194,11 @@ const findVerseMedia = async (options?: GetResourcesOptions) => { /** * Get all chapter reciters. * @description https://quran.api-docs.io/v4/resources/list-of-chapter-reciters - * @param {GetResourcesOptions} options + * @param {GetResourceOptions} options * @example * quran.v4.resources.findAllChapterReciters() */ -const findAllChapterReciters = async (options?: GetResourcesOptions) => { +const findAllChapterReciters = async (options?: GetResourceOptions) => { const params = getResourcesOptions(options); const { reciters } = await fetcher<{ reciters: ChapterReciterResource[]; diff --git a/src/sdk/v4/search.ts b/src/sdk/v4/search.ts index 45d2da2..8ec8d34 100644 --- a/src/sdk/v4/search.ts +++ b/src/sdk/v4/search.ts @@ -20,13 +20,13 @@ const getSearchOptions = (q: string, options: SearchOptions = {}) => { /** * Search * @description https://quran.api-docs.io/v4/search/KfCmk4KQYbtyK9adj - * @param q search query - * @param options search options + * @param {string} q search query + * @param {SearchOptions} options * @example - * quran.v4.search.search('الله') - * quran.v4.search.search('الله', { language: Language.ENGLISH }) - * quran.v4.search.search('الله', { language: Language.ENGLISH, size: 10 }) - * quran.v4.search.search('الله', { language: Language.ENGLISH, page: 2 }) + * quran.v4.search.search('نور') + * quran.v4.search.search('نور', { language: Language.ENGLISH }) + * quran.v4.search.search('نور', { language: Language.ENGLISH, size: 10 }) + * quran.v4.search.search('نور', { language: Language.ENGLISH, page: 2 }) */ const search = async (q: string, options?: SearchOptions) => { const params = getSearchOptions(q, options);