Module: Foursquared::Tips
- Included in:
- Client
- Defined in:
- lib/foursquared/tips.rb
Overview
Tips module
Instance Method Summary collapse
-
#add_tip(options = {}) ⇒ Foursquared::Response::Tip
Add a tip.
-
#like_tip(tip_id, options = {}) ⇒ Hash
Like or unlike a tip.
-
#mark_tip_done(tip_id) ⇒ Foursquared::Response::Tip
Mark a tip done.
-
#mark_tip_todo(tip_id) ⇒ Foursquared::Response::Todo
Mark a tip to-do.
-
#search_tips(options = {}) ⇒ Array
Search Nearby Tips.
-
#tip(tip_id) ⇒ Foursquared::Response::Tip
Tip detail.
-
#tip_dones(tip_id, options = {}) ⇒ Object
Users who have done a tip.
-
#tip_likes(tip_id) ⇒ Hash
Users who have liked a tip.
-
#tip_listed(tip_id, options = {}) ⇒ Hash
The lists that this tip appears on.
-
#unmark_tip_todo(tip_id) ⇒ Foursquared::Response::Tip
Unmark a tip as to-do.
Instance Method Details
#add_tip(options = {}) ⇒ Foursquared::Response::Tip
Add a tip
19 20 21 22 |
# File 'lib/foursquared/tips.rb', line 19 def add_tip ={} response = post("/tips/add", )["response"] Foursquared::Response::Tip.new(self, response["tip"]) end |
#like_tip(tip_id, options = {}) ⇒ Hash
Like or unlike a tip
81 82 83 84 85 86 |
# File 'lib/foursquared/tips.rb', line 81 def like_tip tip_id, ={} response = post("/tips/#{tip_id}/like", )["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
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
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
33 34 35 36 37 |
# File 'lib/foursquared/tips.rb', line 33 def search_tips ={} response = get("/tips/search", )["response"] @tips = response["tips"] @tips.collect{|tip| Foursquared::Response::Tip.new(self, tip)} end |
#tip(tip_id) ⇒ Foursquared::Response::Tip
Tip detail
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
45 46 47 48 49 50 |
# File 'lib/foursquared/tips.rb', line 45 def tip_dones tip_id, ={} response = get("/tips/#{tip_id}/done", )["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
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
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/foursquared/tips.rb', line 64 def tip_listed tip_id, ={} 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
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 |