quran-go

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

aayat.go (659B)


      1 package fetch
      2 
      3 import (
      4 	"fmt"
      5 	"time"
      6 
      7 	q "git.hanabi.in/gitbox/quran-go/src/quran-com"
      8 	t "git.hanabi.in/gitbox/quran-go/src/types"
      9 )
     10 
     11 // Fetch an aayah based on translation ID, chapter ID, verse, with delay; returns aayat, and error if any.
     12 func Aayat(transID t.Trans, chapterID t.Chap, verse t.Verse, delay t.Delay) (aayat string, err error) {
     13 
     14 	var verseData t.VerseData
     15 	uri := fmt.Sprintf("%s/translations/%d/by_ayah/%d:%d", q.API, transID, chapterID, verse)
     16 
     17 	time.Sleep(time.Duration(delay) * time.Millisecond)
     18 
     19 	if err = q.HttpGet(uri, &verseData); err != nil {
     20 		return aayat, err
     21 	}
     22 
     23 	aayat = verseData.Translations[0].Text
     24 
     25 	return aayat, err
     26 
     27 }