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.



57
58
59
60
61
62
# File 'lib/foursquare2/tips.rb', line 57

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, options = {}) ⇒ Object

Mark a tip done for the authenticated user.

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



79
80
81
82
83
84
# File 'lib/foursquare2/tips.rb', line 79

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

#mark_tip_todo(tip_id, options = {}) ⇒ Object

Mark a tip todo for the authenticated user.

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



68
69
70
71
72
73
# File 'lib/foursquare2/tips.rb', line 68

def mark_tip_todo(tip_id, options={})
  response = connection.post do |req|
    req.url "tips/#{tip_id}/marktodo", options
  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.



24
25
26
27
28
29
# File 'lib/foursquare2/tips.rb', line 24

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, options = {}) ⇒ Object

Retrieve information about a tip.

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



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

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

#unmark_tip(tip_id, options = {}) ⇒ Object

Unmark a tip todo for the authenticated user.

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



90
91
92
93
94
95
# File 'lib/foursquare2/tips.rb', line 90

def unmark_tip(tip_id, options={})
  response = connection.post do |req|
    req.url "tips/#{tip_id}/unmark", options
  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.



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

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