Elibri Connect gem
Continuous integration status
Gem designed to allow easy addition of elibri based product system to your application. Currently tested and supported 1.8.7 versions of ruby (MRI, rbx, REE).
gem 'elibri_connect'to you Gemfile
Now - depending on your situation you may choose one of four options:
rails generate elibri:connect:configto create only configuration file in initializers, in which you need to supply your own user/password combination.
rails generate elibri:connect:db_structureto create db structure and models (product, contributor and product_text), which will have turned on elibri synchronisation.
rails generate elibri:connect:wheneverto create config/schedule.rb file, which will invoke elibri sync every 6 hours. It will overwrite your actual config/schedule.rb - so please be careful.
rails generate elibri:connect:installwhich will invoke all three previous generators.
If you have working application, and you need to add support to existing product model - please look here for more information about adding acts_as_elibri_product declaration to model (including traverse vector examples): elibri/acts_as_elibri_product
After creation of config file, gem will provide you with rake task:
rake elibri:update_products which will connect to elibri, download new and update existing product. You can also use it from your code using
If you need to access raw api client - you can get it by invoking
Gem has additional mode of operation called test_mode - you can get into it, by setting
test_mode=true inside configuration file. When using it your application will not connect to elibri, instead it will use elibri_xml_mocks to mock and create product for your app.
Also when installed elibri_connect you will receive method to look into related products imported from elibri. There is one to many relationship between product and related_products. You can use it, like this:
product.related_products #list of related objects product.related_products.objects #list of actual products related to our product.related_products.first.object #actual product that is related
Anatomy of config file
Config file looks like this, and needs to be in config/initializers directory (generate command can provide one for you):
Elibri::Connect.setup do |config| config.login = your elibri api login here config.password = your elibri api password here config.api_version = 'v1' #api_version - doesn't need to be changed config.onix_dialect = '3.0.1' #onix_dialect - doesn't need to be changed config.product_model = :product #if you use other model than product - you need to set different name here config.test_mode = true #- add this line to config if you want to avoid connecting to elibri and use mocked data end