Module: Elibri::Connect

Defined in:
lib/elibri_connect.rb,
lib/generators/elibri/connect/config/config_generator.rb,
lib/generators/elibri/connect/install/install_generator.rb,
lib/generators/elibri/connect/whenever/whenever_generator.rb,
lib/generators/elibri/connect/db_structure/db_structure_generator.rb

Defined Under Namespace

Classes: ConfigGenerator, DbStructureGenerator, InstallGenerator, WheneverGenerator

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_versionObject

Returns the value of attribute api_version.



12
13
14
# File 'lib/elibri_connect.rb', line 12

def api_version
  @api_version
end

.loginObject

Returns the value of attribute login.



12
13
14
# File 'lib/elibri_connect.rb', line 12

def 
  @login
end

.onix_dialectObject

Returns the value of attribute onix_dialect.



12
13
14
# File 'lib/elibri_connect.rb', line 12

def onix_dialect
  @onix_dialect
end

.passwordObject

Returns the value of attribute password.



12
13
14
# File 'lib/elibri_connect.rb', line 12

def password
  @password
end

.product_modelObject

Returns the value of attribute product_model.



12
13
14
# File 'lib/elibri_connect.rb', line 12

def product_model
  @product_model
end

.test_modeObject

Returns the value of attribute test_mode.



12
13
14
# File 'lib/elibri_connect.rb', line 12

def test_mode
  @test_mode
end

.tracing_objectObject

Returns the value of attribute tracing_object.



12
13
14
# File 'lib/elibri_connect.rb', line 12

def tracing_object
  @tracing_object
end

Class Method Details

.api_clientObject



19
20
21
22
# File 'lib/elibri_connect.rb', line 19

def self.api_client
  Elibri::ApiClient.new(:login => , :password => password, 
                        :api_version => api_version, :onix_dialect => onix_dialect)
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



15
16
17
# File 'lib/elibri_connect.rb', line 15

def self.setup(&block)
  yield self
end

.update_products(refill_queue = false) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/elibri_connect.rb', line 24

def self.update_products(refill_queue = false)
  if test_mode
    book = Elibri::XmlMocks::Examples.book_example
    (self.product_model).to_s.capitalize.constantize.batch_create_or_update_from_elibri(Elibri::ONIX::XMLGenerator.new(book).to_s)
  else
    api = Elibri::ApiClient.new(:login => , :password => password, 
                                :api_version => api_version, :onix_dialect => onix_dialect)

    api.refill_all_queues! if refill_queue
    while (queue = api.pending_queues.find { |q| q.name == 'meta' })
      response = api.pop_from_queue('meta', :count => 25)                            
      (self.product_model).to_s.capitalize.constantize.batch_create_or_update_from_elibri(response.onix, self.tracing_object)
    end
  end
end

.update_products!Object



40
41
42
# File 'lib/elibri_connect.rb', line 40

def self.update_products!
  self.update_products(true)
end