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, options = {}) ⇒ Boolean
Yo to specific user.
-
#yoall(options = {}) ⇒ 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
42 43 44 45 46 47 |
# File 'lib/yo_client.rb', line 42 def subscribers_count response = connection_wrapper { @faraday.get '/subscribers_count/', token_hash } response.body['result'] end |
#yo(username, options = {}) ⇒ Boolean
Yo to specific user
32 33 34 35 36 37 38 |
# File 'lib/yo_client.rb', line 32 def yo(username, = {}) .merge!(username: username.upcase) response = connection_wrapper { @faraday.post '/yo/', token_hash.merge() } response.success? end |
#yoall(options = {}) ⇒ Boolean
Yo to all subscribers
21 22 23 24 25 26 |
# File 'lib/yo_client.rb', line 21 def yoall( = {}) response = connection_wrapper { @faraday.post '/yoall/', token_hash.merge() } response.success? end |