Module: Foursquared::Tips

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

Overview

Tips module

Instance Method Summary collapse

Instance Method Details

#add_tip(options = {}) ⇒ Foursquared::Response::Tip

Add a tip

Parameters:

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

Options Hash (options):

  • :venueId (String)

    required, the venue where you want to add this tip.

  • :text (String)

    required, the text of the tip, up to 200 characters.

  • :url (String)

    A URL related to this tip.

  • :broadcast (String)

    eg: twitter,facebook

Returns:



19
20
21
22
# File 'lib/foursquared/tips.rb', line 19

def add_tip options={}
  response = post("/tips/add", options)["response"]
  Foursquared::Response::Tip.new(self, response["tip"])
end

#like_tip(tip_id, options = {}) ⇒ Hash

Like or unlike a tip

Parameters:

  • tip_id (String)

    required, ID of tip.

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

Options Hash (options):

  • :set (Integer)

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

Returns:

  • (Hash)

    Updated count and groups of users who like this tip.



81
82
83
84
85
86
# File 'lib/foursquared/tips.rb', line 81

def like_tip tip_id, options={}
  response = post("/tips/#{tip_id}/like", options)["response"]
  @likes = response["likes"]
  @likes["groups"].each{ |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes["groups"]
  @likes
end

#mark_tip_done(tip_id) ⇒ Foursquared::Response::Tip

Mark a tip done

Parameters:

  • tip_id (String)

    required, ID of tip.

Returns:



91
92
93
94
# File 'lib/foursquared/tips.rb', line 91

def mark_tip_done tip_id
  response = post("/tips/#{tip_id}/markdone")["response"]
  Foursquared::Response::Tip.new(self, response["tip"])
end

#mark_tip_todo(tip_id) ⇒ Foursquared::Response::Todo

Mark a tip to-do

Parameters:

  • tip_id (String)

    required, ID of tip.

Returns:

  • (Foursquared::Response::Todo)

    The marked to-do.



99
100
101
102
# File 'lib/foursquared/tips.rb', line 99

def mark_tip_todo tip_id
  response = post("/tips/#{tip_id}/marktodo")["response"]
  Foursquared::Response::Todo.new(self, response["todo"])
end

#search_tips(options = {}) ⇒ Array

Search Nearby Tips

Parameters:

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

Options Hash (options):

  • :ll (String)

    required, unless near is provided. Latitude and longitude of the user’s location.

  • :near (String)

    required, unless ll is provided. A string naming a place in the world

  • :limit (Integer)

    optional, number of results to return, up to 500.

  • :offset (Integer)

    optional, used to page through results.

  • :filter (String)

    if set to friends, only show nearby tips from friends.

  • :query (String)

    only find tips matching the given term, cannot be used in conjunction with friends filter.

Returns:

  • (Array)

    tips matching the criteria



33
34
35
36
37
# File 'lib/foursquared/tips.rb', line 33

def search_tips options={}
  response = get("/tips/search", options)["response"]
  @tips = response["tips"]
  @tips.collect{|tip| Foursquared::Response::Tip.new(self, tip)}
end

#tip(tip_id) ⇒ Foursquared::Response::Tip

Tip detail

Parameters:

  • tip_id (String)

    required, ID of tip to retrieve.

Returns:



7
8
9
10
# File 'lib/foursquared/tips.rb', line 7

def tip tip_id
  response = get("/tips/#{tip_id}")["response"]
  Foursquared::Response::Tip.new(self, response["tip"])
end

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

Users who have done a tip

Parameters:

  • tip_id (String)

    required, ID of tip.

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

Options Hash (options):

  • :limit (Integer)

    optional, number of results to return, up to 200.

  • :offset (Integer)

    optional, used to page through results.

Returns:

  • A count and items of compact user objects



45
46
47
48
49
50
# File 'lib/foursquared/tips.rb', line 45

def tip_dones tip_id, options={}
  response = get("/tips/#{tip_id}/done", options)["response"]
  @users = response["users"]
  @users["items"].map!{|item| Foursquared::Response::User.new(self, item)} if @users["items"]
  @users
end

#tip_likes(tip_id) ⇒ Hash

Users who have liked a tip

Parameters:

  • tip_id (String)

    required, ID of tip.

Returns:

  • (Hash)

    A count and groups of users who like this tip



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

def tip_likes tip_id
  response = get("/tips/#{tip_id}/likes")["response"]
  @likes = response["likes"]
  @likes["groups"].each{ |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes["groups"]
end

#tip_listed(tip_id, options = {}) ⇒ Hash

The lists that this tip appears on

Parameters:

  • tip_id (String)

    required, ID of tip.

Returns:

  • (Hash)


64
65
66
67
68
69
70
71
72
73
74
# File 'lib/foursquared/tips.rb', line 64

def tip_listed tip_id, options={}
  response = get("/tips/#{tip_id}/listed")["response"]
  @lists = response["lists"]
  if @lists["groups"]
    @lists["groups"].each do |group|
      group["items"].map!{|item| Foursquared::Response::List.new(client, item) } if group["items"]
    end
  elsif @lists["items"]
    @lists["items"].map!{|item| Foursquared::Response::List.new(client, item) }
  end
end

#unmark_tip_todo(tip_id) ⇒ Foursquared::Response::Tip

Unmark a tip as to-do

Parameters:

  • tip_id (String)

    required, ID of tip.

Returns:



107
108
109
110
# File 'lib/foursquared/tips.rb', line 107

def unmark_tip_todo tip_id
  response = post("/tips/#{tip_id}/unmark")["response"]
  Foursquared::Response::Tip.new(self, response["tip"])
end