john-mayer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # John Mayer
2
+
3
+ It's a Foursquare API wrapper.
4
+
5
+ ## Usage
6
+
7
+ Get a foursquare:
8
+
9
+ foursquare = Foursquare.new("ACCESS_TOKEN")
10
+
11
+ Find a user:
12
+
13
+ foursquare.users.find("USER_ID")
14
+
15
+ Find a checkin:
16
+
17
+ foursquare.checkins.find("CHECKIN_ID")
18
+
19
+ Find a venue:
20
+
21
+ foursquare.venues.find("VENUE_ID")
data/lib/foursquare.rb ADDED
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)
2
+
3
+ require "rubygems"
4
+ require "typhoeus"
5
+ require "json"
6
+ require "foursquare/base"
7
+ require "foursquare/checkin_proxy"
8
+ require "foursquare/checkin"
9
+ require "foursquare/user_proxy"
10
+ require "foursquare/user"
11
+ require "foursquare/venue_proxy"
12
+ require "foursquare/venue"
13
+
14
+ module Foursquare
15
+ end
@@ -0,0 +1,27 @@
1
+ module Foursquare
2
+ class Base
3
+ API = "https://api.foursquare.com/v2/"
4
+
5
+ def initialize(access_token)
6
+ @access_token = access_token
7
+ end
8
+
9
+ def users
10
+ Foursquare::UserProxy.new(self)
11
+ end
12
+
13
+ def checkins
14
+ Foursquare::CheckinProxy.new(self)
15
+ end
16
+
17
+ def venues
18
+ Foursquare::VenueProxy.new(self)
19
+ end
20
+
21
+ def get(path, params={})
22
+ params.merge!(:oauth_token => @access_token)
23
+ response = JSON.parse(Typhoeus::Request.get(API + path, :params => params).body)
24
+ response["meta"]["code"] == 200 ? response["response"] : nil
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Foursquare
2
+ class Checkin
3
+ def initialize(foursquare, json)
4
+ @foursquare, @json = foursquare, json
5
+ end
6
+
7
+ def id
8
+ @json["id"]
9
+ end
10
+
11
+ def shout
12
+ @json["shout"]
13
+ end
14
+
15
+ def mayor?
16
+ @json["isMayor"]
17
+ end
18
+
19
+ def timezone
20
+ @json["timeZone"]
21
+ end
22
+
23
+ def venue
24
+ Foursquare::Venue.new(@foursquare, @json["venue"])
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,11 @@
1
+ module Foursquare
2
+ class CheckinProxy
3
+ def initialize(foursquare)
4
+ @foursquare = foursquare
5
+ end
6
+
7
+ def find(id)
8
+ Foursquare::Checkin.new(@foursquare, @foursquare.get("checkins/#{id}")["checkin"])
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,64 @@
1
+ module Foursquare
2
+ class User
3
+ def initialize(foursquare, json)
4
+ @foursquare, @json = foursquare, json
5
+ end
6
+
7
+ def id
8
+ @json["id"]
9
+ end
10
+
11
+ def name
12
+ [first_name, last_name].join(' ').strip
13
+ end
14
+
15
+ def first_name
16
+ @json["firstName"]
17
+ end
18
+
19
+ def last_name
20
+ @json["lastName"]
21
+ end
22
+
23
+ def photo
24
+ @json["photo"]
25
+ end
26
+
27
+ def gender
28
+ @json["gender"]
29
+ end
30
+
31
+ def home_city
32
+ @json["homeCity"]
33
+ end
34
+
35
+ def relationship
36
+ @json["relationship"]
37
+ end
38
+
39
+ def pings
40
+ @json["pings"]
41
+ end
42
+
43
+ def contact
44
+ @json["contact"]
45
+ end
46
+
47
+ def badge_count
48
+ @json["badges"]["count"]
49
+ end
50
+
51
+ def mayorships
52
+ @json["mayorships"]["items"]
53
+ end
54
+
55
+ def checkin_count
56
+ @json["checkins"]["count"]
57
+ end
58
+
59
+ def last_checkin
60
+ item = @json["checkins"]["items"].last
61
+ Foursquare::Checkin.new(@foursquare, item)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,11 @@
1
+ module Foursquare
2
+ class UserProxy
3
+ def initialize(foursquare)
4
+ @foursquare = foursquare
5
+ end
6
+
7
+ def find(id)
8
+ Foursquare::User.new(@foursquare, @foursquare.get("users/#{id}")["user"])
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,43 @@
1
+ module Foursquare
2
+ class Venue
3
+ def initialize(foursquare, json)
4
+ @foursquare, @json = foursquare, json
5
+ end
6
+
7
+ def id
8
+ @json["id"]
9
+ end
10
+
11
+ def name
12
+ @json["name"]
13
+ end
14
+
15
+ def contact
16
+ @json["contact"]
17
+ end
18
+
19
+ def location
20
+ @json["location"]
21
+ end
22
+
23
+ def categories
24
+ @json["categories"]
25
+ end
26
+
27
+ def verified?
28
+ @json["verified"]
29
+ end
30
+
31
+ def checkins_count
32
+ @json["stats"]["checkinsCount"]
33
+ end
34
+
35
+ def users_count
36
+ @json["stats"]["usersCount"]
37
+ end
38
+
39
+ def todos_count
40
+ @json["todos"]["count"]
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,11 @@
1
+ module Foursquare
2
+ class VenueProxy
3
+ def initialize(foursquare)
4
+ @foursquare = foursquare
5
+ end
6
+
7
+ def find(id)
8
+ Foursquare::Venue.new(@foursquare, @foursquare.get("venues/#{id}")["venue"])
9
+ end
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ My bad. Whatevz.
data/test.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'lib/foursquare'
2
+
3
+ FOURSQUARE = Foursquare::Base.new('TOKEN')
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: john-mayer
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Pat Nakajima
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-14 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: typhoeus
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: json
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description:
50
+ email: pat@groupme.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - README.md
59
+ - lib/foursquare.rb
60
+ - lib/foursquare/base.rb
61
+ - lib/foursquare/checkin.rb
62
+ - lib/foursquare/checkin_proxy.rb
63
+ - lib/foursquare/user.rb
64
+ - lib/foursquare/user_proxy.rb
65
+ - lib/foursquare/venue.rb
66
+ - lib/foursquare/venue_proxy.rb
67
+ - spec/THERE_ARENT_ANY
68
+ - test.rb
69
+ has_rdoc: true
70
+ homepage: https://github.com/groupme/john-mayer
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ requirements: []
97
+
98
+ rubyforge_project:
99
+ rubygems_version: 1.3.7
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: A Foursquare API wrapper
103
+ test_files: []
104
+