lexis_nexis_api 1.0.4
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.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/README.md +2 -0
- data/Rakefile +2 -0
- data/doc/AdminRequest.xsd +47 -0
- data/doc/AdminResponse.xsd +64 -0
- data/doc/CPBackgroundReports.xsd +55 -0
- data/doc/CPScreenings.xsd +1762 -0
- data/doc/admin.wsdl +57 -0
- data/lexis_nexis_api.gemspec +27 -0
- data/lib/lexis_nexis_api/background_check.rb +309 -0
- data/lib/lexis_nexis_api/password_change.rb +65 -0
- data/lib/lexis_nexis_api/remote_actions.rb +116 -0
- data/lib/lexis_nexis_api/version.rb +3 -0
- data/lib/lexis_nexis_api/xml_helper.rb +26 -0
- data/lib/lexis_nexis_api/xml_samples.rb +50 -0
- data/lib/lexis_nexis_api.rb +124 -0
- data/test/background_check_test.rb +304 -0
- data/test/lexis_nexis_api_test.rb +70 -0
- data/test/password_change_test.rb +32 -0
- data/test/remote_actions_test.rb +47 -0
- data/test/test_helper.rb +143 -0
- metadata +134 -0
data/doc/admin.wsdl
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<wsdl:definitions
|
3
|
+
targetNamespace="http://www.cpscreen.com/schemas"
|
4
|
+
xmlns:tns="http://www.cpscreen.com/schemas"
|
5
|
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
6
|
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
7
|
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
8
|
+
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
9
|
+
<wsdl:types>
|
10
|
+
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.cpscreen.com/schemas">
|
11
|
+
<xs:include schemaLocation="AdminRequest.xsd"/>
|
12
|
+
<xs:include schemaLocation="AdminResponse.xsd"/>
|
13
|
+
</xs:schema>
|
14
|
+
</wsdl:types>
|
15
|
+
<wsdl:message name="AdminRequestMessage">
|
16
|
+
<wsdl:part name="Message" element="tns:ChoicePointAdminRequest"/>
|
17
|
+
</wsdl:message>
|
18
|
+
<wsdl:message name="AdminResponseMessage">
|
19
|
+
<wsdl:part name="Message" element="tns:ChoicePointAdminResponse"/>
|
20
|
+
</wsdl:message>
|
21
|
+
<wsdl:portType name="AdminInterface">
|
22
|
+
<wsdl:operation name="ChangePasswords">
|
23
|
+
<wsdl:input message="tns:AdminRequestMessage"/>
|
24
|
+
<wsdl:output message="tns:AdminResponseMessage"/>
|
25
|
+
</wsdl:operation>
|
26
|
+
<wsdl:operation name="GetPackages">
|
27
|
+
<wsdl:input message="tns:AdminRequestMessage"/>
|
28
|
+
<wsdl:output message="tns:AdminResponseMessage"/>
|
29
|
+
</wsdl:operation>
|
30
|
+
</wsdl:portType>
|
31
|
+
<wsdl:binding name="AdminSoapHttpBinding" type="tns:AdminInterface">
|
32
|
+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
33
|
+
<wsdl:operation name="ChangePasswords">
|
34
|
+
<soap:operation soapAction="http://www.cpscreen.com/pub/xchange/admin/ChangePasswords"/>
|
35
|
+
<wsdl:input>
|
36
|
+
<soap:body use="literal"/>
|
37
|
+
</wsdl:input>
|
38
|
+
<wsdl:output>
|
39
|
+
<soap:body use="literal"/>
|
40
|
+
</wsdl:output>
|
41
|
+
</wsdl:operation>
|
42
|
+
<wsdl:operation name="GetPackages">
|
43
|
+
<soap:operation soapAction="http://www.cpscreen.com/pub/xchange/admin/GetPackages"/>
|
44
|
+
<wsdl:input>
|
45
|
+
<soap:body use="literal"/>
|
46
|
+
</wsdl:input>
|
47
|
+
<wsdl:output>
|
48
|
+
<soap:body use="literal"/>
|
49
|
+
</wsdl:output>
|
50
|
+
</wsdl:operation>
|
51
|
+
</wsdl:binding>
|
52
|
+
<wsdl:service name="AdminService">
|
53
|
+
<wsdl:port name="AdminEndpoint" binding="tns:AdminSoapHttpBinding">
|
54
|
+
<soap:address location="https://www.cpscreen.com/pub/xchange/admin"/>
|
55
|
+
</wsdl:port>
|
56
|
+
</wsdl:service>
|
57
|
+
</wsdl:definitions>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "lexis_nexis_api/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "lexis_nexis_api"
|
7
|
+
s.version = LexisNexisApi::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jeff Emminger"]
|
10
|
+
s.email = ["jeff@7compass.com"]
|
11
|
+
s.homepage = "http://github.com/7compass/lexis_nexis_api"
|
12
|
+
s.summary = %q{Lexis Nexis Api gem}
|
13
|
+
s.description = %q{}
|
14
|
+
|
15
|
+
s.rubyforge_project = "lexis_nexis_api"
|
16
|
+
|
17
|
+
s.add_runtime_dependency("nokogiri")
|
18
|
+
s.add_runtime_dependency("net/http")
|
19
|
+
s.add_runtime_dependency("net/https")
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
|
26
|
+
s.license = 'MIT'
|
27
|
+
end
|
@@ -0,0 +1,309 @@
|
|
1
|
+
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module LexisNexisApi
|
5
|
+
|
6
|
+
class BackgroundCheck
|
7
|
+
extend XmlHelper
|
8
|
+
|
9
|
+
#
|
10
|
+
# PRI-FAM:
|
11
|
+
# PRI-FFM:
|
12
|
+
# PRI-FIM:
|
13
|
+
# PRINCRF:
|
14
|
+
# PRINCRP:
|
15
|
+
# PersonalData/PersonName
|
16
|
+
# PersonalData/PostalAddress
|
17
|
+
#
|
18
|
+
# SSNV:
|
19
|
+
# PersonalData/DemographicDetail
|
20
|
+
#
|
21
|
+
# MVR:
|
22
|
+
# PersonalData/Licenses
|
23
|
+
#
|
24
|
+
|
25
|
+
|
26
|
+
# combos
|
27
|
+
# 2112 = Package 1 = PRI-FIM, PRINCRF, PRINCRP, SSNV
|
28
|
+
# 2113 = Package 2 = PRI-FAM, PRINCRP, SSNV
|
29
|
+
# 2114 = Package 3 = MVR, PRINCRP, SSNV
|
30
|
+
#
|
31
|
+
# ala carte
|
32
|
+
# 2116 = Package 5 = MVR only
|
33
|
+
# 2117 = Package 6 = PRINCRP
|
34
|
+
# 2168 = Package 7 = PRI-FFM, SSNV
|
35
|
+
# 2169 = Package 9 = PRI-FFM
|
36
|
+
# 2360 = Package 14 = PRI-FAM
|
37
|
+
#
|
38
|
+
#
|
39
|
+
# 2011-02-22:
|
40
|
+
# Package 1 can logically be ordered with 5,9 & 14
|
41
|
+
# Package 2 can logically be ordered with 5 & 9
|
42
|
+
# Package 3 can logically be ordered with 9 & 14
|
43
|
+
# Any combination of 5,6,7,9 & 14 could be ordered.
|
44
|
+
#
|
45
|
+
#
|
46
|
+
def self.for_package(package_id, options)
|
47
|
+
package_id = package_id.to_i
|
48
|
+
|
49
|
+
background_check = self.new(options.merge(:package_id => package_id))
|
50
|
+
|
51
|
+
background_check.add_ssnv # required for one-step orders
|
52
|
+
|
53
|
+
background_check.add_name_and_address if [2112, 2113, 2114, 2116, 2117, 2168, 2169, 2360].include?(package_id)
|
54
|
+
background_check.add_mvr if [2114, 2116].include?(package_id)
|
55
|
+
|
56
|
+
background_check
|
57
|
+
end
|
58
|
+
|
59
|
+
def initialize(options={})
|
60
|
+
@options = options
|
61
|
+
@xml = create_root
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# <BackgroundCheck
|
67
|
+
# xmlns="http://www.cpscreen.com/schemas"
|
68
|
+
# userId="XCHANGE"
|
69
|
+
# account="#{@account}"
|
70
|
+
# password="#{@password}">
|
71
|
+
# <BackgroundSearchPackage xmlns="">
|
72
|
+
# <PackageInformation>
|
73
|
+
# <PositionAppliedFor>Current InterVarsity Staff</PositionAppliedFor>
|
74
|
+
# <PackageId>#{options[:package_id]}</PackageId>
|
75
|
+
# <ClientReferences>
|
76
|
+
# <ClientReference>Region: Graduate & Faculty Ministry North Atlantic</ClientReference>
|
77
|
+
# <ClientReference>Washington, DC</ClientReference>
|
78
|
+
# </ClientReferences>
|
79
|
+
# <OrderAccount>
|
80
|
+
# <UserId></UserId>
|
81
|
+
# <Account></Account>
|
82
|
+
# </OrderAccount>
|
83
|
+
# </PackageInformation>
|
84
|
+
# <PersonalData>
|
85
|
+
# <ContactMethod>
|
86
|
+
# <InternetEmailAddress></InternetEmailAddress>
|
87
|
+
# </ContactMethod>
|
88
|
+
# </PersonalData>
|
89
|
+
# </BackgroundSearchPackage>
|
90
|
+
# </BackgroundCheck>
|
91
|
+
#
|
92
|
+
def create_root
|
93
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
94
|
+
xml.BackgroundCheck(
|
95
|
+
:xmlns => 'http://www.cpscreen.com/schemas',
|
96
|
+
:userId => 'XCHANGE',
|
97
|
+
:account => @options[:account],
|
98
|
+
:password => @options[:password]
|
99
|
+
){
|
100
|
+
xml.BackgroundSearchPackage(:xmlns => ''){
|
101
|
+
xml.PackageInformation{
|
102
|
+
xml.PositionAppliedFor @options[:position_applied_for]
|
103
|
+
xml.PackageId @options[:package_id]
|
104
|
+
xml.ClientReferences{
|
105
|
+
xml.ClientReference @options[:client_reference1]
|
106
|
+
xml.ClientReference @options[:order_as_user_id]
|
107
|
+
}
|
108
|
+
xml.OrderAccount{
|
109
|
+
xml.UserId 'XCHANGE'
|
110
|
+
xml.Account "#{@options[:account]}#{@options[:order_as_account_suffix]}"
|
111
|
+
} if @options[:order_as_account_suffix]
|
112
|
+
}
|
113
|
+
xml.PersonalData{
|
114
|
+
xml.ContactMethod{
|
115
|
+
xml.InternetEmailAddress @options[:contact_email]
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
builder.to_xml
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# Optional element:
|
127
|
+
# /BackgroundCheck/BackgroundSearchPackage/PersonalData/Licenses
|
128
|
+
#
|
129
|
+
# Contains 0*
|
130
|
+
# /BackgroundCheck/BackgroundSearchPackage/PersonalData/Licenses/License
|
131
|
+
#
|
132
|
+
# options should contain:
|
133
|
+
# licenses: an array of license info hashes
|
134
|
+
#
|
135
|
+
# license info hash:
|
136
|
+
# :valid_from datetime or string YYYY-MM-DD
|
137
|
+
# :valid_to datetime or string YYYY-MM-DD
|
138
|
+
# :country_code 2 char ISO country code
|
139
|
+
# :license_number AN 1..20
|
140
|
+
# :license_region 2 char State/Region
|
141
|
+
#
|
142
|
+
def add_mvr
|
143
|
+
builder = Nokogiri::XML::Builder.with(personal_data_node) do |xml|
|
144
|
+
xml.Licenses {
|
145
|
+
@options[:licenses].each do |hash|
|
146
|
+
xml.License(:validFrom => ymd(hash[:valid_from]), :validTo => ymd(hash[:valid_to])) {
|
147
|
+
xml.CountryCode(hash[:country_code])
|
148
|
+
xml.LicenseNumber(hash[:license_number])
|
149
|
+
xml.LicenseName 'mvr'
|
150
|
+
xml.LicenseDescription 'mvr'
|
151
|
+
xml.LicenseRegion hash[:license_region] # State
|
152
|
+
}
|
153
|
+
end
|
154
|
+
}
|
155
|
+
end
|
156
|
+
|
157
|
+
@xml = builder.to_xml
|
158
|
+
end
|
159
|
+
|
160
|
+
#
|
161
|
+
# expects an array of :person_names in @options
|
162
|
+
# expects an array of :postal_addresses in @options
|
163
|
+
#
|
164
|
+
# <PersonName type="subject|alias">
|
165
|
+
# <GivenName>Kevin</GivenName>
|
166
|
+
# <MiddleName>Fred</MiddleName>
|
167
|
+
# <FamilyName>Test</FamilyName>
|
168
|
+
# </PersonName>
|
169
|
+
# <PostalAddress type="current|prior" validFrom="2009-01-01">
|
170
|
+
# <Municipality>Madison</Municipality>
|
171
|
+
# <Region>WI</Region>
|
172
|
+
# <PostalCode>53711</PostalCode>
|
173
|
+
# <CountryCode>US</CountryCode>
|
174
|
+
# <DeliveryAddress>
|
175
|
+
# <AddressLine>1234 Main Rd</AddressLine>
|
176
|
+
# </DeliveryAddress>
|
177
|
+
# </PostalAddress>
|
178
|
+
def add_name_and_address
|
179
|
+
builder = Nokogiri::XML::Builder.with(personal_data_node) do |xml|
|
180
|
+
@options[:person_names].each do |hash|
|
181
|
+
xml.PersonName(:type => hash[:type]){
|
182
|
+
xml.GivenName hash[:first_name]
|
183
|
+
xml.MiddleName hash[:middle_name]
|
184
|
+
xml.FamilyName hash[:last_name]
|
185
|
+
}
|
186
|
+
end if @options[:person_names]
|
187
|
+
|
188
|
+
@options[:postal_addresses].each do |hash|
|
189
|
+
xml.PostalAddress(:type => hash[:type], :validFrom => ymd(hash[:valid_from]), :validTo => ymd(hash[:valid_to])){
|
190
|
+
xml.Municipality hash[:municipality]
|
191
|
+
xml.Region hash[:region]
|
192
|
+
xml.PostalCode hash[:postal_code]
|
193
|
+
xml.CountryCode hash[:country_code]
|
194
|
+
xml.DeliveryAddress{
|
195
|
+
xml.AddressLine hash[:address1]
|
196
|
+
xml.AddressLine(hash[:address2]) if hash[:address2].present?
|
197
|
+
}
|
198
|
+
}
|
199
|
+
end if @options[:postal_addresses]
|
200
|
+
end
|
201
|
+
|
202
|
+
@xml = builder.to_xml
|
203
|
+
end
|
204
|
+
|
205
|
+
# <DemographicDetail>
|
206
|
+
# <GovernmentId issuingAuthority="SSN">123456789</GovernmentId>
|
207
|
+
# <DateOfBirth>1950-01-01</DateOfBirth>
|
208
|
+
# </DemographicDetail>
|
209
|
+
#
|
210
|
+
def add_ssnv
|
211
|
+
builder = Nokogiri::XML::Builder.with(personal_data_node) do |xml|
|
212
|
+
xml.DemographicDetail{
|
213
|
+
xml.GovernmentId(@options[:ssn], :issuingAuthority => 'SSN')
|
214
|
+
xml.DateOfBirth(ymd(@options[:date_of_birth]))
|
215
|
+
}
|
216
|
+
end
|
217
|
+
|
218
|
+
@xml = builder.to_xml
|
219
|
+
end
|
220
|
+
|
221
|
+
def to_xml
|
222
|
+
self.class.soap_wrapper(@xml)
|
223
|
+
end
|
224
|
+
|
225
|
+
protected
|
226
|
+
|
227
|
+
def doc
|
228
|
+
Nokogiri::XML(@xml)
|
229
|
+
end
|
230
|
+
|
231
|
+
def personal_data_node
|
232
|
+
doc.at('//xmlns:BackgroundCheck/BackgroundSearchPackage/PersonalData', 'xmlns' => 'http://www.cpscreen.com/schemas')
|
233
|
+
end
|
234
|
+
|
235
|
+
# expects a Time or DateTime
|
236
|
+
def ymd(date)
|
237
|
+
return date if date.is_a?(String)
|
238
|
+
date.strftime("%Y-%m-%d") if date
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
module XML
|
243
|
+
|
244
|
+
SAMPLE_ORDER_RESPONSE = %Q{<?xml version="1.0" encoding="UTF-8"?>
|
245
|
+
<soapenv:Envelope
|
246
|
+
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
247
|
+
xmlns:cp="http://www.cpscreen.com/schemas"
|
248
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
249
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
250
|
+
<soapenv:Body>
|
251
|
+
<BackgroundReports xmlns="http://www.cpscreen.com/schemas">
|
252
|
+
<BackgroundReportPackage type="report">
|
253
|
+
<ProviderReferenceId>WPS-6266154</ProviderReferenceId>
|
254
|
+
<PackageInformation>
|
255
|
+
<ClientReferences>
|
256
|
+
<ClientReference>Youth123456</ClientReference>
|
257
|
+
<ClientReference>CN=Youth Tester/O=Youth</ClientReference>
|
258
|
+
</ClientReferences>
|
259
|
+
<Quotebacks>
|
260
|
+
<Quoteback name="Youth-83SQ7J"/>
|
261
|
+
</Quotebacks>
|
262
|
+
</PackageInformation>
|
263
|
+
<PersonalData>
|
264
|
+
<PersonName type="subject">
|
265
|
+
<GivenName>Test</GivenName>
|
266
|
+
<FamilyName>Youth</FamilyName>
|
267
|
+
</PersonName>
|
268
|
+
<DemographicDetail>
|
269
|
+
<GovernmentId issuingAuthority="SSN">123456789</GovernmentId>
|
270
|
+
<DateOfBirth/>
|
271
|
+
<Gender>F</Gender>
|
272
|
+
</DemographicDetail>
|
273
|
+
</PersonalData>
|
274
|
+
<ScreeningStatus>
|
275
|
+
<OrderStatus>InProgress</OrderStatus>
|
276
|
+
</ScreeningStatus>
|
277
|
+
<ScreeningResults mediaType="html">
|
278
|
+
<InternetWebAddress>https://screentest.lexisnexis.com/pub/l/login/userLogin.do?referer=https://screentest.lexisnexis.com/pub/l/jsp/menu/orderViewingMenuFrameSet.jsp?key=123|ABCDEFG</InternetWebAddress>
|
279
|
+
</ScreeningResults>
|
280
|
+
</BackgroundReportPackage>
|
281
|
+
</BackgroundReports>
|
282
|
+
</soapenv:Body>
|
283
|
+
</soapenv:Envelope>
|
284
|
+
}
|
285
|
+
|
286
|
+
SAMPLE_USER_LOCKED_RESPONSE = %q[<?xml version="1.0" encoding="UTF-8"?>
|
287
|
+
<soapenv:Envelope
|
288
|
+
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
289
|
+
xmlns:cp="http://www.cpscreen.com/schemas"
|
290
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
291
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
292
|
+
<soapenv:Body>
|
293
|
+
<BackgroundReports xmlns="http://www.cpscreen.com/schemas">
|
294
|
+
<BackgroundReportPackage type="errors">
|
295
|
+
<ErrorReport>
|
296
|
+
<ErrorCode>210</ErrorCode>
|
297
|
+
<ErrorDescription>User is locked</ErrorDescription>
|
298
|
+
</ErrorReport>
|
299
|
+
</BackgroundReportPackage>
|
300
|
+
</BackgroundReports>
|
301
|
+
</soapenv:Body>
|
302
|
+
</soapenv:Envelope>
|
303
|
+
]
|
304
|
+
|
305
|
+
end # module XML
|
306
|
+
|
307
|
+
end # class BackgroundCheck
|
308
|
+
|
309
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module LexisNexisApi
|
5
|
+
|
6
|
+
class PasswordChange
|
7
|
+
extend XmlHelper
|
8
|
+
|
9
|
+
#
|
10
|
+
# options:
|
11
|
+
# :account
|
12
|
+
# :password
|
13
|
+
# :new_password
|
14
|
+
#
|
15
|
+
def initialize(account, password, new_password, subaccount=nil)
|
16
|
+
@account, @password, @new_password, @subaccount = account, password, new_password, subaccount
|
17
|
+
@xml = create_xml
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
%q[
|
22
|
+
<ChoicePointAdminRequest
|
23
|
+
xmlns="http://www.cpscreen.com/schemas"
|
24
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
25
|
+
xsi:schemaLocation="http://www.cpscreen.com/schemas AdminRequest.xsd"
|
26
|
+
userId="XCHANGE"
|
27
|
+
account="999999KLX"
|
28
|
+
password="XXXXXXXXX">
|
29
|
+
|
30
|
+
<ChangePassword>
|
31
|
+
<Account>999999KLX</Account>
|
32
|
+
<UserId>XCHANGE</UserId>
|
33
|
+
<Password>As@34Gsg!#</Password>
|
34
|
+
<NewPassword>the_new_password</NewPassword>
|
35
|
+
</ChangePassword>
|
36
|
+
|
37
|
+
</ChoicePointAdminRequest>
|
38
|
+
]
|
39
|
+
def create_xml
|
40
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
41
|
+
xml.ChoicePointAdminRequest(
|
42
|
+
:xmlns => 'http://www.cpscreen.com/schemas',
|
43
|
+
:userId => 'XCHANGE',
|
44
|
+
:account => "#{@account}#{@subaccount}",
|
45
|
+
:password => @password
|
46
|
+
){
|
47
|
+
xml.ChangePassword{
|
48
|
+
xml.Account "#{@account}#{@subaccount}"
|
49
|
+
xml.UserId 'XCHANGE'
|
50
|
+
xml.Password @password
|
51
|
+
xml.NewPassword @new_password
|
52
|
+
}
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
builder.to_xml
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_xml
|
60
|
+
self.class.soap_wrapper(@xml)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
|
4
|
+
module LexisNexisApi
|
5
|
+
|
6
|
+
module RemoteActions
|
7
|
+
|
8
|
+
class Response
|
9
|
+
attr_accessor :status
|
10
|
+
attr_accessor :body
|
11
|
+
attr_accessor :raw_response
|
12
|
+
|
13
|
+
def initialize(ret_val, resp)
|
14
|
+
self.status = ret_val
|
15
|
+
self.raw_response = resp
|
16
|
+
self.body = resp.body
|
17
|
+
end
|
18
|
+
|
19
|
+
def failure?
|
20
|
+
!success?
|
21
|
+
end
|
22
|
+
|
23
|
+
def success?
|
24
|
+
(self.body =~ %r{<Error(Report)?>}m).nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
def errors
|
28
|
+
error_code = self.body.match(%r{<ErrorCode>(.+)</ErrorCode>})[1] rescue '???'
|
29
|
+
error_description = self.body.match(%r{<ErrorDescription>(.+)</ErrorDescription>})[1] rescue '???'
|
30
|
+
{
|
31
|
+
:error_code => error_code,
|
32
|
+
:error_description => error_description
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# for use in tests
|
38
|
+
#
|
39
|
+
# options:
|
40
|
+
# :ret_val the Net::HTTP return value
|
41
|
+
# pass true for Net::HTTPSuccess, Net::HTTPRedirection
|
42
|
+
# pass false for all others
|
43
|
+
#
|
44
|
+
# :body the body 'returned' by the supposed Net::HTTP request
|
45
|
+
#
|
46
|
+
class MockResponse < Response
|
47
|
+
def initialize(options={})
|
48
|
+
Struct.new('MockHttpResponse', :body) unless defined?(Struct::MockHttpResponse)
|
49
|
+
mock_http_response = Struct::MockHttpResponse.new(options[:body])
|
50
|
+
super(options[:ret_val], mock_http_response)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Request
|
55
|
+
attr_accessor :headers
|
56
|
+
attr_accessor :proxy
|
57
|
+
attr_accessor :proxy_port
|
58
|
+
attr_accessor :body
|
59
|
+
attr_accessor :http_process
|
60
|
+
attr_accessor :url
|
61
|
+
|
62
|
+
def initialize(options={})
|
63
|
+
default_options = {
|
64
|
+
:body => nil,
|
65
|
+
:headers => {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'},
|
66
|
+
:proxy => nil,
|
67
|
+
:proxy_port => nil,
|
68
|
+
}
|
69
|
+
default_options.merge!(options)
|
70
|
+
|
71
|
+
self.proxy = default_options[:proxy]
|
72
|
+
self.proxy_port = default_options[:proxy_port]
|
73
|
+
self.headers = default_options[:headers]
|
74
|
+
self.body = default_options[:body]
|
75
|
+
self.url = default_options[:url]
|
76
|
+
end
|
77
|
+
|
78
|
+
def host_from_url
|
79
|
+
self.url.match(%r{(?:https?://)?([^/]+)})[1] rescue nil
|
80
|
+
end
|
81
|
+
|
82
|
+
def is_ssl?
|
83
|
+
!!(self.url =~ /^https:/i)
|
84
|
+
end
|
85
|
+
|
86
|
+
def port_from_url
|
87
|
+
return 443 if self.url =~ /^https:/i
|
88
|
+
|
89
|
+
if m = self.url.match(%r{(?:http://)[^:]+:(\d+)/?})
|
90
|
+
return m[1].to_i
|
91
|
+
else
|
92
|
+
80
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def send_request
|
97
|
+
self.http_process = Net::HTTP.new( host_from_url, port_from_url, self.proxy, self.proxy_port )
|
98
|
+
self.http_process.use_ssl = is_ssl?
|
99
|
+
|
100
|
+
http_process.start
|
101
|
+
resp = http_process.post(self.url, self.body, self.headers)
|
102
|
+
ret_val = false
|
103
|
+
case resp
|
104
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
105
|
+
ret_val = true
|
106
|
+
else
|
107
|
+
ret_val = false
|
108
|
+
end
|
109
|
+
return LexisNexisApi::RemoteActions::Response.new(ret_val, resp)
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module LexisNexisApi
|
3
|
+
|
4
|
+
module XmlHelper
|
5
|
+
|
6
|
+
def soap_wrapper(xml)
|
7
|
+
%Q{<?xml version="1.0"?>
|
8
|
+
<soapenv:Envelope
|
9
|
+
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
10
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
11
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
12
|
+
<soapenv:Body>
|
13
|
+
#{strip_instruct(xml)}
|
14
|
+
</soapenv:Body>
|
15
|
+
</soapenv:Envelope>
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def strip_instruct(xml)
|
20
|
+
xml.gsub!(%r{<\?xml\s+version=['"]1.0['"]\s*\?>}, '')
|
21
|
+
xml
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module LexisNexisApi
|
2
|
+
|
3
|
+
module XmlSamples
|
4
|
+
|
5
|
+
CHANGE_PASSWORD_COMPLETE_RESPONSE = %q[<?xml version="1.0" encoding="UTF-8"?>
|
6
|
+
<soapenv:Envelope
|
7
|
+
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
8
|
+
xmlns:cp="http://www.cpscreen.com/schemas"
|
9
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
10
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
11
|
+
<soapenv:Body>
|
12
|
+
<ChoicePointAdminResponse xmlns="http://www.cpscreen.com/schemas">
|
13
|
+
<ChangePassword>
|
14
|
+
<Status>Complete</Status>
|
15
|
+
<Account>036483</Account>
|
16
|
+
<UserId>XCHANGE</UserId>
|
17
|
+
<Password>This should be right</Password>
|
18
|
+
<NewPassword>hC0^eL0@sK9@aN7^mV4#iT6(cM0!vG1(cH8#aO8@</NewPassword>
|
19
|
+
</ChangePassword>
|
20
|
+
</ChoicePointAdminResponse>
|
21
|
+
</soapenv:Body>
|
22
|
+
</soapenv:Envelope>
|
23
|
+
]
|
24
|
+
|
25
|
+
CHANGE_PASSWORD_FAIL_RESPONSE = %q[<?xml version="1.0" encoding="UTF-8"?>
|
26
|
+
<soapenv:Envelope
|
27
|
+
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
28
|
+
xmlns:cp="http://www.cpscreen.com/schemas"
|
29
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
30
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
31
|
+
<soapenv:Body>
|
32
|
+
<ChoicePointAdminResponse xmlns="http://www.cpscreen.com/schemas">
|
33
|
+
<ChangePassword>
|
34
|
+
<Status>Fail</Status>
|
35
|
+
<Account>036483</Account>
|
36
|
+
<UserId>XCHANGE</UserId>
|
37
|
+
<Password>This should be wrong</Password>
|
38
|
+
<NewPassword>hC0^eL0@sK9@aN7^mV4#iT6(cM0!vG1(cH8#aO8@</NewPassword>
|
39
|
+
<Error>
|
40
|
+
<ErrorCode>250</ErrorCode>
|
41
|
+
<ErrorDescription>Invalid old password</ErrorDescription>
|
42
|
+
</Error>
|
43
|
+
</ChangePassword>
|
44
|
+
</ChoicePointAdminResponse>
|
45
|
+
</soapenv:Body>
|
46
|
+
</soapenv:Envelope>
|
47
|
+
]
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|