etsy 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.travis.yml +8 -0
- data/Gemfile +10 -0
- data/README.md +300 -0
- data/Rakefile +2 -30
- data/etsy.gemspec +36 -0
- data/lib/etsy.rb +46 -17
- data/lib/etsy/address.rb +47 -0
- data/lib/etsy/basic_client.rb +1 -1
- data/lib/etsy/category.rb +84 -0
- data/lib/etsy/country.rb +27 -0
- data/lib/etsy/image.rb +7 -3
- data/lib/etsy/listing.rb +107 -8
- data/lib/etsy/model.rb +99 -3
- data/lib/etsy/payment_template.rb +33 -0
- data/lib/etsy/profile.rb +49 -0
- data/lib/etsy/request.rb +85 -17
- data/lib/etsy/response.rb +80 -4
- data/lib/etsy/section.rb +16 -0
- data/lib/etsy/secure_client.rb +49 -4
- data/lib/etsy/shipping_template.rb +32 -0
- data/lib/etsy/shop.rb +21 -12
- data/lib/etsy/transaction.rb +18 -0
- data/lib/etsy/user.rb +45 -13
- data/lib/etsy/verification_request.rb +2 -2
- data/test/fixtures/address/getUserAddresses.json +12 -0
- data/test/fixtures/category/findAllSubCategoryChildren.json +78 -0
- data/test/fixtures/category/findAllTopCategory.json +347 -0
- data/test/fixtures/category/findAllTopCategory.single.json +18 -0
- data/test/fixtures/category/findAllTopCategoryChildren.json +308 -0
- data/test/fixtures/category/getCategory.multiple.json +28 -0
- data/test/fixtures/category/getCategory.single.json +18 -0
- data/test/fixtures/country/getCountry.json +1 -0
- data/test/fixtures/listing/findAllListingActive.category.json +827 -0
- data/test/fixtures/listing/{findAllShopListingsActive.json → findAllShopListings.json} +0 -0
- data/test/fixtures/listing/getListing.multiple.json +1 -0
- data/test/fixtures/listing/getListing.single.json +1 -0
- data/test/fixtures/payment_template/getPaymentTemplate.json +1 -0
- data/test/fixtures/profile/new.json +28 -0
- data/test/fixtures/section/getShopSection.json +18 -0
- data/test/fixtures/shipping_template/getShippingTemplate.json +1 -0
- data/test/fixtures/shop/getShop.single.json +4 -3
- data/test/fixtures/transaction/findAllShopTransactions.json +1 -0
- data/test/fixtures/user/getUser.single.withProfile.json +38 -0
- data/test/fixtures/user/getUser.single.withShops.json +41 -0
- data/test/test_helper.rb +9 -4
- data/test/unit/etsy/address_test.rb +61 -0
- data/test/unit/etsy/category_test.rb +106 -0
- data/test/unit/etsy/country_test.rb +64 -0
- data/test/unit/etsy/listing_test.rb +112 -5
- data/test/unit/etsy/model_test.rb +64 -0
- data/test/unit/etsy/payment_template_test.rb +68 -0
- data/test/unit/etsy/profile_test.rb +111 -0
- data/test/unit/etsy/request_test.rb +89 -53
- data/test/unit/etsy/response_test.rb +118 -4
- data/test/unit/etsy/section_test.rb +28 -0
- data/test/unit/etsy/secure_client_test.rb +27 -5
- data/test/unit/etsy/shipping_template_test.rb +24 -0
- data/test/unit/etsy/shop_test.rb +12 -5
- data/test/unit/etsy/transaction_test.rb +52 -0
- data/test/unit/etsy/user_test.rb +147 -8
- data/test/unit/etsy/verification_request_test.rb +3 -3
- data/test/unit/etsy_test.rb +19 -7
- metadata +133 -77
- data/README.rdoc +0 -208
- data/lib/etsy/version.rb +0 -13
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":2,"results":[{"listing_id":59759273,"state":"active","user_id":7301949,"title":"Vinyl Wall Art Decal -- Multi-colored Flowers Set","description":"The listing is for a beautiful set of multi-colored flowers, colors as shown in the picture.\r\n\r\nExclusive design only from OrqueShaw's walldecors! you won't find this anywhere else on etsy!\r\n\r\nHeights of the 4 large flowers: 52in\/37in\/29in\/26in.\r\n\r\nAll of our decals are computer die-cut, there are no "edges" nor "backgrounds", all you will get is the lovely image! and after applying they will look like they are stenciled on with paint!\r\n\r\nuggested install areas: Walls, Mirrors, Metals, Woods, Plastic...Lightly textured surfaces would be just fine! \r\n\r\n\r\n\r\n\r\nABOUT US AND OUR BEAUTIFUL DECALS:\r\n\r\nWe want to transform your walls....and your lives.\r\nDid you know that you can save literally hundreds of dollars designing your own interior space? Seriously, got bored of painting walls,using stencils, applying borders, and putting up wallpapers?? Using our super convenient n' simply gorgeous wall art decals is a very cool and a great way to make a room shine (or to change a room) w\/out damaging your walls or the bank! great alternative to wall paper or a head board, and without any of the mess and hassle involved with painting. Especially nice if you rent and cannot paint your walls, You can even take your wall decals to work and redesign your office or cubical. Easy to apply even for the creative or somewhat domestically challenged . We carry a variety of colors, styles and themes which you could use to decorate every room for anyone in the family!\r\n\r\nOur wall art decals are hand made, they are easy and fun to install.These wall stickers affix on most smooth surfaces and can be removed without leaving any residues. Complete and simple step-by-step instructions are included with your order. \r\n\r\n\r\nSHIPPING:\r\n\r\n*We combine shipping for multiple purchases!\r\n\r\n*Orders usually ship within 2 business days after the clear of payment. \r\n\r\n*All of our shipments are packed in 3 ply spiral wound mailing tubes to ensure the maximum protection during deliveries.\r\n\r\n*Shipping rates: $9.75 for US and Canada $16.75 for other countries.\r\n\r\n*2-7 business days for shipping in Canada, 6-12 business days for shipping to US and other countries, we are not responsible for the delays caused by the custom clearance.\r\n\r\n*Faster delivery options are available upon request.\r\n\r\n*We ship worldwide except the following places: Africa, China, South & North Korea, Italy, Republic Of Serbia, Turkmenistan and Republic Of Montenegro.\r\n\r\n\r\nPAYMENT:\r\n\r\n*Please remit payment within 3 days. Your product will not be shipped until payment is received. Thank you!\r\n\r\n*If you are not 100% satisfied with your purchase, please return the item in its original condition(unopened) within 30 days of delivery of your shipment. Please note that we cannot accept the returns of opened items or items returned more than 30 days past delivery, shipping cost is not refundable and buyers are responsible for the return shipping fees at any case. \r\n","creation_tsz":1288738828,"ending_tsz":1299042000,"original_creation_tsz":1287867280,"last_modified_tsz":1288738828,"price":"42.00","currency_code":"USD","quantity":1,"tags":["children","wallpaper_graphic","nursery_playroom","red_orange_pink","green_lime_color","furniture","office_room","bedroom_bathroom","nature_garden","girl_boy_baby","everything_else","cheersandtears","front_page","soft_colors"],"materials":["self_adhesive_vinyl","decal_transfer_paper"],"shop_section_id":6489554,"featured_rank":null,"state_tsz":1288738828,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/59759273\/vinyl-wall-art-decal-multi-colored","views":202,"num_favorers":5},{"listing_id":33133147,"state":"active","user_id":6399616,"title":"Sketch","description":"Sketch is not your typical run-of-the mill\r\nguy. He is completely self-effacing, but\r\nnot annoyingly so. He draws little scketches\r\nof himself in his notes, in the sand, in the tree,\r\nanywhere really. He even has an embroidered \r\ntattoo of himself on his chest.\r\nTake him home and he will teach you to see \r\nthe lighter side of life. \r\n\r\nHe stands approximately 10 1\/2" tall and 6 1\/2" wide.\r\n\r\n\r\n\r\n","creation_tsz":1287443905,"ending_tsz":1298005200,"original_creation_tsz":1256319445,"last_modified_tsz":1288933827,"price":"34.00","currency_code":"USD","quantity":1,"tags":["children","baby","toy","plush","boy"],"materials":["polyester_stuffing","polyester_thread","cotton_fabric","wool_felt_blend","cotton_embroidery_floss"],"shop_section_id":5861494,"featured_rank":null,"state_tsz":1288933827,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/33133147\/sketch","views":146,"num_favorers":1}],"params":{"listing_id":"59759273,33133147"},"type":"Listing"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":1,"results":[{"listing_id":59759273,"state":"active","user_id":7301949,"title":"Vinyl Wall Art Decal -- Multi-colored Flowers Set","description":"The listing is for a beautiful set of multi-colored flowers, colors as shown in the picture.\r\n\r\nExclusive design only from OrqueShaw's walldecors! you won't find this anywhere else on etsy!\r\n\r\nHeights of the 4 large flowers: 52in\/37in\/29in\/26in.\r\n\r\nAll of our decals are computer die-cut, there are no "edges" nor "backgrounds", all you will get is the lovely image! and after applying they will look like they are stenciled on with paint!\r\n\r\nuggested install areas: Walls, Mirrors, Metals, Woods, Plastic...Lightly textured surfaces would be just fine! \r\n\r\n\r\n\r\n\r\nABOUT US AND OUR BEAUTIFUL DECALS:\r\n\r\nWe want to transform your walls....and your lives.\r\nDid you know that you can save literally hundreds of dollars designing your own interior space? Seriously, got bored of painting walls,using stencils, applying borders, and putting up wallpapers?? Using our super convenient n' simply gorgeous wall art decals is a very cool and a great way to make a room shine (or to change a room) w\/out damaging your walls or the bank! great alternative to wall paper or a head board, and without any of the mess and hassle involved with painting. Especially nice if you rent and cannot paint your walls, You can even take your wall decals to work and redesign your office or cubical. Easy to apply even for the creative or somewhat domestically challenged . We carry a variety of colors, styles and themes which you could use to decorate every room for anyone in the family!\r\n\r\nOur wall art decals are hand made, they are easy and fun to install.These wall stickers affix on most smooth surfaces and can be removed without leaving any residues. Complete and simple step-by-step instructions are included with your order. \r\n\r\n\r\nSHIPPING:\r\n\r\n*We combine shipping for multiple purchases!\r\n\r\n*Orders usually ship within 2 business days after the clear of payment. \r\n\r\n*All of our shipments are packed in 3 ply spiral wound mailing tubes to ensure the maximum protection during deliveries.\r\n\r\n*Shipping rates: $9.75 for US and Canada $16.75 for other countries.\r\n\r\n*2-7 business days for shipping in Canada, 6-12 business days for shipping to US and other countries, we are not responsible for the delays caused by the custom clearance.\r\n\r\n*Faster delivery options are available upon request.\r\n\r\n*We ship worldwide except the following places: Africa, China, South & North Korea, Italy, Republic Of Serbia, Turkmenistan and Republic Of Montenegro.\r\n\r\n\r\nPAYMENT:\r\n\r\n*Please remit payment within 3 days. Your product will not be shipped until payment is received. Thank you!\r\n\r\n*If you are not 100% satisfied with your purchase, please return the item in its original condition(unopened) within 30 days of delivery of your shipment. Please note that we cannot accept the returns of opened items or items returned more than 30 days past delivery, shipping cost is not refundable and buyers are responsible for the return shipping fees at any case. \r\n","creation_tsz":1288738828,"ending_tsz":1299042000,"original_creation_tsz":1287867280,"last_modified_tsz":1288738828,"price":"42.00","currency_code":"USD","quantity":1,"tags":["children","wallpaper_graphic","nursery_playroom","red_orange_pink","green_lime_color","furniture","office_room","bedroom_bathroom","nature_garden","girl_boy_baby","everything_else","cheersandtears","front_page","soft_colors"],"materials":["self_adhesive_vinyl","decal_transfer_paper"],"shop_section_id":6489554,"featured_rank":null,"state_tsz":1288738828,"hue":0,"saturation":0,"brightness":100,"is_black_and_white":false,"url":"http:\/\/www.etsy.com\/listing\/59759273\/vinyl-wall-art-decal-multi-colored","views":178,"num_favorers":5}],"params":{"listing_id":"59759273"},"type":"Listing"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":1,"results":[{"payment_template_id":51,"allow_bt":false,"allow_check":false,"allow_mo":false,"allow_other":true,"allow_paypal":true,"allow_cc":false,"paypal_email":"user@example.com","name":"Example Template","first_line":null,"second_line":null,"city":"Chicago","state":"IL","zip":"60605","country_id":4,"user_id":14888443,"listing_payment_id":51}],"params":{"payment_template_id":"51"},"type":"PaymentTemplate","pagination":{}}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"count":1,
|
3
|
+
"results":{
|
4
|
+
"user_profile_id":123,
|
5
|
+
"user_id":5327518,
|
6
|
+
"login_name":"littletjane",
|
7
|
+
"bio":"I make stuff",
|
8
|
+
"gender":"female",
|
9
|
+
"birth_month":"01",
|
10
|
+
"birth_day":"01",
|
11
|
+
"birth_year":"1970",
|
12
|
+
"join_tsz":1225392413,
|
13
|
+
"materials":"",
|
14
|
+
"country_id":209,
|
15
|
+
"city":"BigCity",
|
16
|
+
"region":"The Desert",
|
17
|
+
"location":"HQ",
|
18
|
+
"avatar_id":345,
|
19
|
+
"lat":39.5304,
|
20
|
+
"lon":-119.8144,
|
21
|
+
"transaction_buy_count":19,
|
22
|
+
"transaction_sold_count":16,
|
23
|
+
"is_seller":true,
|
24
|
+
"image_url_75x75":"some_image.jpg",
|
25
|
+
"first_name":"Tinker",
|
26
|
+
"last_name":"Bell"
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"count":1,
|
3
|
+
"results":[
|
4
|
+
{
|
5
|
+
"shop_section_id":11045327,
|
6
|
+
"title":"Blue Items",
|
7
|
+
"rank":3,
|
8
|
+
"user_id":9569349,
|
9
|
+
"active_listing_count":7
|
10
|
+
}
|
11
|
+
],
|
12
|
+
"params":{
|
13
|
+
"shop_id":"6441123",
|
14
|
+
"shop_section_id":"11045327"
|
15
|
+
},
|
16
|
+
"type":"ShopSection",
|
17
|
+
"pagination":{}
|
18
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":1,"results":[{"shipping_template_id":212,"title":"Small Items","user_id":14888443}],"params":{"shipping_template_id":"212"},"type":"ShippingTemplate","pagination":{}}
|
@@ -25,8 +25,9 @@
|
|
25
25
|
"policy_additional":"ok. well, that's about it! mostly, just be good, nice, honest, and fair, and this will return to you tenfold.\r\n\r\nif you have any questions, please don't hesitate to ask me.\r\n\r\nthanks a bunch, you! cheers!",
|
26
26
|
"policy_updated_tsz":1249084871,
|
27
27
|
"vacation_autoreply":null,
|
28
|
-
"
|
29
|
-
"http
|
28
|
+
"url" : "http://www.etsy.com/shop/littletjane",
|
29
|
+
"image_url_760x100" : "http://ny-image3.etsy.com/iusb_760x100.8484779.jpg",
|
30
|
+
"num_favorers" : 684
|
30
31
|
}
|
31
32
|
]
|
32
|
-
}
|
33
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":2,"results":[{"transaction_id":27230877,"title":"git is my co-pilot. t-shirt (men's medium)","description":"Have an affinity for DVCSes? Has Git saved your bacon on multiple occasions? Show the world how you feel by wearing this t-shirt.\r\n\r\nThe simple statement "git is my co-pilot." printed on an asphalt American Apparel jersey T-shirt.\r\n\r\nSize: Men's Medium\r\n\r\nGarment Measurements (in inches):\r\nLength: 29.375\r\nWidth: 20\r\n\r\nManufacturer Suggested Body Measurements (in inches):\r\nChest: 38-40\r\nWaist: 32-34\r\nInseam: 32\r\n\r\n**Note** American Apparel shirts tend to fit a bit snug, so you may want to order a size larger than you normally wear.\r\n\r\nDesigned by Owen Shifflett (http:\/\/owenshifflett.com)","seller_user_id":53780,"buyer_user_id":9641557,"creation_tsz":1269957380,"paid_tsz":1269997470,"shipped_tsz":null,"price":"20.00","currency_code":"USD","quantity":1,"tags":["clothing","tshirt","men"],"materials":["cotton_shirt","ink"],"image_listing_id":126754470,"receipt_id":18791138,"shipping_cost":"2.50","listing_id":41680579,"seller_feedback_id":null,"buyer_feedback_id":null,"transaction_type":"listing","url":"http:\/\/www.etsy.com\/transaction\/27230877"},{"transaction_id":27230845,"title":"git is my co-pilot. t-shirt (men's medium)","description":"Have an affinity for DVCSes? Has Git saved your bacon on multiple occasions? Show the world how you feel by wearing this t-shirt.\r\n\r\nThe simple statement "git is my co-pilot." printed on an asphalt American Apparel jersey T-shirt.\r\n\r\nSize: Men's Medium\r\n\r\nGarment Measurements (in inches):\r\nLength: 29.375\r\nWidth: 20\r\n\r\nManufacturer Suggested Body Measurements (in inches):\r\nChest: 38-40\r\nWaist: 32-34\r\nInseam: 32\r\n\r\n**Note** American Apparel shirts tend to fit a bit snug, so you may want to order a size larger than you normally wear.\r\n\r\nDesigned by Owen Shifflett (http:\/\/owenshifflett.com)","seller_user_id":53780,"buyer_user_id":9641557,"creation_tsz":1269957313,"paid_tsz":null,"shipped_tsz":null,"price":"20.00","currency_code":"USD","quantity":1,"tags":["clothing","tshirt","men"],"materials":["cotton_shirt","ink"],"image_listing_id":126754470,"receipt_id":18791117,"shipping_cost":"2.50","listing_id":41680579,"seller_feedback_id":null,"buyer_feedback_id":null,"transaction_type":"listing","url":"http:\/\/www.etsy.com\/transaction\/27230845"}],"params":{"shop_id":"5818087","limit":25,"offset":0},"type":"Transaction"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"count": 1,
|
3
|
+
"results": [{
|
4
|
+
"user_id": 5327518,
|
5
|
+
"login_name": "littletjane",
|
6
|
+
"creation_tsz": 1191381578,
|
7
|
+
"referred_by_user_id": null,
|
8
|
+
"feedback_info": {
|
9
|
+
"count": 417,
|
10
|
+
"score": 100
|
11
|
+
},
|
12
|
+
"Profile": {
|
13
|
+
"user_profile_id":123,
|
14
|
+
"user_id":5327518,
|
15
|
+
"login_name":"littletjane",
|
16
|
+
"bio":"I make stuff",
|
17
|
+
"gender":"female",
|
18
|
+
"birth_month":"01",
|
19
|
+
"birth_day":"01",
|
20
|
+
"birth_year":"1970",
|
21
|
+
"join_tsz":1225392413,
|
22
|
+
"materials":"",
|
23
|
+
"country_id":209,
|
24
|
+
"city":"BigCity",
|
25
|
+
"region":"The Desert",
|
26
|
+
"location":"HQ",
|
27
|
+
"avatar_id":345,
|
28
|
+
"lat":39.5304,
|
29
|
+
"lon":-119.8144,
|
30
|
+
"transaction_buy_count":19,
|
31
|
+
"transaction_sold_count":16,
|
32
|
+
"is_seller":true,
|
33
|
+
"image_url_75x75":"some_image.jpg",
|
34
|
+
"first_name":"Tinker",
|
35
|
+
"last_name":"Bell"
|
36
|
+
}
|
37
|
+
}]
|
38
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"count": 1,
|
3
|
+
"results": [{
|
4
|
+
"user_id": 5327518,
|
5
|
+
"login_name": "littletjane",
|
6
|
+
"creation_tsz": 1191381578,
|
7
|
+
"referred_by_user_id": null,
|
8
|
+
"feedback_info": {
|
9
|
+
"count": 417,
|
10
|
+
"score": 100
|
11
|
+
},
|
12
|
+
"Shops": [{
|
13
|
+
"shop_id":6952442,
|
14
|
+
"shop_name":"LittleJane",
|
15
|
+
"user_id":5327518,
|
16
|
+
"creation_tsz":1338484503,
|
17
|
+
"title":"",
|
18
|
+
"announcement":"",
|
19
|
+
"currency_code":"USD",
|
20
|
+
"is_vacation":false,
|
21
|
+
"vacation_message":null,
|
22
|
+
"sale_message":"",
|
23
|
+
"last_updated_tsz":1338490441,
|
24
|
+
"listing_active_count":1,
|
25
|
+
"login_name":"littletjane",
|
26
|
+
"alchemy_message":"",
|
27
|
+
"is_refusing_alchemy":false,
|
28
|
+
"policy_welcome":null,
|
29
|
+
"policy_payment":null,
|
30
|
+
"policy_shipping":null,
|
31
|
+
"policy_refunds":null,
|
32
|
+
"policy_additional":null,
|
33
|
+
"policy_seller_info":null,
|
34
|
+
"policy_updated_tsz":0,
|
35
|
+
"vacation_autoreply":null,
|
36
|
+
"url":"http://www.etsy.com/shop/LittleJane?utm_source=something&utm_medium=api&utm_campaign=api",
|
37
|
+
"image_url_760x100":null,
|
38
|
+
"num_favorers":0
|
39
|
+
}]
|
40
|
+
}]
|
41
|
+
}
|
data/test/test_helper.rb
CHANGED
@@ -6,12 +6,12 @@ require 'test/unit'
|
|
6
6
|
require 'shoulda'
|
7
7
|
require 'matchy'
|
8
8
|
require 'mocha'
|
9
|
+
require 'cgi'
|
9
10
|
|
10
11
|
require File.expand_path('../../lib/etsy', __FILE__)
|
11
12
|
|
12
13
|
class Test::Unit::TestCase
|
13
14
|
|
14
|
-
|
15
15
|
def raw_fixture_data(filename)
|
16
16
|
file = File.dirname(__FILE__) + "/fixtures/#{filename}"
|
17
17
|
File.read(file)
|
@@ -23,13 +23,18 @@ class Test::Unit::TestCase
|
|
23
23
|
|
24
24
|
def mock_request(endpoint, options, resource, file)
|
25
25
|
objects = []
|
26
|
-
|
26
|
+
underscored_fixture_filename = "#{resource.gsub(/([^^])([A-Z])/, '\1_\2').downcase}/#{file}"
|
27
|
+
response_data = raw_fixture_data(underscored_fixture_filename)
|
27
28
|
|
28
|
-
Etsy::Request.stubs(:new).with(endpoint, options).returns(stub(:get => stub(:body => response_data)))
|
29
|
+
Etsy::Request.stubs(:new).with(endpoint, options).returns(stub(:get => stub(:body => response_data, :code => '200')))
|
29
30
|
|
30
31
|
JSON.parse(response_data)['results'].each_with_index do |result, index|
|
31
32
|
object = "#{resource.downcase}_#{index}"
|
32
|
-
|
33
|
+
if options[:access_token] && options[:access_secret]
|
34
|
+
Etsy.const_get(resource).stubs(:new).with(result, options[:access_token], options[:access_secret]).returns(object)
|
35
|
+
else
|
36
|
+
Etsy.const_get(resource).stubs(:new).with(result).returns(object)
|
37
|
+
end
|
33
38
|
objects << object
|
34
39
|
end
|
35
40
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class AddressTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
context "The Address class" do
|
7
|
+
|
8
|
+
should "be able to find a user's addresses" do
|
9
|
+
addresses = mock_request('/users/littletjane/addresses', {}, 'Address', 'getUserAddresses.json')
|
10
|
+
Address.find('littletjane').should == addresses
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
context "An instance of the Address class" do
|
16
|
+
|
17
|
+
context "with response data" do
|
18
|
+
setup do
|
19
|
+
data = read_fixture('address/getUserAddresses.json')
|
20
|
+
@address = Address.new(data.first)
|
21
|
+
end
|
22
|
+
|
23
|
+
should "have a value for :id" do
|
24
|
+
@address.id.should == 123
|
25
|
+
end
|
26
|
+
|
27
|
+
should "have a value for :name" do
|
28
|
+
@address.name.should == "Tinker Bell"
|
29
|
+
end
|
30
|
+
|
31
|
+
should "have a value for :first_line" do
|
32
|
+
@address.first_line.should == "123 Fake St."
|
33
|
+
end
|
34
|
+
|
35
|
+
should "have a value for :second_line" do
|
36
|
+
@address.second_line.should == nil
|
37
|
+
end
|
38
|
+
|
39
|
+
should "have a value for :city" do
|
40
|
+
@address.city.should == 'BigCity'
|
41
|
+
end
|
42
|
+
|
43
|
+
should "have a value for :state" do
|
44
|
+
@address.state.should == 'XX'
|
45
|
+
end
|
46
|
+
|
47
|
+
should "have a value for :zip" do
|
48
|
+
@address.zip.should == '12345'
|
49
|
+
end
|
50
|
+
|
51
|
+
should "have a value for :country" do
|
52
|
+
@address.country.should == 'United States'
|
53
|
+
end
|
54
|
+
|
55
|
+
should "have a value for :country_id" do
|
56
|
+
@address.country_id.should == 209
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class CategoryTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
context "The Category class" do
|
7
|
+
|
8
|
+
should "be able to find a single top-level category" do
|
9
|
+
categories = mock_request('/categories/accessories', {}, 'Category', 'getCategory.single.json')
|
10
|
+
Category.find_top('accessories').should == categories.first
|
11
|
+
end
|
12
|
+
|
13
|
+
should "be able to find multiple categories" do
|
14
|
+
categories = mock_request('/categories/accessories,art', {}, 'Category', 'getCategory.multiple.json')
|
15
|
+
Category.find_top('accessories', 'art').should == categories
|
16
|
+
end
|
17
|
+
|
18
|
+
should "be able to find all top-level categories" do
|
19
|
+
categories = mock_request('/taxonomy/categories', {}, 'Category', 'findAllTopCategory.json')
|
20
|
+
Category.all_top.should == categories
|
21
|
+
end
|
22
|
+
|
23
|
+
should "return an array of categories if there is only 1 result returned" do
|
24
|
+
categories = mock_request('/taxonomy/categories', {}, 'Category', 'findAllTopCategory.single.json')
|
25
|
+
Category.all_top.should == categories
|
26
|
+
end
|
27
|
+
|
28
|
+
context "within the scope of a top-level category" do
|
29
|
+
|
30
|
+
should "be able to find all subcategories" do
|
31
|
+
categories = mock_request('/taxonomy/categories/accessories', {}, 'Category', 'findAllTopCategoryChildren.json')
|
32
|
+
Category.find_all_subcategories('accessories').should == categories
|
33
|
+
end
|
34
|
+
|
35
|
+
should "be able to find the subcategories of a subcategory" do
|
36
|
+
categories = mock_request('/taxonomy/categories/accessories/apron', {}, 'Category', 'findAllSubCategoryChildren.json')
|
37
|
+
Category.find_all_subcategories('accessories/apron').should == categories
|
38
|
+
end
|
39
|
+
|
40
|
+
should "return nil when trying to find the subcategories of a subcategory of a subcategory" do
|
41
|
+
Category.find_all_subcategories('accessories/apron/women').should be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "An instance of the Category class" do
|
49
|
+
|
50
|
+
context "with response data" do
|
51
|
+
setup do
|
52
|
+
data = read_fixture('category/getCategory.single.json')
|
53
|
+
@category = Category.new(data.first)
|
54
|
+
end
|
55
|
+
|
56
|
+
should "have a value for :id" do
|
57
|
+
@category.id.should == 69150467
|
58
|
+
end
|
59
|
+
|
60
|
+
should "have a value for :page_description" do
|
61
|
+
@category.page_description.should == "Shop for unique, handmade accessories from our artisan community"
|
62
|
+
end
|
63
|
+
|
64
|
+
should "have a value for :page_title" do
|
65
|
+
@category.page_title.should == "Handmade accessories"
|
66
|
+
end
|
67
|
+
|
68
|
+
should "have a value for :category_name" do
|
69
|
+
@category.category_name.should == "accessories"
|
70
|
+
end
|
71
|
+
|
72
|
+
should "have a value for :short_name" do
|
73
|
+
@category.short_name.should == "Accessories"
|
74
|
+
end
|
75
|
+
|
76
|
+
should "have a value for :long_name" do
|
77
|
+
@category.long_name.should == "Accessories"
|
78
|
+
end
|
79
|
+
|
80
|
+
should "have a value for :children_count" do
|
81
|
+
@category.children_count.should == 27
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
should "have a collection of active listings" do
|
86
|
+
category = Category.new
|
87
|
+
category.stubs(:category_name).with().returns('accessories')
|
88
|
+
|
89
|
+
Listing.stubs(:find_all_active_by_category).with('accessories').returns('listings')
|
90
|
+
|
91
|
+
category.active_listings.should == 'listings'
|
92
|
+
end
|
93
|
+
|
94
|
+
should "have a collection of subcategories" do
|
95
|
+
category = Category.new
|
96
|
+
category.stubs(:category_name).with().returns('accessories')
|
97
|
+
|
98
|
+
Category.stubs(:find_all_subcategories).with('accessories').returns('categories')
|
99
|
+
|
100
|
+
category.subcategories.should == 'categories'
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class CountryTest < Test::Unit::TestCase
|
5
|
+
context "The Country class" do
|
6
|
+
should "be findable by ISO3166-1 Alpha-2 codes" do
|
7
|
+
united_states = mock
|
8
|
+
united_states.stubs(:iso_country_code => "US")
|
9
|
+
|
10
|
+
great_britain = mock
|
11
|
+
great_britain.stubs(:iso_country_code => "GB")
|
12
|
+
|
13
|
+
Country.stubs(:find_all).returns([great_britain, united_states])
|
14
|
+
Country.find_by_alpha2("us").should == united_states
|
15
|
+
end
|
16
|
+
|
17
|
+
should "be findable by world bank country codes" do
|
18
|
+
united_states = mock
|
19
|
+
united_states.stubs(:world_bank_country_code => "USA")
|
20
|
+
|
21
|
+
great_britain = mock
|
22
|
+
great_britain.stubs(:world_bank_country_code => "GBR")
|
23
|
+
|
24
|
+
Country.stubs(:find_all).returns([great_britain, united_states])
|
25
|
+
Country.find_by_world_bank_country_code("gbr").should == great_britain
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "An instance of the Country class" do
|
30
|
+
setup do
|
31
|
+
data = read_fixture('country/getCountry.json')
|
32
|
+
@listing = Country.new(data.first)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "have an id" do
|
36
|
+
@listing.id.should == 55
|
37
|
+
end
|
38
|
+
|
39
|
+
should "have an iso_country_code" do
|
40
|
+
@listing.iso_country_code.should == "AF"
|
41
|
+
end
|
42
|
+
|
43
|
+
should "have an world_bank_country_code" do
|
44
|
+
@listing.world_bank_country_code.should == "AFG"
|
45
|
+
end
|
46
|
+
|
47
|
+
should "have an name" do
|
48
|
+
@listing.name.should == "Afghanistan"
|
49
|
+
end
|
50
|
+
|
51
|
+
should "have an slug" do
|
52
|
+
@listing.slug.should == "afghanistan"
|
53
|
+
end
|
54
|
+
|
55
|
+
should "have an lat" do
|
56
|
+
@listing.lat.should == 33.78
|
57
|
+
end
|
58
|
+
|
59
|
+
should "have an lon" do
|
60
|
+
@listing.lon.should == 66.17
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -5,9 +5,96 @@ module Etsy
|
|
5
5
|
|
6
6
|
context "The Listing class" do
|
7
7
|
|
8
|
-
should "be able to find
|
9
|
-
listings = mock_request('/
|
10
|
-
Listing.
|
8
|
+
should "be able to find a single listing" do
|
9
|
+
listings = mock_request('/listings/123', {}, 'Listing', 'getListing.single.json')
|
10
|
+
Listing.find(123).should == listings.first
|
11
|
+
end
|
12
|
+
|
13
|
+
should "be able to find multiple listings" do
|
14
|
+
listings = mock_request('/listings/123,456', {}, 'Listing', 'getListing.multiple.json')
|
15
|
+
Listing.find('123', '456').should == listings
|
16
|
+
end
|
17
|
+
|
18
|
+
context "within the scope of a shop" do
|
19
|
+
|
20
|
+
should "be able to find the first 25 active listings" do
|
21
|
+
listings = mock_request('/shops/1/listings/active', {}, 'Listing', 'findAllShopListings.json')
|
22
|
+
Listing.find_all_by_shop_id(1).should == listings
|
23
|
+
end
|
24
|
+
|
25
|
+
should "be able to find expired listings" do
|
26
|
+
listings = mock_request('/shops/1/listings/expired', {}, 'Listing', 'findAllShopListings.json')
|
27
|
+
Listing.find_all_by_shop_id(1, :state => :expired).should == listings
|
28
|
+
end
|
29
|
+
|
30
|
+
should "be able to find inactive listings" do
|
31
|
+
listings = mock_request('/shops/1/listings/inactive', {}, 'Listing', 'findAllShopListings.json')
|
32
|
+
Listing.find_all_by_shop_id(1, :state => :inactive).should == listings
|
33
|
+
end
|
34
|
+
|
35
|
+
should "be able to find featured listings" do
|
36
|
+
listings = mock_request('/shops/1/listings/featured', {}, 'Listing', 'findAllShopListings.json')
|
37
|
+
Listing.find_all_by_shop_id(1, :state => :featured).should == listings
|
38
|
+
end
|
39
|
+
|
40
|
+
should "be able to find sold listings" do
|
41
|
+
transaction_1 = stub(:listing_id => 1)
|
42
|
+
transaction_2 = stub(:listing_id => 2)
|
43
|
+
transaction_3 = stub(:listing_id => 1)
|
44
|
+
|
45
|
+
transactions = [transaction_1, transaction_2, transaction_3]
|
46
|
+
|
47
|
+
Transaction.stubs(:find_all_by_shop_id).with(1, {}).returns(transactions)
|
48
|
+
Listing.stubs(:find).with([1, 2], {}).returns(['listings'])
|
49
|
+
|
50
|
+
Listing.find_all_by_shop_id(1, :state => :sold).should == ['listings']
|
51
|
+
end
|
52
|
+
|
53
|
+
should "defer associations to listings from transaction (sold listings)" do
|
54
|
+
transaction_1 = stub(:listing_id => 1)
|
55
|
+
transaction_2 = stub(:listing_id => 2)
|
56
|
+
|
57
|
+
Transaction.stubs(:find_all_by_shop_id).with(1, {}).returns [transaction_1, transaction_2]
|
58
|
+
Listing.stubs(:find).with([1, 2], {:includes => :an_association}).returns(['listings'])
|
59
|
+
|
60
|
+
Listing.find_all_by_shop_id(1, :state => :sold, :includes => :an_association).should == ['listings']
|
61
|
+
end
|
62
|
+
|
63
|
+
should "pass options through to the listing call" do
|
64
|
+
transaction_1 = stub(:listing_id => 1)
|
65
|
+
transaction_2 = stub(:listing_id => 2)
|
66
|
+
|
67
|
+
Transaction.stubs(:find_all_by_shop_id).with(1, {:other => :params}).returns [transaction_1, transaction_2]
|
68
|
+
Listing.stubs(:find).with([1, 2], {:other => :params}).returns(['listings'])
|
69
|
+
|
70
|
+
Listing.find_all_by_shop_id(1, :state => :sold, :other => :params).should == ['listings']
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
should "not ask the API for listings if there are no transactions" do
|
75
|
+
Transaction.stubs(:find_all_by_shop_id).with(1, {}).returns([])
|
76
|
+
Listing.expects(:find).never
|
77
|
+
Listing.sold_listings(1, {})
|
78
|
+
end
|
79
|
+
|
80
|
+
should "be able to override limit and offset" do
|
81
|
+
options = {:limit => 100, :offset => 100}
|
82
|
+
listings = mock_request('/shops/1/listings/active', options, 'Listing', 'findAllShopListings.json')
|
83
|
+
Listing.find_all_by_shop_id(1, options).should == listings
|
84
|
+
end
|
85
|
+
|
86
|
+
should "raise an exception when calling with an invalid state" do
|
87
|
+
options = {:state => :awesome}
|
88
|
+
lambda { Listing.find_all_by_shop_id(1, options) }.should raise_error(ArgumentError)
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context "within the scope of a category" do
|
94
|
+
should "be able to find active listings" do
|
95
|
+
active_listings = mock_request('/listings/active', {:category => 'accessories'}, 'Listing', 'findAllListingActive.category.json')
|
96
|
+
Listing.find_all_active_by_category('accessories').should == active_listings
|
97
|
+
end
|
11
98
|
end
|
12
99
|
|
13
100
|
end
|
@@ -16,7 +103,7 @@ module Etsy
|
|
16
103
|
|
17
104
|
context "with response data" do
|
18
105
|
setup do
|
19
|
-
data = read_fixture('listing/
|
106
|
+
data = read_fixture('listing/findAllShopListings.json')
|
20
107
|
@listing = Listing.new(data.first)
|
21
108
|
end
|
22
109
|
|
@@ -48,6 +135,10 @@ module Etsy
|
|
48
135
|
@listing.created_at.should == Time.at(1287602289)
|
49
136
|
end
|
50
137
|
|
138
|
+
should "have a value for :modified_at" do
|
139
|
+
@listing.modified_at.should == Time.at(1287602289)
|
140
|
+
end
|
141
|
+
|
51
142
|
should "have a value for :price" do
|
52
143
|
@listing.price.should == "15.00"
|
53
144
|
end
|
@@ -71,6 +162,22 @@ module Etsy
|
|
71
162
|
should "have a value for :materials" do
|
72
163
|
@listing.materials.should == %w(material_1 material_2)
|
73
164
|
end
|
165
|
+
|
166
|
+
should "have a value for :hue" do
|
167
|
+
@listing.hue.should == 0
|
168
|
+
end
|
169
|
+
|
170
|
+
should "have a value for :saturation" do
|
171
|
+
@listing.saturation.should == 0
|
172
|
+
end
|
173
|
+
|
174
|
+
should "have a value for :brightness" do
|
175
|
+
@listing.brightness.should == 100
|
176
|
+
end
|
177
|
+
|
178
|
+
should "have a value for :black_and_white?" do
|
179
|
+
@listing.black_and_white?.should == false
|
180
|
+
end
|
74
181
|
end
|
75
182
|
|
76
183
|
%w(active removed sold_out expired alchemy).each do |state|
|
@@ -107,4 +214,4 @@ module Etsy
|
|
107
214
|
|
108
215
|
end
|
109
216
|
end
|
110
|
-
end
|
217
|
+
end
|