Class: Foursquared::Response::Checkin

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

Overview

Checkin response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, response) ⇒ Checkin

Returns a new instance of Checkin.



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

def client
  @client
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#add_comment(options = {}) ⇒ Object

Add a comment to a check-in

Parameters:

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

Options Hash (options):

  • :text (String)

    The text of the comment, up to 200 characters.

  • :mentions (String)

    Mentions in your check-in.



151
152
153
154
155
156
# File 'lib/foursquared/response/checkin.rb', line 151

def add_comment options={}
  response = post("/checkins/#{id}/addcomment", options)["response"]
  @comment = response["comment"]
  @comment["user"] = Foursquared::Response::User.new(client, @comment["user"])
  @comment
end

#commentsHash

Count and items for comments on this checkin.

Returns:

  • (Hash)


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

def comments
  response["comments"]
end

#created_atTime

The time at which the checkin was created

Returns:

  • (Time)


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

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

#delete_comment(options = {}) ⇒ Foursquared::Response::Checkin

Remove commment from check-in

Parameters:

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

Options Hash (options):

  • :commentId (String)

    The ID of the checkin to remove a comment from.

Returns:



162
163
164
165
# File 'lib/foursquared/response/checkin.rb', line 162

def delete_comment options={}
  response = post("/checkins/#{id}/deletecomment", options)["response"]
  @checkin = Foursquared::Response::Checkin.new(client, response["checkin"])
end

#full_commentsHash

Full list of comments for this checkin

Returns:

  • (Hash)


62
63
64
# File 'lib/foursquared/response/checkin.rb', line 62

def full_comments
  client.get("/checkin/#{id}/comments")["comments"]
end

#full_likesHash

The full groups of users who have liked the checkin

Returns:

  • (Hash)


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

def full_likes
  @likes = client.get("/checkins/#{id}/likes")["response"]["likes"]
  @likes["groups"].each do |group|
    group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
  end
  @likes
end

#full_photosHash

The count and items of all the photos associated with the checkin

Returns:

  • (Hash)


140
141
142
143
144
145
# File 'lib/foursquared/response/checkin.rb', line 140

def full_photos
  resp = get("/checkins/#{id}/photos")
  @photos = resp["photos"]
  @photos["items"].map!{|item| Foursquared::Response::Photo.new(client, item)}
  @photos
end

#idString

ID of the checkin

Returns:

  • (String)


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

def id
  response["id"]
end

#like(options = {}) ⇒ Object

Like or unlike a checkin

Parameters:

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

Options Hash (options):

  • :set (Integer)

    If 1, like this checkin. If 0 unlike (un-do a previous like) it. Default value is 1.



170
171
172
173
174
175
176
# File 'lib/foursquared/response/checkin.rb', line 170

def like options={}
  response =  post("/checkins/#{id}/like", options)["response"]["likes"]
  response["groups"].each do |group|
    group["items"].map!{|item| Foursquared::Response::User.new(client, item)}
  end
  response
end

#like?Boolean

Whether the acting user likes the checkin

Returns:

  • (Boolean)


86
87
88
# File 'lib/foursquared/response/checkin.rb', line 86

def like?
  response["like"]
end

#likesHash

Groups of users who have liked the checkin

Returns:

  • (Hash)


112
113
114
115
116
117
118
# File 'lib/foursquared/response/checkin.rb', line 112

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

#locationHash

The current location of the user

Returns:

  • (Hash)


42
43
44
# File 'lib/foursquared/response/checkin.rb', line 42

def location
  response["location"]
end

#overlapsHash

Optional count and items of checkins from friends checked into the same venue around the same time.

Returns:

  • (Hash)


48
49
50
51
52
# File 'lib/foursquared/response/checkin.rb', line 48

def overlaps
  @overlaps = response["overlaps"]
  @overlaps["items"].map!{|item| Foursquared::Response::Checkin.new(client, item)} if @overlaps
  @overlaps
end

#photosHash

The count and items of photos associated with the checkin

Returns:

  • (Hash)


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

def photos
  @photos = response["photos"]
  @photos["photos"]["items"].map!{|item| Foursquared::Response::Photo.new(client, item)} if response["photos"]
  @photos
end

#privateObject

If present, it indicates the checkin was marked as private and not sent to friends



30
31
32
# File 'lib/foursquared/response/checkin.rb', line 30

def private
  response["private"]
end

#scoreHash

Total and scores for this checkin

Returns:

  • (Hash)


80
81
82
# File 'lib/foursquared/response/checkin.rb', line 80

def score
  response["score"]
end

#shoutString

Message from check-in, if present and visible to the acting user.

Returns:

  • (String)


68
69
70
# File 'lib/foursquared/response/checkin.rb', line 68

def shout
  response["shout"]
end

#sourceHash

If present, the name and url for the application that created this checkin.

Returns:

  • (Hash)


74
75
76
# File 'lib/foursquared/response/checkin.rb', line 74

def source
  response["source"]
end

#time_zone_offsetString

String representation of the time zone where this check-in occurred.

Returns:

  • (String)


92
93
94
# File 'lib/foursquared/response/checkin.rb', line 92

def time_zone_offset
  response["timeZoneOffset"]
end

#typeString

One of checkin, shout, or venueless.

Returns:

  • (String)


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

def type
  response["type"]
end

#userFoursquared::Response::User

If the user is not clear from context, then a compact user is present



36
37
38
# File 'lib/foursquared/response/checkin.rb', line 36

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

#venueFoursquared::Response::Venue

The venue of checkin



98
99
100
# File 'lib/foursquared/response/checkin.rb', line 98

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