etsy 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTBjNjZiZWJmMWIwZTA2YmMwZjRmZjhiNjYxMmMzZDI0ODBkYzgzNQ==
5
+ data.tar.gz: !binary |-
6
+ ZjJkMTg0Y2ZhOGM5ODZjMmQ3N2M2MDM1ZTVjOTA0NmI4ZWU0MmU3NQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YjZhNjQwODA1OWI1NjIwNjgzMjViNzMyYzFlMDNmYjE4MjZkYWVlMWUyZDUx
10
+ NGEwNTIyMGM0ODc0MWRjZTBkZDY5NmI0ZTE2NDE0NjYwOWYyMTZjNThhMDFm
11
+ M2Y2ZDA4NDM4ZmMxYTA5NTAxYjI0MjQ5ZDQ0MmIxMjhkNTg5ZWQ=
12
+ data.tar.gz: !binary |-
13
+ ZTk3NmZmMTkzOTA5NTQzOWViODBjMjc1ZjljYjM2MDA4YjI3MjhhYzg5ZWRj
14
+ YmI0NGVmNWUzZWI5ZWRkYmY0OTk5ZjkzZWYzZmFlZmQ0NzI0NTNjZGU1OWM0
15
+ ZjRjOWQ4ZjM0OTBlOWU2ZDgwMTk4MDU0ODAwZDM0Njk1MDM0MmQ=
data/Gemfile CHANGED
@@ -1,10 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- group :test do
6
- gem 'jnunemaker-matchy', '0.4.0', :require => 'matchy'
7
- gem 'shoulda', '2.11.1'
8
- gem 'mocha', '0.9.8'
9
- end
10
-
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2009 - 2012 Patrick Reagan (reaganpr@gmail.com), Katrina Owen (katrina.owen@gmail.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Etsy
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/kytrinyx/etsy.png)](http://travis-ci.org/kytrinyx/etsy)
4
+ [![Dependency Status](https://gemnasium.com/kytrinyx/etsy.png)](https://gemnasium.com/kytrinyx/etsy)
4
5
 
5
6
  ## Description
6
7
 
@@ -14,9 +15,9 @@ Installing the latest stable version is simple:
14
15
 
15
16
  If you want to be on the bleeding edge, install from GitHub:
16
17
 
17
- $ git clone git://github.com/reagent/etsy.git
18
+ $ git clone git://github.com/kytrinyx/etsy.git
18
19
  $ cd etsy
19
- $ rake gem && gem install pkg/etsy-<version>.gem
20
+ $ rake install
20
21
 
21
22
  ### Dependencies
22
23
 
@@ -221,6 +222,64 @@ If you want a more fine-grained response, you can specify the associations as an
221
222
  >> association = {:resource => 'Images', :fields => ['red','green','blue'], :limit => 1, :offset => 0}
222
223
  >> Listing.find(1, {:includes => [association]})
223
224
 
225
+ ## Public mode vs authenticated calls
226
+
227
+ This additional example should make clear the difference between issuing public versus authenticated requests:
228
+
229
+ ### Public workflow
230
+
231
+ >> Etsy.api_key = 'key'
232
+ >> user = Etsy.user('user_id_or_name')
233
+ >> Etsy::Listing.find_all_by_shop_id(user.shop.id, :limit => 5)
234
+
235
+ ### Authenticated workflow
236
+
237
+ >> Etsy.api_key = 'key'
238
+ >> Etsy.api_secret = 'secret'
239
+ >> user = Etsy.myself(token, secret)
240
+ >> access = { :access_token => user.token, :access_secret => user.secret }
241
+ >> Etsy::Listing.find_all_by_shop_id(user.shop.id, access.merge(:limit => 5))
242
+
243
+ ## Error handling
244
+
245
+ Next versions of this gem will raise errors when requests are unsuccessful. The current version does not.
246
+ Use either of following workarounds:
247
+
248
+ ### Low-level API
249
+
250
+ Instead of doing this:
251
+
252
+ >> Etsy::Request.get('/users/__SELF__', access).result
253
+
254
+ Write this:
255
+
256
+ >> Etsy::Request.get('/users/__SELF__', access).to_hash["results"]
257
+
258
+ ### Monkey patch
259
+
260
+ This is Ruby, reopen the <code>Response</code> class anywhere in your codebase and redefine <code>result</code>:
261
+
262
+ class Etsy::Response
263
+ def result
264
+ if success?
265
+ results = to_hash['results'] || []
266
+ count == 1 ? results.first : results
267
+ else
268
+ validate!
269
+ end
270
+ end
271
+ end
272
+
273
+ ### Usage
274
+
275
+ With the above in place, you can now rescue errors and act upon them:
276
+
277
+ begin
278
+ Etsy.myself(access.token, access.secret)
279
+ rescue Etsy::OAuthTokenRevoked, Etsy::InvalidUserID, Etsy::MissingShopID, Etsy::EtsyJSONInvalid, Etsy::TemporaryIssue => e
280
+ puts e.message
281
+ end
282
+
224
283
  ## Contributing
225
284
 
226
285
  I have a "commit bit" policy for contributions to this repository. Once I accept
@@ -239,7 +298,7 @@ I ask that you not submit patches that include changes to the version or gemspec
239
298
  git fork
240
299
  bundle
241
300
  rake
242
-
301
+
243
302
  # Normal flow
244
303
  git checkout -b your-feature-or-bug
245
304
  # Write your tests
@@ -262,6 +321,7 @@ These people have helped make the Etsy gem what it is today:
262
321
  * [Trae Robrock](https://github.com/trobrock)
263
322
  * [Jimmy Tang](https://github.com/jimmytang)
264
323
  * [Julio Santos](https://github.com/julio)
324
+ * [Roger Smith](https://github.com/rogsmith)
265
325
 
266
326
  ### Github Flow
267
327
 
@@ -276,25 +336,4 @@ For those of you with commit access, please check out Scott Chacon's blog post a
276
336
 
277
337
  ## License
278
338
 
279
- Copyright (c) 2009 - 2012 Patrick Reagan (reaganpr@gmail.com)
280
-
281
- Permission is hereby granted, free of charge, to any person
282
- obtaining a copy of this software and associated documentation
283
- files (the "Software"), to deal in the Software without
284
- restriction, including without limitation the rights to use,
285
- copy, modify, merge, publish, distribute, sublicense, and/or sell
286
- copies of the Software, and to permit persons to whom the
287
- Software is furnished to do so, subject to the following
288
- conditions:
289
-
290
- The above copyright notice and this permission notice shall be
291
- included in all copies or substantial portions of the Software.
292
-
293
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
294
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
295
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
296
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
297
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
298
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
299
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
300
- OTHER DEALINGS IN THE SOFTWARE.
339
+ The Etsy rubygem is released under the MIT license.
data/etsy.gemspec CHANGED
@@ -1,10 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/etsy/version', __FILE__)
2
3
 
3
4
  Gem::Specification.new do |gem|
4
- gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
5
- gem.rubygems_version = "1.8.10"
6
-
7
- gem.authors = ["Katrina Owen"]
8
5
  gem.authors = ["Patrick Reagan", "Katrina Owen"]
9
6
  gem.email = ["reaganpr@gmail.com", "katrina.owen@gmail.com"]
10
7
  gem.description = %q{A friendly Ruby interface to the Etsy API}
@@ -14,23 +11,23 @@ Gem::Specification.new do |gem|
14
11
  gem.files = `git ls-files`.split($\)
15
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
13
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
- gem.name = "etsy"
14
+ gem.name = "etsy"
18
15
  gem.require_paths = ["lib"]
19
- gem.version = "0.2.1"
16
+ gem.version = Etsy::VERSION
20
17
 
21
- if gem.respond_to? :specification_version then
22
- gem.specification_version = 3
18
+ gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
19
+ gem.rubygems_version = "1.8.10"
23
20
 
24
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- gem.add_runtime_dependency("json", [">= 1.5.0"])
26
- gem.add_runtime_dependency("oauth", ["~> 0.4.0"])
27
- else
28
- gem.add_dependency("json", [">= 1.5.0"])
29
- gem.add_dependency("oauth", ["~> 0.4.0"])
30
- end
31
- else
32
- gem.add_dependency("json", [">= 1.5.0"])
33
- gem.add_dependency("oauth", ["~> 0.4.0"])
34
- end
21
+ gem.add_dependency "json", ">= 1.5.0"
22
+ gem.add_dependency "oauth", "~> 0.4.0"
35
23
 
24
+ gem.add_development_dependency "rake", "~> 10.0.4"
25
+ gem.add_development_dependency "jnunemaker-matchy", "~> 0.4.0"
26
+ gem.add_development_dependency 'shoulda', "~> 3.4.0"
27
+ gem.add_development_dependency 'mocha', "~> 0.13.3"
28
+ # shoulda-context blows up on ActiveSupport not being defined
29
+ # on shoulda/context.rb:7
30
+ # But then when you load active_support, shoulda-context decides
31
+ # to load MiniTest
32
+ gem.add_development_dependency 'minitest'
36
33
  end
data/lib/etsy.rb CHANGED
@@ -25,6 +25,7 @@ require 'etsy/payment_template'
25
25
  require 'etsy/country'
26
26
  require 'etsy/shipping_template'
27
27
  require 'etsy/section'
28
+ require 'etsy/favorite_listing'
28
29
 
29
30
  # = Etsy: A friendly Ruby interface to the Etsy API
30
31
  #
@@ -8,8 +8,8 @@ module Etsy
8
8
 
9
9
  # Create a new client that will connect to the specified host
10
10
  #
11
- def initialize(host)
12
- @host = host
11
+ def initialize
12
+ @host = Etsy.host
13
13
  end
14
14
 
15
15
  def client # :nodoc:
@@ -0,0 +1,26 @@
1
+ module Etsy
2
+ class FavoriteListing
3
+ include Model
4
+
5
+ attributes :user_id, :listing_state, :listing_id, :create_date
6
+
7
+ #Create a new favorite listing
8
+ #
9
+ def self.create(user, listing, options = {})
10
+ options.merge!(:require_secure => true)
11
+ post("/users/#{user.id}/favorites/listings/#{listing.id}", options)
12
+ end
13
+
14
+ #Find all listings favorited by a user
15
+ #
16
+ def self.find_all_user_favorite_listings(user_id, options = {})
17
+ get_all("/users/#{user_id}/favorites/listings", options)
18
+ end
19
+
20
+ #Find a set of favorelistings associated with a listing_id
21
+ #
22
+ def self.find_all_listings_favored_by(listing_id, options = {})
23
+ get_all("/listings/#{listing_id}/favored-by", options)
24
+ end
25
+ end
26
+ end
data/lib/etsy/listing.rb CHANGED
@@ -43,7 +43,8 @@ module Etsy
43
43
  attribute :ending, :from => :ending_tsz
44
44
 
45
45
  attributes :title, :description, :state, :url, :price, :quantity,
46
- :tags, :materials, :hue, :saturation, :brightness, :is_black_and_white
46
+ :tags, :materials, :hue, :saturation, :brightness, :is_black_and_white,
47
+ :featured_rank, :occasion, :num_favorers, :user_id
47
48
 
48
49
  association :image, :from => 'Images'
49
50
 
@@ -154,6 +155,15 @@ module Etsy
154
155
  Time.at(ending)
155
156
  end
156
157
 
158
+ #Return a list of users who have favorited this listing
159
+ #
160
+ def admirers(options = {})
161
+ options = options.merge(:access_token => token, :access_secret => secret) if (token && secret)
162
+ favorite_listings = FavoriteListing.find_all_listings_favored_by(id, options)
163
+ user_ids = favorite_listings.map {|f| f.user_id }.uniq
164
+ (user_ids.size > 0) ? Array(Etsy::User.find(user_ids, options)) : []
165
+ end
166
+
157
167
  private
158
168
 
159
169
  def self.valid?(state)
@@ -174,5 +184,25 @@ module Etsy
174
184
  (listing_ids.size > 0) ? Array(find(listing_ids, options)) : []
175
185
  end
176
186
 
187
+ #Find all listings favored by a user
188
+ #
189
+ def self.find_all_user_favorite_listings(user_id, options = {})
190
+ favorite_listings = FavoriteListing.find_all_user_favorite_listings(user_id, options)
191
+ listing_ids = favorite_listings.map {|f| f.listing_id }.uniq
192
+ (listing_ids.size > 0) ? Array(find(listing_ids, options)) : []
193
+ end
194
+
195
+ #Find all listings that have been bought by a user
196
+ #
197
+ def self.bought_listings(user_id, options = {})
198
+ includes = options.delete(:includes)
199
+
200
+ transactions = Transaction.find_all_by_buyer_id(user_id, options)
201
+ listing_ids = transactions.map {|t| t.listing_id }.uniq
202
+
203
+ options = options.merge(:includes => includes) if includes
204
+ (listing_ids.size > 0) ? Array(find(listing_ids, options)) : []
205
+ end
206
+
177
207
  end
178
208
  end
data/lib/etsy/request.rb CHANGED
@@ -128,7 +128,7 @@ module Etsy
128
128
  end
129
129
 
130
130
  def basic_client
131
- BasicClient.new(Etsy.host)
131
+ BasicClient.new
132
132
  end
133
133
 
134
134
  def secure?
data/lib/etsy/response.rb CHANGED
@@ -73,7 +73,7 @@ module Etsy
73
73
  raise MissingShopID if missing_shop_id?
74
74
  raise InvalidUserID if invalid_user_id?
75
75
  raise TemporaryIssue if temporary_etsy_issue? || resource_unavailable? || exceeded_rate_limit?
76
- raise EtsyJSONInvalid.new(data) unless valid_json?
76
+ raise EtsyJSONInvalid.new("CODE: #{code}, BODY: #{data}") unless valid_json?
77
77
  true
78
78
  end
79
79
 
@@ -10,6 +10,12 @@ module Etsy
10
10
  get_all("/shops/#{shop_id}/transactions", options)
11
11
  end
12
12
 
13
+ #Find all Transactions by the buyer_id
14
+ #
15
+ def self.find_all_by_buyer_id(user_id, options = {})
16
+ get_all("/users/#{user_id}/transactions", options)
17
+ end
18
+
13
19
  def buyer
14
20
  @buyer ||= User.find(buyer_id)
15
21
  end
data/lib/etsy/user.rb CHANGED
@@ -87,5 +87,23 @@ module Etsy
87
87
  Time.at(created)
88
88
  end
89
89
 
90
+ # Retrieve list of favorited items for this user
91
+ #
92
+ def favorites
93
+ unless @favorites
94
+ @favorites = Listing.find_all_user_favorite_listings(id, {:access_token => token, :access_secret => secret})
95
+ end
96
+ @favorites
97
+ end
98
+
99
+ #Return a set of listings that have been bought
100
+ #
101
+ def bought_listings
102
+ unless @bought_listings
103
+ @bought_listings = Listing.bought_listings(id, {:access_token => token, :access_secret => secret})
104
+ end
105
+ @bought_listings
106
+ end
107
+
90
108
  end
91
109
  end
@@ -0,0 +1,3 @@
1
+ module Etsy
2
+ VERSION = "0.2.2"
3
+ end
@@ -0,0 +1 @@
1
+ {"count":2,"results":[{"listing_id":27230877,"user_id":1,"listing_state": "active", "create_date":1288738828},{"listing_id":69065674,"user_id":1,"listing_state": "active", "create_date":1288738828}],"type":"FavoriteListing"}
data/test/test_helper.rb CHANGED
@@ -2,10 +2,12 @@
2
2
  $:.reject! { |e| e.include? 'TextMate' }
3
3
 
4
4
  require 'rubygems'
5
+ require 'active_support' # workaround load issue with shoulda in rubinius
6
+ require 'minitest/autorun' # workaround load issue with shoulda in rubinius
5
7
  require 'test/unit'
6
8
  require 'shoulda'
7
9
  require 'matchy'
8
- require 'mocha'
10
+ require 'mocha/setup'
9
11
  require 'cgi'
10
12
 
11
13
  require File.expand_path('../../lib/etsy', __FILE__)
@@ -6,7 +6,8 @@ module Etsy
6
6
  context "An instance of the BasicClient class" do
7
7
 
8
8
  should "be able to construct a client" do
9
- client = BasicClient.new('example.com')
9
+ Etsy.stubs(:host).returns 'example.com'
10
+ client = BasicClient.new
10
11
  Net::HTTP.stubs(:new).with('example.com').returns('client')
11
12
 
12
13
  client.client.should == 'client'
@@ -16,7 +17,7 @@ module Etsy
16
17
  http_client = stub()
17
18
  http_client.stubs(:get).with('endpoint').returns('response')
18
19
 
19
- client = BasicClient.new('')
20
+ client = BasicClient.new
20
21
  client.stubs(:client).returns(http_client)
21
22
 
22
23
  client.get('endpoint').should == 'response'
@@ -0,0 +1,44 @@
1
+ require File.expand_path('../../../test_helper', __FILE__)
2
+
3
+ module Etsy
4
+ class FavoriteListingTest < Test::Unit::TestCase
5
+
6
+ context "The FavoriteListing class" do
7
+
8
+ should "be able to find favorite listings for a user" do
9
+ favorite_listings = mock_request('/users/1/favorites/listings', {'key' => 'value'}, 'FavoriteListing', 'findAllFavoriteListings.json')
10
+ FavoriteListing.find_all_user_favorite_listings(1, {'key' => 'value'}).should == favorite_listings
11
+ end
12
+
13
+ should "be able to find favorite listings associated to a listing" do
14
+ favorite_listings = mock_request('/listings/1/favored-by', {'key' => 'value'}, 'FavoriteListing', 'findAllFavoriteListings.json')
15
+ FavoriteListing.find_all_listings_favored_by(1, {'key' => 'value'}).should == favorite_listings
16
+ end
17
+
18
+ end
19
+
20
+ context "An instance of the FavoriteListing class" do
21
+
22
+ context "with response data" do
23
+ setup do
24
+ data = read_fixture('favorite_listing/findAllFavoriteListings.json')
25
+ @favorite_listing = FavoriteListing.new(data.first)
26
+ end
27
+
28
+ should "have a value for :listing_id" do
29
+ @favorite_listing.listing_id.should == 27230877
30
+ end
31
+
32
+ should "have a value for :user_id" do
33
+ @favorite_listing.user_id.should == 1
34
+ end
35
+
36
+ should "have a value for :listing_state" do
37
+ @favorite_listing.listing_state.should == "active"
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+ end
@@ -213,5 +213,21 @@ module Etsy
213
213
  end
214
214
 
215
215
  end
216
+
217
+ context "with favorite listings data" do
218
+ setup do
219
+ data = read_fixture('listing/findAllShopListings.json')
220
+ @listing = Listing.new(data.first)
221
+ listing_1 = stub(:listing_id => @listing.id, :user_id => 1)
222
+ listing_2 = stub(:listing_id => @listing.id, :user_id => 2)
223
+ @favorite_listings = [listing_1, listing_2]
224
+ end
225
+
226
+ should "have all listings" do
227
+ FavoriteListing.stubs(:find_all_listings_favored_by).with(@listing.id, {:access_token => nil, :access_secret => nil}).returns(@favorite_listings)
228
+ User.stubs(:find).with([1, 2], {:access_token => nil, :access_secret => nil}).returns(['users'])
229
+ @listing.admirers({:access_token => nil, :access_secret => nil}).should == ['users']
230
+ end
231
+ end
216
232
  end
217
233
  end
@@ -132,9 +132,8 @@ module Etsy
132
132
 
133
133
  should "know the client for read-only mode" do
134
134
  Etsy.stubs(:access_mode).returns(:read_only)
135
- Etsy.stubs(:host).returns('example.com')
136
135
 
137
- BasicClient.stubs(:new).with('example.com').returns('client')
136
+ BasicClient.stubs(:new).returns 'client'
138
137
 
139
138
  r = Request.new('')
140
139
 
@@ -143,9 +142,8 @@ module Etsy
143
142
 
144
143
  should "know the client for authenticated mode when there is no access token information" do
145
144
  Etsy.stubs(:access_mode).returns(:authenticated)
146
- Etsy.stubs(:host).returns('example.com')
147
145
 
148
- BasicClient.stubs(:new).with('example.com').returns('client')
146
+ BasicClient.stubs(:new).returns 'client'
149
147
 
150
148
  r = Request.new('')
151
149
 
@@ -71,10 +71,11 @@ module Etsy
71
71
 
72
72
  should "raise an invalid JSON exception if the response is not json" do
73
73
  raw_response = mock
74
- raw_response.stubs(:body => "I am not JSON")
74
+ raw_response.stubs(:body => "I am not JSON", :code => 500)
75
75
  r = Response.new(raw_response)
76
76
 
77
77
  lambda { r.to_hash }.should raise_error(Etsy::EtsyJSONInvalid)
78
+ lambda { r.to_hash }.should raise_error("CODE: 500, BODY: I am not JSON")
78
79
  end
79
80
 
80
81
  should "raise OAuthTokenRevoked" do
@@ -10,6 +10,11 @@ module Etsy
10
10
  Transaction.find_all_by_shop_id(1, {'key' => 'value'}).should == transactions
11
11
  end
12
12
 
13
+ should "be able to find transactions for a buyer" do
14
+ transactions = mock_request('/users/1/transactions', {'key' => 'value'}, 'Transaction', 'findAllShopTransactions.json')
15
+ Transaction.find_all_by_buyer_id(1, {'key' => 'value'}).should == transactions
16
+ end
17
+
13
18
  end
14
19
 
15
20
  context "An instance of the Transaction class" do
@@ -203,6 +203,38 @@ module Etsy
203
203
 
204
204
  user.created_at.should == Time.at(1)
205
205
  end
206
+
207
+ context "with favorite listings data" do
208
+ setup do
209
+ data = read_fixture('user/getUser.single.withProfile.json')
210
+ @user = User.new(data.first)
211
+ listing_1 = stub(:listing_id => 1, :user_id => @user.id)
212
+ listing_2 = stub(:listing_id => 2, :user_id => @user.id)
213
+ @favorite_listings = [listing_1, listing_2]
214
+ end
215
+
216
+ should "have all listings" do
217
+ FavoriteListing.stubs(:find_all_user_favorite_listings).with(@user.id, {:access_token => nil, :access_secret => nil}).returns(@favorite_listings)
218
+ Listing.stubs(:find).with([1, 2], {:access_token => nil, :access_secret => nil}).returns(['listings'])
219
+ @user.favorites.should == ['listings']
220
+ end
221
+ end
222
+
223
+ context "with bought listings data" do
224
+ setup do
225
+ data = read_fixture('user/getUser.single.withProfile.json')
226
+ @user = User.new(data.first)
227
+ listing_1 = stub(:listing_id => 1, :user_id => @user.id)
228
+ listing_2 = stub(:listing_id => 2, :user_id => @user.id)
229
+ @bought_listings = [listing_1, listing_2]
230
+ end
231
+
232
+ should "have all listings" do
233
+ Transaction.stubs(:find_all_by_buyer_id).with(@user.id, {:access_token => nil, :access_secret => nil}).returns(@bought_listings)
234
+ Listing.stubs(:find).with([1, 2], {:access_token => nil, :access_secret => nil}).returns(['listings'])
235
+ @user.bought_listings.should == ['listings']
236
+ end
237
+ end
206
238
  end
207
239
 
208
240
  should "know the addresses for a user" do
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.2.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Patrick Reagan
@@ -10,30 +9,106 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-07-04 00:00:00.000000000Z
12
+ date: 2013-06-04 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: json
17
- requirement: &70157167530640 !ruby/object:Gem::Requirement
18
- none: false
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  requirements:
20
18
  - - ! '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: 1.5.0
23
21
  type: :runtime
24
22
  prerelease: false
25
- version_requirements: *70157167530640
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 1.5.0
26
28
  - !ruby/object:Gem::Dependency
27
29
  name: oauth
28
- requirement: &70157167530160 !ruby/object:Gem::Requirement
29
- none: false
30
+ requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - ~>
32
33
  - !ruby/object:Gem::Version
33
34
  version: 0.4.0
34
35
  type: :runtime
35
36
  prerelease: false
36
- version_requirements: *70157167530160
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 0.4.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: 10.0.4
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 10.0.4
56
+ - !ruby/object:Gem::Dependency
57
+ name: jnunemaker-matchy
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 0.4.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.4.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: shoulda
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 3.4.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: 3.4.0
84
+ - !ruby/object:Gem::Dependency
85
+ name: mocha
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 0.13.3
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: 0.13.3
98
+ - !ruby/object:Gem::Dependency
99
+ name: minitest
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
37
112
  description: A friendly Ruby interface to the Etsy API
38
113
  email:
39
114
  - reaganpr@gmail.com
@@ -45,6 +120,7 @@ files:
45
120
  - .gitignore
46
121
  - .travis.yml
47
122
  - Gemfile
123
+ - LICENSE
48
124
  - README.md
49
125
  - Rakefile
50
126
  - etsy.gemspec
@@ -53,6 +129,7 @@ files:
53
129
  - lib/etsy/basic_client.rb
54
130
  - lib/etsy/category.rb
55
131
  - lib/etsy/country.rb
132
+ - lib/etsy/favorite_listing.rb
56
133
  - lib/etsy/image.rb
57
134
  - lib/etsy/listing.rb
58
135
  - lib/etsy/model.rb
@@ -67,6 +144,7 @@ files:
67
144
  - lib/etsy/transaction.rb
68
145
  - lib/etsy/user.rb
69
146
  - lib/etsy/verification_request.rb
147
+ - lib/etsy/version.rb
70
148
  - test/fixtures/address/getUserAddresses.json
71
149
  - test/fixtures/category/findAllSubCategoryChildren.json
72
150
  - test/fixtures/category/findAllTopCategory.json
@@ -75,6 +153,7 @@ files:
75
153
  - test/fixtures/category/getCategory.multiple.json
76
154
  - test/fixtures/category/getCategory.single.json
77
155
  - test/fixtures/country/getCountry.json
156
+ - test/fixtures/favorite_listing/findAllFavoriteListings.json
78
157
  - test/fixtures/image/findAllListingImages.json
79
158
  - test/fixtures/listing/findAllListingActive.category.json
80
159
  - test/fixtures/listing/findAllShopListings.json
@@ -99,6 +178,7 @@ files:
99
178
  - test/unit/etsy/basic_client_test.rb
100
179
  - test/unit/etsy/category_test.rb
101
180
  - test/unit/etsy/country_test.rb
181
+ - test/unit/etsy/favorite_listing_test.rb
102
182
  - test/unit/etsy/image_test.rb
103
183
  - test/unit/etsy/listing_test.rb
104
184
  - test/unit/etsy/model_test.rb
@@ -116,27 +196,26 @@ files:
116
196
  - test/unit/etsy_test.rb
117
197
  homepage: http://github.com/kytrinyx/etsy
118
198
  licenses: []
199
+ metadata: {}
119
200
  post_install_message:
120
201
  rdoc_options: []
121
202
  require_paths:
122
203
  - lib
123
204
  required_ruby_version: !ruby/object:Gem::Requirement
124
- none: false
125
205
  requirements:
126
206
  - - ! '>='
127
207
  - !ruby/object:Gem::Version
128
208
  version: '0'
129
209
  required_rubygems_version: !ruby/object:Gem::Requirement
130
- none: false
131
210
  requirements:
132
211
  - - ! '>='
133
212
  - !ruby/object:Gem::Version
134
213
  version: '0'
135
214
  requirements: []
136
215
  rubyforge_project:
137
- rubygems_version: 1.8.10
216
+ rubygems_version: 2.0.3
138
217
  signing_key:
139
- specification_version: 3
218
+ specification_version: 4
140
219
  summary: Provides a friendly ruby-like wrapper for the Etsy API
141
220
  test_files:
142
221
  - test/fixtures/address/getUserAddresses.json
@@ -147,6 +226,7 @@ test_files:
147
226
  - test/fixtures/category/getCategory.multiple.json
148
227
  - test/fixtures/category/getCategory.single.json
149
228
  - test/fixtures/country/getCountry.json
229
+ - test/fixtures/favorite_listing/findAllFavoriteListings.json
150
230
  - test/fixtures/image/findAllListingImages.json
151
231
  - test/fixtures/listing/findAllListingActive.category.json
152
232
  - test/fixtures/listing/findAllShopListings.json
@@ -171,6 +251,7 @@ test_files:
171
251
  - test/unit/etsy/basic_client_test.rb
172
252
  - test/unit/etsy/category_test.rb
173
253
  - test/unit/etsy/country_test.rb
254
+ - test/unit/etsy/favorite_listing_test.rb
174
255
  - test/unit/etsy/image_test.rb
175
256
  - test/unit/etsy/listing_test.rb
176
257
  - test/unit/etsy/model_test.rb
@@ -186,3 +267,4 @@ test_files:
186
267
  - test/unit/etsy/user_test.rb
187
268
  - test/unit/etsy/verification_request_test.rb
188
269
  - test/unit/etsy_test.rb
270
+ has_rdoc: