quran-go

Read Qur'an right in the terminal.
git clone http://git.hanabi.in/repos/quran-go.git
Log | Files | Refs | README | LICENSE

all-translations.go (625B)


      1 package fetch
      2 
      3 import (
      4 	"sort"
      5 
      6 	q "git.hanabi.in/gitbox/quran-go/src/quran-com"
      7 	t "git.hanabi.in/gitbox/quran-go/src/types"
      8 )
      9 
     10 // Fetch all available translations of Qur'an sorted based on the ID provided by quran.com.
     11 func AllTranslations() (translationList []t.Translations, err error) {
     12 
     13 	var resp t.TranslationList
     14 	uri := q.API + "/resources/translations"
     15 
     16 	err = q.HttpGet(uri, &resp)
     17 	if err != nil {
     18 		return translationList, err
     19 	}
     20 
     21 	translationList = resp.Translations
     22 	sort.Slice(translationList, func(a, b int) bool {
     23 		return translationList[a].ID < translationList[b].ID
     24 	})
     25 
     26 	return translationList, err
     27 
     28 }