Class: Foursquared::Response::List

Inherits:
Object
  • Object
show all
Defined in:
lib/foursquared/response/list.rb

Overview

List response

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/foursquared/response/list.rb', line 5

def client
  @client
end

#responseObject (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

Parameters:

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

Options Hash (options):

  • :venueId (String)

    A venue to add to the list

  • :text (String)

    If the target is a user-created list, this will create a public tip on the venue. If the target is /userid/todos, the text will be a private note that is only visible to the author.

  • :url (String)

    If adding a new tip via text, this can associate a url with the tip.

  • :tipId (String)

    Used to add a tip to a list. Cannot be used in conjunction with the text and url fields.

  • :tipId (String)

    Used to add a tip to a list. Cannot be used in conjunction with the text and url fields.

  • :listId (String)

    Used in conjuction with itemId, the id for a user created or followed list as well as one of USER_ID/tips, USER_ID/todos, or USER_ID/dones.

  • :itemId (String)

    Used in conjuction with listId, the id of an item on that list that we wish to copy to this list.

Returns:



163
164
165
166
# File 'lib/foursquared/response/list.rb', line 163

def add_item options={}
  @item = client.post("/lists/#{id}/additem", options)["response"]["item"]
  Foursquared::Response::ListItem.new(client, @item) if @item
end

#canonical_urlString

The canonical URL for this list

Returns:

  • (String)


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

Returns:

  • (Boolean)


49
50
51
# File 'lib/foursquared/response/list.rb', line 49

def collaborative?
  response["collaborative"]
end

#collaboratorsHash

Count and items of users who have edited this list

Returns:

  • (Hash)


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_atTime

The time at which the list was created

Returns:

  • (Time)


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

Parameters:

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

Options Hash (options):

  • :venueId (String)

    ID of a venue to be deleted.

  • :itemId (String)

    ID of the item to delete.

  • :tipId (String)

    id of a tip to be deleted.

Returns:

  • (Hash)

    A count and items of list items that were just deleted.



184
185
186
187
188
# File 'lib/foursquared/response/list.rb', line 184

def delete_item options={}
  @items = client.post("/lists/#{id}/deleteitem", options)["response"]["items"]
  @items["items"].map!{|item| Foursquared::Response::ListItem.new(client, item)}
  @list_items
end

#descriptionString

The list description

Returns:

  • (String)


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

Returns:

  • (Boolean)


37
38
39
# File 'lib/foursquared/response/list.rb', line 37

def editable?
  response["editable"]
end

#followersHash

List Followers

Returns:

  • (Hash)

    A count and items of users following this list.



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

Returns:

  • (Boolean)


61
62
63
# File 'lib/foursquared/response/list.rb', line 61

def following?
  response["following"]
end

#idString

Id of the list

Returns:

  • (String)


13
14
15
# File 'lib/foursquared/response/list.rb', line 13

def id
  response["id"]
end

#list_itemsHash

Count and items of list items on this list.

Returns:

  • (Hash)


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

#nameString

Name of the list

Returns:

  • (String)


19
20
21
# File 'lib/foursquared/response/list.rb', line 19

def name
  response["name"]
end

#photoFoursquared::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

Returns:

  • (Boolean)


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.

Parameters:

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

Options Hash (options):

  • :itemId (String)

    required, The ID of the list item

Returns:

  • (Hash)

    Groups user and others containing lists (a count and items of photos) of photos uploaded by this user and uploaded by other users.



121
122
123
124
125
126
127
128
129
# File 'lib/foursquared/response/list.rb', line 121

def suggest_photo options={}
  @photos = client.get("/lists/#{id}/suggestphoto", options)["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

Parameters:

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

Options Hash (options):

  • :itemId (String)

    required, The ID of the list item



143
144
145
146
147
148
149
150
151
# File 'lib/foursquared/response/list.rb', line 143

def suggest_tip options={}
  @tips = client.get("/lists/#{id}/suggesttip", options)["response"]["tips"]
  if @tips
    @tips.each_key do |key|
      key["items"].map!{|item| Foursquared::Response::Photo.new(client, item)}
    end
  end
  @tips
end

#suggest_venuesArray

Suggests venues that may be appropriate for this list.

Returns:

  • (Array)

    Compact 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

#typeString

The type of list

Returns:

  • (String)


31
32
33
# File 'lib/foursquared/response/list.rb', line 31

def type
  response["type"]
end

#updated_atTime

The time at which the list was last updated

Returns:

  • (Time)


91
92
93
# File 'lib/foursquared/response/list.rb', line 91

def updated_at
  Time.at(response["updatedAt"]) if response["updatedAt"]
end

#urlString

The list url

Returns:

  • (String)


55
56
57
# File 'lib/foursquared/response/list.rb', line 55

def url
  response["url"]
end

#userFoursquared::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_countInteger

The number of unique venues on the list.

Returns:

  • (Integer)


79
80
81
# File 'lib/foursquared/response/list.rb', line 79

def venue_count
  response["venueCount"]
end

#visited_countInteger

The number of venues on the list visited by the acting user

Returns:

  • (Integer)


73
74
75
# File 'lib/foursquared/response/list.rb', line 73

def visited_count
  response["visitedCount"]
end