tailored-etsy 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.gitignore +8 -0
  2. data/.travis.yml +8 -0
  3. data/Gemfile +3 -0
  4. data/LICENSE +9 -0
  5. data/README.md +280 -0
  6. data/Rakefile +12 -0
  7. data/etsy.gemspec +28 -0
  8. data/lib/etsy.rb +172 -0
  9. data/lib/etsy/address.rb +47 -0
  10. data/lib/etsy/basic_client.rb +26 -0
  11. data/lib/etsy/category.rb +84 -0
  12. data/lib/etsy/country.rb +27 -0
  13. data/lib/etsy/image.rb +34 -0
  14. data/lib/etsy/listing.rb +178 -0
  15. data/lib/etsy/model.rb +123 -0
  16. data/lib/etsy/payment_template.rb +33 -0
  17. data/lib/etsy/profile.rb +49 -0
  18. data/lib/etsy/request.rb +148 -0
  19. data/lib/etsy/response.rb +112 -0
  20. data/lib/etsy/section.rb +16 -0
  21. data/lib/etsy/secure_client.rb +128 -0
  22. data/lib/etsy/shipping_template.rb +32 -0
  23. data/lib/etsy/shop.rb +83 -0
  24. data/lib/etsy/transaction.rb +18 -0
  25. data/lib/etsy/user.rb +91 -0
  26. data/lib/etsy/verification_request.rb +17 -0
  27. data/lib/etsy/version.rb +3 -0
  28. data/test/fixtures/address/getUserAddresses.json +12 -0
  29. data/test/fixtures/category/findAllSubCategoryChildren.json +78 -0
  30. data/test/fixtures/category/findAllTopCategory.json +347 -0
  31. data/test/fixtures/category/findAllTopCategory.single.json +18 -0
  32. data/test/fixtures/category/findAllTopCategoryChildren.json +308 -0
  33. data/test/fixtures/category/getCategory.multiple.json +28 -0
  34. data/test/fixtures/category/getCategory.single.json +18 -0
  35. data/test/fixtures/country/getCountry.json +1 -0
  36. data/test/fixtures/image/findAllListingImages.json +102 -0
  37. data/test/fixtures/listing/findAllListingActive.category.json +827 -0
  38. data/test/fixtures/listing/findAllShopListings.json +69 -0
  39. data/test/fixtures/listing/getListing.multiple.json +1 -0
  40. data/test/fixtures/listing/getListing.single.json +1 -0
  41. data/test/fixtures/payment_template/getPaymentTemplate.json +1 -0
  42. data/test/fixtures/profile/new.json +28 -0
  43. data/test/fixtures/section/getShopSection.json +18 -0
  44. data/test/fixtures/shipping_template/getShippingTemplate.json +1 -0
  45. data/test/fixtures/shop/findAllShop.json +1 -0
  46. data/test/fixtures/shop/findAllShop.single.json +1 -0
  47. data/test/fixtures/shop/getShop.multiple.json +1 -0
  48. data/test/fixtures/shop/getShop.single.json +33 -0
  49. data/test/fixtures/transaction/findAllShopTransactions.json +1 -0
  50. data/test/fixtures/user/getUser.multiple.json +29 -0
  51. data/test/fixtures/user/getUser.single.json +13 -0
  52. data/test/fixtures/user/getUser.single.private.json +18 -0
  53. data/test/fixtures/user/getUser.single.withProfile.json +38 -0
  54. data/test/fixtures/user/getUser.single.withShops.json +41 -0
  55. data/test/test_helper.rb +44 -0
  56. data/test/unit/etsy/address_test.rb +61 -0
  57. data/test/unit/etsy/basic_client_test.rb +28 -0
  58. data/test/unit/etsy/category_test.rb +106 -0
  59. data/test/unit/etsy/country_test.rb +64 -0
  60. data/test/unit/etsy/image_test.rb +43 -0
  61. data/test/unit/etsy/listing_test.rb +217 -0
  62. data/test/unit/etsy/model_test.rb +64 -0
  63. data/test/unit/etsy/payment_template_test.rb +68 -0
  64. data/test/unit/etsy/profile_test.rb +111 -0
  65. data/test/unit/etsy/request_test.rb +192 -0
  66. data/test/unit/etsy/response_test.rb +164 -0
  67. data/test/unit/etsy/section_test.rb +28 -0
  68. data/test/unit/etsy/secure_client_test.rb +132 -0
  69. data/test/unit/etsy/shipping_template_test.rb +24 -0
  70. data/test/unit/etsy/shop_test.rb +104 -0
  71. data/test/unit/etsy/transaction_test.rb +52 -0
  72. data/test/unit/etsy/user_test.rb +218 -0
  73. data/test/unit/etsy/verification_request_test.rb +26 -0
  74. data/test/unit/etsy_test.rb +114 -0
  75. metadata +269 -0
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../../../test_helper', __FILE__)
2
+
3
+ module Etsy
4
+ class VerificationRequestTest < Test::Unit::TestCase
5
+
6
+ context "An instance of the VerificationRequest class" do
7
+ setup { @request = VerificationRequest.new }
8
+
9
+ should "have a client" do
10
+ SecureClient.stubs(:new).returns('client')
11
+ @request.client.should == 'client'
12
+ end
13
+
14
+ should "know the url" do
15
+ client = stub()
16
+ client.stubs(:request_token).returns(stub(:params => {:login_url => 'http://www.etsy.com?foo=bar&baz=true'}, :secret => 'secret'))
17
+
18
+ @request.stubs(:client).returns(client)
19
+
20
+ @request.url.should == 'http://www.etsy.com?foo=bar&baz=true'
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,114 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ class EtsyTest < Test::Unit::TestCase
4
+
5
+ context "The Etsy module" do
6
+ setup do
7
+ Etsy.instance_variable_set(:@environment, nil)
8
+ Etsy.instance_variable_set(:@access_mode, nil)
9
+ Etsy.instance_variable_set(:@callback_url, nil)
10
+ Etsy.instance_variable_set(:@host, nil)
11
+ Etsy.instance_variable_set(:@api_key, nil)
12
+ Etsy.instance_variable_set(:@api_secret, nil)
13
+ Etsy.instance_variable_set(:@permission_scopes, nil)
14
+ end
15
+
16
+ should "be able to set and retrieve the API key" do
17
+ Etsy.api_key = 'key'
18
+ Etsy.api_key.should == 'key'
19
+ end
20
+
21
+ should "be able to find a user by username" do
22
+ user = stub()
23
+
24
+ Etsy::User.expects(:find).with('littletjane').returns(user)
25
+ Etsy.user('littletjane').should == user
26
+ end
27
+
28
+ should "use the sandbox environment by default" do
29
+ Etsy.environment.should == :sandbox
30
+ end
31
+
32
+ should "be able to set the environment to a valid value" do
33
+ Etsy.environment = :production
34
+ Etsy.environment.should == :production
35
+ end
36
+
37
+ should "raise an exception when attempting to set an invalid environment" do
38
+ lambda { Etsy.environment = :invalid }.should raise_error(ArgumentError)
39
+ end
40
+
41
+ should "be able to set and retrieve the API secret" do
42
+ Etsy.api_secret = 'secret'
43
+ Etsy.api_secret.should == 'secret'
44
+ end
45
+
46
+ should "know the host for the sandbox environment" do
47
+ Etsy.environment = :sandbox
48
+ Etsy.host.should == 'sandbox.openapi.etsy.com'
49
+ end
50
+
51
+ should "know the host for the production environment" do
52
+ Etsy.environment = :production
53
+ Etsy.host.should == 'openapi.etsy.com'
54
+ end
55
+
56
+ should "default to sandbox host" do
57
+ Etsy.host.should == 'sandbox.openapi.etsy.com'
58
+ end
59
+
60
+ should "be able to set the callback url" do
61
+ Etsy.callback_url = 'http://localhost'
62
+ Etsy.callback_url.should == 'http://localhost'
63
+ end
64
+
65
+ should "default callback to out-of-band" do
66
+ Etsy.callback_url.should == 'oob'
67
+ end
68
+
69
+ should "default permission scopes to an empty array" do
70
+ Etsy.permission_scopes.should == []
71
+ end
72
+
73
+ should "be able to set the scopes" do
74
+ Etsy.permission_scopes = %w(a_scope another_scope)
75
+ Etsy.permission_scopes.should == ['a_scope', 'another_scope']
76
+ end
77
+ end
78
+
79
+ context "The Etsy module when set up properly" do
80
+ setup do
81
+ Etsy.instance_variable_set(:@environment, :sandbox)
82
+ Etsy.instance_variable_set(:@access_mode, :read_write)
83
+ Etsy.instance_variable_set(:@api_key, 'key')
84
+ Etsy.instance_variable_set(:@api_secret, 'secret')
85
+ Etsy.instance_variable_set(:@verification_request, nil)
86
+ end
87
+
88
+ should "provide a request token" do
89
+ request = stub(:request_token => 'token')
90
+ Etsy::VerificationRequest.stubs(:new).returns(request)
91
+
92
+ Etsy.request_token.should == 'token'
93
+ end
94
+
95
+ should "be able to generate an access token" do
96
+ Etsy::SecureClient.stubs(:new).with({
97
+ :request_token => 'toke',
98
+ :request_secret => 'secret',
99
+ :verifier => 'verifier'
100
+ }).returns(stub(:client => 'token'))
101
+
102
+ Etsy.access_token('toke', 'secret', 'verifier').should == 'token'
103
+ end
104
+
105
+ should "provide a verification URL" do
106
+ request = stub(:url => 'url')
107
+ Etsy::VerificationRequest.stubs(:new).returns(request)
108
+
109
+ Etsy.verification_url.should == 'url'
110
+ end
111
+
112
+ end
113
+
114
+ end
metadata ADDED
@@ -0,0 +1,269 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tailored-etsy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Patrick Reagan
9
+ - Katrina Owen
10
+ - Wong Liang Zan
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2012-08-25 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: json
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: 1.5.0
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: 1.5.0
32
+ - !ruby/object:Gem::Dependency
33
+ name: oauth
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: 0.4.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.0
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 0.9.2
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: 0.9.2
64
+ - !ruby/object:Gem::Dependency
65
+ name: jnunemaker-matchy
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: 0.4.0
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 0.4.0
80
+ - !ruby/object:Gem::Dependency
81
+ name: shoulda
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 3.1.0
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: 3.1.0
96
+ - !ruby/object:Gem::Dependency
97
+ name: mocha
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 0.12.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: 0.12.0
112
+ description: A friendly Ruby interface to the Etsy API
113
+ email:
114
+ - reaganpr@gmail.com
115
+ - katrina.owen@gmail.com
116
+ - zan@liangzan.net
117
+ executables: []
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - .gitignore
122
+ - .travis.yml
123
+ - Gemfile
124
+ - LICENSE
125
+ - README.md
126
+ - Rakefile
127
+ - etsy.gemspec
128
+ - lib/etsy.rb
129
+ - lib/etsy/address.rb
130
+ - lib/etsy/basic_client.rb
131
+ - lib/etsy/category.rb
132
+ - lib/etsy/country.rb
133
+ - lib/etsy/image.rb
134
+ - lib/etsy/listing.rb
135
+ - lib/etsy/model.rb
136
+ - lib/etsy/payment_template.rb
137
+ - lib/etsy/profile.rb
138
+ - lib/etsy/request.rb
139
+ - lib/etsy/response.rb
140
+ - lib/etsy/section.rb
141
+ - lib/etsy/secure_client.rb
142
+ - lib/etsy/shipping_template.rb
143
+ - lib/etsy/shop.rb
144
+ - lib/etsy/transaction.rb
145
+ - lib/etsy/user.rb
146
+ - lib/etsy/verification_request.rb
147
+ - lib/etsy/version.rb
148
+ - test/fixtures/address/getUserAddresses.json
149
+ - test/fixtures/category/findAllSubCategoryChildren.json
150
+ - test/fixtures/category/findAllTopCategory.json
151
+ - test/fixtures/category/findAllTopCategory.single.json
152
+ - test/fixtures/category/findAllTopCategoryChildren.json
153
+ - test/fixtures/category/getCategory.multiple.json
154
+ - test/fixtures/category/getCategory.single.json
155
+ - test/fixtures/country/getCountry.json
156
+ - test/fixtures/image/findAllListingImages.json
157
+ - test/fixtures/listing/findAllListingActive.category.json
158
+ - test/fixtures/listing/findAllShopListings.json
159
+ - test/fixtures/listing/getListing.multiple.json
160
+ - test/fixtures/listing/getListing.single.json
161
+ - test/fixtures/payment_template/getPaymentTemplate.json
162
+ - test/fixtures/profile/new.json
163
+ - test/fixtures/section/getShopSection.json
164
+ - test/fixtures/shipping_template/getShippingTemplate.json
165
+ - test/fixtures/shop/findAllShop.json
166
+ - test/fixtures/shop/findAllShop.single.json
167
+ - test/fixtures/shop/getShop.multiple.json
168
+ - test/fixtures/shop/getShop.single.json
169
+ - test/fixtures/transaction/findAllShopTransactions.json
170
+ - test/fixtures/user/getUser.multiple.json
171
+ - test/fixtures/user/getUser.single.json
172
+ - test/fixtures/user/getUser.single.private.json
173
+ - test/fixtures/user/getUser.single.withProfile.json
174
+ - test/fixtures/user/getUser.single.withShops.json
175
+ - test/test_helper.rb
176
+ - test/unit/etsy/address_test.rb
177
+ - test/unit/etsy/basic_client_test.rb
178
+ - test/unit/etsy/category_test.rb
179
+ - test/unit/etsy/country_test.rb
180
+ - test/unit/etsy/image_test.rb
181
+ - test/unit/etsy/listing_test.rb
182
+ - test/unit/etsy/model_test.rb
183
+ - test/unit/etsy/payment_template_test.rb
184
+ - test/unit/etsy/profile_test.rb
185
+ - test/unit/etsy/request_test.rb
186
+ - test/unit/etsy/response_test.rb
187
+ - test/unit/etsy/section_test.rb
188
+ - test/unit/etsy/secure_client_test.rb
189
+ - test/unit/etsy/shipping_template_test.rb
190
+ - test/unit/etsy/shop_test.rb
191
+ - test/unit/etsy/transaction_test.rb
192
+ - test/unit/etsy/user_test.rb
193
+ - test/unit/etsy/verification_request_test.rb
194
+ - test/unit/etsy_test.rb
195
+ homepage: http://github.com/tailored/etsy
196
+ licenses: []
197
+ post_install_message:
198
+ rdoc_options: []
199
+ require_paths:
200
+ - lib
201
+ required_ruby_version: !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ! '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ segments:
208
+ - 0
209
+ hash: 4587863110027678949
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ none: false
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ requirements: []
217
+ rubyforge_project:
218
+ rubygems_version: 1.8.24
219
+ signing_key:
220
+ specification_version: 3
221
+ summary: Provides a friendly ruby-like wrapper for the Etsy API
222
+ test_files:
223
+ - test/fixtures/address/getUserAddresses.json
224
+ - test/fixtures/category/findAllSubCategoryChildren.json
225
+ - test/fixtures/category/findAllTopCategory.json
226
+ - test/fixtures/category/findAllTopCategory.single.json
227
+ - test/fixtures/category/findAllTopCategoryChildren.json
228
+ - test/fixtures/category/getCategory.multiple.json
229
+ - test/fixtures/category/getCategory.single.json
230
+ - test/fixtures/country/getCountry.json
231
+ - test/fixtures/image/findAllListingImages.json
232
+ - test/fixtures/listing/findAllListingActive.category.json
233
+ - test/fixtures/listing/findAllShopListings.json
234
+ - test/fixtures/listing/getListing.multiple.json
235
+ - test/fixtures/listing/getListing.single.json
236
+ - test/fixtures/payment_template/getPaymentTemplate.json
237
+ - test/fixtures/profile/new.json
238
+ - test/fixtures/section/getShopSection.json
239
+ - test/fixtures/shipping_template/getShippingTemplate.json
240
+ - test/fixtures/shop/findAllShop.json
241
+ - test/fixtures/shop/findAllShop.single.json
242
+ - test/fixtures/shop/getShop.multiple.json
243
+ - test/fixtures/shop/getShop.single.json
244
+ - test/fixtures/transaction/findAllShopTransactions.json
245
+ - test/fixtures/user/getUser.multiple.json
246
+ - test/fixtures/user/getUser.single.json
247
+ - test/fixtures/user/getUser.single.private.json
248
+ - test/fixtures/user/getUser.single.withProfile.json
249
+ - test/fixtures/user/getUser.single.withShops.json
250
+ - test/test_helper.rb
251
+ - test/unit/etsy/address_test.rb
252
+ - test/unit/etsy/basic_client_test.rb
253
+ - test/unit/etsy/category_test.rb
254
+ - test/unit/etsy/country_test.rb
255
+ - test/unit/etsy/image_test.rb
256
+ - test/unit/etsy/listing_test.rb
257
+ - test/unit/etsy/model_test.rb
258
+ - test/unit/etsy/payment_template_test.rb
259
+ - test/unit/etsy/profile_test.rb
260
+ - test/unit/etsy/request_test.rb
261
+ - test/unit/etsy/response_test.rb
262
+ - test/unit/etsy/section_test.rb
263
+ - test/unit/etsy/secure_client_test.rb
264
+ - test/unit/etsy/shipping_template_test.rb
265
+ - test/unit/etsy/shop_test.rb
266
+ - test/unit/etsy/transaction_test.rb
267
+ - test/unit/etsy/user_test.rb
268
+ - test/unit/etsy/verification_request_test.rb
269
+ - test/unit/etsy_test.rb