Class: Foursquared::Response::Tip

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

Overview

Tip response class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, response) ⇒ Tip

Returns a new instance of Tip.



6
7
8
9
# File 'lib/foursquared/response/tip.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/tip.rb', line 5

def client
  @client
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#canonical_urlString

The canonical url for the tip

Returns:

  • (String)

    url



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

def canonical_url
  response["canonicalUrl"]
end

#created_atTime

Time since creation of the tip

Returns:

  • (Time)


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

def created_at
  Time.at(response["createdAt"]) if response["createdAt"]
end

#doneHash

Users who have done this tip todo

Returns:

  • (Hash)

    count and groups of users



95
96
97
98
# File 'lib/foursquared/response/tip.rb', line 95

def done 
  @done = response["done"]
  @done["groups"].each {|group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @done and @done["groups"]
end

#idString

ID of the tip

Returns:

  • (String)

    tip id



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

def id
  response["id"]
end

#like(options = {}) ⇒ Hash

Like or unlike the tip

Parameters:

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



104
105
106
107
108
109
# File 'lib/foursquared/response/tip.rb', line 104

def like options={}
  response = post("/tips/#{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

#like?Boolean

Whether the acting user likes the tip

Returns:

  • (Boolean)

    true or false



44
45
46
# File 'lib/foursquared/response/tip.rb', line 44

def like?
  response["like"]
end

#likesHash

Groups of users who like the tip

Returns:

  • (Hash)

    count, groups and summary



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

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

#listedHash

Groups of lists

Returns:

  • (Hash)

    count and groups of lists



62
63
64
65
66
# File 'lib/foursquared/response/tip.rb', line 62

def listed
  @listed = response["listed"]

  @listed["groups"].each{|group| group["items"].map!{|item| Foursquared::Response::List.new(client, item)}} if @listed and @listed["groups"]
end

#mark_doneFoursquared::Response::Tip

Mark the tip done

Returns:



113
114
115
116
# File 'lib/foursquared/response/tip.rb', line 113

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

#mark_todoFoursquared::Response::Todo

Mark the tip to-do

Returns:

  • (Foursquared::Response::Todo)

    The marked to-do.



120
121
122
123
# File 'lib/foursquared/response/tip.rb', line 120

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

#photoFoursquared::Response::Photo

Photo for this tip



70
71
72
# File 'lib/foursquared/response/tip.rb', line 70

def photo
  Foursquared::Response::Photo.new(client, response["photo"]) if response["photo"]
end

#statusString

Status of this tip.

Returns:

  • (String)

    todo or done



76
77
78
# File 'lib/foursquared/response/tip.rb', line 76

def status
  response["status"]
end

#textString

The actual tip

Returns:

  • (String)


25
26
27
# File 'lib/foursquared/response/tip.rb', line 25

def text
  response["text"]
end

#todoHash

Users who have marked this tip todo

Returns:

  • (Hash)

    count and groups of users



88
89
90
91
# File 'lib/foursquared/response/tip.rb', line 88

def todo
  @todo = response["todo"]
  @todo["groups"].each {|group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @todo and @todo["groups"]
end

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

Unmark the tip as to-do

Returns:



127
128
129
130
# File 'lib/foursquared/response/tip.rb', line 127

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

#urlString

A URL for more information.

Returns:

  • (String)


82
83
84
# File 'lib/foursquared/response/tip.rb', line 82

def url
  response["url"]
end

#userFoursquared::Response::User

If the context allows tips from multiple venues, the compact venue for this tip.



56
57
58
# File 'lib/foursquared/response/tip.rb', line 56

def user
  Foursquared::Response::User.new(client, response["user"]) if response["user"]
end

#venueFoursquared::Response::Venue

If the context allows tips from multiple venues, the compact venue for this tip.



50
51
52
# File 'lib/foursquared/response/tip.rb', line 50

def venue
  Foursquared::Response::Venue.new(client, response["venue"]) if response["venue"]
end