diff --git a/src/quran/audio.ts b/src/quran/audio.ts index 38ae9f5..9d2ee5e 100644 --- a/src/quran/audio.ts +++ b/src/quran/audio.ts @@ -1,12 +1,11 @@ import { AxiosError } from "axios"; import url from "url"; import Api from "../api"; -import { AudioApi, AudioQueryParams, IAudio, IListOfAllAudioOfAReciter, IRecitation, ISingleRecitation, IReciters, IAyahRecitationSpecificSurah, IAyahRecitationSpecificJuz, IAyahRecitationSpecificMadaniMushafPage, IAyahRecitationSpecificRubelHizb, IAyahRecitationSpecificHizb, IAyahRecitationSpecificAyah } from "../types"; +import { AudioApi, AudioQueryParams, IAudio, IListOfAllAudioOfAReciter, IRecitation, ISingleRecitation, IReciters, IAyahRecitationSpecificSurah, IAyahRecitationSpecificJuz, IAyahRecitationSpecificMadaniMushafPage, IAyahRecitationSpecificRubelHizb, IAyahRecitationSpecificHizb, IAyahRecitationSpecificAyah, ALLOWED_LANGUAGES } from "../types"; import { handleError, handleResponse } from "../utils"; const api = Api(); -const ALLOWED_LANGUAGES = new Set(['en', 'ur', 'bn', 'tr', 'es', 'fr', 'bs', 'ru', 'ml', 'id', 'uz', 'nl', 'de', 'tg', 'ta', 'ja', 'it', 'vi', 'zh', 'sq', 'fa', 'bg', 'bm', 'ha', 'pt', 'ro', 'hi', 'sw', 'kk', 'th', 'tl', 'km', 'as', 'ko', 'so', 'az', 'ku', 'dv', 'ms', 'prs', 'zgh', 'am', 'ce', 'cs', 'fi', 'gu', 'he', 'ka', 'kn', 'ks', 'lg', 'mk', 'mr', 'mrn', 'ne', 'no', 'om', 'pl', 'ps', 'rw', 'sd', 'se', 'si', 'sr', 'sv', 'te', 'tt', 'ug', 'uk', 'sq', 'yo']); const audio: AudioApi = { diff --git a/src/quran/chapter.ts b/src/quran/chapter.ts index 0106031..2875a97 100644 --- a/src/quran/chapter.ts +++ b/src/quran/chapter.ts @@ -1,12 +1,10 @@ import { AxiosError } from "axios"; import Api from "../api"; -import { ChapterApi, ListChapters, Chapter, ChapterInfo } from "../types"; +import { ChapterApi, ListChapters, Chapter, ChapterInfo, ALLOWED_LANGUAGES } from "../types"; import { handleError, handleResponse } from "../utils"; const api = Api(); -const ALLOWED_LANGUAGES = new Set(['en', 'ur', 'bn', 'tr', 'es', 'fr', 'bs', 'ru', 'ml', 'id', 'uz', 'nl', 'de', 'tg', 'ta', 'ja', 'it', 'vi', 'zh', 'sq', 'fa', 'bg', 'bm', 'ha', 'pt', 'ro', 'hi', 'sw', 'kk', 'th', 'tl', 'km', 'as', 'ko', 'so', 'az', 'ku', 'dv', 'ms', 'prs', 'zgh', 'am', 'ce', 'cs', 'fi', 'gu', 'he', 'ka', 'kn', 'ks', 'lg', 'mk', 'mr', 'mrn', 'ne', 'no', 'om', 'pl', 'ps', 'rw', 'sd', 'se', 'si', 'sr', 'sv', 'te', 'tt', 'ug', 'uk', 'sq', 'yo']); - const chapter: ChapterApi = { listChapters(language = 'en'): Promise { diff --git a/src/quran/resource.test.ts b/src/quran/resource.test.ts index 11cedf0..d63320c 100644 --- a/src/quran/resource.test.ts +++ b/src/quran/resource.test.ts @@ -1,131 +1,131 @@ import resources from "./resource"; describe("Fetching the recitation by id", () => { - beforeEach(() => jest.clearAllMocks()); - - it("Should fetch the recitation info of a specific recitaion", async () => { - const res: any = await resources.getRecitationInfo('1'); - expect(res).toHaveProperty('info'); - expect(res.info).toHaveProperty('id'); - expect(res.info).toHaveProperty('info'); - }); - - it("Should return a response with 404 status code", async () => { - const res: any = await resources.getRecitationInfo('101839'); - expect(res).toHaveProperty('status'); - expect(res.status).toEqual(404); - }); + beforeEach(() => jest.clearAllMocks()); + + it("Should fetch the recitation info of a specific recitaion", async () => { + const res: any = await resources.getRecitationInfo('1'); + expect(res).toHaveProperty('info'); + expect(res.info).toHaveProperty('id'); + expect(res.info).toHaveProperty('info'); + }); + + it("Should return a response with 404 status code", async () => { + const res: any = await resources.getRecitationInfo('101839'); + expect(res).toHaveProperty('status'); + expect(res.status).toEqual(404); + }); }); describe("Fetching the translation info by translation_id", () => { - beforeEach(() => jest.clearAllMocks()); - - it("Should fetch the translation info of a specific recitaion by translation_id", async () => { - const res: any = await resources.getTranslationInfo('23'); - expect(res).toHaveProperty('info'); - expect(res.info).toHaveProperty('id'); - expect(res.info).toHaveProperty('info'); - expect(res.info.info).toBeNull(); - }); - - it("Should return a response with 404 status code", async () => { - const res: any = await resources.getTranslationInfo('101839'); - expect(res).toHaveProperty('status'); - expect(res.status).toEqual(404); - }); + beforeEach(() => jest.clearAllMocks()); + + it("Should fetch the translation info of a specific recitaion by translation_id", async () => { + const res: any = await resources.getTranslationInfo('23'); + expect(res).toHaveProperty('info'); + expect(res.info).toHaveProperty('id'); + expect(res.info).toHaveProperty('info'); + expect(res.info.info).toBeNull(); + }); + + it("Should return a response with 404 status code", async () => { + const res: any = await resources.getTranslationInfo('101839'); + expect(res).toHaveProperty('status'); + expect(res.status).toEqual(404); + }); }); describe("Fetching all translations info by language", () => { - beforeEach(() => jest.clearAllMocks()); - - it("Should fetch all translations info by language", async () => { - const res: any = await resources.getTranslations('ha'); - expect(res).toHaveProperty('translations'); - }); - - it("Should reject with a error if an invalid language iso code is provided", async () => { - try { - const res: any = await resources.getTranslations('abcd'); - } catch (err: any) { - expect(err.message).toEqual('Provided language is not supported'); - } - }); + beforeEach(() => jest.clearAllMocks()); + + it("Should fetch all translations info by language", async () => { + const res: any = await resources.getTranslations('ha'); + expect(res).toHaveProperty('translations'); + }); + + it("Should reject with a error if an invalid language iso code is provided", async () => { + try { + const res: any = await resources.getTranslations('abcd'); + } catch (err: any) { + expect(err.message).toEqual('Provided language is not supported'); + } + }); }); describe("Fetching all tafsirs info by language", () => { - beforeEach(() => jest.clearAllMocks()); - - it("Should fetch all tafsirs info by language", async () => { - const res: any = await resources.getTafsirs('ha'); - expect(res).toHaveProperty('tafsirs'); - }); - - it("Should reject with a error if an invalid language iso code is provided", async () => { - try { - const res: any = await resources.getTafsirs('abcd'); - } catch (err: any) { - expect(err.message).toEqual('Provided language is not supported'); - } - }); + beforeEach(() => jest.clearAllMocks()); + + it("Should fetch all tafsirs info by language", async () => { + const res: any = await resources.getTafsirs('ha'); + expect(res).toHaveProperty('tafsirs'); + }); + + it("Should reject with a error if an invalid language iso code is provided", async () => { + try { + const res: any = await resources.getTafsirs('abcd'); + } catch (err: any) { + expect(err.message).toEqual('Provided language is not supported'); + } + }); }); describe("Fetching tafsir info by tafsir_id", () => { - beforeEach(() => jest.clearAllMocks()); - - it("Should fetch tafsir info by tafsir_id", async () => { - const res: any = await resources.getTafsirInfo('381'); - expect(res).toHaveProperty('info'); - expect(res.info).toHaveProperty('id'); - expect(res.info.id).toBe(381); - expect(res.info.info).toBe(""); - }); - - it("Should reject with a error if an invalid tafsir_id is provided", async () => { - const res: any = await resources.getTafsirInfo('1'); - expect(res).toHaveProperty('status'); - expect(res.status).toEqual(404); - expect(res.error).toBe('Tafsir not found'); - }); + beforeEach(() => jest.clearAllMocks()); + + it("Should fetch tafsir info by tafsir_id", async () => { + const res: any = await resources.getTafsirInfo('381'); + expect(res).toHaveProperty('info'); + expect(res.info).toHaveProperty('id'); + expect(res.info.id).toBe(381); + expect(res.info.info).toBe(""); + }); + + it("Should reject with a error if an invalid tafsir_id is provided", async () => { + const res: any = await resources.getTafsirInfo('1'); + expect(res).toHaveProperty('status'); + expect(res.status).toEqual(404); + expect(res.error).toBe('Tafsir not found'); + }); }); describe("Fetching all recitation styles", () => { - beforeEach(() => jest.clearAllMocks()); - - it("Should fetch all recitation styles", async () => { - const res: any = await resources.getRecitationStyles(); - expect(res).toHaveProperty('recitation_styles'); - expect(res.recitation_styles).toHaveProperty('mujawwad'); - expect(res.recitation_styles).toHaveProperty('murattal'); - expect(res.recitation_styles).toHaveProperty('muallim'); - }); + beforeEach(() => jest.clearAllMocks()); + + it("Should fetch all recitation styles", async () => { + const res: any = await resources.getRecitationStyles(); + expect(res).toHaveProperty('recitation_styles'); + expect(res.recitation_styles).toHaveProperty('mujawwad'); + expect(res.recitation_styles).toHaveProperty('murattal'); + expect(res.recitation_styles).toHaveProperty('muallim'); + }); }); describe("Fetching all languages", () => { - beforeEach(() => jest.clearAllMocks()); + beforeEach(() => jest.clearAllMocks()); - it("Should fetch all languages", async () => { - const res: any = await resources.getLanguages(); - expect(res).toHaveProperty('languages');; - expect(res.languages).toBeInstanceOf(Array); - }); + it("Should fetch all languages", async () => { + const res: any = await resources.getLanguages(); + expect(res).toHaveProperty('languages');; + expect(res.languages).toBeInstanceOf(Array); + }); }); describe("Fetching all Chapter infos", () => { - beforeEach(() => jest.clearAllMocks()); + beforeEach(() => jest.clearAllMocks()); - it("Should fetch all Chapter infos", async () => { - const res: any = await resources.getChapterInfos(); - expect(res).toHaveProperty('chapter_infos');; - expect(res.chapter_infos).toBeInstanceOf(Array); - }); + it("Should fetch all Chapter infos", async () => { + const res: any = await resources.getChapterInfos(); + expect(res).toHaveProperty('chapter_infos');; + expect(res.chapter_infos).toBeInstanceOf(Array); + }); }); describe("Fetching all Media verses", () => { - beforeEach(() => jest.clearAllMocks()); + beforeEach(() => jest.clearAllMocks()); - it("Should fetch all Media verses", async () => { - const res: any = await resources.getVerseMedias(); - expect(res).toHaveProperty('verse_media');; - expect(res.verse_media).toBeInstanceOf(Array); - }); + it("Should fetch all Media verses", async () => { + const res: any = await resources.getVerseMedias(); + expect(res).toHaveProperty('verse_media');; + expect(res.verse_media).toBeInstanceOf(Array); + }); }); \ No newline at end of file diff --git a/src/quran/resource.ts b/src/quran/resource.ts index 4e7fe48..0456f85 100644 --- a/src/quran/resource.ts +++ b/src/quran/resource.ts @@ -1,11 +1,10 @@ import { AxiosError } from "axios"; import Api from "../api"; -import { ResourceApi, RecitaionInfo, TranslationInfo, TranslationResponse, TafsirsResponse, TafsirInfoResponse, RecitationStyleResponse, LanguageResponse, ChapterInfos, VerseMediaResponse } from "../types"; +import { ResourceApi, RecitaionInfo, TranslationInfo, TranslationResponse, TafsirsResponse, TafsirInfoResponse, RecitationStyleResponse, LanguageResponse, ChapterInfos, VerseMediaResponse, ALLOWED_LANGUAGES } from "../types"; import { handleError, handleResponse } from "../utils"; const api = Api(); -const ALLOWED_LANGUAGES = new Set(['en', 'ur', 'bn', 'tr', 'es', 'fr', 'bs', 'ru', 'ml', 'id', 'uz', 'nl', 'de', 'tg', 'ta', 'ja', 'it', 'vi', 'zh', 'sq', 'fa', 'bg', 'bm', 'ha', 'pt', 'ro', 'hi', 'sw', 'kk', 'th', 'tl', 'km', 'as', 'ko', 'so', 'az', 'ku', 'dv', 'ms', 'prs', 'zgh', 'am', 'ce', 'cs', 'fi', 'gu', 'he', 'ka', 'kn', 'ks', 'lg', 'mk', 'mr', 'mrn', 'ne', 'no', 'om', 'pl', 'ps', 'rw', 'sd', 'se', 'si', 'sr', 'sv', 'te', 'tt', 'ug', 'uk', 'sq', 'yo']); const resources: ResourceApi = { getRecitationInfo(recitation_id: string): Promise { diff --git a/src/quran/verse.ts b/src/quran/verse.ts new file mode 100644 index 0000000..2443aeb --- /dev/null +++ b/src/quran/verse.ts @@ -0,0 +1,54 @@ +import { AxiosError } from "axios"; +import Api from "../api"; +import { ALLOWED_LANGUAGES, VerseApi, VerseQuery, VerseResponse } from "../types"; +import { handleError, handleResponse } from "../utils"; + +const api = Api(); + +const verse: VerseApi = { + getVerseByChapter(chapter_number: string, query?: VerseQuery): Promise { + if (query?.language && !ALLOWED_LANGUAGES.has(query.language)) throw new Error('Provided query language is not allowed'); + const uri = query ? `/verses/by_chapter/${chapter_number}?${new URLSearchParams(query as URLSearchParams)}` : `/verses/by_chapter/${chapter_number}`; + return new Promise((resolve, reject) => { + api.get(uri) + .then(handleResponse(resolve)) + .catch(handleError(reject)); + }); + }, + getVerseByPage(page_number: string, query?: VerseQuery): Promise { + if (query?.language && !ALLOWED_LANGUAGES.has(query.language)) throw new Error('Provided query language is not allowed'); + const uri = query ? `/verses/by_page/${page_number}?${new URLSearchParams(query as URLSearchParams)}` : `/verses/by_page/${page_number}`; + return new Promise((resolve, reject) => { + api.get(uri) + .then(handleResponse(resolve)) + .catch(handleError(reject)); + }); + }, + getVerseByJuz(juz_number: string, query?: VerseQuery): Promise { + if (query?.language && !ALLOWED_LANGUAGES.has(query.language)) throw new Error('Provided query language is not allowed'); + const uri = query ? `/verses/by_juz/${juz_number}?${new URLSearchParams(query as URLSearchParams)}` : `/verses/by_juz/${juz_number}`; + return new Promise((resolve, reject) => { + api.get(uri) + .then(handleResponse(resolve)) + .catch(handleError(reject)); + }); + }, + getVerseByHizbNumber(hizb_number: string, query?: VerseQuery): Promise { + if (query?.language && !ALLOWED_LANGUAGES.has(query.language)) throw new Error('Provided query language is not allowed'); + const uri = query ? `/verses/by_hizb/${hizb_number}?${new URLSearchParams(query as URLSearchParams)}` : `/verses/by_hizb/${hizb_number}`; + return new Promise((resolve, reject) => { + api.get(uri) + .then(handleResponse(resolve)) + .catch(handleError(reject)); + }); + }, + getVerseByRubElHizbNumber(rub_el_hizb_number: string, query?: VerseQuery): Promise { + if (query?.language && !ALLOWED_LANGUAGES.has(query.language)) throw new Error('Provided query language is not allowed'); + const uri = query ? `/verses/by_rub/${rub_el_hizb_number}?${new URLSearchParams(query as URLSearchParams)}` : `/verses/by_rub/${rub_el_hizb_number}`; + return new Promise((resolve, reject) => { + api.get(uri) + .then(handleResponse(resolve)) + .catch(handleError(reject)); + }); + }, +}; \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 5926fd3..789529e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,278 +1,366 @@ import { AxiosError } from "axios"; +export const ALLOWED_LANGUAGES = new Set(['en', 'ur', 'bn', 'tr', 'es', 'fr', 'bs', 'ru', 'ml', 'id', 'uz', 'nl', 'de', 'tg', 'ta', 'ja', 'it', 'vi', 'zh', 'sq', 'fa', 'bg', 'bm', 'ha', 'pt', 'ro', 'hi', 'sw', 'kk', 'th', 'tl', 'km', 'as', 'ko', 'so', 'az', 'ku', 'dv', 'ms', 'prs', 'zgh', 'am', 'ce', 'cs', 'fi', 'gu', 'he', 'ka', 'kn', 'ks', 'lg', 'mk', 'mr', 'mrn', 'ne', 'no', 'om', 'pl', 'ps', 'rw', 'sd', 'se', 'si', 'sr', 'sv', 'te', 'tt', 'ug', 'uk', 'sq', 'yo']); + export interface CustomHeaders { - [key: string]: string; + [key: string]: string; }; export interface AxiosConfig { - baseURL?: string; - token?: string; - customHeaders?: CustomHeaders; + baseURL?: string; + token?: string; + customHeaders?: CustomHeaders; }; export interface AudioQueryParams { - fields?: string; - chapter_number?: string; - juz_number?: string; - page_number?: string; - hizb_number?: string; - rub_el_hizb_number?: string; - verse_key?: string; + fields?: string; + chapter_number?: string; + juz_number?: string; + page_number?: string; + hizb_number?: string; + rub_el_hizb_number?: string; + verse_key?: string; }; export interface IAudio { - id: number; - chapter_id: number; - file_size: number; - format: string; - total_files: number; - audio_url: string; + id: number; + chapter_id: number; + file_size: number; + format: string; + total_files: number; + audio_url: string; }; export interface IListOfAllAudioOfAReciter { - audio_files: IAudio[]; + audio_files: IAudio[]; }; export interface IRecitation { - id: number; - reciter_name: string; - style: string; - translated_name: ITranslatedName; + id: number; + reciter_name: string; + style: string; + translated_name: ITranslatedName; }; export interface ITranslatedName { - name: string; - language_name: string; + name: string; + language_name: string; }; export interface ISingleRecitationAudio { - url: string; - duration: number; - format: string; - segments?: any[]; + url: string; + duration: number; + format: string; + segments?: any[]; }; export interface IRecitationMeta { - reciter_name: string; - recitation_style?: string | null; + reciter_name: string; + recitation_style?: string | null; }; export interface ISingleRecitation { - audio_files: ISingleRecitationAudio[]; - meta: IRecitationMeta; + audio_files: ISingleRecitationAudio[]; + meta: IRecitationMeta; }; export interface IReciter { - id: number; - name: string; - arabic_name: string; - relative_path: string; - format: string; - files_size: number; + id: number; + name: string; + arabic_name: string; + relative_path: string; + format: string; + files_size: number; }; export interface IReciters { - reciters: IReciter[]; + reciters: IReciter[]; }; export interface IAudioPagination { - per_page: number; - current_page: number; - next_page: number; - total_pages: number; - total_records: number; + per_page: number; + current_page: number; + next_page: number; + total_pages: number; + total_records: number; }; export interface IAyahRecitationSpecificSurah { - audio_files: ISingleRecitationAudio[]; - pagination: IAudioPagination; + audio_files: ISingleRecitationAudio[]; + pagination: IAudioPagination; }; export interface IAyahRecitationSpecificJuz { - audio_files: ISingleRecitationAudio[]; - pagination: IAudioPagination; + audio_files: ISingleRecitationAudio[]; + pagination: IAudioPagination; }; export interface IAyahRecitationSpecificMadaniMushafPage { - audio_files: ISingleRecitationAudio[]; - pagination: IAudioPagination; + audio_files: ISingleRecitationAudio[]; + pagination: IAudioPagination; }; export interface IAyahRecitationSpecificRubelHizb { - audio_files: ISingleRecitationAudio[]; - pagination: IAudioPagination; + audio_files: ISingleRecitationAudio[]; + pagination: IAudioPagination; }; export interface IAyahRecitationSpecificHizb { - audio_files: ISingleRecitationAudio[]; - pagination: IAudioPagination; + audio_files: ISingleRecitationAudio[]; + pagination: IAudioPagination; }; export interface IAyahRecitationSpecificAyah { - audio_files: ISingleRecitationAudio[]; - pagination: IAudioPagination; + audio_files: ISingleRecitationAudio[]; + pagination: IAudioPagination; }; export interface AudioApi { - getChaptersAudioOfAReciter(id: number, chapter_number: number): Promise; - getAllChaptersAudioOfAReciter(id: number): Promise; - getRecitations(language: string): Promise; - getAllAudioFilesofARecitation(recitation_id: number, query?: AudioQueryParams): Promise; - getListOfChapterReciters(language: string): Promise; - getAyahRecitationsForSpecificSurah(recitation_id: number, chapter_number: number): Promise; - getAyahRecitationsForSpecificJuz(recitation_id: number, juz_number: number): Promise; - getAyahRecitationForSpecificMadaniMushafPage(recitation_id: number, page_number: number): Promise; - getAyahRecitationForSpecificRubelHizb(recitation_id: number, rub_el_hizb_number: number): Promise; - getAyahRecitationForSpecificHizb(recitation_id: number, hizb_number: number): Promise; - getAyahRecitationForSpecificAyah(recitation_id: number, ayah_key: string): Promise; + getChaptersAudioOfAReciter(id: number, chapter_number: number): Promise; + getAllChaptersAudioOfAReciter(id: number): Promise; + getRecitations(language: string): Promise; + getAllAudioFilesofARecitation(recitation_id: number, query?: AudioQueryParams): Promise; + getListOfChapterReciters(language: string): Promise; + getAyahRecitationsForSpecificSurah(recitation_id: number, chapter_number: number): Promise; + getAyahRecitationsForSpecificJuz(recitation_id: number, juz_number: number): Promise; + getAyahRecitationForSpecificMadaniMushafPage(recitation_id: number, page_number: number): Promise; + getAyahRecitationForSpecificRubelHizb(recitation_id: number, rub_el_hizb_number: number): Promise; + getAyahRecitationForSpecificHizb(recitation_id: number, hizb_number: number): Promise; + getAyahRecitationForSpecificAyah(recitation_id: number, ayah_key: string): Promise; }; export interface ChapterTranslate { - language_name: string; - name: string; + language_name: string; + name: string; }; export interface Chapter { - id: number; - revelation_place: string; - revelation_order: number; - bismillah_pre: boolean; - name_simple: string; - name_complex: string; - name_arabic: string; - verses_count: number; - pages: number[]; - translated_name: ChapterTranslate; + id: number; + revelation_place: string; + revelation_order: number; + bismillah_pre: boolean; + name_simple: string; + name_complex: string; + name_arabic: string; + verses_count: number; + pages: number[]; + translated_name: ChapterTranslate; }; export interface ListChapters { - chapters?: Chapter[]; + chapters?: Chapter[]; }; export interface ChapterInfo { - id: number; - chapter_id: number; - language_name: string; - short_text: string; - source: string; - text: string; + id: number; + chapter_id: number; + language_name: string; + short_text: string; + source: string; + text: string; }; export interface ChapterInfoResponse { - chapter_info?: ChapterInfo; + chapter_info?: ChapterInfo; }; export interface ChapterApi { - listChapters: (language?: string) => Promise; - getChapter: (id: number, language?: string) => Promise; - getChapterInfo: (chapter_id: number, language?: string) => Promise; + listChapters: (language?: string) => Promise; + getChapter: (id: number, language?: string) => Promise; + getChapterInfo: (chapter_id: number, language?: string) => Promise; }; export interface JuzResponse { - juzs: any[]; + juzs: any[]; }; export interface JuzApi { - getAllJuzs: () => Promise; + getAllJuzs: () => Promise; }; export interface RecitaionInfo { - info: Info; + info: Info; } export interface Info { - id: number; - info: any; + id: number; + info: any; }; export interface TranslationInfo { - info: Info; + info: Info; }; export interface Root { - translations: Translation[]; + translations: Translation[]; }; export interface Translation { - id: number; - name: string; - author_name: string; - slug: string; - language_name: string; - translated_name: TranslatedName; + id: number; + name: string; + author_name: string; + slug: string; + language_name: string; + translated_name: TranslatedName; }; export interface TranslationResponse { - translations: Translation[]; + translations: Translation[]; }; export interface TafsirsResponse { - tafsirs: Translation[]; + tafsirs: Translation[]; }; export interface TafsirInfoResponse { - id: number; - info: string | null; + id: number; + info: string | null; }; export interface RecitationStyle { - mujawwad: string; - murattal: string; - muallim: string; + mujawwad: string; + murattal: string; + muallim: string; }; export interface RecitationStyleResponse { - recitation_styles: RecitationStyle[]; + recitation_styles: RecitationStyle[]; }; export interface Languages { - id: number; - name: string; - iso_code: string; - native_name: string; - direction: string; - translations_count: number; - translated_name: TranslatedName; + id: number; + name: string; + iso_code: string; + native_name: string; + direction: string; + translations_count: number; + translated_name: TranslatedName; }; export interface LanguageResponse { - languagess: Languages[]; + languagess: Languages[]; }; export interface TranslatedName { - name: string; - language_name: string; + name: string; + language_name: string; }; export interface ChapterInfos { - chapter_infos: Translation[]; + chapter_infos: Translation[]; }; export interface VerseMedia { - id: number; - name: string; - author_name: string; - slug: string; - language_name: string; - translated_name: TranslatedName; + id: number; + name: string; + author_name: string; + slug: string; + language_name: string; + translated_name: TranslatedName; }; export interface VerseMediaResponse { - verse_media: VerseMedia[]; + verse_media: VerseMedia[]; }; export interface ResourceApi { - getRecitationInfo: (recitation_id: string) => Promise; - getTranslationInfo: (translation_id: string) => Promise; - getTranslations: (language?: string) => Promise; - getTafsirs: (language?: string) => Promise; - getTafsirInfo: (tafsir_id: string) => Promise; - getRecitationStyles: () => Promise; - getLanguages: () => Promise; - getChapterInfos: () => Promise; - getVerseMedias: () => Promise; + getRecitationInfo: (recitation_id: string) => Promise; + getTranslationInfo: (translation_id: string) => Promise; + getTranslations: (language?: string) => Promise; + getTafsirs: (language?: string) => Promise; + getTafsirInfo: (tafsir_id: string) => Promise; + getRecitationStyles: () => Promise; + getLanguages: () => Promise; + getChapterInfos: () => Promise; + getVerseMedias: () => Promise; +}; + +export interface VerseResponse { + verses: Verse[]; + pagination: Pagination; +}; + +export interface Verse { + id: number; + verse_number: number; + page_number: number; + verse_key: string; + juz_number: number; + hizb_number: number; + rub_el_hizb_number: number; + sajdah_type: any; + sajdah_number: any; + words: Word[]; + translations: Translation2[]; + tafsirs: Tafsir[]; +}; + +export interface Word { + id: number; + position: number; + audio_url: string; + char_type_name: string; + line_number: number; + page_number: number; + code_v1: string; + translation: Translation; + transliteration: Transliteration; +}; + +export interface Translation { + text: string; + language_name: string; +}; + +export interface Transliteration { + text: string; + language_name: string; +}; + +export interface Translation2 { + resource_id: number; + text: string; +}; + +export interface Tafsir { + id: number; + language_name: string; + name: string; + text: string; +}; + +export interface Pagination { + per_page: number; + current_page: number; + next_page: number; + total_pages: number; + total_records: number; +}; + +export interface VerseQuery { + language?: string; + words?: string; + translations?: string; + audio?: string; + tafsirs?: string; + word_fields?: string; + translation_fields?: string; + fields?: string; + page?: string; + per_page?: string; +}; + + +export interface VerseApi { + getVerseByChapter: (chapter_number: string, query?: VerseQuery) => Promise; + getVerseByPage: (page_number: string, query?: VerseQuery) => Promise; + getVerseByJuz: (juz_number: string, query?: VerseQuery) => Promise; + getVerseByHizbNumber: (hizb_number: string, query?: VerseQuery) => Promise; + getVerseByRubElHizbNumber: (rub_el_hizb_number: string, query?: VerseQuery) => Promise; + getSpecificVerseByVerseKey: (verse_key: string, query?: VerseQuery) => Promise; + getRandomAyah: (query?: VerseQuery) => Promise; }; \ No newline at end of file