class Yo::HTTP
Public Class Methods
new(api_token: nil)
click to toggle source
# File lib/yo4r/http.rb, line 6 def initialize(api_token: nil) @api_token = api_token @faraday = Faraday.new('http://api.justyo.co') end
Public Instance Methods
subscribers_count()
click to toggle source
# File lib/yo4r/http.rb, line 19 def subscribers_count access_api { @faraday.get('/subscribers_count/', api_token: @api_token) } end
yo(username: nil)
click to toggle source
# File lib/yo4r/http.rb, line 11 def yo(username: nil) return true if access_api { @faraday.post('/yo/', api_token: @api_token, username: username) } end
yoall()
click to toggle source
# File lib/yo4r/http.rb, line 15 def yoall access_api { @faraday.post('/yoall/', api_token: @api_token) } end
Private Instance Methods
access_api() { || ... }
click to toggle source
# File lib/yo4r/http.rb, line 23 def access_api begin params = JSON.parse(yield.body) rescue Exception => e raise UnknownError, e.message end raise ClientError, params['error'] if params['error'] params['result'] end