Class: RBC

Inherits:
Object
  • Object
show all
Includes:
BSIServices, RBCVersion
Defined in:
lib/rbc.rb

Constant Summary collapse

BSI_INSTANCES =
{
  'mirror'     => 'https://websvc-mirror.bsisystems.com:2271/bsi/xmlrpc',
  'staging'    => 'https://websvc-mirror.bsisystems.com:2271/bsi/xmlrpc',
  'production' => 'https://websvc.bsisystems.com:2262/bsi/xmlrpc'
}

Constants included from RBCVersion

RBCVersion::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(creds, options = {:debug=>false, :stealth=>false, :instance=>:mirror}) ⇒ RBC

Initialize connection based on provided credentials

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rbc.rb', line 24

def initialize(creds, options={:debug=>false, :stealth=>false, :instance=>:mirror})
  options[:stealth]   ||= false
  options[:instance]  ||= 'mirror'
  raise ArgumentError, """
No credentials hash provided, expected a hash in the form of:
{
  :user     => 'username',
  :pass     => 'password',
  :server   => 'MYBSIDATABASE',
}
  """ if creds.class != Hash || creds[:user].nil? || creds[:pass].nil? || creds[:server].nil?

  options[:url] ||= BSI_INSTANCES[options[:instance].to_s]
  @url_target = options[:url]
  if options[:stealth]==false && @url_target.nil?
    raise ArgumentError, 'Please provide either a valid instance key or specify a custom url using option key :url => \'https://...\''
  end

  self.session_id = creds[:session_id] if creds[:session_id]
  services = YAML::load(File.open(File.join(File.dirname(__FILE__), 'service_spec.yaml')))
  (services.keys).each do |k|
    instance_eval(
      "self.#{k} = #{k.to_s.capitalize}.new(creds, options.merge( { :methods => services[k][:methods] } ) )"
    )
  end

  @test       = Test.new(creds, options)
  @common     = Common.new(creds, options)
=begin
  # Initialize BSI service connection adaptors
  @attachment = Attachment.new(creds, options.merge({:methods => %w(download) } ) )
  @batch      = Batch.new(creds, options.merge( { :methods => %w(addVials commit create delete get getBatchProperties getHeaders getVialProperties performL1Checks performL2Checks removeVials update updateVials reserveAvailableBsiIds)}) )
  @database   = Database.new(creds, options.merge( { :methods => %w(getFields getTables normalizeValues)}) )
  @shipment   = Shipment.new(creds, options.merge( { :methods => %w(getProperties getShipment submit update uploadManifest updateDiscrepancyResolutionSuggestions)}) )
  @requisition= Requisition.new(creds, options.merge( { :methods => %w(addVials getAttachments getProperties getReqDiscrepancies removeVials save submit submitSavedRequisitions update updateDiscrepancyResolutions updatePriorities uploadAttachment uploadManifest)}) )
  @reults     = Report.new(creds, options.merge( { :methods => %w(createResultsBatch)}) )
  @report     = Report.new(creds, options.merge( { :methods => %w(count execute)}) )
  @study      = Study.new(creds, options.merge( { :methods => %w(getAttachments)}) )
  @user       = User.new(creds, options.merge( { :methods => %w(authorize create getInfo update)}) )
  @subject    = Subject.new(creds, options.merge( { :methods => %w(deleteSubject getAttachments getSubject getSubjectProperties performL1Checks performL2Checks saveNewSubject saveSubject)}) )
=end
  @common.logon if @session_id.nil?
end

Instance Attribute Details

#commonObject

Returns the value of attribute common.



14
15
16
# File 'lib/rbc.rb', line 14

def common
  @common
end

#credsObject

Returns the value of attribute creds.



14
15
16
# File 'lib/rbc.rb', line 14

def creds
  @creds
end

#session_idObject

Returns the value of attribute session_id.



14
15
16
# File 'lib/rbc.rb', line 14

def session_id
  @session_id
end

#testObject

Returns the value of attribute test.



14
15
16
# File 'lib/rbc.rb', line 14

def test
  @test
end

#url_targetObject

Returns the value of attribute url_target.



14
15
16
# File 'lib/rbc.rb', line 14

def url_target
  @url_target
end