Class: SBroker
- Inherits:
-
Object
- Object
- SBroker
- Defined in:
- lib/servicebroker/broker.rb
Constant Summary collapse
- SERVICE_BROKER_ROOT =
File.dirname(__FILE__)
- XSL_ROOT =
File.join(SERVICE_BROKER_ROOT, 'xsl')
- MOCK_ROOT =
File.join(SERVICE_BROKER_ROOT, 'mocks')
Class Method Summary collapse
- .ApplyTransform(xml, transform, code) ⇒ Object
- .ExtractSectionPremium(xml, response_xml) ⇒ Object
- .GetMockRatingResponse(mockFile) ⇒ Object
- .InvokeRTE(msg) ⇒ Object
- .RequestRatingService(process, product, full, partial, knockout) ⇒ Object
Class Method Details
.ApplyTransform(xml, transform, code) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/servicebroker/broker.rb', line 27 def self.ApplyTransform(xml,transform,code) require 'xml/xslt' xslt = XML::XSLT.new() xslt.xml = xml xslt.xsl = File.join(XSL_ROOT, transform) if (code != nil) then xslt.parameters = { "code" => "#{code}" } end transformed_xml = xslt.serve() transformed_xml end |
.ExtractSectionPremium(xml, response_xml) ⇒ Object
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 67 68 |
# File 'lib/servicebroker/broker.rb', line 40 def self.ExtractSectionPremium(xml,response_xml) begin #expects a standard format message with a code value in #will be ok since all the schemas are derived from the #formal polaris library transformed_xml = SBroker.ApplyTransform(xml,"extractCode.xsl",nil) if (transformed_xml == nil) transformed_xml = SBroker.ApplyTransform(xml,"extractDescription.xsl",nil) end msg = transformed_xml.strip vals = msg.split('>') #get some odd initial character here...quick hack to remove it #need to figure out what it is code = vals[1][1,vals[1].length] #now extract the premium from the response #this approach is taken so that the xslt can hide the nasties of a none XML dictionary #TODO: provide a XSLT conversation on the way back from thre RTE transformed_xml = SBroker.ApplyTransform(response_xml,"extractPremium.xsl",code) msg = transformed_xml.strip vals = msg.split('>') #get some odd initial character here...quick hack to remove it #need to figure out what it is premium = vals[1][1,vals[1].length] rescue Exception => e puts "THE SECTION PREMIUM ERROR'ED WITH:#{e.}" end end |
.GetMockRatingResponse(mockFile) ⇒ Object
70 71 72 73 |
# File 'lib/servicebroker/broker.rb', line 70 def self.GetMockRatingResponse(mockFile) quote = open("#{MOCK_ROOT}/" + mockFile) {|f| f.read } quote.to_s end |
.InvokeRTE(msg) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/servicebroker/broker.rb', line 20 def self.InvokeRTE(msg) Net::HTTP.start(APP_CONFIG['rte_restful_ip'], 80) do |http| response = http.post('/RestfulXRTE.ashx/quote',msg) response.body end end |
.RequestRatingService(process, product, full, partial, knockout) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/servicebroker/broker.rb', line 12 def self.RequestRatingService(process,product,full,partial,knockout) open("#{PRODUCTS_ROOT}/#{product}/dsl.rb") {|f| @contents = f.read } script = @contents.to_s mycmd = RatingEngineResolver.execute(script) cmd = eval(mycmd) cmd end |