Class: YoClient::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/yo_client.rb

Instance Method Summary collapse

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_countInteger

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

#yoallObject

Yo to all subscribers



19
20
21
# File 'lib/yo_client.rb', line 19

def yoall
  @faraday.post '/yoall/', token_hash
end