Skip to content

Commit c7d426a

Browse files
committed
fix: update to delphiselect2
1 parent 5afcbfc commit c7d426a

7 files changed

+70
-23
lines changed

src/Clients/DelphiSelect.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class DelphiSelect
1212
{
1313
use UsesOAuth;
1414

15-
protected $url = '/risk/consumer/v1/dataselect/';
15+
protected $url = '/risk/consumer/v2/dataselect/';
1616

1717

1818
/**
@@ -24,6 +24,9 @@ public function create(Submission $submission): Response
2424
$res = $this->client()
2525
->withBody(json_encode($submission), 'application/json')
2626
->post('application');
27+
28+
// dd($res->json());
29+
2730
$res->throw();
2831
$response = new Response($res->json()['Response']);
2932
$response->Metrics = $res->json()['Metrics'];
@@ -76,7 +79,7 @@ public function expinscvSubmission()
7679
}
7780
}
7881

79-
/**
82+
/*
8083
* With info about client
8184
* - get credt
8285
*/
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace CustomD\LaravelExperian\ExperianModels;
4+
5+
/**
6+
* Other name the applicant may be known by.
7+
* For example, Bill may be an alias of William. Each applicant may submit up to three Alias
8+
*
9+
* @property string $MainApplicantNMI - Main Applicant Supplied - Net Monthly Income in GBP
10+
* @property string $JointApplicantNMI - Joint Applicant Supplied - Net Monthly Income in GBP
11+
*/
12+
class AffordabilityIQ extends Base
13+
{
14+
protected $fields = [
15+
"JointApplicantNMI" => "integer",
16+
"MainApplicantNMI" => "integer",
17+
];
18+
19+
protected $defaults = [
20+
"JointApplicantNMI" => 0,
21+
"MainApplicantNMI" => 0,
22+
];
23+
}

src/ExperianModels/Applicant.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
namespace CustomD\LaravelExperian\ExperianModels;
44

5-
/**
5+
/*
66
* Containing the the financial and personal information of the applicants to be targeted as part of the Consumer Application.
77
* Data will be used for Identity Authentication and Affordability calculations (e.g. income, number of dependants, telephone number etc.).
88
* The first submitted applicant will be the main applicant.
9-
*/
9+
*
10+
* @property string $ApplicantIdentifier
11+
* @property string $Person
12+
* @property string $Alias
13+
* @property string $Association
14+
* @property string $ApplicantData
15+
*/
1016
class Applicant extends Base
1117
{
1218
protected $fields = [

src/ExperianModels/ApplicantData.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class ApplicantData extends Base
99
'PersonalDetails' => PersonalDetails::class,
1010
'BankDetails' => BankDetails::class,
1111
'EmploymentDetails' => EmploymentDetails::class,
12-
'AdditionalData' => AdditionalData::class
12+
'AdditionalData' => AdditionalData::class,
13+
'AffordabilityIQ' => AffordabilityIQ::class
1314
];
1415
}

src/ExperianModels/Base.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ public function __get(string $key)
2929
return $this->attributes[$key] ?? null;
3030
}
3131

32-
public function __set(string $key, $value): self
32+
public function __set(string $key, $value): void
3333
{
3434
if ($this->hasSetMutator($key)) {
3535
$this->setMutatedAttributeValue($key, $value);
3636
} else {
3737
$this->setAttribute($key, $value);
3838
}
39-
return $this;
4039
}
4140

4241
public function getAttribute($key)

src/ExperianModels/Submission.php

+11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ class Submission extends Base
1515
'Options' => Options::class
1616
];
1717

18+
protected $defaults = [
19+
// 'Options' => new Options()
20+
];
21+
22+
23+
protected function fillDefaults(): void
24+
{
25+
parent::fillDefaults();
26+
$this->Options = new Options();
27+
}
28+
1829

1930
public function jsonSerialize()
2031
{

tests/LaravelExperianTest.php

+20-16
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
use CustomD\LaravelExperian\ExperianModels\Application;
2323
use CustomD\LaravelExperian\ExperianModels\Residencies;
2424
use CustomD\LaravelExperian\ExperianModels\LocationItem;
25+
use CustomD\LaravelExperian\ExperianModels\ApplicantData;
2526
use CustomD\LaravelExperian\ExperianModels\ResidencyItem;
27+
use CustomD\LaravelExperian\ExperianModels\AffordabilityIQ;
2628

2729
class LaravelExperianTest extends TestCase
2830
{
@@ -38,10 +40,6 @@ protected function getPackageAliases($app)
3840
];
3941
}
4042

41-
public function testExample()
42-
{
43-
$this->assertEquals(1, 1);
44-
}
4543

4644
protected function buildSubmission()
4745
{
@@ -54,6 +52,11 @@ protected function buildSubmission()
5452
'Surname' => 'Mayer',
5553
'DateOfBirth' => '1981-06-19'
5654
]);
55+
56+
$applicant->ApplicantData = new ApplicantData([
57+
'AffordabilityIQ' => new AffordabilityIQ(),
58+
]);
59+
5760
$submission->Applicants = new Applicants([$applicant]);
5861

5962
$uklocation = new UKLocation([
@@ -100,6 +103,13 @@ public function testBuildsASubmissionBasic()
100103

101104
$this->assertEquals('{
102105
"Submission": {
106+
"Options": {
107+
"ProductCode": "DelphiSelect",
108+
"FullFBLRequired": true,
109+
"AuthenticatePlusRequired": true,
110+
"DetectRequired": true,
111+
"TestDatabase": "A"
112+
},
103113
"Applicants": [
104114
{
105115
"ApplicantIdentifier": 1,
@@ -108,6 +118,12 @@ public function testBuildsASubmissionBasic()
108118
"Forename": "Alexander",
109119
"Surname": "Mayer",
110120
"DateOfBirth": "1981-06-19"
121+
},
122+
"ApplicantData": {
123+
"AffordabilityIQ": {
124+
"JointApplicantNMI": 0,
125+
"MainApplicantNMI": 0
126+
}
111127
}
112128
}
113129
],
@@ -138,27 +154,15 @@ public function testBuildsASubmissionBasic()
138154
"ManualAuthenticationRequired": false,
139155
"SearchConsent": true
140156
},
141-
"Options": {
142-
"ProductCode": "DelphiSelect",
143-
"FullFBLRequired": true,
144-
"AuthenticatePlusRequired": true,
145-
"DetectRequired": true,
146-
"TestDatabase": "A"
147-
},
148157
"ClientData": {
149158
"ClientAccountNumber": "A1234"
150159
}
151160
}
152161
}', json_encode($this->buildSubmission(), JSON_PRETTY_PRINT));
153162
}
154163

155-
public function DisabledtestCall()
156164
{
157165
Config::set('experian.credentials', [
158-
'client_id' => "xxx",
159-
'client_secret' => "xxx",
160-
'username' => "xxx",
161-
'password' => "xxx",
162166
]);
163167

164168
Response::macro('getScore', function () {

0 commit comments

Comments
 (0)