cafepress_api 0.1.1 → 0.1.2

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.
@@ -15,5 +15,5 @@
15
15
  # along with CafePressAPI. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  module CafePressAPI
18
- VERSION = "0.1.1"
18
+ VERSION = "0.1.2"
19
19
  end
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
@@ -0,0 +1,11 @@
1
+ # Mapping between colors and colorIds
2
+ module ProductColors
3
+ # color_id => color_description
4
+ COLOR_DESCRIPTIONS = {
5
+ '6' => 'Black',
6
+ '9' => 'Red',
7
+ '26' => 'Navy',
8
+ '28' => 'Brown',
9
+ '89' => 'SportGrey'
10
+ }
11
+ end
@@ -1,4 +1,4 @@
1
- # Copyright 2011 Benjamin Lee Smith <benjamin.lee.smith@gmail.com>
1
+ # Copyright 2011 Benjamin Lee Smith <benjamin.lee.smith@gmail.com>
2
2
  #
3
3
  # This file is part of CafePressAPI.
4
4
  # CafePressAPI is free software: you can redistribute it and/or modify
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: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.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-01 00:00:00 -07:00
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