class RBC
Constants
- BSI_INSTANCES
Attributes
common[RW]
creds[RW]
session_id[RW]
test[RW]
url_target[RW]
Public Class Methods
new(creds, options={:debug=>false, :stealth=>false, :instance=>:mirror})
click to toggle source
Initialize connection based on provided credentials
# 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