Documentation ¶
Index ¶
- type Chapter
- type ChapterInfo
- type Client
- func (c *Client) Chapter(ctx context.Context, id int, reqOpts ...ReqOptFn) (Chapter, error)
- func (c *Client) ChapterInfo(ctx context.Context, id int, reqOpts ...ReqOptFn) (ChapterInfo, error)
- func (c *Client) Chapters(ctx context.Context, reqOpts ...ReqOptFn) ([]Chapter, error)
- func (c *Client) Juzzah(ctx context.Context) ([]Juz, error)
- func (c *Client) Languages(ctx context.Context, reqOpts ...ReqOptFn) ([]Language, error)
- func (c *Client) Recitations(ctx context.Context, reqOpts ...ReqOptFn) ([]Recitation, error)
- func (c *Client) Search(ctx context.Context, query SearchRequest) (SearchResponse, error)
- func (c *Client) Tafsiraat(ctx context.Context, reqOpts ...ReqOptFn) ([]Tafsir, error)
- func (c *Client) Translations(ctx context.Context, reqOpts ...ReqOptFn) ([]Translation, error)
- func (c *Client) Verse(ctx context.Context, chapterID, verseID int) (Verse, error)
- func (c *Client) VerseTafsir(ctx context.Context, chapterID, verseID int, reqOpts ...VerseTafsirReqOptFn) ([]VerseTafsir, error)
- func (c *Client) Verses(ctx context.Context, chapterID int, reqOpts ...VersesReqOptFn) ([]Verse, error)
- type ClientOptFn
- type Doer
- type Juz
- type JuzMapping
- type Language
- type QuranAPI
- type Recitation
- type ReqOptFn
- type Resource
- type SearchRequest
- type SearchResponse
- type SearchVerse
- type Tafsir
- type TranslatedName
- type Translation
- type Verse
- type VerseTafsir
- type VerseTafsirReqOptFn
- type VersesReqOptFn
- func VersesLanguage(isoCode string) VersesReqOptFn
- func VersesLimit(i int) VersesReqOptFn
- func VersesMedia(media []int) VersesReqOptFn
- func VersesOffset(i int) VersesReqOptFn
- func VersesPage(i int) VersesReqOptFn
- func VersesRecitation(recitation int) VersesReqOptFn
- func VersesTextType(textType string) VersesReqOptFn
- func VersesTranslations(translations []int) VersesReqOptFn
- type Word
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chapter ¶
type Chapter struct { ID int `json:"id"` ChapterNumber int `json:"chapter_number"` BismillahPre bool `json:"bismillah_pre"` RevelationOrder int `json:"revelation_order"` RevelationPlace string `json:"revelation_place"` NameComplex string `json:"name_complex"` NameArabic string `json:"name_arabic"` NameSimple string `json:"name_simple"` VersesCount int `json:"verses_count"` Pages struct { Start int `json:"start"` End int `json:"end"` } `json:"pages"` TranslatedName TranslatedName `json:"translated_name"` }
Chapter or surah along with its relevant metadata combine to detail the summary of the chatper as a whole.
type ChapterInfo ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the API client that translates the quran.com api into familiar go types.
func New ¶
func New(opts ...ClientOptFn) *Client
New Constructs a new Client. All default options will be used if no options are provided to overwrite them. The defaults are:
host: https://quran.com/api
func (*Client) ChapterInfo ¶
func (*Client) Recitations ¶
Recitations returns all the available quran.com recitations.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query SearchRequest) (SearchResponse, error)
func (*Client) Translations ¶
Translations returns all the available quran.com translations.
func (*Client) Verse ¶
TODO: make github issue to fix the route in api docs for this route is routed incorrectly
func (*Client) VerseTafsir ¶
func (c *Client) VerseTafsir(ctx context.Context, chapterID, verseID int, reqOpts ...VerseTafsirReqOptFn) ([]VerseTafsir, error)
type ClientOptFn ¶
type ClientOptFn func(opt clientOpt) clientOpt
ClientOptFn is an option to set the options of the client constructor.
func WithHTTPClient ¶
func WithHTTPClient(doer Doer) ClientOptFn
WithHTTPClient sets the http client on the quran api client.
type Juz ¶
type Juz struct { ID int `json:"id"` JuzNumber int `json:"juz_number"` VerseMapping []JuzMapping `json:"verse_mapping"` }
type JuzMapping ¶
type Language ¶
type Language struct { ID int `json:"id"` Name string `json:"name"` IsoCode string `json:"iso_code"` NativeName string `json:"native_name"` Direction string `json:"direction"` TranslatedNames []TranslatedName `json:"translated_names"` }
Language is the a language with associated quran.com identifiers. The language ID is useful in filtering other api calls to the language provided. The iso code is useful in other contexts like search and verses calls.
type QuranAPI ¶
type QuranAPI interface { Recitations(ctx context.Context, reqOpts ...ReqOptFn) ([]Recitation, error) Translations(ctx context.Context, reqOpts ...ReqOptFn) ([]Translation, error) Languages(ctx context.Context, reqOpts ...ReqOptFn) ([]Language, error) Tafsiraat(ctx context.Context, reqOpts ...ReqOptFn) ([]Tafsir, error) Chapters(ctx context.Context, reqOpts ...ReqOptFn) ([]Chapter, error) Chapter(ctx context.Context, id int, reqOpts ...ReqOptFn) (Chapter, error) ChapterInfo(ctx context.Context, id int, reqOpts ...ReqOptFn) (ChapterInfo, error) Verses(ctx context.Context, chapterID int, reqOpts ...VersesReqOptFn) ([]Verse, error) Verse(ctx context.Context, chapterID, verseID int) (Verse, error) Juzzah(ctx context.Context) ([]Juz, error) VerseTafsir(ctx context.Context, chapterID, verseID int, reqOpts ...VerseTafsirReqOptFn) ([]VerseTafsir, error) Search(ctx context.Context, query SearchRequest) (SearchResponse, error) }
type Recitation ¶
type Recitation struct { ID int `json:"id"` Style string `json:"style"` ReciterNameEng string `json:"reciter_name_eng"` ReciterNameTranslated string `json:"reciter_name_translated"` }
Recitation is a recitation provided from quran.com.
type SearchResponse ¶
type SearchVerse ¶
type Tafsir ¶
type Tafsir struct { ID int `json:"id"` AuthorName string `json:"author_name"` Slug string `json:"slug"` Name string `json:"name"` LanguageName string `json:"language_name"` }
Tafsir is a tafsir overview available from quran.com. Food for thought, the slug is never populated but is "supported" through the docs, but not in reality.
type TranslatedName ¶
TranslatedName is a name and the language is is translated from.
type Translation ¶
type Translation struct { ID int `json:"id"` AuthorName string `json:"author_name"` LanguageName string `json:"language_name"` Name string `json:"name"` Slug string `json:"slug"` }
Translation is a translation available via the quran.com api. The translation's ID maybe used in other api calls to add translations to the response.
type Verse ¶
type Verse struct { ID int `json:"id"` VerseNumber int `json:"verse_number"` ChapterID int `json:"chapter_id"` VerseKey string `json:"verse_key"` TextMadani string `json:"text_madani"` TextIndopak string `json:"text_indopak"` TextSimple string `json:"text_simple"` JuzNumber int `json:"juz_number"` HizbNumber int `json:"hizb_number"` RubNumber int `json:"rub_number"` Sajdah string `json:"sajdah"` SajdahNumber int `json:"sajdah_number"` PageNumber int `json:"page_number"` Audio struct { URL string `json:"url"` Duration int `json:"duration"` Segments [][]string `json:"segments"` Format string `json:"format"` } `json:"audio"` Translations []Resource `json:"translations"` MediaContents []struct { URL string `json:"url"` EmbedText string `json:"embed_text"` Provider string `json:"provider"` AuthorName string `json:"author_name"` } `json:"media_contents"` Words []Word `json:"words"` }
type VerseTafsir ¶
type VerseTafsir struct { ID int `json:"id"` Text string `json:"text"` VerseID int `json:"verse_id"` LanguageName string `json:"language_name"` ResourceName string `json:"resource_name"` // VerseKey outlined int he api response, but there is nothing that speaks // to it in the api documentation... hopefully someone can fill in the gap here VerseKey interface{} `json:"verse_key"` }
type VerseTafsirReqOptFn ¶
type VerseTafsirReqOptFn func(opts verseTafsirReqOpts) verseTafsirReqOpts
func TafsirID ¶
func TafsirID(id int) VerseTafsirReqOptFn
type VersesReqOptFn ¶
type VersesReqOptFn func(opts versesReqOpt) versesReqOpt
func VersesLanguage ¶
func VersesLanguage(isoCode string) VersesReqOptFn
func VersesLimit ¶
func VersesLimit(i int) VersesReqOptFn
func VersesMedia ¶
func VersesMedia(media []int) VersesReqOptFn
func VersesOffset ¶
func VersesOffset(i int) VersesReqOptFn
func VersesPage ¶
func VersesPage(i int) VersesReqOptFn
func VersesRecitation ¶
func VersesRecitation(recitation int) VersesReqOptFn
func VersesTextType ¶
func VersesTextType(textType string) VersesReqOptFn
func VersesTranslations ¶
func VersesTranslations(translations []int) VersesReqOptFn
type Word ¶
type Word struct { ID int `json:"id"` Position int `json:"position"` TextMadani string `json:"text_madani"` TextIndopak string `json:"text_indopak"` TextSimple string `json:"text_simple"` VerseKey string `json:"verse_key"` ClassName string `json:"class_name"` LineNumber int `json:"line_number"` PageNumber int `json:"page_number"` Code string `json:"code"` CodeV3 string `json:"code_v3"` CharType string `json:"char_type"` Audio struct { URL string `json:"url"` } `json:"audio"` Translation Resource `json:"translation"` Transliteration Resource `json:"transliteration"` }