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) ⇒ Object
Yo to specific user.
-
#yoall ⇒ Object
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
31 32 33 34 |
# File 'lib/yo_client.rb', line 31 def subscribers_count response = @faraday.get '/subscribers_count/', token_hash response.body['result'] end |
#yo(username) ⇒ Object
Yo to specific user
25 26 27 |
# File 'lib/yo_client.rb', line 25 def yo(username) @faraday.post '/yo/', token_hash.merge(username: username.upcase) end |
#yoall ⇒ Object
Yo to all subscribers
19 20 21 |
# File 'lib/yo_client.rb', line 19 def yoall @faraday.post '/yoall/', token_hash end |