gem 'elibri_api_client'
elibri = Elibri::ApiClient.new(:login => '1b20fa9d72234423979c', :password => '2847cbf4f15a4057e2ab', :api_version => 'v1', :onix_dialect => '3.0.1')
elibri.publishers.each do |publisher| puts "#{publisher.name}, #{publisher.city} (#{publisher.products_count} produktow)" publisher.products.each_with_index do |product, product_no| puts "\t#{product_no}. #{product.title}" # puts product.onix_xml end end
# Wypelnij wszystkie kolejki oczekujace, wszystkimi dostepnymi danymi. # Przydatne przy wykonywaniu pelnej synchronizacji pomiedzy nasza aplikacja a Elibri. elibri.refill_all_queues! elibri.pending_queues.each do |pending_queue| # Wykonuj blok, dopoki sa dane w kolejce pending_queue.each_pop(:count => 10) do |pop| next if pop.xml.blank? puts pop.onix.release pop.onix.products.each do |product| puts "#{product.record_reference} #{product.isbn13} #{product.publisher.name} #{product.full_title}" end end end
meta = elibri.pending_queues.find {|queue| queue.name == 'meta'} pop = meta.pop(:count => 5, :testing => true) pop.onix.products.each {|product| puts product.full_title } puts pop.xml last_pop = meta.last_pop
last_pop = elibri.last_pop_from_queue('meta')
Copyright © 2011 elibri.com.pl. See LICENSE.txt for further details.