skittles 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,9 +3,23 @@ module Skittles
3
3
  # Define methods related to specials.
4
4
  # @see http://developer.foursquare.com/docs/specials/specials.html
5
5
  module Special
6
+ # Allows users to indicate a special is improper in some way.
7
+ #
8
+ # @params special_id [String] The id of the special being flagged.
9
+ # @param venue_id [String] The id of the venue running the special.
10
+ # @param problem [String] One of not_redeemable, not_valuable, other.
11
+ # @param options [Hash] A customizable set of options.
12
+ # @option options [String] text Additional text about why the user has flagged this special.
13
+ # @require_acting_user Yes
14
+ # @see https://developer.foursquare.com/docs/specials/flag.html
15
+ def flag_special(special_id, venue_id, problem, options = {})
16
+ post("specials/#{special_id}/flag", { :venueId => venue_id, :problem => problem }.merge(options))
17
+ nil
18
+ end
19
+
6
20
  # Gives details about a special, including text and unlock rules.
7
21
  #
8
- # @param id [String] Id of special to retrieve.
22
+ # @param special_id [String] Id of special to retrieve.
9
23
  # @return [Hashie::Mash] A complete special.
10
24
  # @requires_acting_user No
11
25
  # @see http://developer.foursquare.com/docs/specials/specials.html
@@ -1,3 +1,5 @@
1
+ require 'mime/types'
2
+
1
3
  module Skittles
2
4
  class Client
3
5
  # Define methods related to users.
@@ -81,6 +83,7 @@ module Skittles
81
83
  def friends(id, options = {})
82
84
  get("users/#{id}/friends").friends
83
85
  end
86
+
84
87
  # Returns the user's leaderboard.
85
88
  #
86
89
  # @param neightbors [Integer] Number of friends' scores to return that are adjacent to your score in ranked order. The current user's score is returned as well.
@@ -91,6 +94,16 @@ module Skittles
91
94
  get('users/leaderboard').leaderboard
92
95
  end
93
96
 
97
+ # Returns a user's mayorships
98
+ #
99
+ # @params user [String] Identity of the user to get mayorships for. Pass self to get friends of the acting user.
100
+ # @return [Hashie::Mash] A count and items of objects which currently only contain compact venue objects.
101
+ # @requires_acting_user Yes
102
+ # @see https://developer.foursquare.com/docs/users/mayorships.html
103
+ def mayorships(user = 'self')
104
+ get("users/#{user}/mayorships").mayorships
105
+ end
106
+
94
107
  # Changes whether the acting user will receive pings (phone
95
108
  # notifications) when the specified user checks in.
96
109
  #
@@ -116,6 +129,36 @@ module Skittles
116
129
  get("users/#{id}/todos", { :sort => sort }.merge(options)).todos
117
130
  end
118
131
 
132
+ # Updates the user's profile photo.
133
+ #
134
+ # @param photo [String] Photo under 100KB in multipark MIME encoding with content type image/jpeg, image/gif, or image/png.
135
+ # @return [Hashie::Mash] The current user object
136
+ # @requires_acting_user Yes
137
+ # @see https://developer.foursquare.com/docs/users/update.html
138
+ def update_user_photo(photo)
139
+ mime_type = MIME::Types.type_for(photo)[0]
140
+ params = {
141
+ :photo => UploadIO.new(photo, mime_type.to_s, "image.#{mime_type.extensions[0]}"),
142
+ :oauth_token => access_token
143
+ }
144
+ uri = URI.parse("#{endpoint}/users/self/update")
145
+ File.open(photo) do
146
+ req = Net::HTTP::Post::Multipart.new(uri.path, params)
147
+ http = Net::HTTP.new(uri.host, uri.port)
148
+ http.use_ssl = true if uri.scheme == 'https'
149
+ resp = http.start do |net|
150
+ net.request(req)
151
+ end
152
+
153
+ case resp.code.to_i
154
+ when 200..299
155
+ return Skittles::Utils.parse_json(resp.body).response.user
156
+ when 400..599
157
+ Skittles::Utils.handle_foursquare_error(resp)
158
+ end
159
+ end
160
+ end
161
+
119
162
  # Returns profile information for a given user, including selected badges
120
163
  # and mayorships.
121
164
  #
@@ -215,7 +215,7 @@ module Skittles
215
215
  # @requires_acting_user No
216
216
  # @see http://developer.foursquare.com/docs/venues/search.html
217
217
  def venue_search(ll, options = {})
218
- get('venues/search', { :ll => ll }.merge(options)).groups
218
+ get('venues/search', { :ll => ll }.merge(options)).venues
219
219
  end
220
220
 
221
221
  # Returns tips for a venue.
@@ -233,4 +233,4 @@ module Skittles
233
233
  end
234
234
  end
235
235
  end
236
- end
236
+ end
@@ -1,3 +1,3 @@
1
1
  module Skittles
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,116 +1,124 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: skittles
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
4
5
  prerelease:
5
- version: 0.4.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Anthony Smith
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-23 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-07-29 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: oauth2
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70223019913040 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
18
+ requirements:
21
19
  - - ~>
22
- - !ruby/object:Gem::Version
20
+ - !ruby/object:Gem::Version
23
21
  version: 0.4.1
24
22
  type: :runtime
25
23
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *70223019913040
25
+ - !ruby/object:Gem::Dependency
28
26
  name: yajl-ruby
29
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &70223019912560 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
29
+ requirements:
32
30
  - - ~>
33
- - !ruby/object:Gem::Version
31
+ - !ruby/object:Gem::Version
34
32
  version: 0.8.1
35
33
  type: :runtime
36
34
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *70223019912560
36
+ - !ruby/object:Gem::Dependency
39
37
  name: hashie
40
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &70223019912080 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
40
+ requirements:
43
41
  - - ~>
44
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
45
43
  version: 1.0.0
46
44
  type: :runtime
47
45
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *70223019912080
47
+ - !ruby/object:Gem::Dependency
48
+ name: mime-types
49
+ requirement: &70223019911600 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70223019911600
58
+ - !ruby/object:Gem::Dependency
50
59
  name: rspec
51
- requirement: &id004 !ruby/object:Gem::Requirement
60
+ requirement: &70223019911120 !ruby/object:Gem::Requirement
52
61
  none: false
53
- requirements:
62
+ requirements:
54
63
  - - ~>
55
- - !ruby/object:Gem::Version
64
+ - !ruby/object:Gem::Version
56
65
  version: 2.5.0
57
66
  type: :development
58
67
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *70223019911120
69
+ - !ruby/object:Gem::Dependency
61
70
  name: bundler
62
- requirement: &id005 !ruby/object:Gem::Requirement
71
+ requirement: &70223019910640 !ruby/object:Gem::Requirement
63
72
  none: false
64
- requirements:
73
+ requirements:
65
74
  - - ~>
66
- - !ruby/object:Gem::Version
75
+ - !ruby/object:Gem::Version
67
76
  version: 1.0.15
68
77
  type: :development
69
78
  prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *70223019910640
80
+ - !ruby/object:Gem::Dependency
72
81
  name: jeweler
73
- requirement: &id006 !ruby/object:Gem::Requirement
82
+ requirement: &70223019910160 !ruby/object:Gem::Requirement
74
83
  none: false
75
- requirements:
84
+ requirements:
76
85
  - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 1.6.2
86
+ - !ruby/object:Gem::Version
87
+ version: 1.6.4
79
88
  type: :development
80
89
  prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *70223019910160
91
+ - !ruby/object:Gem::Dependency
83
92
  name: rcov
84
- requirement: &id007 !ruby/object:Gem::Requirement
93
+ requirement: &70223019909680 !ruby/object:Gem::Requirement
85
94
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
90
99
  type: :development
91
100
  prerelease: false
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
101
+ version_requirements: *70223019909680
102
+ - !ruby/object:Gem::Dependency
94
103
  name: yard
95
- requirement: &id008 !ruby/object:Gem::Requirement
104
+ requirement: &70223019909200 !ruby/object:Gem::Requirement
96
105
  none: false
97
- requirements:
106
+ requirements:
98
107
  - - ~>
99
- - !ruby/object:Gem::Version
108
+ - !ruby/object:Gem::Version
100
109
  version: 0.7.2
101
110
  type: :development
102
111
  prerelease: false
103
- version_requirements: *id008
104
- description: Foursquare v2 REST API client library for Ruby
112
+ version_requirements: *70223019909200
113
+ description: A Ruby implementation of the Foursquare v2 REST API. This library implements
114
+ the Foursquare v2 API and the Foursquare Venues Project (beta) endpoints.
105
115
  email: anthony@sticksnleaves.com
106
116
  executables: []
107
-
108
117
  extensions: []
109
-
110
- extra_rdoc_files:
118
+ extra_rdoc_files:
111
119
  - LICENSE.txt
112
120
  - README.rdoc
113
- files:
121
+ files:
114
122
  - lib/skittles.rb
115
123
  - lib/skittles/api.rb
116
124
  - lib/skittles/client.rb
@@ -129,36 +137,32 @@ files:
129
137
  - lib/skittles/version.rb
130
138
  - LICENSE.txt
131
139
  - README.rdoc
132
- has_rdoc: true
133
140
  homepage: http://github.com/anthonator/skittles
134
- licenses:
141
+ licenses:
135
142
  - MIT
136
143
  post_install_message:
137
144
  rdoc_options: []
138
-
139
- require_paths:
145
+ require_paths:
140
146
  - lib
141
- required_ruby_version: !ruby/object:Gem::Requirement
147
+ required_ruby_version: !ruby/object:Gem::Requirement
142
148
  none: false
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- hash: -3536193774362662556
147
- segments:
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ segments:
148
154
  - 0
149
- version: "0"
150
- required_rubygems_version: !ruby/object:Gem::Requirement
155
+ hash: 3746734199987061722
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
157
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- version: "0"
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
156
162
  requirements: []
157
-
158
163
  rubyforge_project:
159
- rubygems_version: 1.6.2
164
+ rubygems_version: 1.8.6
160
165
  signing_key:
161
166
  specification_version: 3
162
167
  summary: Foursquare v2 REST API client library for Ruby
163
168
  test_files: []
164
-