quimby 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -6,8 +6,10 @@ It's a Foursquare API wrapper. It uses objects instead of hashes, and tries to b
6
6
 
7
7
  ## Installation
8
8
 
9
- Install it as a gem (in your `Gemfile`)
9
+ Install it as a gem (in your `Gemfile`) and its dependencies:
10
10
 
11
+ gem "json"
12
+ gem "typhoeus"
11
13
  gem "quimby"
12
14
 
13
15
  ## Usage
@@ -51,7 +53,7 @@ Find a user:
51
53
  user = foursquare.users.find("USER_ID")
52
54
 
53
55
  Now we've got a `Foursquare::User` object. You can call sweet methods like `user.name` and even
54
- `user.last_checkin`. **In general, John Mayer's Foursquare object methods are just snake-cased
56
+ `user.last_checkin`. **In general, Quimby's Foursquare object methods are just snake-cased
55
57
  versions of the attributes returned in the JSON.** Now let's accidentally that user's friends:
56
58
 
57
59
  user.friends
@@ -19,6 +19,7 @@ require "foursquare/category"
19
19
 
20
20
  module Foursquare
21
21
  class Error < StandardError ; end
22
+ class InvalidAuth < Foursquare::Error; end
22
23
  class ServiceUnavailable < Foursquare::Error; end
23
24
 
24
25
  def self.verbose=(setting)
@@ -115,6 +115,8 @@ module Foursquare
115
115
  else
116
116
  error_type = response['meta']['errorType']
117
117
  case error_type
118
+ when "invalid_auth"
119
+ raise Foursquare::InvalidAuth.new(Foursquare::ERRORS[error_type])
118
120
  when "server_error"
119
121
  raise Foursquare::ServiceUnavailable.new(Foursquare::ERRORS[error_type])
120
122
  else
@@ -60,6 +60,18 @@ module Foursquare
60
60
  def twitter
61
61
  contact["twitter"]
62
62
  end
63
+
64
+ def facebook
65
+ contact["facebook"]
66
+ end
67
+
68
+ def twitter?
69
+ !twitter.blank?
70
+ end
71
+
72
+ def facebook?
73
+ !facebook.blank?
74
+ end
63
75
 
64
76
  def phone_number
65
77
  contact["phone"]
@@ -5,6 +5,11 @@ module Foursquare
5
5
  def initialize(foursquare, json)
6
6
  @foursquare, @json = foursquare, json
7
7
  end
8
+
9
+ def fetch
10
+ @json = @foursquare.get("venues/#{id}")["venue"]
11
+ self
12
+ end
8
13
 
9
14
  def id
10
15
  @json["id"]
@@ -57,6 +62,10 @@ module Foursquare
57
62
  primary_category ? primary_category["icon"] : "https://foursquare.com/img/categories/none.png"
58
63
  end
59
64
 
65
+ def short_url
66
+ @json["shortUrl"]
67
+ end
68
+
60
69
  def photos_count
61
70
  @json["photos"]["count"]
62
71
  end
@@ -77,5 +86,20 @@ module Foursquare
77
86
  end
78
87
  end
79
88
 
89
+ # count the people who have checked-in at the venue in the last two hours
90
+ def here_now_count
91
+ fetch unless @json.has_key?("hereNow")
92
+ @json["hereNow"]["count"]
93
+ end
94
+
95
+ # returns a list of checkins (only if a valid oauth token from a user is provided)
96
+ # https://developer.foursquare.com/docs/venues/herenow.html
97
+ # options: limit, offset, aftertimestamp
98
+ def here_now_checkins(options={:limit => "50"})
99
+ @foursquare.get("venues/#{id}/herenow", options)["hereNow"]["items"].map do |item|
100
+ Foursquare::Checkin.new(@foursquare, item)
101
+ end
102
+ end
103
+
80
104
  end
81
105
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quimby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 3
10
- version: 0.4.3
9
+ - 4
10
+ version: 0.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pat Nakajima