Skip to content

Instantly share code, notes, and snippets.

@stephaniewilkinson
Last active July 24, 2017 17:21
Show Gist options
  • Select an option

  • Save stephaniewilkinson/f8b77fec9ecc710374d4b1bc2c62dfa3 to your computer and use it in GitHub Desktop.

Select an option

Save stephaniewilkinson/f8b77fec9ecc710374d4b1bc2c62dfa3 to your computer and use it in GitHub Desktop.
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