Class: Kerrylondon
- Inherits:
-
Object
- Object
- Kerrylondon
- Defined in:
- lib/kerrylondon.rb
Class Method Summary collapse
- .defaultData ⇒ Object
- .dump(resp, data) ⇒ Object
- .findPremium(data) ⇒ Object
- .keyfacts(data) ⇒ Object
- .makeQuote(username, password, product, saveQuote, data) ⇒ Object
- .mapping ⇒ Object
Class Method Details
.defaultData ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/kerrylondon.rb', line 11 def Kerrylondon.defaultData {'SOF'=>'STATEMENT', 'AgreetoSOF'=>1, 'sofreason'=>'&endorsement', 'insured1'=> 'Hamilton Nash 8', 'clientadd1'=> 'Garden Cottage', 'clientadd2'=>'', 'clienttown'=>'', 'clientCounty'=>'', 'clientPostcode'=>'LA6 2RZ', 'trade'=>'805', 'clientnewventure'=>0, 'clientyib'=>255, 'clientexperience'=>'', 'clienthealth'=>1, 'clienthsdetails'=>'', 'clientupdate'=>1, 'clientupdatedetails'=>'', 'clientrisk'=>1, 'clientriskdetails'=>'', 'clientoutsideuk'=>0, 'clientoutsideukdets'=>'', 'clientlocation'=>0, 'clientlocationdets'=>'', 'clienttradeass'=>0, 'clienttradedets'=>'', 'clientiso9002'=>0, 'bfscins'=>1, 'bfscinsdetails'=>'', 'safety'=>1, 'satefydets'=>'', 'handling'=>1, 'handlingdets'=>'', 'clothing'=>1, 'clothingdets'=>'', 'hazard'=>0, 'hazarddets'=>'', 'pplamount'=>2, 'pplotheramount'=>'', 'pplheataway'=>0, 'pplheatdesc'=>'', 'pplheatturnover'=>'', 'pplheatprecautions'=>'', 'pplexcess'=>2, 'estturnover'=>50000, 'plemployees0'=>1, 'plwageroll0'=>10000, 'plwageroll1'=>0, 'plwageroll2'=>0, 'pltrade3'=>805, 'plemployees3'=>1, 'plwageroll3'=>10000, 'plemployees4'=>0, 'plwageroll4'=>0, 'plwageroll5'=>0, 'pltrade6'=>0, 'plemployees6'=>0, 'plwageroll6'=>0, 'plemployees7'=>0, 'plwageroll7'=>0, 'plwageroll8'=>0, 'pltrade9'=>0, 'plemployees9'=>0, 'plwageroll9'=>0, 'plemployees10'=>0, 'plwageroll10'=>0, 'plemployees11'=>0, 'plwageroll11'=>0, 'contreq'=>0, 'contmax'=>'', 'contplant'=>'', 'contplantmax'=>'', 'conthiring'=>'', 'conthiringmax'=>'', 'contexcess'=>2, 'quoteid'=>'', 'lossturnover0'=>0, 'losselpd0'=>0, 'losselos0'=>0, 'lossplpd0'=>0, 'lossplos0'=>0, 'losscarpd0'=>0, 'losscaros0'=>0, 'losstotal0'=>0, 'lossturnover1'=>0, 'losselpd1'=>0, 'losselos1'=>0, 'lossplpd1'=>0, 'lossplos1'=>0, 'losscarpd1'=>0, 'losscaros1'=>0, 'losstotal1'=>0, 'lossturnover2'=>0, 'losselpd2'=>0, 'losselos2'=>0, 'lossplpd2'=>0, 'lossplos2'=>0, 'losscarpd2'=>0, 'losscaros2'=>0, 'losstotal2'=>0, 'lossturnover3'=>0, 'losselpd3'=>0, 'losselos3'=>0, 'lossplpd3'=>0, 'lossplos3'=>0, 'losscarpd3'=>0, 'losscaros3'=>0, 'losstotal3'=>0, 'lossturnover4'=>0, 'losselpd4'=>0, 'losselos4'=>0, 'lossplpd4'=>0, 'lossplos4'=>0, 'losscarpd4'=>0, 'losscaros4'=>0, 'losstotal4'=>0, 'claimdate1'=>'', 'claimtype1'=>'', 'claimpaid1'=>0, 'claimos1'=>0, 'claimdate2'=>'', 'claimtype2'=>'', 'claimpaid2'=>0, 'claimos2'=>0, 'claimdate3'=>'', 'claimtype3'=>'', 'claimpaid3'=>0, 'claimos3'=>0 } end |
.dump(resp, data) ⇒ Object
224 225 226 227 228 229 |
# File 'lib/kerrylondon.rb', line 224 def Kerrylondon.dump(resp,data) puts 'Code = ' + resp.code puts 'Message = ' + resp. resp.each {|key, val| puts key + ' = ' + val} puts "==================" end |
.findPremium(data) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/kerrylondon.rb', line 184 def Kerrylondon.findPremium(data) results = "<PremiumQuoteBreakdown>" doc = Hpricot(data) divs = doc.search("//td[@class='infoBoxContents']") if (divs.length > 1) i = 0 name = "" divs.each do |e| i = i + 1 if i % 2 == 1 name = e.inner_html next end fieldName = "#{name.gsub("<b>","").gsub("</b>","")}" case fieldName when "Premium" then fieldName = "Amount" when "IPT" then fieldName = "IPTAmount" when "TOTAL PAYABLE" then fieldName = "GrossAmount" when "Documentation Fee" then fieldName = "DocumentationFee" end fieldValue = "#{e.inner_html.gsub("<b>","").gsub("</b>","").gsub("£","")}" results << "<#{fieldName}>#{fieldValue}</#{fieldName}>" end else #referral? divs = doc.search("//td[@class='infoBoxContents2']") divs.each do |e| results << "<GrossAmount>#{e.inner_html}</GrossAmount>" end end results << "</PremiumQuoteBreakdown>" results end |
.keyfacts(data) ⇒ Object
142 143 144 |
# File 'lib/kerrylondon.rb', line 142 def Kerrylondon.keyfacts(data) Kerrylondon.defaultData.merge(data) end |
.makeQuote(username, password, product, saveQuote, data) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/kerrylondon.rb', line 146 def Kerrylondon.makeQuote(username,password,product,saveQuote,data) result = "" #commands needed to obtain quote cmd1 = "username=#{username}&passwd=#{password}&Submit=Login" cmd2 = "SelPackID=#{product}&submit=OK" #commands needed to save quote cmd4 = "insurer=lld&submit=Continue" cmd5 = "nextaction=open&submit=Continue" cmd3 = "" data.each do |k,v| cmd3 << "&#{k}=#{v}" end headers = { 'Content-Type' => 'application/x-www-form-urlencoded', 'Cookie' => 'PHPSESSID=jr0966pqcsqjcpgl57u4g4pcj0' } #if we omit Cookie from the header parms then the kerrylondon server will return one in the first call #this then would have to be included since an authenticated session is associated with a unique #string stored in the browsers cookie cache - stored forever I think!!!! Net::HTTP.start('www.kluaonline.co.uk', 80) do |http| resp ,data = http.post('/index.php?option=login',cmd1,headers) resp ,data = http.post('/index.php?option=quotewizard&action=quotewizard',cmd2,headers) resp ,data = http.post('/index.php?option=other&action=CSPCalcPremium',cmd3,headers) result = Kerrylondon.findPremium(data) # the following commands ensure the quote is saved to the quote db at kerrylondon if saveQuote puts "ATTENTION! - saving quote to kerrylondon DB" resp ,data = http.post('/index.php?option=other&action=CSPquotedetails',cmd4,headers) resp ,data = http.post('/index.php?option=other&action=CSPupdatequote',cmd5,headers) end end result end |
.mapping ⇒ Object
7 8 9 |
# File 'lib/kerrylondon.rb', line 7 def Kerrylondon.mapping {"Turnover" => "estturnover","ManualWages" => "plwageroll0"} end |