cafepress_api 0.0.3 → 0.1.0

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/README CHANGED
@@ -31,6 +31,8 @@ $ irb
31
31
  => true
32
32
  > CafePressAPI.get_store_products('carabinerpirate','YOUR-CAFEPRESS-API-KEY')
33
33
  => [{:cafepress_design_id=>"21823412", :cafepress_back_design_id=>nil, :default_caption=>"Women's Long Sleeve Dark T-Shirt", :cafepress_product_id=>"164539429", :name=>"Pirates of the Carabiner Women's Long Sleeve Shirt", :url=>"http://www.cafepress.com/buy/x/-/pv_design_prod/pg_1/p_2627625.164539429/pNo_164539429"}, ...]
34
+ > CafePressAPI.add_to_cart_url('164539432', '6', '29', 2, 'http://rockclimbingshirts.com')
35
+ => "http://www.cafepress.com/cp/addtocart.aspx?color_164539432=29&size_164539432=6&qty_164539432=2&keepshopping=http://rockclimbingshirts.com&storeid=search"
34
36
 
35
37
  I wrote this gem for a Rails app which creates a portal of multiple CafePress
36
38
  basic stores (https://github.com/benjaminleesmith/cafepress_wrapper). This gem
@@ -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.0.3"
18
+ VERSION = "0.1.0"
19
19
  end
data/lib/cafepress_api.rb CHANGED
@@ -19,6 +19,11 @@ require 'open-uri'
19
19
  module CafePressAPI
20
20
  RESULTS_PER_PAGE = 100
21
21
 
22
+ #Generates a url to add one product to a CafePress cart.
23
+ def self.add_to_cart_url(product_id, size, color, quantity, keep_shopping_url)
24
+ "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
+ end
26
+
22
27
  def self.user_token(app_key = ENV['cp_app_key'], email = ENV['cp_email'], password = ENV['cp_password'])
23
28
  content = ''
24
29
  open("http://open-api.cafepress.com/authentication.getUserToken.cp?appKey=#{app_key}&email=#{email}&password=#{password}") do |s| content = s.read 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: 25
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 0.0.3
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Benjamin Lee Smith