whatser 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,7 +7,7 @@ The 'Whatser API' Gem is a simple Ruby / Rails wrapper for interacting with What
7
7
  * read/write API access
8
8
  * OAuth 2 authentication (using oauth2)
9
9
  * network connectivity (using httparty)
10
- * simple DSL for API resource classes (spots, media, reviews, check ins, etc.)
10
+ * simple DSL for API resource classes (spots, media, comments, check ins, etc.)
11
11
  * user spot collection management
12
12
  * check-in aggregation
13
13
  * social network integration (facebook, twitter, foursquare, gowalla)
@@ -111,7 +111,7 @@ The API stores user profiles, which may have originated either directly from API
111
111
  m = Whatser.client.users.find( user_id )
112
112
  m.connection
113
113
 
114
- <Whatser::User @bio="Example", @location="Amsterdam, NL", @facebook_id="1234567890", @email="user@example.com", @gowalla_id="1234567890", @avatar_pic="http://example.com/img/14.jpg", @promoted=false, @name="User", @twitter_name="example", @last_login_at="2010-12-24T16:46:23Z", @twitter_id="1234567890", @id=101, @foursquare_id="1234567890">
114
+ <Whatser::User @bio="Example", @location="Amsterdam, NL", @facebook_id="1234567890", @email="user@example.com", @gowalla_id="1234567890", @avatar_pic="http://example.com/img/14.jpg", @promoted=false, @name="User", @twitter_name="example", @last_login_at="2010-12-24T16:46:23Z", @twitter_id="1234567890", @id=101, @foursquare_id="1234567890", @thanks_count=0, @poi_count=0, @check_ins_count=0, @media_count=0, @taggings_count=0, @follows_count=0, @followers_count=0, @comments_count=0>
115
115
 
116
116
  The API also permits anonymous user access, but in order to do so an anonymous user must first be created. Anonymous users have limited privileges and no email address, but otherwise function identically to authorized users. After the user is created, you can get the oauth token to use with your client and perform actions on behalf of the anonymous user.
117
117
 
@@ -134,8 +134,7 @@ A spot is a named geographical location and the most fundamental kind of content
134
134
  m = Whatser.client.spots.new( :name => 'my spot', :lat => 52.0, :lng => 4.0 )
135
135
  m.save
136
136
  m.delete
137
- results = m.details
138
- results = m.reviews
137
+ results = m.comments
139
138
  results = m.tags
140
139
  results = m.activity
141
140
 
@@ -170,36 +169,6 @@ A user's cities represent the cities in which they have collected spots.
170
169
  <Whatser::City @count=5, @name="Amsterdam">
171
170
 
172
171
 
173
- === Reviews
174
-
175
- A review is a short- to long-form text article about a spot.
176
-
177
- Whatser.client.reviews.list( spot_id, :page => 1, :per_page => 10 )
178
- Whatser.client.reviews.find( spot_id, review_id )
179
- Whatser.client.reviews.create( spot_id, :body => 'my spot review.' )
180
- Whatser.client.reviews.delete( spot_id, review_id )
181
- m = Whatser.client.reviews.new( :body => 'my spot review.' )
182
- m.save
183
- m.delete
184
-
185
- <Whatser::Review @user_id=null, @id=101, @body="whatser spot review.", @created_at="2010-12-24T16:45:55Z">
186
-
187
-
188
- === Details
189
-
190
- Details are miscellaneous, freeform information about a spot, such as operating hours, pricing, etc. The data attribute serializes a hash, which can be used to store arbitrary spot details.
191
-
192
- Whatser.client.details.list( spot_id, :page => 1, :per_page => 10 )
193
- Whatser.client.details.find( spot_id, details_id )
194
- Whatser.client.details.create( spot_id, :data => {:title => 'details', :opening_hours => '8:00-5:00'} )
195
- Whatser.client.details.delete( spot_id, review_id )
196
- m = Whatser.client.details.new( :data => {:title => 'details', :opening_hours => '8:00-5:00'} )
197
- m.save
198
- m.delete
199
-
200
- <Whatser::Detail @data={"meta"=>"Long metadata here", "opening_hours" => "9-5"}, @user_id=null, @id=101>
201
-
202
-
203
172
  === Media
204
173
 
205
174
  Media are photos, logos, and other graphics associated with a spot. You can create new media either by supplying a file for a multipart upload, or else with a link to an existing online image.
@@ -226,7 +195,16 @@ Tags are freeform text that reflect user thoughts, opinions, and feedback on spe
226
195
  m.save
227
196
  m.delete
228
197
 
229
- <Whatser::Tag @name="my tag">
198
+ Tags can also be accessed through their spot, either by calling the model's cached tag_list, branded_tags, or making an API request for a full tag listing.
199
+
200
+ spot = Whatser.client.spots.find( spot_id )
201
+ spot.tag_list
202
+ spot.branded_tags
203
+ spot.tags
204
+
205
+ In addition to user tags, some spots will also have branded tags, keywords promoted by Whatser partners and associated with branded images; for normal user tags, these image urls are not used. The images are customized for three platforms (web, touch, and wap), and two sizes (list and detail).
206
+
207
+ <Whatser::Tag @name="my tag", @poi_id=101, @web_list_pic="http://wht.sr/1.png", @web_detail_pic="http://wht.sr/2.png", @touch_list_pic="http://wht.sr/3.png", @touch_detail_pic="http://wht.sr/4.png", @wap_list_pic="http://wht.sr/5.png", @wap_detail_pic="http://wht.sr/6.png">
230
208
 
231
209
 
232
210
  === Follows
@@ -241,7 +219,7 @@ Follows represent a user's interest in another user, namely the user's spot acti
241
219
  m.save
242
220
  m.delete
243
221
 
244
- <Whatser::Follow @location="Amsterdam, NL", @premium=false, @avatar_pic="http://example.com/avatars/thumb/1.jpg", @promoted=false, @name="Example User", @id=1>
222
+ <Whatser::Follow @location="Amsterdam, NL", @avatar_pic="http://example.com/avatars/thumb/1.jpg", @promoted=false, @name="Example User", @id=1>
245
223
 
246
224
 
247
225
  === Check Ins
@@ -256,18 +234,6 @@ A check in represents a user's visit to a spot, and will typically have a counte
256
234
  <Whatser::CheckIn @message="statuscastin' over here", @lng=4.8931739, @rating=3, @lat=52.3665312, @check_out_at="2010-12-24T16:46:38Z", @name="Popular Spot", @poi_id=101, @check_in_at="2010-12-24T16:31:38Z", @user_id=101>
257
235
 
258
236
 
259
- === Data Sources
260
-
261
- A data source represents a free or purchasable content stream of collected spots, media, and reviews. Users can subscribe to data sources in order to access their content in Whatser. To begin the subscription and payment process, redirect your user to the data source's subscription_url.
262
-
263
- Whatser.client.data_sources.list( :page => 1, :per_page => 10 )
264
- Whatser.client.data_sources.for_users( :user_id => [101,23], :page => 1, :per_page => 10 )
265
- m = Whatser.client.data_sources.find( 1 )
266
- redirect_to m.subscription_url(:display => 'touch')
267
-
268
- <Whatser::DataSource @review_count=405, @poi_count=0, @price=0.0, @collection_count=0, @name="Rough Guides - Barcelona", @media_count=0, @id=9, @users=[{"name": "premium user", "id": 33}]>
269
-
270
-
271
237
  === Comments
272
238
 
273
239
  A comment is just a short user note that can be associated with other resources. At the moment, you can comment on a POI, Media, or an Activity Feed. Users can also delete their own comments.
@@ -342,6 +308,6 @@ You can use convenience methods on users and spots to determine their connection
342
308
 
343
309
  == Copyright
344
310
 
345
- Copyright (c) 2010 Travis Dunn / SoGeo Company. See LICENSE.txt for
311
+ Copyright (c) 2010-2011 Travis Dunn / SoGeo Company. See LICENSE.txt for
346
312
  further details.
347
313
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -28,12 +28,10 @@ module Whatser
28
28
  def check_ins; Whatser::CheckIn.set(self); end
29
29
  def collections; Whatser::Collection.set(self); end
30
30
  def data_sources; Whatser::DataSource.set(self); end
31
- def details; Whatser::Detail.set(self); end
32
31
  def media; Whatser::Media.set(self); end
33
32
  def spots; Whatser::Poi.set(self); end
34
33
  def users; Whatser::User.set(self); end
35
34
  def follows; Whatser::Follow.set(self); end
36
- def reviews; Whatser::Review.set(self); end
37
35
  def subscriptions; Whatser::Subscription.set(self); end
38
36
  def tags; Whatser::Tag.set(self); end
39
37
  def comments; Whatser::Comment.set(self); end
@@ -1,6 +1,6 @@
1
1
  module Whatser
2
2
  class Comment < Whatser::Resource
3
- attr_accessor :id,:user_id,:activity_feed_id,:subject_id,:created_at
3
+ attr_accessor :id,:user_id,:activity_feed_id,:subject_id,:poi_id,:created_at
4
4
  attr_accessor :user_name,:user_avatar,:subject_type,:subject_name,:body
5
5
 
6
6
  class << self
@@ -21,6 +21,14 @@ module Whatser
21
21
  end
22
22
  end
23
23
 
24
+ def poi
25
+ Whatser::Poi.set(self.class.client).find(poi_id) if poi_id
26
+ end
27
+
28
+ def user
29
+ Whatser::User.set(self.class.client).find(user_id) if user_id
30
+ end
31
+
24
32
  def delete
25
33
  self.class.delete(id)
26
34
  end
@@ -2,7 +2,7 @@ module Whatser
2
2
  class Follow < Whatser::Resource
3
3
  attr_accessor :id
4
4
  attr_accessor :name,:avatar_pic,:location
5
- attr_accessor :promoted,:premium,:collections_count
5
+ attr_accessor :promoted,:collections_count
6
6
  attr_accessor :following,:followed,:foaf_count,:foaf
7
7
 
8
8
  class << self
@@ -1,8 +1,9 @@
1
1
  module Whatser
2
2
  class Poi < Whatser::Resource
3
3
  attr_accessor :id,:user_id,:gowalla_id,:foursquare_id
4
- attr_accessor :name,:lat,:lng,:street,:district,:region,:city,:postal_code,:country
5
- attr_accessor :tag_list,:created_at
4
+ attr_accessor :name,:opening_times,:directions,:payment_methods,:pricing,:website,:phone_number
5
+ attr_accessor :lat,:lng,:street,:district,:region,:city,:postal_code,:country
6
+ attr_accessor :tag_list,:created_at,:branded_tags
6
7
 
7
8
  class << self
8
9
  def suggested(opts={})
@@ -26,6 +27,19 @@ module Whatser
26
27
  end
27
28
  end
28
29
 
30
+ def branded_tags=(val)
31
+ if val.is_a?(Array)
32
+ @branded_tags = []
33
+ val.each do |tag|
34
+ if tag.is_a?(Whatser::Tag)
35
+ @branded_tags << tag
36
+ else
37
+ @branded_tags << Resource.from_hash_to_model(tag, Whatser::Tag)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
29
43
  def save
30
44
  if id.blank?
31
45
  self.class.create(to_params)
@@ -50,14 +64,6 @@ module Whatser
50
64
  Whatser::Media.list(id, opts)
51
65
  end
52
66
 
53
- def reviews(opts={})
54
- Whatser::Review.set(self.class.client).list(id, opts)
55
- end
56
-
57
- def details(opts={})
58
- Whatser::Detail.set(self.class.client).list(id, opts)
59
- end
60
-
61
67
  def activity(opts)
62
68
  Whatser::ActivityFeed.set(self.class.client).spot( self.id, opts )
63
69
  end
@@ -2,6 +2,7 @@ module Whatser
2
2
  class Tag < Whatser::Resource
3
3
  attr_accessor :id,:poi_id
4
4
  attr_accessor :name
5
+ attr_accessor :web_list_pic,:web_detail_pic,:touch_list_pic,:touch_detail_pic,:wap_list_pic,:wap_detail_pic
5
6
 
6
7
  class << self
7
8
  def list(poi_id, opts={})
@@ -2,9 +2,10 @@ module Whatser
2
2
  class User < Whatser::Resource
3
3
  attr_accessor :id,:facebook_id,:gowalla_id,:foursquare_id,:twitter_id
4
4
  attr_accessor :name,:twitter_name,:avatar_pic,:location,:bio,:email
5
- attr_accessor :last_login_at,:promoted,:premium,:collections_count
5
+ attr_accessor :last_login_at,:promoted
6
6
  attr_writer :avatar,:remote_avatar,:password,:lat,:lng
7
- attr_writer :access_tokens
7
+ attr_writer :comments_count,:poi_count,:check_ins_count,:media_count,:taggings_count,:follows_count,:followers_count,:collections_count
8
+ attr_writer :access_token
8
9
 
9
10
  class << self
10
11
  def me
@@ -53,13 +54,7 @@ module Whatser
53
54
  end
54
55
 
55
56
  def oauth_token
56
- if access_tokens.blank?
57
- nil
58
- elsif access_tokens.is_a?(Array)
59
- access_tokens.first
60
- else
61
- access_token
62
- end
57
+ access_token
63
58
  end
64
59
 
65
60
  def facebook_connected?
data/lib/whatser.rb CHANGED
@@ -12,11 +12,8 @@ require File.expand_path('../whatser/resources/resource', __FILE__)
12
12
  require File.expand_path('../whatser/resources/city', __FILE__)
13
13
  require File.expand_path('../whatser/resources/check_in', __FILE__)
14
14
  require File.expand_path('../whatser/resources/collection', __FILE__)
15
- require File.expand_path('../whatser/resources/data_source', __FILE__)
16
- require File.expand_path('../whatser/resources/detail', __FILE__)
17
15
  require File.expand_path('../whatser/resources/media', __FILE__)
18
16
  require File.expand_path('../whatser/resources/poi', __FILE__)
19
- require File.expand_path('../whatser/resources/review', __FILE__)
20
17
  require File.expand_path('../whatser/resources/subscription', __FILE__)
21
18
  require File.expand_path('../whatser/resources/tag', __FILE__)
22
19
  require File.expand_path('../whatser/resources/user', __FILE__)
data/test/test_client.rb CHANGED
@@ -67,8 +67,7 @@ class TestClient < Test::Unit::TestCase
67
67
  client = Whatser::Client.new
68
68
  assert_equal Whatser::CheckIn, client.check_ins
69
69
  assert_equal Whatser::Collection, client.collections
70
- assert_equal Whatser::DataSource, client.data_sources
71
- assert_equal Whatser::Detail, client.details
70
+ assert_equal Whatser::Comment, client.comments
72
71
  assert_equal Whatser::Media, client.media
73
72
  assert_equal Whatser::Poi, client.spots
74
73
  assert_equal Whatser::Subscription, client.subscriptions
@@ -82,8 +81,7 @@ class TestClient < Test::Unit::TestCase
82
81
 
83
82
  assert_equal client, client.check_ins.client
84
83
  assert_equal client, client.collections.client
85
- assert_equal client, client.data_sources.client
86
- assert_equal client, client.details.client
84
+ assert_equal client, client.comments.client
87
85
  assert_equal client, client.media.client
88
86
  assert_equal client, client.spots.client
89
87
  assert_equal client, client.subscriptions.client
data/test/test_comment.rb CHANGED
@@ -5,7 +5,20 @@ class TestComment < Test::Unit::TestCase
5
5
  @client = Whatser::Client.new
6
6
  @poi_id = 1
7
7
  @media_id = 1
8
- @comment = Whatser::Comment.new(:poi_id => @poi_id, :body => 'test')
8
+ @user_id = 1
9
+ @comment = Whatser::Comment.new(:poi_id => @poi_id, :body => 'test', :user_id => @user_id)
10
+ end
11
+
12
+ def test_poi
13
+ assert @comment.poi.is_a?(Whatser::Response)
14
+ @comment.poi_id = nil
15
+ assert_nil @comment.poi
16
+ end
17
+
18
+ def test_user
19
+ assert @comment.user.is_a?(Whatser::Response)
20
+ @comment.user_id = nil
21
+ assert_nil @comment.user
9
22
  end
10
23
 
11
24
  def test_poi_list
data/test/test_poi.rb CHANGED
@@ -79,13 +79,25 @@ class TestPoi < Test::Unit::TestCase
79
79
 
80
80
  def test_comments
81
81
  assert @poi.comments(:opt => 'test').is_a?(Whatser::Response)
82
- end
82
+ end
83
83
 
84
- def test_details
85
- assert @poi.details(:page => 1).is_a?(Whatser::Response)
84
+ def branded_tags
85
+ @poi.branded_tags = nil
86
+ assert_nil @poi.branded_tags
87
+
88
+ @poi.branded_tags = {}
89
+ assert_nil @poi.branded_tags
90
+
91
+ @poi.branded_tags = []
92
+ assert_equal [], @poi.branded_tags
93
+
94
+ tag = Whatser::Tag.new(:name => 'test')
95
+ tags = [tag]
96
+ @poi.branded_tags = tags
97
+ assert_equal [tag], @poi.branded_tags
98
+
99
+ tags = [{"name"=>"hash","web_detail_pic_url"=>nil,"touch_detail_pic_url"=>nil,"touch_list_pic_url"=>nil,"web_list_pic_url"=>nil,"wap_detail_pic_url"=>nil,"wap_list_pic_url"=>nil}]
100
+ @poi.branded_tags = tags
101
+ assert_equal "hash", @poi.branded_tags.first.name
86
102
  end
87
-
88
- def test_reviews
89
- assert @poi.reviews(:page => 1).is_a?(Whatser::Response)
90
- end
91
103
  end
data/whatser.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{whatser}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Travis Dunn"]
12
- s.date = %q{2011-02-03}
12
+ s.date = %q{2011-03-04}
13
13
  s.description = %q{The 'Whatser API' Gem is a simple Ruby / Rails wrapper for interacting with Whatser's location-based web services (see http://docs.sogeoapi.com for more details).}
14
14
  s.email = %q{cmd@travisdunn.com}
15
15
  s.extra_rdoc_files = [
@@ -42,13 +42,10 @@ Gem::Specification.new do |s|
42
42
  "lib/whatser/resources/city.rb",
43
43
  "lib/whatser/resources/collection.rb",
44
44
  "lib/whatser/resources/comment.rb",
45
- "lib/whatser/resources/data_source.rb",
46
- "lib/whatser/resources/detail.rb",
47
45
  "lib/whatser/resources/follow.rb",
48
46
  "lib/whatser/resources/media.rb",
49
47
  "lib/whatser/resources/poi.rb",
50
48
  "lib/whatser/resources/resource.rb",
51
- "lib/whatser/resources/review.rb",
52
49
  "lib/whatser/resources/subscription.rb",
53
50
  "lib/whatser/resources/tag.rb",
54
51
  "lib/whatser/resources/user.rb",
@@ -60,8 +57,6 @@ Gem::Specification.new do |s|
60
57
  "test/test_collection.rb",
61
58
  "test/test_comment.rb",
62
59
  "test/test_configuration.rb",
63
- "test/test_data_source.rb",
64
- "test/test_detail.rb",
65
60
  "test/test_facebook.rb",
66
61
  "test/test_follow.rb",
67
62
  "test/test_foursquare.rb",
@@ -72,7 +67,6 @@ Gem::Specification.new do |s|
72
67
  "test/test_poi.rb",
73
68
  "test/test_resource.rb",
74
69
  "test/test_response.rb",
75
- "test/test_review.rb",
76
70
  "test/test_service.rb",
77
71
  "test/test_subscription.rb",
78
72
  "test/test_tag.rb",
@@ -94,8 +88,6 @@ Gem::Specification.new do |s|
94
88
  "test/test_collection.rb",
95
89
  "test/test_comment.rb",
96
90
  "test/test_configuration.rb",
97
- "test/test_data_source.rb",
98
- "test/test_detail.rb",
99
91
  "test/test_facebook.rb",
100
92
  "test/test_follow.rb",
101
93
  "test/test_foursquare.rb",
@@ -106,7 +98,6 @@ Gem::Specification.new do |s|
106
98
  "test/test_poi.rb",
107
99
  "test/test_resource.rb",
108
100
  "test/test_response.rb",
109
- "test/test_review.rb",
110
101
  "test/test_service.rb",
111
102
  "test/test_subscription.rb",
112
103
  "test/test_tag.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whatser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Travis Dunn
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-03 00:00:00 +01:00
18
+ date: 2011-03-04 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -141,13 +141,10 @@ files:
141
141
  - lib/whatser/resources/city.rb
142
142
  - lib/whatser/resources/collection.rb
143
143
  - lib/whatser/resources/comment.rb
144
- - lib/whatser/resources/data_source.rb
145
- - lib/whatser/resources/detail.rb
146
144
  - lib/whatser/resources/follow.rb
147
145
  - lib/whatser/resources/media.rb
148
146
  - lib/whatser/resources/poi.rb
149
147
  - lib/whatser/resources/resource.rb
150
- - lib/whatser/resources/review.rb
151
148
  - lib/whatser/resources/subscription.rb
152
149
  - lib/whatser/resources/tag.rb
153
150
  - lib/whatser/resources/user.rb
@@ -159,8 +156,6 @@ files:
159
156
  - test/test_collection.rb
160
157
  - test/test_comment.rb
161
158
  - test/test_configuration.rb
162
- - test/test_data_source.rb
163
- - test/test_detail.rb
164
159
  - test/test_facebook.rb
165
160
  - test/test_follow.rb
166
161
  - test/test_foursquare.rb
@@ -171,7 +166,6 @@ files:
171
166
  - test/test_poi.rb
172
167
  - test/test_resource.rb
173
168
  - test/test_response.rb
174
- - test/test_review.rb
175
169
  - test/test_service.rb
176
170
  - test/test_subscription.rb
177
171
  - test/test_tag.rb
@@ -221,8 +215,6 @@ test_files:
221
215
  - test/test_collection.rb
222
216
  - test/test_comment.rb
223
217
  - test/test_configuration.rb
224
- - test/test_data_source.rb
225
- - test/test_detail.rb
226
218
  - test/test_facebook.rb
227
219
  - test/test_follow.rb
228
220
  - test/test_foursquare.rb
@@ -233,7 +225,6 @@ test_files:
233
225
  - test/test_poi.rb
234
226
  - test/test_resource.rb
235
227
  - test/test_response.rb
236
- - test/test_review.rb
237
228
  - test/test_service.rb
238
229
  - test/test_subscription.rb
239
230
  - test/test_tag.rb
@@ -1,24 +0,0 @@
1
- module Whatser
2
- class DataSource < Whatser::Resource
3
- attr_accessor :id
4
- attr_accessor :name,:price,:review_count,:media_count,:collection_count,:poi_count
5
- attr_accessor :users
6
-
7
- class << self
8
- def list(opts={})
9
- api_request :get, "/api/data_sources", {:query => opts}
10
- end
11
-
12
- def for_users(user_id, opts={})
13
- user_id = user_id.is_a?(Array) ? user_id.join(',') : user_id
14
- api_request :get, "/api/data_sources", {:query => {:user_id => user_id}.merge(opts || {})}
15
- end
16
- end
17
-
18
- def subscription_url(opts={})
19
- url = "#{self.class.client.api_uri}/payments/data_sources/#{id}/orders/new?oauth_token=#{self.class.client.oauth_token}"
20
- url = "#{url}&#{opts.to_params}" unless opts.blank?
21
- url
22
- end
23
- end
24
- end
@@ -1,40 +0,0 @@
1
- module Whatser
2
- class Detail < Whatser::Resource
3
- attr_accessor :id,:user_id,:poi_id
4
- attr_accessor :data,:created_at
5
-
6
- class << self
7
- def list(poi_id, opts={})
8
- api_request :get, "/api/poi/#{poi_id}/details", {:query => opts}
9
- end
10
-
11
- def find(poi_id, id, opts={})
12
- api_request :get, "/api/poi/#{poi_id}/details/#{id}", {:query => opts}
13
- end
14
-
15
- def create(poi_id, params={})
16
- api_request :post, "/api/poi/#{poi_id}/details", {:body => {'detail' => params} }
17
- end
18
-
19
- def delete(poi_id, id)
20
- api_request :delete, "/api/poi/#{poi_id}/details/#{id}"
21
- end
22
- end
23
-
24
- def save
25
- if id.blank?
26
- self.class.create(poi_id, to_params)
27
- else
28
- api_request :put, "/api/poi/#{poi_id}/details/#{id}", {:body => {'detail' => to_params} }
29
- end
30
- end
31
-
32
- def delete
33
- self.class.delete(poi_id, id)
34
- end
35
-
36
- def to_params
37
- {:data => data}
38
- end
39
- end
40
- end
@@ -1,40 +0,0 @@
1
- module Whatser
2
- class Review < Whatser::Resource
3
- attr_accessor :id,:user_id,:poi_id
4
- attr_accessor :body,:created_at
5
-
6
- class << self
7
- def list(poi_id, opts={})
8
- api_request :get, "/api/poi/#{poi_id}/reviews", {:query => opts}
9
- end
10
-
11
- def find(poi_id, id, opts={})
12
- api_request :get, "/api/poi/#{poi_id}/reviews/#{id}", {:query => opts}
13
- end
14
-
15
- def create(poi_id, params={})
16
- api_request :post, "/api/poi/#{poi_id}/reviews", {:body => {'review' => params} }
17
- end
18
-
19
- def delete(poi_id, id)
20
- api_request :delete, "/api/poi/#{poi_id}/reviews/#{id}"
21
- end
22
- end
23
-
24
- def save
25
- if id.blank?
26
- self.class.create(poi_id, to_params)
27
- else
28
- api_request :put, "/api/poi/#{poi_id}/reviews/#{id}", {:body => {'review' => to_params} }
29
- end
30
- end
31
-
32
- def delete
33
- self.class.delete(poi_id, id)
34
- end
35
-
36
- def to_params
37
- {:body => body}
38
- end
39
- end
40
- end
@@ -1,35 +0,0 @@
1
- require 'helper'
2
-
3
- class TestDataSource < Test::Unit::TestCase
4
- def setup
5
- @client = Whatser::Client.new(:oauth_token => '1234')
6
- end
7
-
8
- def test_list
9
- assert @client.data_sources.list(:page => 1).is_a?(Whatser::Response)
10
- end
11
-
12
- def test_for_users_with_id
13
- assert @client.data_sources.for_users(1, :page => 1).is_a?(Whatser::Response)
14
- end
15
-
16
- def test_for_users_with_string
17
- assert @client.data_sources.for_users('1,2,3', :page => 1).is_a?(Whatser::Response)
18
- end
19
-
20
- def test_for_users_with_array
21
- assert @client.data_sources.for_users([1,2,3], :page => 1).is_a?(Whatser::Response)
22
- end
23
-
24
- def test_subscription_url
25
- datasource = @client.data_sources.new(:id => '1')
26
- expected = "#{@client.api_uri}/payments/data_sources/1/orders/new?oauth_token=1234"
27
- assert_equal expected, datasource.subscription_url
28
- end
29
-
30
- def test_subscription_url_with_params
31
- datasource = @client.data_sources.new(:id => '1')
32
- expected = "#{@client.api_uri}/payments/data_sources/1/orders/new?oauth_token=1234&test=2&extra=1"
33
- assert_equal expected, datasource.subscription_url(:extra => 1, :test => 2)
34
- end
35
- end
data/test/test_detail.rb DELETED
@@ -1,38 +0,0 @@
1
- require 'helper'
2
-
3
- class TestDetail < Test::Unit::TestCase
4
- def setup
5
- @client = Whatser::Client.new
6
- @poi_id = 1
7
- @params = {:rating => 'four stars', :hours => '9-5'}
8
- @detail = Whatser::Detail.new(:poi_id => @poi_id, :data => @params)
9
- end
10
-
11
- def test_list
12
- assert @client.reviews.list(@poi_id, :page => 1).is_a?(Whatser::Response)
13
- end
14
-
15
- def test_create
16
- assert @client.reviews.create(@poi_id, :data => @params).is_a?(Whatser::Response)
17
- end
18
-
19
- def test_delete
20
- assert @client.reviews.delete(@poi_id, :data => @params).is_a?(Whatser::Response)
21
- end
22
-
23
- def test_save
24
- assert @detail.save.is_a?(Whatser::Response)
25
- end
26
-
27
- def test_update
28
- @detail.id = 1
29
- assert @detail.save.is_a?(Whatser::Response)
30
- end
31
-
32
- def test_to_params
33
- params = [:data]
34
- params.each do |p|
35
- assert @detail.to_params.keys.include?(p)
36
- end
37
- end
38
- end
data/test/test_review.rb DELETED
@@ -1,37 +0,0 @@
1
- require 'helper'
2
-
3
- class TestReview < Test::Unit::TestCase
4
- def setup
5
- @client = Whatser::Client.new
6
- @poi_id = 1
7
- @review = Whatser::Review.new(:poi_id => @poi_id, :body => 'four stars')
8
- end
9
-
10
- def test_list
11
- assert @client.reviews.list(@poi_id, :page => 1).is_a?(Whatser::Response)
12
- end
13
-
14
- def test_create
15
- assert @client.reviews.create(@poi_id, :body => 'four stars').is_a?(Whatser::Response)
16
- end
17
-
18
- def test_delete
19
- assert @client.reviews.delete(@poi_id, :body => 'four stars').is_a?(Whatser::Response)
20
- end
21
-
22
- def test_save
23
- assert @review.save.is_a?(Whatser::Response)
24
- end
25
-
26
- def test_update
27
- @review.id = 1
28
- assert @review.save.is_a?(Whatser::Response)
29
- end
30
-
31
- def test_to_params
32
- params = [:body]
33
- params.each do |p|
34
- assert @review.to_params.keys.include?(p)
35
- end
36
- end
37
- end