Class: Foursquare::Checkin
Class Method Summary collapse
- .attribute_names ⇒ Object
-
.create(options = {}) ⇒ Object
Allows you to check-in to a place.
Instance Method Summary collapse
-
#initialize(attributes = nil) ⇒ Checkin
constructor
A new instance of Checkin.
Methods inherited from Base
authentication, connect, latitude, location, location=, longitude
Constructor Details
#initialize(attributes = nil) ⇒ Checkin
Returns a new instance of Checkin.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/foursquare/checkin.rb', line 16 def initialize(attributes = nil) if attributes self.id = attributes['id'] self. = attributes['message'] self.created_at = Time.parse(attributes['created']) self.badges = [attributes['badges']['badge']] self.mayor = attributes['mayor'] self.scoring = attributes['scoring'] self.venue = Venue.new(attributes['venue']) end end |
Class Method Details
.attribute_names ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/foursquare/checkin.rb', line 3 def self.attribute_names [:id, :message, :created_at, :badges, :mayor, :scoring, :venue ] end |
.create(options = {}) ⇒ Object
Allows you to check-in to a place.
Options :vid => (optional, not necessary if you are 'shouting' or have a venue name). ID of the venue where you want to check-in. :venue => (optional, not necessary if you are 'shouting' or have a vid) if you don't have a venue ID, pass the venue name as a string using this parameter. foursquare will attempt to match it on the server-side :shout => (optional) a message about your check-in :private => (optional, defaults to the user's setting). true means "don't show your friends". false means "show everyone" :twitter => (optional, defaults to the user's setting). false means "send to twitter". false means "don't send to twitter" :geolat => (optional, but recommended) :geolong => (optional, but recommended)
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/foursquare/checkin.rb', line 44 def self.create( = {}) unless [:private].nil? [:private] = [:private] ? 1 : 0 end unless [:twitter].nil? [:twitter] = ([:twitter] ? 1 : 0) end response = post "/checkin.json", :query => , :basic_auth => authentication raise RecordNotFound if response.keys.include?("addvenueprompt") new(response["checkin"]) end |