getPassage method
Queries bible.org.
Note that the extra
field will return a list within the
extra.extra field. This contains the original API response.
Implementation
@override
Future<PassageQuery> getPassage(BibleReference query,
{Map<String, String>? parameters, String? key, String? version}) async {
final params = {
'type': 'json',
'passage': query.reference,
};
final uri = Uri.https('labs.bible.org', '/api/', params);
final res = await http.get(uri);
var json = jsonDecode(res.body);
var passage = StringBuffer();
var verses = <String, String?>{};
var extra = {
'extra': json,
};
json.forEach((x) => {
passage.write(x['text']),
verses['${x['bookname']} ${x['chapter']}:${x['verse']}'] = x['text'],
});
return PassageQuery.fromProvider(passage.toString(), query.reference, 'NET',
extra: extra, verses: verses);
}