callcredit 0.3.2 → 0.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d41d5aaa1a9fdb9f23a7b104f235102e2d93bbde
4
- data.tar.gz: ea69cb9394e2c66e77b25ba6034ddec764c99974
3
+ metadata.gz: c6fd66f12894e3525ef98fd4192476f407c8b163
4
+ data.tar.gz: f82113873639cb39ed16a22b8aeeaa7623ff7a07
5
5
  SHA512:
6
- metadata.gz: d3feaa1b7f4d7e3ba4837a8a36a6e300338ad6a79334bf2f2b0272878b4798f01154c392c2781710cefd53d0258f250899fbd2e3607b9e7ef3f5640b54642844
7
- data.tar.gz: 4fb33f55e7429dd3a541f6b8d58eb33824dc9481c5d8867b1c2ad520362761ac12bba866fc4a6749cb41db9df5a3e97323506efd221fd032b88ea913b0c1d666
6
+ metadata.gz: 5b67b4c59f4de25e394bd99a378f756b2896d51e98d676376a5cdfc1a1b251f45dfa828c9af8b1b1bbac1cc8769439c6cd6187c2a2ab8a43e0d05cbb38a1f994
7
+ data.tar.gz: 78e6accb62801e823ad54f27819142ad75c26215bad8104b4cc202b52c92d865ebca50a1531236993473a4d6f00c54bf7e449ab334c1a9426ca642c31652c9f0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.3 - February 19, 2014
2
+
3
+ - Handle errors from Callcredit that aren't name-spaced to a module
4
+
1
5
  ## 0.3.2 - February 11, 2014
2
6
 
3
7
  - Allow a title to be passed as personal data. Specify "Unknown" if not
@@ -9,8 +9,8 @@ module Callcredit
9
9
 
10
10
  if results["Errors"]
11
11
  errors = results["Errors"].values.flatten
12
- message = errors.map { |e| e["__content__"] }.join(" | ")
13
- raise APIError.new(message, env[:status], env)
12
+ messages = errors.map { |e| e.is_a?(Hash) ? e["__content__"] : e }
13
+ raise APIError.new(messages.join(" | "), env[:status], env)
14
14
  end
15
15
  response_values(env)
16
16
  end
@@ -1,3 +1,5 @@
1
+ require 'ostruct'
2
+
1
3
  module Callcredit
2
4
  class Response
3
5
  def initialize(response_data)
@@ -1,3 +1,3 @@
1
1
  module Callcredit
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.3.3'.freeze
3
3
  end
@@ -7,17 +7,8 @@ describe Callcredit::Checks::IDEnhanced do
7
7
 
8
8
  let(:response_hash) { { status: status, body: body } }
9
9
  let(:status) { 200 }
10
- let(:body) do
11
- "<Results>
12
- <Result>
13
- <Displays>
14
- <InputData/>
15
- <IdentityCheck/>
16
- </Displays>
17
- </Result>
18
- <Errors/>
19
- </Results>"
20
- end
10
+ let(:body) { response_xml }
11
+ let(:response_xml) { load_fixture('response.xml') }
21
12
  before { stub_request(:get, config[:api_endpoint]).to_return(response_hash) }
22
13
 
23
14
  describe "#perform" do
@@ -29,7 +29,7 @@
29
29
  <Personal>
30
30
  <Individual>
31
31
  <Dateofbirth>01/01/2000</Dateofbirth>
32
- <Title>Mr</Title>
32
+ <Title>Unknown</Title>
33
33
  <Firstname/>
34
34
  <Othernames/>
35
35
  <Surname/>
@@ -0,0 +1,98 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:/tac/Customer-Output-V4-5-3.xsd" APIVERSION="4.5.3 - 20131119">
3
+ <Result RID="" PID="LTJ-CT2-1606-13927-46399" DateTime="18-02-2014 18:00">
4
+ <Displays>
5
+ <ChecksCompleted>
6
+ <BankStandard>no</BankStandard>
7
+ <BankEnhanced>no</BankEnhanced>
8
+ <CardLive>no</CardLive>
9
+ <CardEnhanced>no</CardEnhanced>
10
+ <IDEnhanced>yes</IDEnhanced>
11
+ <NCOAAlert>no</NCOAAlert>
12
+ <CallValidate3D>no</CallValidate3D>
13
+ <TheAffordabilityReport>no</TheAffordabilityReport>
14
+ <DeliveryFraud>no</DeliveryFraud>
15
+ <EmailValidate>no</EmailValidate>
16
+ <CreditScore>no</CreditScore>
17
+ <Zodiac>no</Zodiac>
18
+ <IPAddress>no</IPAddress>
19
+ <BankAccountPlus>no</BankAccountPlus>
20
+ <BankOFA>no</BankOFA>
21
+ <CardOFA>no</CardOFA>
22
+ </ChecksCompleted>
23
+ <InputData>
24
+ <Individual>
25
+ <Dateofbirth>01/01/1901</Dateofbirth>
26
+ <Title>Mr</Title>
27
+ <Firstname>Grey</Firstname>
28
+ <Surname>Baker</Surname>
29
+ </Individual>
30
+ <Address>
31
+ <Buildingnumber>1</Buildingnumber>
32
+ <Postcode>EX8M PLE</Postcode>
33
+ </Address>
34
+ </InputData>
35
+ <IdentityCheck>
36
+ <appverified>Yes</appverified>
37
+ <matchlevel>IndividualReport</matchlevel>
38
+ <ervalid>4</ervalid>
39
+ <levelofconfidenceer>-4</levelofconfidenceer>
40
+ <levelofconfidencedob>3</levelofconfidencedob>
41
+ <levelofconfidenceshare>3</levelofconfidenceshare>
42
+ <levelofconfidenceccjs>0</levelofconfidenceccjs>
43
+ <levelofconfidencebai>0</levelofconfidencebai>
44
+ <levelofconfidenceinvestors>0</levelofconfidenceinvestors>
45
+ <confirmatorydobs>2</confirmatorydobs>
46
+ <totaldobs>3</totaldobs>
47
+ <numprimarychecks>4</numprimarychecks>
48
+ <numcorroborativechecks>1</numcorroborativechecks>
49
+ <numprimaryotheridsconfirmed>0</numprimaryotheridsconfirmed>
50
+ <numccjs>0</numccjs>
51
+ <numbais>0</numbais>
52
+ <numinvestors>0</numinvestors>
53
+ <numaddresslinks>0</numaddresslinks>
54
+ <numsharerecords>3</numsharerecords>
55
+ <halomatch>false</halomatch>
56
+ <readmatch>false</readmatch>
57
+ <grodeceased>false</grodeceased>
58
+ <dvlawarning>false</dvlawarning>
59
+ <passportwarning>false</passportwarning>
60
+ <namepicklistfound>false</namepicklistfound>
61
+ <addresspicklistfound>false</addresspicklistfound>
62
+ <IDBasic/>
63
+ </IdentityCheck>
64
+ <AgeVerify>
65
+ <Age>113</Age>
66
+ <DateOfBirth>1901-01-01</DateOfBirth>
67
+ <Over18>yes</Over18>
68
+ </AgeVerify>
69
+ <OtherChecks>
70
+ <IdentityResult>Fail</IdentityResult>
71
+ <IdentityScore>40</IdentityScore>
72
+ </OtherChecks>
73
+ <VelocityChecks>
74
+ <card/>
75
+ <bank/>
76
+ <individual/>
77
+ <email/>
78
+ </VelocityChecks>
79
+ <Warnings>
80
+ <NonGBRCardWarning>false</NonGBRCardWarning>
81
+ <NamePicklistWarning>false</NamePicklistWarning>
82
+ <AddressPicklistWarning>false</AddressPicklistWarning>
83
+ <PAFNonValidWarning>false</PAFNonValidWarning>
84
+ <CardAccountClosedWarning>false</CardAccountClosedWarning>
85
+ <BankAccountClosedWarning>false</BankAccountClosedWarning>
86
+ </Warnings>
87
+ <InternalUse>
88
+ <CESValue>40</CESValue>
89
+ <BESValue>40</BESValue>
90
+ <CESCARD_DIAG>WVRveE9udHBPakE3Y3pveE1qZzZJalBMSW43aktyRmRLWWdINnI3aER3ZVIvN3hkRjNqUm11ZzRwTnV6UjE4bGJkZUdlcTRPVkJ6b1BYWXNIRE8wMU1wRDhpS1ZUek50U250V0oxNkJRYys3MmxNbE0vVXlWVzgwRHlyKzZFSjF2M29PbXIzOE53VUY4cVE0NTVObTVhN04rNGFIMENlRlQ0ZlpsOTh2VzYrQzNvSzNhNHUwcG5hSmFYd1RiRlNpSWp0OSNLRVlTI7uQIxTC60UH5vu/HJ4ZevjOtRN5tnNeDSh971BnCn1rjP0hyhzgvVkH7Vd+GYNfrMDQDgjc4QOaFGr+q2BynE5P58rjjFxi6f0nNvkcToZBb+r3ahzjBhBCmEcVJT8Uva2ACFpTtM1eDtTEF/PAFpT2qTjngpUUNMpHRZ9t/67M+xNy+VyG1C32xxMb53HeTkbkON2UIUPXWvJ2sKbU9I1IGUMZFI8BNLwHegpSD9BIHB0U91aSWOjuv3Ci+sQkyk9x2nA5zuQVaVo3g531MhVD9Rve30KqK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jBs7o2kBy8r/DJS+r+bWhRqqRcPjifC5bS42EU8s4sOWIoi90lZvExfjTKBJGYvDjAw4coBcK5oSz8OvPushs7Knd2ZyHsX/n9g4+w7xiViFzGyZ+0U7BlU6VQxqP1w+trNjkXd5F5gmZscXxudU/iI9q9EOI+ejkPpC7x9hwr0bzjLsQ9wK/apLyqG9jQ5vutIROzxpOr+dj</BESCARD_DIAG>
92
+ <CVSVER/>
93
+ <CAST>.02.7.1.4.1.0.16202370.0</CAST>
94
+ </InternalUse>
95
+ </Displays>
96
+ </Result>
97
+ <Errors/>
98
+ </Results>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:/tac/Customer-Output-V4-5-3.xsd" APIVERSION="4.5.3 - 20131119">
3
+ <Errors>
4
+ <Error>Error 1</Error>
5
+ <FatalError>Error 2</FatalError>
6
+ </Errors>
7
+ </Results>
data/spec/request_spec.rb CHANGED
@@ -17,10 +17,7 @@ describe Callcredit::Request do
17
17
  subject(:build_request_xml) do
18
18
  request.build_request_xml(:id_enhanced, check_data).to_s
19
19
  end
20
- let(:request_xml) do
21
- path = File.join(File.dirname(__FILE__), 'fixtures', 'request.xml')
22
- File.open(path.to_s).read
23
- end
20
+ let(:request_xml) { load_fixture('request.xml') }
24
21
 
25
22
  it { should == request_xml }
26
23
 
@@ -66,11 +63,7 @@ describe Callcredit::Request do
66
63
  end
67
64
 
68
65
  context "200 with a single error from Callcredit" do
69
- let(:body) do
70
- path = File.join(File.dirname(__FILE__),
71
- 'fixtures', 'bad_request.xml')
72
- File.open(path.to_s).read
73
- end
66
+ let(:body) { load_fixture('bad_request.xml') }
74
67
 
75
68
  it "wraps the error" do
76
69
  expect { perform_check }.
@@ -79,11 +72,7 @@ describe Callcredit::Request do
79
72
  end
80
73
 
81
74
  context "200 with multiple errors from Callcredit" do
82
- let(:body) do
83
- path = File.join(File.dirname(__FILE__),
84
- 'fixtures', 'access_denied.xml')
85
- File.open(path.to_s).read
86
- end
75
+ let(:body) { load_fixture('access_denied.xml') }
87
76
 
88
77
  it "wraps the error" do
89
78
  expect { perform_check }.
@@ -91,6 +80,15 @@ describe Callcredit::Request do
91
80
  end
92
81
  end
93
82
 
83
+ context "200 with errors from Callcredit that aren't in a module" do
84
+ let(:body) { load_fixture('system_call_failure.xml') }
85
+
86
+ it "wraps the error" do
87
+ expect { perform_check }.
88
+ to raise_error(Callcredit::APIError, "Error 1 | Error 2")
89
+ end
90
+ end
91
+
94
92
  context "200 with unexpected XML" do
95
93
  let(:body) { "<TopLevel></TopLevel>" }
96
94
 
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'multi_xml'
3
+
4
+ describe Callcredit::Response do
5
+ let(:result_hash) { MultiXml.parse(load_fixture('response.xml')) }
6
+ subject(:response) { Callcredit::Response.new(result_hash) }
7
+
8
+ it "makes some helper methods available" do
9
+ response.pid.should == "LTJ-CT2-1606-13927-46399"
10
+ end
11
+ end
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,10 @@ def configure_callcredit
6
6
  Callcredit.configure { |config| config[:first_name] = "Grey" }
7
7
  end
8
8
 
9
+ def load_fixture(*filename)
10
+ File.open(File.join('spec', 'fixtures', *filename)).read
11
+ end
12
+
9
13
  shared_examples "it validates presence" do |property|
10
14
  context "with a missing #{property}" do
11
15
  before { check_data.delete(property) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callcredit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grey Baker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -127,7 +127,10 @@ files:
127
127
  - spec/fixtures/access_denied.xml
128
128
  - spec/fixtures/bad_request.xml
129
129
  - spec/fixtures/request.xml
130
+ - spec/fixtures/response.xml
131
+ - spec/fixtures/system_call_failure.xml
130
132
  - spec/request_spec.rb
133
+ - spec/response_spec.rb
131
134
  - spec/spec_helper.rb
132
135
  homepage: https://github.com/gocardless/callcredit-ruby
133
136
  licenses: []
@@ -159,5 +162,8 @@ test_files:
159
162
  - spec/fixtures/access_denied.xml
160
163
  - spec/fixtures/bad_request.xml
161
164
  - spec/fixtures/request.xml
165
+ - spec/fixtures/response.xml
166
+ - spec/fixtures/system_call_failure.xml
162
167
  - spec/request_spec.rb
168
+ - spec/response_spec.rb
163
169
  - spec/spec_helper.rb