cafepress_api 0.1.0 → 0.1.1
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.rb +24 -2
- data/lib/cafepress_api/version.rb +1 -1
- data/lib/product_genders.rb +219 -0
- metadata +5 -4
data/lib/cafepress_api.rb
CHANGED
@@ -16,10 +16,17 @@
|
|
16
16
|
|
17
17
|
require 'rexml/document'
|
18
18
|
require 'open-uri'
|
19
|
+
require 'product_genders'
|
19
20
|
module CafePressAPI
|
20
21
|
RESULTS_PER_PAGE = 100
|
22
|
+
include ProductGenders
|
21
23
|
|
22
|
-
|
24
|
+
def self.store_url(cafepress_store_id)
|
25
|
+
"http://cafepress.com/#{cafepress_store_id}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Generates a url to add one product to a CafePress cart.
|
29
|
+
# This isn't part of the CafePress API, use at your own risk!
|
23
30
|
def self.add_to_cart_url(product_id, size, color, quantity, keep_shopping_url)
|
24
31
|
"http://www.cafepress.com/cp/addtocart.aspx?color_#{product_id}=#{color}&size_#{product_id}=#{size}&qty_#{product_id}=#{quantity}&keepshopping=#{keep_shopping_url}&storeid=search"
|
25
32
|
end
|
@@ -42,13 +49,28 @@ module CafePressAPI
|
|
42
49
|
cafepress_back_design_id = nil
|
43
50
|
end
|
44
51
|
|
52
|
+
# The CafePress API doesn't have a concept of genders... so I'm faking it
|
53
|
+
# Gender mapping was created by hand, use at own risk
|
54
|
+
if (gender = PRODUCT_GENDERS[product.attributes['merchandiseId']]).nil?
|
55
|
+
gender = PRODUCT_GENDERS[product.attributes['defaultCaption']]
|
56
|
+
if gender.nil?
|
57
|
+
gender = UNISEX
|
58
|
+
warn(%{
|
59
|
+
\nWARNING: the product with defaultCaption '#{product.attributes['defaultCaption']}' and merchandiseId #{product.attributes['merchandiseId']} does not exist in the gender mapping!\n
|
60
|
+
Please send benjamin.lee.smith@gmail.com an email and copy/paste this warning message.\n
|
61
|
+
Or better yet, add the mapping yourself in product_genders.rb and submit it back https://github.com/benjaminleesmith/cafepress_api\n
|
62
|
+
%})
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
45
66
|
products << {
|
46
67
|
:name => product.attributes['name'],
|
47
68
|
:default_caption => product.attributes['defaultCaption'],
|
48
69
|
:cafepress_product_id => product.attributes['id'],
|
49
70
|
:url => product.attributes['marketplaceUri'],
|
50
71
|
:cafepress_design_id => product.get_elements("mediaConfiguration[@perspectives='Front']").first.attributes['designId'],
|
51
|
-
:cafepress_back_design_id => cafepress_back_design_id
|
72
|
+
:cafepress_back_design_id => cafepress_back_design_id,
|
73
|
+
:gender => gender # See comment above
|
52
74
|
}
|
53
75
|
end
|
54
76
|
products
|
@@ -0,0 +1,219 @@
|
|
1
|
+
# Copyright 2011 Benjamin Lee Smith <benjamin.lee.smith@gmail.com>
|
2
|
+
#
|
3
|
+
# This file is part of CafePressAPI.
|
4
|
+
# CafePressAPI is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# CafePressAPI is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with CafePressAPI. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# Seriously CafePress... just return gender values for your products so I
|
18
|
+
# don't have to do this crap. This is a mapping of merchandise to genders
|
19
|
+
module ProductGenders
|
20
|
+
MALE = 'm'
|
21
|
+
FEMALE = 'f'
|
22
|
+
UNISEX = 'u' # this is basically everything that isn't male or female
|
23
|
+
|
24
|
+
# Mapping... done by hand... from default captions and mechandiseId to genders
|
25
|
+
PRODUCT_GENDERS = {
|
26
|
+
'2.25" Button' => UNISEX, '118' => UNISEX,
|
27
|
+
'2.25" Button (10 pack)' => UNISEX, '120' => UNISEX,
|
28
|
+
'2.25" Button (100 pack)' => UNISEX, '121' => UNISEX,
|
29
|
+
'2.25" Magnet (10 pack)' => UNISEX, '122' => UNISEX,
|
30
|
+
'2.25" Magnet (100 pack)' => UNISEX, '123' => UNISEX,
|
31
|
+
'21x7 Wall Peel' => UNISEX, '453' => UNISEX,
|
32
|
+
'22x14 Oval Wall Peel' => UNISEX, '449' => UNISEX,
|
33
|
+
'22x14 Wall Peel' => UNISEX, '451' => UNISEX,
|
34
|
+
'3" Lapel Sticker (48 pk)' => UNISEX, '207' => UNISEX,
|
35
|
+
'3.5" Button' => UNISEX, '203' => UNISEX,
|
36
|
+
'3.5" Button (10 pack)' => UNISEX, '204' => UNISEX,
|
37
|
+
'3.5" Button (100 pack)' => UNISEX, '205' => UNISEX,
|
38
|
+
'38.5 x 24.5 Oval Wall Peel' => UNISEX, '450' => UNISEX,
|
39
|
+
'38.5 x 24.5 Wall Peel' => UNISEX, '452' => UNISEX,
|
40
|
+
'42x14 Wall Peel' => UNISEX, '454' => UNISEX,
|
41
|
+
'Aluminum License Plate' => UNISEX, '495' => UNISEX,
|
42
|
+
'Aluminum Oval Keychain' => UNISEX, '494' => UNISEX,
|
43
|
+
'Aluminum Photo Keychain' => UNISEX, '493' => UNISEX,
|
44
|
+
'Apron' => UNISEX, '42' => UNISEX,
|
45
|
+
'Apron (dark)' => UNISEX, '287' => UNISEX,
|
46
|
+
'Audio CD' => UNISEX, '93' => UNISEX,
|
47
|
+
'Banner' => UNISEX, '208' => UNISEX,
|
48
|
+
'Baseball Jersey' => MALE, '38' => MALE,
|
49
|
+
'Beach Tote' => UNISEX, '289' => UNISEX,
|
50
|
+
'Bib' => UNISEX, '73' => UNISEX,
|
51
|
+
'Black Cap' => UNISEX, '65' => UNISEX,
|
52
|
+
'Book' => UNISEX, '97' => UNISEX,
|
53
|
+
'Boxer Brief' => MALE, '296' => MALE,
|
54
|
+
'Boxer Shorts' => MALE, '15' => MALE,
|
55
|
+
'Calendar Print' => UNISEX, '74' => UNISEX,
|
56
|
+
'Cap' => UNISEX, '140' => UNISEX,
|
57
|
+
'Ceramic Travel Mug' => UNISEX, '220' => UNISEX,
|
58
|
+
'Charm Bracelet, One Charm' => FEMALE, '488' => FEMALE,
|
59
|
+
'Christmas Stocking' => UNISEX, '434' => UNISEX,
|
60
|
+
'Classic Thong' => FEMALE, '80' => FEMALE,
|
61
|
+
'Customized Felt Christmas Stocking' => UNISEX, '435' => UNISEX,
|
62
|
+
'Dark T-Shirt' => MALE, '152' => MALE,
|
63
|
+
'Data CD' => UNISEX, '94' => UNISEX,
|
64
|
+
'Denim Shirt' => MALE, '217' => MALE,
|
65
|
+
'Dog T-Shirt' => UNISEX, '110' => UNISEX,
|
66
|
+
'Earring Circle Charm' => FEMALE, '490' => FEMALE,
|
67
|
+
'Earring Heart Charm' => FEMALE, '492' => FEMALE,
|
68
|
+
'Earring Oval Charm' => FEMALE, '489' => FEMALE,
|
69
|
+
'Fathead Wall Graphic' => UNISEX, '502' => UNISEX,
|
70
|
+
'Fitted T-Shirt' => MALE, '106' => MALE,
|
71
|
+
'Framed Tile' => UNISEX, '147' => UNISEX,
|
72
|
+
'Golf Shirt' => MALE, '45' => MALE,
|
73
|
+
'Green T-Shirt' => MALE, '108' => MALE,
|
74
|
+
'Greeting Card' => UNISEX, '192' => UNISEX,
|
75
|
+
'Greeting Cards (Pk of 10)' => UNISEX, '78' => UNISEX,
|
76
|
+
'Greeting Cards (Pk of 20)' => UNISEX, '193' => UNISEX,
|
77
|
+
'Gym Bag' => UNISEX, '288' => UNISEX,
|
78
|
+
'Hooded Sweatshirt' => MALE, '23' => MALE,
|
79
|
+
'Hoodie (dark)' => MALE, '244' => MALE,
|
80
|
+
'Infant Bodysuit' => UNISEX, '72' => UNISEX,
|
81
|
+
'Infant T-Shirt' => UNISEX, '440' => UNISEX,
|
82
|
+
'Journal' => UNISEX, '100' => UNISEX,
|
83
|
+
'Jr. Hoodie' => FEMALE, '103' => FEMALE,
|
84
|
+
'Jr. Jersey T-Shirt' => FEMALE, '6' => FEMALE,
|
85
|
+
'Jr. Raglan' => FEMALE, '102' => FEMALE,
|
86
|
+
'Jr. Ringer T-Shirt' => FEMALE, '113' => FEMALE,
|
87
|
+
'Jr. Spaghetti Tank' => FEMALE, '96' => FEMALE,
|
88
|
+
'Keepsake Box' => UNISEX, '86' => UNISEX,
|
89
|
+
'Kid\'s Pajamas' => UNISEX, '501' => UNISEX,
|
90
|
+
'Kids Baseball Jersey' => UNISEX, '136' => UNISEX,
|
91
|
+
'Kids Dark T-Shirt' => UNISEX, '181' => UNISEX,
|
92
|
+
'Kids Hoodie' => UNISEX, '133' => UNISEX,
|
93
|
+
'Kids Light T-Shirt' => UNISEX, '70' => UNISEX,
|
94
|
+
'Kids Sweatshirt' => UNISEX, '135' => UNISEX,
|
95
|
+
'Large Mug ' => UNISEX, '1' => UNISEX,
|
96
|
+
'Large Pet Bowl' => UNISEX, '216' => UNISEX,
|
97
|
+
'Large Thermos Bottle' => UNISEX, '364' => UNISEX,
|
98
|
+
'Large Wall Clock' => UNISEX, '232' => UNISEX,
|
99
|
+
'License Plate Frame' => UNISEX, '52' => UNISEX,
|
100
|
+
'License Plate Holder' => UNISEX, '496' => UNISEX,
|
101
|
+
'Light T-Shirt' => MALE, '7' => MALE,
|
102
|
+
'Long Sleeve Dark T-Shirt' => MALE, '155' => MALE,
|
103
|
+
'Long Sleeve Infant Bodysuit' => UNISEX, '360' => UNISEX,
|
104
|
+
'Long Sleeve Infant T-Shirt' => UNISEX, '361' => UNISEX,
|
105
|
+
'Long Sleeve T-Shirt' => MALE, '5' => MALE,
|
106
|
+
'Magnet' => UNISEX, '119' => UNISEX,
|
107
|
+
'Maternity Dark T-Shirt' => FEMALE, '190' => FEMALE,
|
108
|
+
'Maternity T-Shirt' => FEMALE, '189' => FEMALE,
|
109
|
+
'Men\'s Dark Pajamas ' => MALE, '497' => MALE,
|
110
|
+
'Men\'s Fitted T-Shirt (dark)' => MALE, '159' => MALE,
|
111
|
+
'Men\'s Light Pajamas ' => MALE, '498' => MALE,
|
112
|
+
'Men\'s Performance Jacket' => MALE, '221' => MALE,
|
113
|
+
'Men\'s Polo' => MALE, '218' => MALE,
|
114
|
+
'Men\'s Sleeveless Tee' => MALE, '115' => MALE,
|
115
|
+
'Messenger Bag' => UNISEX, '18' => UNISEX,
|
116
|
+
'Military Cap' => UNISEX, '223' => UNISEX,
|
117
|
+
'Mini Button' => UNISEX, '141' => UNISEX,
|
118
|
+
'Mini Button (10 pack)' => UNISEX, '142' => UNISEX,
|
119
|
+
'Mini Button (100 pack)' => UNISEX, '143' => UNISEX,
|
120
|
+
'Modern Wall Clock' => UNISEX, '233' => UNISEX,
|
121
|
+
'Mousepad ' => UNISEX, '3' => UNISEX,
|
122
|
+
'Mug ' => UNISEX, '0' => UNISEX,
|
123
|
+
'Necklace Circle Charm' => FEMALE, '485' => FEMALE,
|
124
|
+
'Necklace Heart Charm' => FEMALE, '487' => FEMALE,
|
125
|
+
'Necklace Oval Charm' => FEMALE, '486' => FEMALE,
|
126
|
+
'Note Cards (Pk of 10)' => UNISEX, '194' => UNISEX,
|
127
|
+
'Note Cards (Pk of 20)' => UNISEX, '195' => UNISEX,
|
128
|
+
'Organic Baby Bodysuit' => UNISEX, '259' => UNISEX,
|
129
|
+
'Organic Baby T-Shirt' => UNISEX, '258' => UNISEX,
|
130
|
+
'Organic Kids T-Shirt' => UNISEX, '256' => UNISEX,
|
131
|
+
'Organic Kids T-Shirt (dark)' => UNISEX, '257' => UNISEX,
|
132
|
+
'Organic Men\'s Fitted T-Shirt' => MALE, '111' => MALE,
|
133
|
+
'Organic Men\'s Fitted T-Shirt (dark)' => MALE, '260' => MALE,
|
134
|
+
'Organic Men\'s T-Shirt' => MALE, '250' => MALE,
|
135
|
+
'Organic Men\'s T-Shirt (dark)' => MALE, '251' => MALE,
|
136
|
+
'Organic Toddler T-Shirt' => UNISEX, '261' => UNISEX,
|
137
|
+
'Organic Toddler T-Shirt (dark)' => UNISEX, '262' => UNISEX,
|
138
|
+
'Organic Women\'s Fitted T-Shirt' => FEMALE, '254' => FEMALE,
|
139
|
+
'Organic Women\'s Fitted T-Shirt (dark)' => FEMALE, '255' => FEMALE,
|
140
|
+
'Organic Women\'s T-Shirt' => FEMALE, '252' => FEMALE,
|
141
|
+
'Organic Women\'s T-Shirt (dark)' => FEMALE, '253' => FEMALE,
|
142
|
+
'Ornament (Oval)' => UNISEX, '105' => UNISEX,
|
143
|
+
'Ornament (Round)' => UNISEX, '124' => UNISEX,
|
144
|
+
'Oversized Wall Calendar' => UNISEX, '162' => UNISEX,
|
145
|
+
'Postcards (Package of 8)' => UNISEX, '77' => UNISEX,
|
146
|
+
'Rectangle Magnet' => UNISEX, '137' => UNISEX,
|
147
|
+
'Rectangle Magnet (10 pack)' => UNISEX, '138' => UNISEX,
|
148
|
+
'Rectangle Magnet (100 pack)' => UNISEX, '139' => UNISEX,
|
149
|
+
'Ringer T' => MALE, '126' => MALE,
|
150
|
+
'Sigg Water Bottle 0.6L' => UNISEX, '281' => UNISEX,
|
151
|
+
'Sigg Water Bottle 1.0L' => UNISEX, '280' => UNISEX,
|
152
|
+
'Small Pet Bowl' => UNISEX, '215' => UNISEX,
|
153
|
+
'Stackable Mug Set (4 mugs)' => UNISEX, '293' => UNISEX,
|
154
|
+
'Stadium Blanket' => UNISEX, '368' => UNISEX,
|
155
|
+
'Stainless Water Bottle 0.6L' => UNISEX, '358' => UNISEX,
|
156
|
+
'Stainless Water Bottle 1.0L' => UNISEX, '359' => UNISEX,
|
157
|
+
'Stein' => UNISEX, '359' => UNISEX,
|
158
|
+
'Sticker (Bumper 10 pk)' => UNISEX, '209' => UNISEX,
|
159
|
+
'Sticker (Bumper 50 pk)' => UNISEX, '210' => UNISEX,
|
160
|
+
'Sticker (Bumper)' => UNISEX, '90' => UNISEX,
|
161
|
+
'Sticker (Oval 10 pk)' => UNISEX, '211' => UNISEX,
|
162
|
+
'Sticker (Oval 50 pk)' => UNISEX, '212' => UNISEX,
|
163
|
+
'Sticker (Oval)' => UNISEX, '51' => UNISEX,
|
164
|
+
'Sticker (Rectangle 10 pk)' => UNISEX, '213' => UNISEX,
|
165
|
+
'Sticker (Rectangle 50 pk)' => UNISEX, '214' => UNISEX,
|
166
|
+
'Sticker (Rectangle)' => UNISEX, '50' => UNISEX,
|
167
|
+
'Stonewashed Cap' => UNISEX, '224' => UNISEX,
|
168
|
+
'Sweatshirt' => MALE, '4' => MALE,
|
169
|
+
'Sweatshirt (dark)' => MALE, '249' => MALE,
|
170
|
+
'Teddy Bear' => UNISEX, '26' => UNISEX,
|
171
|
+
'Thermos Bottle (12oz)' => UNISEX, '366' => UNISEX,
|
172
|
+
'Thermos Can Cooler' => UNISEX, '367' => UNISEX,
|
173
|
+
'Thermos Food Jar' => UNISEX, '365' => UNISEX,
|
174
|
+
'Throw Pillow' => UNISEX, '125' => UNISEX,
|
175
|
+
'Tile Coaster' => UNISEX, '37' => UNISEX,
|
176
|
+
'Toddler T-Shirt' => UNISEX, '69' => UNISEX,
|
177
|
+
'Tote Bag' => UNISEX, '17' => UNISEX,
|
178
|
+
'Trek Water Bottle' => UNISEX, '305' => UNISEX,
|
179
|
+
'Trucker Hat' => UNISEX, '101' => UNISEX,
|
180
|
+
'Value T-shirt' => MALE, '112' => MALE,
|
181
|
+
'Vertical Wall Calendar' => UNISEX, '163' => UNISEX,
|
182
|
+
'Wall Calendar' => UNISEX, '75' => UNISEX,
|
183
|
+
'Wall Clock' => UNISEX, '49' => UNISEX,
|
184
|
+
'White T-Shirt' => MALE, '2' => MALE,
|
185
|
+
'Women\'s Boy Brief' => FEMALE, '295' => FEMALE,
|
186
|
+
'Women\'s Cap Sleeve T-Shirt' => FEMALE, '134' => FEMALE,
|
187
|
+
'Women\'s Dark Pajamas ' => FEMALE, '499' => FEMALE,
|
188
|
+
'Women\'s Dark T-Shirt' => FEMALE, '161' => FEMALE,
|
189
|
+
'Women\'s Fitted T-Shirt (dark)' => FEMALE, '263' => FEMALE,
|
190
|
+
'Women\'s Light Pajamas ' => FEMALE, '500' => FEMALE,
|
191
|
+
'Women\'s Light T-Shirt' => FEMALE, '109' => FEMALE,
|
192
|
+
'Women\'s Long Sleeve Dark T-Shirt' => FEMALE, '164' => FEMALE,
|
193
|
+
'Women\'s Long Sleeve T-Shirt' => FEMALE, '165' => FEMALE,
|
194
|
+
'Women\'s Performance Jacket' => FEMALE, '222' => FEMALE,
|
195
|
+
'Women\'s Plus Size Scoop Neck Dark T-Shirt' => FEMALE, '184' => FEMALE,
|
196
|
+
'Women\'s Plus Size Scoop Neck T-Shirt' => FEMALE, '183' => FEMALE,
|
197
|
+
'Women\'s Plus Size V-Neck Dark T-Shirt' => FEMALE, '186' => FEMALE,
|
198
|
+
'Women\'s Plus Size V-Neck T-Shirt' => FEMALE, '185' => FEMALE,
|
199
|
+
'Women\'s Polo' => FEMALE, '219' => FEMALE,
|
200
|
+
'Women\'s Raglan Hoodie' => FEMALE, '128' => FEMALE,
|
201
|
+
'Women\'s T-Shirt' => FEMALE, '89' => FEMALE,
|
202
|
+
'Women\'s Tank Top' => FEMALE, '114' => FEMALE,
|
203
|
+
'Women\'s Tracksuit' => FEMALE, '129' => FEMALE,
|
204
|
+
'Women\'s V-Neck Dark T-Shirt' => FEMALE, '167' => FEMALE,
|
205
|
+
'Women\'s V-Neck T-Shirt' => FEMALE, '166' => FEMALE,
|
206
|
+
'Women\'s Zip Hoodie' => FEMALE, '247' => FEMALE,
|
207
|
+
'Yard Sign' => UNISEX, '206' => UNISEX,
|
208
|
+
'Yellow T-Shirt' => MALE, '107' => MALE,
|
209
|
+
'Zip Hoodie' => MALE, '245' => MALE,
|
210
|
+
'Zip Hoodie (dark)' => MALE, '246' => MALE,
|
211
|
+
'baby blanket' => UNISEX, '363' => UNISEX,
|
212
|
+
'baby hat' => UNISEX, '362' => UNISEX,
|
213
|
+
'iPad 5-in-1 Case' => UNISEX, '460' => UNISEX,
|
214
|
+
'iPad Case' => UNISEX, '459' => UNISEX,
|
215
|
+
'iPhone 3G Hard Case' => UNISEX, '441' => UNISEX,
|
216
|
+
'iPhone 4 Clear Case' => UNISEX, '444' => UNISEX,
|
217
|
+
'iPhone 4 Slider Case' => UNISEX, '443' => UNISEX
|
218
|
+
}
|
219
|
+
end
|
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: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
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-
|
18
|
+
date: 2011-03-01 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_genders.rb
|
40
41
|
has_rdoc: true
|
41
42
|
homepage: https://github.com/benjaminleesmith/cafepress_api
|
42
43
|
licenses: []
|