cafepress_api 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cafepress_api/version.rb +1 -1
- data/lib/cafepress_api.rb +18 -1
- data/lib/product_colors.rb +11 -0
- data/lib/product_genders.rb +1 -1
- metadata +5 -4
data/lib/cafepress_api.rb
CHANGED
@@ -17,9 +17,13 @@
|
|
17
17
|
require 'rexml/document'
|
18
18
|
require 'open-uri'
|
19
19
|
require 'product_genders'
|
20
|
+
require 'product_colors'
|
20
21
|
module CafePressAPI
|
21
22
|
RESULTS_PER_PAGE = 100
|
23
|
+
FRONT_PRODUCT_VIEW = 'f'
|
24
|
+
BACK_PRODUCT_VIEW = 'b'
|
22
25
|
include ProductGenders
|
26
|
+
include ProductColors
|
23
27
|
|
24
28
|
def self.store_url(cafepress_store_id)
|
25
29
|
"http://cafepress.com/#{cafepress_store_id}"
|
@@ -62,6 +66,18 @@ Or better yet, add the mapping yourself in product_genders.rb and submit it back
|
|
62
66
|
%})
|
63
67
|
end
|
64
68
|
end
|
69
|
+
|
70
|
+
image_urls = []
|
71
|
+
product.get_elements("productImage").each do |product_image|
|
72
|
+
if product_image.attributes['productUrl'].include?('_Front_')
|
73
|
+
image_urls << {:color_id => product_image.attributes['colorId'], :url => product_image.attributes['productUrl'], :view => FRONT_PRODUCT_VIEW, :size => product_image.attributes['imageSize']}
|
74
|
+
elsif product_image.attributes['productUrl'].include?('_Back_')
|
75
|
+
image_urls << {:color_id => product_image.attributes['colorId'], :url => product_image.attributes['productUrl'], :view => BACK_PRODUCT_VIEW, :size => product_image.attributes['imageSize']}
|
76
|
+
else
|
77
|
+
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.")
|
78
|
+
image_urls << {:color_id => product_image.attributes['colorId'], :url => product_image.attributes['productUrl'], :view => FRONT_PRODUCT_VIEW, :size => product_image.attributes['imageSize']}
|
79
|
+
end
|
80
|
+
end
|
65
81
|
|
66
82
|
products << {
|
67
83
|
:name => product.attributes['name'],
|
@@ -70,7 +86,8 @@ Or better yet, add the mapping yourself in product_genders.rb and submit it back
|
|
70
86
|
:url => product.attributes['marketplaceUri'],
|
71
87
|
:cafepress_design_id => product.get_elements("mediaConfiguration[@perspectives='Front']").first.attributes['designId'],
|
72
88
|
:cafepress_back_design_id => cafepress_back_design_id,
|
73
|
-
:gender => gender # See comment above
|
89
|
+
:gender => gender, # See comment above
|
90
|
+
:image_urls => image_urls
|
74
91
|
}
|
75
92
|
end
|
76
93
|
products
|
data/lib/product_genders.rb
CHANGED
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: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
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-04 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- cafepress_api.gemspec
|
38
38
|
- lib/cafepress_api.rb
|
39
39
|
- lib/cafepress_api/version.rb
|
40
|
+
- lib/product_colors.rb
|
40
41
|
- lib/product_genders.rb
|
41
42
|
has_rdoc: true
|
42
43
|
homepage: https://github.com/benjaminleesmith/cafepress_api
|