Class: Yelpr::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:

  • _self (Yelpr::Client)

    the object that the method was called on



9
10
11
12
13
14
15
16
17
18
# File 'lib/yelpr/client.rb', line 9

def initialize()
  yield self

  @conn = Faraday.new(:url => 'http://api.yelp.com') do |builder|
    builder.use Faraday::Request::OAuth, auth if auth.values.all?
    builder.use Faraday::Response::Mashify
    builder.use Faraday::Response::ParseJson
    builder.adapter Faraday.default_adapter
  end
end

Instance Attribute Details

#consumer_keyObject

Returns the value of attribute consumer_key.



7
8
9
# File 'lib/yelpr/client.rb', line 7

def consumer_key
  @consumer_key
end

#consumer_secretObject

Returns the value of attribute consumer_secret.



7
8
9
# File 'lib/yelpr/client.rb', line 7

def consumer_secret
  @consumer_secret
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/yelpr/client.rb', line 7

def token
  @token
end

#token_secretObject

Returns the value of attribute token_secret.



7
8
9
# File 'lib/yelpr/client.rb', line 7

def token_secret
  @token_secret
end

Instance Method Details

#business(id) ⇒ Object



28
29
30
31
# File 'lib/yelpr/client.rb', line 28

def business(id)
  response = @conn.get "/v2/business/#{id}"
  response.body
end

#search(options = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/yelpr/client.rb', line 20

def search(options = {})
  response = @conn.get do |request|
    request.url '/v2/search', options
  end

  response.body
end