Class: Foursquared::Response::List
- Inherits:
-
Object
- Object
- Foursquared::Response::List
- Defined in:
- lib/foursquared/response/list.rb
Overview
List response
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#add_item(options = {}) ⇒ Foursquared::Response::ListItem
Add an Item to the list.
-
#canonical_url ⇒ String
The canonical URL for this list.
-
#collaborative? ⇒ Boolean
Whether this list is editable by the owner’s friends.
-
#collaborators ⇒ Hash
Count and items of users who have edited this list.
-
#created_at ⇒ Time
The time at which the list was created.
-
#delete_item(options = {}) ⇒ Hash
Delete an item from the list.
-
#description ⇒ String
The list description.
-
#editable? ⇒ Boolean
Whether the list is editable by the acting user.
-
#followers ⇒ Hash
List Followers.
-
#following? ⇒ Boolean
Whether the acting user is following this list.
-
#id ⇒ String
Id of the list.
-
#initialize(client, response) ⇒ List
constructor
A new instance of List.
-
#list_items ⇒ Hash
Count and items of list items on this list.
-
#name ⇒ String
Name of the list.
-
#photo ⇒ Foursquared::Response::Photo
Photo for the list.
-
#public? ⇒ Boolean
Whether the list is public.
-
#suggest_photo(options = {}) ⇒ Hash
Suggests photos that may be appropriate for this item.
-
#suggest_tip(options = {}) ⇒ Object
Suggests tips that may be appropriate for a list item.
-
#suggest_venues ⇒ Array
Suggests venues that may be appropriate for this list.
-
#type ⇒ String
The type of list.
-
#updated_at ⇒ Time
The time at which the list was last updated.
-
#url ⇒ String
The list url.
-
#user ⇒ Foursquared::Response::User
The user who created the list.
-
#venue_count ⇒ Integer
The number of unique venues on the list.
-
#visited_count ⇒ Integer
The number of venues on the list visited by the acting user.
Constructor Details
#initialize(client, response) ⇒ List
Returns a new instance of List.
6 7 8 9 |
# File 'lib/foursquared/response/list.rb', line 6 def initialize client, response @client = client @response = response end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/foursquared/response/list.rb', line 5 def client @client end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/foursquared/response/list.rb', line 5 def response @response end |
Instance Method Details
#add_item(options = {}) ⇒ Foursquared::Response::ListItem
Add an Item to the list
163 164 165 166 |
# File 'lib/foursquared/response/list.rb', line 163 def add_item ={} @item = client.post("/lists/#{id}/additem", )["response"]["item"] Foursquared::Response::ListItem.new(client, @item) if @item end |
#canonical_url ⇒ String
The canonical URL for this list
67 68 69 |
# File 'lib/foursquared/response/list.rb', line 67 def canonical_url response["canonicalUrl"] end |
#collaborative? ⇒ Boolean
Whether this list is editable by the owner’s friends
49 50 51 |
# File 'lib/foursquared/response/list.rb', line 49 def collaborative? response["collaborative"] end |
#collaborators ⇒ Hash
Count and items of users who have edited this list
192 193 194 195 196 |
# File 'lib/foursquared/response/list.rb', line 192 def collaborators @collaborators = response["collaborators"] @collaborators["items"].map!{|item| Foursquared::Response::User.new(client, item)} @collaborators end |
#created_at ⇒ Time
The time at which the list was created
85 86 87 |
# File 'lib/foursquared/response/list.rb', line 85 def created_at Time.at(response["createdAt"]) if response["createdAt"] end |
#delete_item(options = {}) ⇒ Hash
Delete an item from the list
184 185 186 187 188 |
# File 'lib/foursquared/response/list.rb', line 184 def delete_item ={} @items = client.post("/lists/#{id}/deleteitem", )["response"]["items"] @items["items"].map!{|item| Foursquared::Response::ListItem.new(client, item)} @list_items end |
#description ⇒ String
The list description
25 26 27 |
# File 'lib/foursquared/response/list.rb', line 25 def description response["description"] end |
#editable? ⇒ Boolean
Whether the list is editable by the acting user
37 38 39 |
# File 'lib/foursquared/response/list.rb', line 37 def editable? response["editable"] end |
#followers ⇒ Hash
List Followers
170 171 172 173 174 175 176 |
# File 'lib/foursquared/response/list.rb', line 170 def followers @followers = client.get("/lists/#{id}/followers")["response"]["followers"] if @followers and @followers["items"] @followers["items"].map!{|item| Foursquared::Response::User.new(client, item)} end @followers end |
#following? ⇒ Boolean
Whether the acting user is following this list
61 62 63 |
# File 'lib/foursquared/response/list.rb', line 61 def following? response["following"] end |
#id ⇒ String
Id of the list
13 14 15 |
# File 'lib/foursquared/response/list.rb', line 13 def id response["id"] end |
#list_items ⇒ Hash
Count and items of list items on this list.
109 110 111 112 113 114 115 |
# File 'lib/foursquared/response/list.rb', line 109 def list_items @list_items = response["listItems"] if @list_items and @list_items["items"] @list_items["items"].map!{|item| Foursquared::Response::ListItem.new(client, item)} end @list_items end |
#name ⇒ String
Name of the list
19 20 21 |
# File 'lib/foursquared/response/list.rb', line 19 def name response["name"] end |
#photo ⇒ Foursquared::Response::Photo
Photo for the list
103 104 105 |
# File 'lib/foursquared/response/list.rb', line 103 def photo Foursquared::Response::Photo.new(client, response["photo"]) if response["photo"] end |
#public? ⇒ Boolean
Whether the list is public
43 44 45 |
# File 'lib/foursquared/response/list.rb', line 43 def public? response["public"] end |
#suggest_photo(options = {}) ⇒ Hash
Suggests photos that may be appropriate for this item.
121 122 123 124 125 126 127 128 129 |
# File 'lib/foursquared/response/list.rb', line 121 def suggest_photo ={} @photos = client.get("/lists/#{id}/suggestphoto", )["response"]["photos"] if @photos @photos.each_key do |key| key["items"].map!{|item| Foursquared::Response::Photo.new(client, item)} end end @photos end |
#suggest_tip(options = {}) ⇒ Object
Suggests tips that may be appropriate for a list item
143 144 145 146 147 148 149 150 151 |
# File 'lib/foursquared/response/list.rb', line 143 def suggest_tip ={} @tips = client.get("/lists/#{id}/suggesttip", )["response"]["tips"] if @tips @tips.each_key do |key| key["items"].map!{|item| Foursquared::Response::Photo.new(client, item)} end end @tips end |
#suggest_venues ⇒ Array
Suggests venues that may be appropriate for this list.
132 133 134 135 136 137 138 |
# File 'lib/foursquared/response/list.rb', line 132 def suggest_venues @suggested_venues = client.get("/lists/#{id}/suggestvenues")["response"]["suggestedVenues"] @suggested_venues.each do |item| item["venue"] = Foursquared::Response::Venue.new(client, item["venue"]) end @suggested_venues end |
#type ⇒ String
The type of list
31 32 33 |
# File 'lib/foursquared/response/list.rb', line 31 def type response["type"] end |
#updated_at ⇒ Time
The time at which the list was last updated
91 92 93 |
# File 'lib/foursquared/response/list.rb', line 91 def updated_at Time.at(response["updatedAt"]) if response["updatedAt"] end |
#url ⇒ String
The list url
55 56 57 |
# File 'lib/foursquared/response/list.rb', line 55 def url response["url"] end |
#user ⇒ Foursquared::Response::User
The user who created the list
97 98 99 |
# File 'lib/foursquared/response/list.rb', line 97 def user Foursquared::Response::User.new(client, response["user"]) if response["user"] end |
#venue_count ⇒ Integer
The number of unique venues on the list.
79 80 81 |
# File 'lib/foursquared/response/list.rb', line 79 def venue_count response["venueCount"] end |
#visited_count ⇒ Integer
The number of venues on the list visited by the acting user
73 74 75 |
# File 'lib/foursquared/response/list.rb', line 73 def visited_count response["visitedCount"] end |