Module: Foursquared::Lists

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

Overview

Lists module

Instance Method Summary collapse

Instance Method Details

#add_list(options = {}) ⇒ Foursquared::Response::List

Add a List

Parameters:

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

Options Hash (options):

  • :name (String)

    required, The name of the list.

  • :description (String)

    The description of the list.

  • :collaborative (Boolean)

    Boolean indicating if this list can be edited by friends.

  • :photoId (String)

    The id of a photo that should be set as the list photo.

Returns:



24
25
26
27
# File 'lib/foursquared/lists.rb', line 24

def add_list options={}
  response = post("/lists/add", options)["response"]
  Foursquared::Response::List.new(self, response["list"])
end

#add_list_item(list_id, options = {}) ⇒ Foursquared::Response::ListItem

Add an Item to a list

Parameters:

  • list_id (String)

    required, ID for a list

  • 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.

  • :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:



79
80
81
82
# File 'lib/foursquared/lists.rb', line 79

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

#delete_list_item(list_id, options = {}) ⇒ Hash

Delete an item from the list

Parameters:

  • list_id (String)

    required, ID for a list

  • 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.



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

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

#list(list_id, options = {}) ⇒ Foursquared::Response::List

Gives details about a list.

Parameters:

  • list_id (String)

    required, ID for a list

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

Options Hash (options):

  • :limit (Integer)

    Number of results to return, up to 200.

  • :offset (Integer)

    The number of results to skip

  • :llBounds (String)

    Restricts the returned results to the input bounding box.

  • :categoryId (String)

    Restricts the returned results to venues matching the input category id.

Returns:



12
13
14
15
# File 'lib/foursquared/lists.rb', line 12

def list list_id, options={}
  response = get("/lists/#{list_id}", options)["response"]
  @list = Foursquared::Response::List.new(self, response["list"])
end

#suggest_list_photo(list_id, options = {}) ⇒ Hash

Suggests photos that may be appropriate for a list item.

Parameters:

  • list_id (String)

    required, ID for a list

  • 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.



34
35
36
37
38
39
40
41
42
# File 'lib/foursquared/lists.rb', line 34

def suggest_list_photo list_id, options={}
  @photos = get("/lists/#{list_id}/suggestphoto", options)["response"]["photos"]
  if @photos
    @photos.each_key do |key|
      key["items"] = key["items"].collect{|photo| Foursquared::Response::Photo.new(client, photo)}
    end
  end
  @photos
end

#suggest_list_tip(list_id, options = {}) ⇒ Object

Suggests tips that may be appropriate for a list item

Parameters:

  • list_id (String)

    required, ID for a list

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

Options Hash (options):

  • :itemId (String)

    required, The ID of the list item



59
60
61
62
63
64
65
66
67
# File 'lib/foursquared/lists.rb', line 59

def suggest_list_tip list_id, options={}
  @tips = get("/lists/#{list_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_list_venues(list_id) ⇒ Array

Suggests venues that may be appropriate for a list.

Parameters:

  • list_id (String)

    required, ID for a list

Returns:

  • (Array)

    Compact venues that may be appropriate for this list.



47
48
49
50
51
52
53
# File 'lib/foursquared/lists.rb', line 47

def suggest_list_venues list_id
  @suggested_venues = get("/lists/#{list_id}/suggestvenues")["response"]["suggestedVenues"]
  @suggested_venues.each do |item|
    item["venue"] = Foursquared::Response::Venue.new(self, item["venue"])
  end
  @suggested_venues
end