Last active
July 24, 2017 17:21
-
-
Save stephaniewilkinson/f8b77fec9ecc710374d4b1bc2c62dfa3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HTTP.basic_auth(auth).persistent(BOOKMOOCH_URI) do |http| | |
| if isbns_and_image_urls | |
| def post_to_bookmooch(isbn, image_url,title) | |
| ... | |
| end | |
| pool = ConnectionPool.new(size: 5, timeout: 5) do | |
| HTTP.persistent("https://bookmooch.com/....") | |
| end | |
| isbns_and_image_urls.each do |isbn, image_url, title| | |
| params = {asins: isbn, target: 'wishlist', action: 'add'} | |
| puts "Params: #{URI.encode_www_form params}" | |
| puts 'Adding to wishlist with bookmooch api...' | |
| response = http.get '/api/userbook', params: params | |
| if response.body.to_s.strip == isbn | |
| @books_added << [title, image_url] | |
| else | |
| @books_failed << [title, image_url] | |
| end | |
| end | |
| else | |
| r.redirect '/books' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment