Class: Foursquare::Base

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

Constant Summary collapse

API =
"https://api.foursquare.com/v2/"

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/foursquare/base.rb', line 5

def initialize(access_token)
  @access_token = access_token
end

Instance Method Details

#checkinsObject



13
14
15
# File 'lib/foursquare/base.rb', line 13

def checkins
  Foursquare::CheckinProxy.new(self)
end

#get(path, params = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/foursquare/base.rb', line 25

def get(path, params={})
  params = camelize(params)
  Foursquare.log("GET #{API + path}")
  Foursquare.log("PARAMS: #{params.inspect}")
  params.merge!(:oauth_token => @access_token)
  response = JSON.parse(Typhoeus::Request.get(API + path, :params => params).body)
  Foursquare.log(response.inspect)
  error(response) || response["response"]
end

#post(path, params = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/foursquare/base.rb', line 35

def post(path, params={})
  params = camelize(params)
  Foursquare.log("POST #{API + path}")
  Foursquare.log("PARAMS: #{params.inspect}")
  params.merge!(:oauth_token => @access_token)
  response = JSON.parse(Typhoeus::Request.post(API + path, :params => params).body)
  Foursquare.log(response.inspect)
  error(response) || response["response"]
end

#settingsObject



21
22
23
# File 'lib/foursquare/base.rb', line 21

def settings
  @settings ||= Foursquare::Settings.new(self)
end

#usersObject



9
10
11
# File 'lib/foursquare/base.rb', line 9

def users
  Foursquare::UserProxy.new(self)
end

#venuesObject



17
18
19
# File 'lib/foursquare/base.rb', line 17

def venues
  Foursquare::VenueProxy.new(self)
end