cafepress_api 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cafepress_api/version.rb +1 -1
- data/lib/cafepress_api.rb +16 -8
- metadata +4 -4
data/lib/cafepress_api.rb
CHANGED
@@ -66,16 +66,24 @@ Or better yet, add the mapping yourself in product_genders.rb and submit it back
|
|
66
66
|
%})
|
67
67
|
end
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
|
+
# The CafePress API (at the time of this code) doesn't correctly return
|
71
|
+
# product images only for the colors which are available for the product.
|
72
|
+
# as such, I am filtering out "invalid" colors from the productUrl(s)
|
73
|
+
valid_color_ids = product.get_elements('color').map{|color| color.attributes['id']}
|
74
|
+
|
70
75
|
image_urls = []
|
71
76
|
product.get_elements("productImage").each do |product_image|
|
72
|
-
if
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
# only parse if it is a product image for an available color
|
78
|
+
if valid_color_ids.include?(product_image.attributes['colorId'])
|
79
|
+
if product_image.attributes['productUrl'].include?('_Front')
|
80
|
+
image_urls << {:color_id => product_image.attributes['colorId'], :url => product_image.attributes['productUrl'], :view => FRONT_PRODUCT_VIEW, :size => product_image.attributes['imageSize']}
|
81
|
+
elsif product_image.attributes['productUrl'].include?('_Back')
|
82
|
+
image_urls << {:color_id => product_image.attributes['colorId'], :url => product_image.attributes['productUrl'], :view => BACK_PRODUCT_VIEW, :size => product_image.attributes['imageSize']}
|
83
|
+
else
|
84
|
+
warn("\nWARNING: the image url #{product_image.attributes['productUrl']} does not appear to be a front or back image, assuming it is a front image.")
|
85
|
+
image_urls << {:color_id => product_image.attributes['colorId'], :url => product_image.attributes['productUrl'], :view => FRONT_PRODUCT_VIEW, :size => product_image.attributes['imageSize']}
|
86
|
+
end
|
79
87
|
end
|
80
88
|
end
|
81
89
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafepress_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Lee Smith
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-05 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|