Lulu.com is a print publisher.
This Ruby / Rails library helps you interact with their website.
The API lets you:
-
place orders
-
add this to your Gemfile
gem "lulu_remote", :git =>"http://github.com/TJamesCorcoran/lulu_remote"
-
at the command line type
sudo apt-get install qt5-qmake bundle install
-
get a username and password from Lulu
-
Using credentials from previous step, add this to your config/application.rb
LuluRemote.configure do |config| config.username = 'tru<x>' config.password = '<y>' end
-
That’s it. You can now begin interacting with the Lulu website programatically. Here’s a sample program to get you started:
B1_HARD = "http://www.lulu.com/shop/travis-j-i-corcoran/book-1-hardcover/hardcover/product-23262551.html" B2_HARD = "http://www.lulu.com/shop/travis-j-i-corcoran/book-2-hardcover/hardcover/product-23262547.html"
def error_check(ret) if ! ret puts “*** #{ret}” end end
LuluRemote.login do ret = LuluRemote.empty_cart error_check(ret) ret = LuluRemote.add_book_to_cart(B1_HARD) error_check(ret) ret = LuluRemote.add_coupon("LULU15") error_check(ret) ret = LuluRemote.start_checkout error_check(ret) ret = LuluRemote.add_address("Random Eddie", "100 Quaker St", nil, "Weare", "NH", "02474", "603 529 3462", "US") error_check(ret) ret = LuluRemote.choose_shipping_option error_check(ret) ret = LuluRemote.billing("621") error_check(ret) ret = LuluRemote.review error_check(ret) puts "order = #{ret[:order_num]} ; price = #{ ret[:total_price].to_currency}" end
To develop this library
cd <location> rails new <fake_app_name> cd <fake_app_name> edit Gemfile to contain gem "lulu_remote", :path => "/home/tjic/personal/writing/ari/src/lulu_remote/Gemfile" rails console LuluRemote.login
# # LuluRemote.get_lulu_release_dates(["JAN152628", "JAN152627"] ) => {"JAN152628"=>Wed, 04 Mar 2015, "JAN152627"=>Wed, 04 Mar 2015}