Module: Foursquared::Checkins

Included in:
Client
Defined in:
lib/foursquared/checkins.rb

Overview

Checkins module

Instance Method Summary collapse

Instance Method Details

#add_checkin(options = {}) ⇒ Hash

Create a check-in

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :venueId (String)

    required The venue where the user is checking in.

  • :eventId (String)

    The event the user is checking in to.

  • :shout (String)

    A message about your check-in

  • :mentions (String)

    Semicolon-delimited list of mentions

  • :broadcast (String)

    Who to broadcast this check-in to

  • :ll (String)

    Latitude and longitude of the user’s location.

  • :llAcc (String)

    Accuracy of the user’s latitude and longitude, in meters

  • :alt (String)

    Altitude of the user’s location, in meters.

  • :altAcc (String)

    Vertical accuracy of the user’s location, in meters.

Returns:

  • (Hash)

    A checkin object and the post checkin notifications



28
29
30
31
# File 'lib/foursquared/checkins.rb', line 28

def add_checkin options={}
  response = post("/checkins/add", options)["response"]
  {:checkin => Foursquared::Response::Checkin.new(self, response["checkin"]), :notifications => response["notifications"]}
end

#add_checkin_comment(checkin_id, options = {}) ⇒ Hash

Add a comment to a check-in

Parameters:

  • checkin_id (String)

    The ID of the checkin to add a comment to.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :text (String)

    The text of the comment, up to 200 characters.

  • :mentions (String)

    Mentions in your check-in.

Returns:

  • (Hash)

    The newly-created comment.



61
62
63
64
65
66
# File 'lib/foursquared/checkins.rb', line 61

def add_checkin_comment checkin_id, options={}
  response = post("/checkins/#{checkin_id}/addcomment", options)["response"]
  @comment = response["comment"]
  @comment["user"] = Foursquared::Response::User.new(self, @comment["user"])
  @comment
end

#checkin(checkin_id, options = {}) ⇒ Foursquared::Response::Checkin

Get details of a checkin.

Parameters:

  • checkin_id (String)

    The ID of the checkin to retrieve additional information for.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :signature (String)

Returns:



11
12
13
14
# File 'lib/foursquared/checkins.rb', line 11

def checkin checkin_id, options={}
  response = get("/checkins/#{checkin_id}",options)["response"]
  @checkin = Foursquared::Response::Checkin.new(self, response["checkin"])
end

#checkin_likes(checkin_id) ⇒ Hash

Users who have liked a checkin

Parameters:

  • checkin_id (String)

    The ID of the checkin to get likes for.

Returns:

  • (Hash)

    A count and groups of users who like this checkin



47
48
49
50
51
52
53
# File 'lib/foursquared/checkins.rb', line 47

def checkin_likes checkin_id
  @likes = get("/checkins/#{checkin_id}/likes")["response"]["likes"]
  @likes["groups"].each do |group|
    group["items"].map!{|item|Foursquared::Response::User.new(self, item)}
  end
  @likes
end

#delete_checkin_comment(checkin_id, options = {}) ⇒ Foursquared::Response::Checkin

Remove commment from check-in

Parameters:

  • checkin_id (String)

    The ID of the checkin to remove a comment from.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :commentId (String)

Returns:



73
74
75
76
# File 'lib/foursquared/checkins.rb', line 73

def delete_checkin_comment checkin_id, options={}
  response = post("/checkins/#{checkin_id}/deletecomment", options)["response"]
  @checkin = Foursquared::Response::Checkin.new(self, response["checkin"])
end

#like_checkin(checkin_id, options = {}) ⇒ Object

Like or unlike a checkin

Parameters:

  • checkin_id (String)

    The ID of the checkin to like

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :set (Integer)

    If 1, like this checkin. If 0 unlike (un-do a previous like) it. Default value is 1.



82
83
84
85
86
87
88
# File 'lib/foursquared/checkins.rb', line 82

def like_checkin checkin_id, options={}
  response =  post("/checkins/#{checkin_id}/like", options)["response"]["likes"]
  response["groups"].each do |group|
    group["items"].map!{|item| Foursquared::Response::User.new(self, item)}
  end
  response
end

#recent_checkins(options = {}) ⇒ Array

Recent checkins by friends

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :ll (String)

    Latitude and longitude of the user’s location, so response can include distance

  • :limit (Integer)

    Number of results to return, up to 100.

  • :afterTimestamp (Integer)

    Seconds after which to look for checkins

Returns:

  • (Array)

    An array of checkin objects with user details present



39
40
41
42
# File 'lib/foursquared/checkins.rb', line 39

def recent_checkins options={}
  response = get("/checkins/recent", options)["response"]
  @checkins = response["recent"].collect{|checkin| Foursquared::Response::Checkin.new(self, checkin)}
end