iab-BrokerAdapters 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/kerrylondon.rb +213 -0
  2. metadata +73 -0
@@ -0,0 +1,213 @@
1
+ require 'net/http'
2
+ require 'hpricot'
3
+
4
+
5
+ class Kerrylondon
6
+
7
+ def Kerrylondon.defaultData
8
+ {'SOF'=>'STATEMENT',
9
+ 'AgreetoSOF'=>1,
10
+ 'sofreason'=>'&endorsement',
11
+ 'insured1'=> 'Hamilton Nash 8',
12
+ 'clientadd1'=> 'Garden Cottage',
13
+ 'clientadd2'=>'',
14
+ 'clienttown'=>'',
15
+ 'clientCounty'=>'',
16
+ 'clientPostcode'=>'LA6 2RZ',
17
+ 'trade'=>'805',
18
+ 'clientnewventure'=>0,
19
+ 'clientyib'=>255,
20
+ 'clientexperience'=>'',
21
+ 'clienthealth'=>1,
22
+ 'clienthsdetails'=>'',
23
+ 'clientupdate'=>1,
24
+ 'clientupdatedetails'=>'',
25
+ 'clientrisk'=>1,
26
+ 'clientriskdetails'=>'',
27
+ 'clientoutsideuk'=>0,
28
+ 'clientoutsideukdets'=>'',
29
+ 'clientlocation'=>0,
30
+ 'clientlocationdets'=>'',
31
+ 'clienttradeass'=>0,
32
+ 'clienttradedets'=>'',
33
+ 'clientiso9002'=>0,
34
+ 'bfscins'=>1,
35
+ 'bfscinsdetails'=>'',
36
+ 'safety'=>1,
37
+ 'satefydets'=>'',
38
+ 'handling'=>1,
39
+ 'handlingdets'=>'',
40
+ 'clothing'=>1,
41
+ 'clothingdets'=>'',
42
+ 'hazard'=>0,
43
+ 'hazarddets'=>'',
44
+ 'pplamount'=>2,
45
+ 'pplotheramount'=>'',
46
+ 'pplheataway'=>0,
47
+ 'pplheatdesc'=>'',
48
+ 'pplheatturnover'=>'',
49
+ 'pplheatprecautions'=>'',
50
+ 'pplexcess'=>2,
51
+ 'estturnover'=>50000,
52
+ 'plemployees0'=>1,
53
+ 'plwageroll0'=>10000,
54
+ 'plwageroll1'=>0,
55
+ 'plwageroll2'=>0,
56
+ 'pltrade3'=>805,
57
+ 'plemployees3'=>1,
58
+ 'plwageroll3'=>10000,
59
+ 'plemployees4'=>0,
60
+ 'plwageroll4'=>0,
61
+ 'plwageroll5'=>0,
62
+ 'pltrade6'=>0,
63
+ 'plemployees6'=>0,
64
+ 'plwageroll6'=>0,
65
+ 'plemployees7'=>0,
66
+ 'plwageroll7'=>0,
67
+ 'plwageroll8'=>0,
68
+ 'pltrade9'=>0,
69
+ 'plemployees9'=>0,
70
+ 'plwageroll9'=>0,
71
+ 'plemployees10'=>0,
72
+ 'plwageroll10'=>0,
73
+ 'plemployees11'=>0,
74
+ 'plwageroll11'=>0,
75
+ 'contreq'=>0,
76
+ 'contmax'=>'',
77
+ 'contplant'=>'',
78
+ 'contplantmax'=>'',
79
+ 'conthiring'=>'',
80
+ 'conthiringmax'=>'',
81
+ 'contexcess'=>2,
82
+ 'quoteid'=>'',
83
+ 'lossturnover0'=>0,
84
+ 'losselpd0'=>0,
85
+ 'losselos0'=>0,
86
+ 'lossplpd0'=>0,
87
+ 'lossplos0'=>0,
88
+ 'losscarpd0'=>0,
89
+ 'losscaros0'=>0,
90
+ 'losstotal0'=>0,
91
+ 'lossturnover1'=>0,
92
+ 'losselpd1'=>0,
93
+ 'losselos1'=>0,
94
+ 'lossplpd1'=>0,
95
+ 'lossplos1'=>0,
96
+ 'losscarpd1'=>0,
97
+ 'losscaros1'=>0,
98
+ 'losstotal1'=>0,
99
+ 'lossturnover2'=>0,
100
+ 'losselpd2'=>0,
101
+ 'losselos2'=>0,
102
+ 'lossplpd2'=>0,
103
+ 'lossplos2'=>0,
104
+ 'losscarpd2'=>0,
105
+ 'losscaros2'=>0,
106
+ 'losstotal2'=>0,
107
+ 'lossturnover3'=>0,
108
+ 'losselpd3'=>0,
109
+ 'losselos3'=>0,
110
+ 'lossplpd3'=>0,
111
+ 'lossplos3'=>0,
112
+ 'losscarpd3'=>0,
113
+ 'losscaros3'=>0,
114
+ 'losstotal3'=>0,
115
+ 'lossturnover4'=>0,
116
+ 'losselpd4'=>0,
117
+ 'losselos4'=>0,
118
+ 'lossplpd4'=>0,
119
+ 'lossplos4'=>0,
120
+ 'losscarpd4'=>0,
121
+ 'losscaros4'=>0,
122
+ 'losstotal4'=>0,
123
+ 'claimdate1'=>'',
124
+ 'claimtype1'=>'',
125
+ 'claimpaid1'=>0,
126
+ 'claimos1'=>0,
127
+ 'claimdate2'=>'',
128
+ 'claimtype2'=>'',
129
+ 'claimpaid2'=>0,
130
+ 'claimos2'=>0,
131
+ 'claimdate3'=>'',
132
+ 'claimtype3'=>'',
133
+ 'claimpaid3'=>0,
134
+ 'claimos3'=>0
135
+ }
136
+ end
137
+
138
+ def Kerrylondon.keyfacts(data)
139
+ Kerrylondon.defaultData.merge(data)
140
+ end
141
+
142
+ def Kerrylondon.makeQuote(username,password,product,saveQuote,data)
143
+ result = ""
144
+ #commands needed to obtain quote
145
+ cmd1 = "username=#{username}&passwd=#{password}&Submit=Login"
146
+ cmd2 = "SelPackID=#{product}&submit=OK"
147
+
148
+ #commands needed to save quote
149
+ cmd4 = "insurer=lld&submit=Continue"
150
+ cmd5 = "nextaction=open&submit=Continue"
151
+
152
+ cmd3 = ""
153
+ data.each do |k,v|
154
+ cmd3 << "&#{k}=#{v}"
155
+ end
156
+
157
+ headers = {
158
+ 'Content-Type' => 'application/x-www-form-urlencoded',
159
+ 'Cookie' => 'PHPSESSID=jr0966pqcsqjcpgl57u4g4pcj0'
160
+ }
161
+ #if we omit Cookie from the header parms then the kerrylondon server will return one in the first call
162
+ #this then would have to be included since an authenticated session is associated with a unique
163
+ #string stored in the browsers cookie cache - stored forever I think!!!!
164
+ Net::HTTP.start('www.kluaonline.co.uk', 80) do |http|
165
+ resp ,data = http.post('/index.php?option=login',cmd1,headers)
166
+ resp ,data = http.post('/index.php?option=quotewizard&action=quotewizard',cmd2,headers)
167
+ resp ,data = http.post('/index.php?option=other&action=CSPCalcPremium',cmd3,headers)
168
+ result = Kerrylondon.findPremium(data)
169
+ # the following commands ensure the quote is saved to the quote db at kerrylondon
170
+ if saveQuote
171
+ puts "ATTENTION! - saving quote to kerrylondon DB"
172
+ resp ,data = http.post('/index.php?option=other&action=CSPquotedetails',cmd4,headers)
173
+ resp ,data = http.post('/index.php?option=other&action=CSPupdatequote',cmd5,headers)
174
+ end
175
+ end
176
+
177
+ result
178
+ end
179
+
180
+ def Kerrylondon.findPremium(data)
181
+ results = ""
182
+
183
+ doc = Hpricot(data)
184
+ divs = doc.search("//td[@class='infoBoxContents']")
185
+ if (divs.length > 1)
186
+ i = 0
187
+ name = ""
188
+ divs.each do |e|
189
+ i = i + 1
190
+ if i % 2 == 1
191
+ name = e.inner_html
192
+ next
193
+ end
194
+ results << "#{name.gsub("<b>","").gsub("</b>","")} = #{e.inner_html.gsub("<b>","").gsub("</b>","").gsub("&pound;","")} GBP\n"
195
+ end
196
+ else
197
+ #referral?
198
+ divs = doc.search("//td[@class='infoBoxContents2']")
199
+ divs.each do |e|
200
+ results << "#{e.inner_html}\n"
201
+ end
202
+ end
203
+
204
+ results
205
+ end
206
+
207
+ def Kerrylondon.dump(resp,data)
208
+ puts 'Code = ' + resp.code
209
+ puts 'Message = ' + resp.message
210
+ resp.each {|key, val| puts key + ' = ' + val}
211
+ puts "=================="
212
+ end
213
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iab-BrokerAdapters
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Gary Mawdsley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-31 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mime-types
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "1.15"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: diff-lcs
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.2
34
+ version:
35
+ description: BrokerAdapters provides a mechanism for obtaining rates via supplier web sites and xml gateways
36
+ email: garymawdsley@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - lib/kerrylondon.rb
45
+ has_rdoc: true
46
+ homepage: http://github.com/iab/BrokerAdapters
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --inline-source
50
+ - --charset=UTF-8
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project: BrokerAdapters
68
+ rubygems_version: 1.2.0
69
+ signing_key:
70
+ specification_version: 2
71
+ summary: BrokerAdapters provides a mechanism for obtaining rates via supplier web sites and xml gateways
72
+ test_files: []
73
+