Class: YoClient::Client
- Inherits:
-
Object
- Object
- YoClient::Client
- Defined in:
- lib/yo_client.rb
Instance Method Summary collapse
-
#initialize(api_token) ⇒ Client
constructor
Constructor.
-
#subscribers_count ⇒ Integer
Get a number of subscribers.
-
#yo(username) ⇒ Boolean
Yo to specific user.
-
#yoall ⇒ Boolean
Yo to all subscribers.
Constructor Details
#initialize(api_token) ⇒ Client
Constructor
9 10 11 12 13 14 15 16 |
# File 'lib/yo_client.rb', line 9 def initialize(api_token) @api_token = api_token @faraday = Faraday.new(url: 'http://api.justyo.co') do |faraday| faraday.request :url_encoded faraday.response :json faraday.adapter :net_http end end |
Instance Method Details
#subscribers_count ⇒ Integer
Get a number of subscribers
39 40 41 42 43 44 |
# File 'lib/yo_client.rb', line 39 def subscribers_count response = connection_wrapper { @faraday.get '/subscribers_count/', token_hash } response.body['result'] end |
#yo(username) ⇒ Boolean
Yo to specific user
30 31 32 33 34 35 |
# File 'lib/yo_client.rb', line 30 def yo(username) response = connection_wrapper { @faraday.post '/yo/', token_hash.merge(username: username.upcase) } response.success? end |
#yoall ⇒ Boolean
Yo to all subscribers
20 21 22 23 24 25 |
# File 'lib/yo_client.rb', line 20 def yoall response = connection_wrapper { @faraday.post '/yoall/', token_hash } response.success? end |