Module: Foursquare2::Tips

Included in:
Client
Defined in:
lib/foursquare2/tips.rb

Instance Method Summary collapse

Instance Method Details

#add_tip(options = {}) ⇒ Object

Add a tip

Parameters:

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

Options Hash (options):

  • String (Object)

    :venueId - Required, which venue to add the tip to.

  • String (Object)

    :text - The text of the tip.

  • String (Object)

    :url - Optionally associated url.



55
56
57
58
59
60
# File 'lib/foursquare2/tips.rb', line 55

def add_tip(options={})
  response = connection.post do |req|
    req.url "tips/add", options
  end
  return_error_or_body(response, response.body.response.tip)
end

#mark_tip_done(tip_id) ⇒ Object

Mark a tip done for the authenticated user.

param [String] tip_id - The id of the tip to mark.



77
78
79
80
81
82
# File 'lib/foursquare2/tips.rb', line 77

def mark_tip_done(tip_id)
  response = connection.post do |req|
    req.url "tips/#{tip_id}/markdone"
  end
  return_error_or_body(response, response.body.response)
end

#mark_tip_todo(tip_id) ⇒ Object

Mark a tip todo for the authenticated user.

param [String] tip_id - The id of the tip to mark.



66
67
68
69
70
71
# File 'lib/foursquare2/tips.rb', line 66

def mark_tip_todo(tip_id)
  response = connection.post do |req|
    req.url "tips/#{tip_id}/marktodo"
  end
  return_error_or_body(response, response.body.response)
end

#search_tips(options = {}) ⇒ Object

Search for tips.

Parameters:

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

Options Hash (options):

  • String (Object)

    :ll - Latitude and longitude in format LAT,LON

  • Integer (Object)

    :limit - The limit of results to return.

  • Integer (Object)

    :offset - Used to page through results.

  • String (Object)

    :filter - Set to ‘friends’ to limit tips to those from friends.

  • String (Object)

    :query - Only find tips matching this term.



22
23
24
25
26
27
# File 'lib/foursquare2/tips.rb', line 22

def search_tips(options={})
  response = connection.get do |req|
    req.url "tips/search", options
  end
  return_error_or_body(response, response.body.response.tips)
end

#tip(tip_id) ⇒ Object

Retrieve information about a tip.

param [String] tip_id - The id of the tip to retrieve.



8
9
10
11
# File 'lib/foursquare2/tips.rb', line 8

def tip(tip_id)
  response = connection.get("tips/#{tip_id}")
  return_error_or_body(response, response.body.response.tip)
end

#unmark_tip(tip_id) ⇒ Object

Unmark a tip todo for the authenticated user.

param [String] tip_id - The id of the tip to unmark.



88
89
90
91
92
93
# File 'lib/foursquare2/tips.rb', line 88

def unmark_tip(tip_id)
  response = connection.post do |req|
    req.url "tips/#{tip_id}/unmark"
  end
  return_error_or_body(response, response.body.response)
end

#venue_tips(venue_id, options = {}) ⇒ Object

Search for tips from a venue.

Parameters:

  • venue_id (String)
    • Venue id to flag, required.

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

Options Hash (options):

  • String (Object)

    :sort [recent] One of recent or popular.

  • Integer (Object)

    :limit [100] Number of results to return, up to 500.

  • Integer (Object)

    :offset [100] Used to page through results

  • String (Object)

    :query - Only find tips matching this term.



38
39
40
41
42
43
44
45
46
# File 'lib/foursquare2/tips.rb', line 38

def venue_tips(venue_id, options={})
  query = options.delete(:query)
  response = connection.get do |req|
    req.url "venues/#{venue_id}/tips", options
  end
  tips = return_error_or_body(response, response.body.response.tips)
  tips = Foursquare2.filter(tips, query) if query
  tips
end