class TextMe::JTJVerseExtractor
Helper class to extract Join The Journey's (JTJ) daily devotion specific information
Public Instance Methods
extract_data(entry_id)
click to toggle source
What: Called from Core
class to get the verse name and image link for specific JTJ Input: id of the JTJ entry Output: Hash containing the verse name and verse lock screen image
# File lib/textme-jtj.rb, line 296 def extract_data(entry_id) #Getting the HTTP response in JSON format of the given JTJ entry data = get_verse(entry_id) result = Hash.new #Empty result hash #Get the lock screen image from the JSON if data["entry"]["links"]["lock_screen"] image_link = data["entry"]["links"]["lock_screen"] result["image"] = image_link end #Get the verse name from JSON if data["entry"]["memory_verse"]["reference"] verse_name = data["entry"]["memory_verse"]["reference"] result["verse"] = verse_name end return result end
get_verse(entry_id)
click to toggle source
Helper method What: Makes a HTTP Get request to the JTJ API Input: id of the JTJ entry Output: the API response in JSON format
# File lib/textme-jtj.rb, line 287 def get_verse(entry_id) url = 'https://jtj.watermark.org/api/entries/' + entry_id.to_s result = Net::HTTP.get(URI.parse(url)) return JSON.parse(result) end