Skip to content

Commit 4a12041

Browse files
Merge pull request #93 from hyperwallet/feature/DTPAYHWBM-2-V3-php-adding-reject-reasons
feature/DTPAYHWBM-2-V3-php-adding-reject-reasons
2 parents e4ace8c + 0eba170 commit 4a12041

File tree

5 files changed

+402
-1
lines changed

5 files changed

+402
-1
lines changed

src/Hyperwallet/Hyperwallet.php

+32
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
use Hyperwallet\Model\BankAccountStatusTransition;
1111
use Hyperwallet\Model\BankCard;
1212
use Hyperwallet\Model\BankCardStatusTransition;
13+
use Hyperwallet\Model\HyperWalletVerificationDocument;
14+
use Hyperwallet\Model\HyperWalletVerificationDocumentReason;
15+
use Hyperwallet\Model\HyperWalletVerificationDocumentCollection;
16+
use Hyperwallet\Model\HyperWalletVerificationDocumentReasonCollection;
1317
use Hyperwallet\Model\IProgramAware;
1418
use Hyperwallet\Model\PaperCheck;
1519
use Hyperwallet\Model\PaperCheckStatusTransition;
@@ -76,6 +80,33 @@ public function __construct($username, $password, $programToken = null, $server
7680
$this->programToken = $programToken;
7781
$this->client = new ApiClient($username, $password, $server, $clientOptions, $encryptionData);
7882
}
83+
//--------------------------------------
84+
// Helpers
85+
//--------------------------------------
86+
87+
/**
88+
* Modify body for nested formatting
89+
*
90+
* @param array $bodyResponse Body Response from request
91+
* @return array
92+
*/
93+
private function setDocumentAndReasonFromResponseHelper($bodyResponse) {
94+
$documents = $bodyResponse["documents"];
95+
if ($documents) {
96+
foreach ($documents as &$dVal) {
97+
$reasons = $dVal["reasons"];
98+
if ($reasons) {
99+
foreach ($reasons as &$rVal) {
100+
$rVal = new HyperwalletVerificationDocumentReason($rVal);
101+
}
102+
$dVal["reasons"] = new HyperwalletVerificationDocumentReasonCollection(...$reasons);
103+
}
104+
$dVal = new HyperwalletVerificationDocument($dVal);
105+
}
106+
$bodyResponse["documents"] = new HyperwalletVerificationDocumentCollection(...$documents);
107+
}
108+
return $bodyResponse;
109+
}
79110

80111
//--------------------------------------
81112
// Users
@@ -2175,6 +2206,7 @@ public function uploadDocumentsForUser($userToken, $options) {
21752206
throw new HyperwalletArgumentException('userToken is required!');
21762207
}
21772208
$body = $this->client->putMultipartData('/rest/v3/users/{user-token}', array('user-token' => $userToken), $options);
2209+
$body = $this->setDocumentAndReasonFromResponseHelper($body);
21782210
return new User($body);
21792211
}
21802212

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
<?php
2+
namespace Hyperwallet\Model;
3+
4+
/**
5+
* Represents a V4 HyperwalletVerificationDocument
6+
*
7+
* @property string $category The category of the document
8+
* @property string $type The type of the document
9+
* @property string $status The status of the document
10+
* @property string $country The country origin of the document
11+
* @property HyperwalletVerificationDocumentReasonCollection $reasons The reasons for the documents rejection of type HyperwalletVerificationDocumentReasons
12+
* @property \DateTime $createdOn The document creation date
13+
* @property object $uploadFiles The files uploaded
14+
*
15+
* @package Hyperwallet\Model
16+
*/
17+
class HyperwalletVerificationDocument extends BaseModel {
18+
19+
/**
20+
* @internal
21+
*
22+
* Read only fields
23+
*
24+
* @var string[]
25+
*/
26+
private static $READ_ONLY_FIELDS = array('category', 'type', 'status', 'country', 'reasons', 'createdOn', 'uploadFiles');
27+
28+
/**
29+
* Creates a instance of HyperwalletVerificationDocument
30+
*
31+
* @param string[] $properties The default properties
32+
*/
33+
public function __construct(array $properties = array()) {
34+
parent::__construct(self::$READ_ONLY_FIELDS, $properties);
35+
}
36+
37+
/**
38+
* Get the HyperwalletVerificationDocument creation date
39+
*
40+
* @return \DateTime
41+
*/
42+
public function getCreatedOn() {
43+
return $this->createdOn ? new \DateTime($this->createdOn) : null;
44+
}
45+
46+
/**
47+
* Get the document status
48+
*
49+
* @return string
50+
*/
51+
public function getStatus() {
52+
return $this->status;
53+
}
54+
55+
/**
56+
* Get the document category
57+
*
58+
* @return string
59+
*/
60+
public function getCategory() {
61+
return $this->category;
62+
}
63+
64+
// /**
65+
// * Set the document category
66+
// *
67+
// * @param string $category
68+
// * @return HyperwalletVerificationDocument
69+
// */
70+
// public function setCategory($category) {
71+
// $this->category = $category;
72+
// return $this;
73+
// }
74+
75+
/**
76+
* Get the document type
77+
*
78+
* @return string
79+
*/
80+
public function getType() {
81+
return $this->type;
82+
}
83+
84+
// /**
85+
// * Set the document type
86+
// *
87+
// * @param string $type
88+
// * @return HyperwalletVerificationDocument
89+
// */
90+
// public function setType($type) {
91+
// $this->type = $type;
92+
// return $this;
93+
// }
94+
95+
/**
96+
* Get the country
97+
*
98+
* @return string
99+
*/
100+
public function getCountry() {
101+
return $this->country;
102+
}
103+
104+
// /**
105+
// * Set the country
106+
// *
107+
// * @param string $country
108+
// * @return HyperwalletVerificationDocument
109+
// */
110+
// public function setCountry($country) {
111+
// $this->country = $country;
112+
// return $this;
113+
// }
114+
115+
/**
116+
* Get the document reasons
117+
*
118+
* @return HyperwalletVerificationDocumentReason $reasons
119+
*/
120+
public function getReasons($reasons) {
121+
return $this->reasons;
122+
}
123+
124+
// /**
125+
// * Set the document reasons
126+
// *
127+
// * @param HyperwalletVerificationDocumentReason $reasons
128+
// * @return HyperwalletVerificationDocument
129+
// */
130+
// public function setReasons($reasons) {
131+
// $this->reasons = $reasons;
132+
// return $this;
133+
// }
134+
135+
/**
136+
* Get the uploadFiles
137+
*
138+
* @return object $uploadFiles
139+
*/
140+
public function getUploadFiles($uploadFiles) {
141+
return $this->uploadFiles;
142+
}
143+
144+
// /**
145+
// * Set the uploadFiles
146+
// *
147+
// * @param object $uploadFiles
148+
// * @return HyperwalletVerificationDocument
149+
// */
150+
// public function setUploadFiles($uploadFiles) {
151+
// $this->uploadFiles = $uploadFiles;
152+
// return $this;
153+
// }
154+
}
155+
156+
/**
157+
* Represents a V4 HyperwalletVerificationDocumentCollection
158+
*
159+
* @property array $documents The list of documents
160+
*
161+
* @package Hyperwallet\Model
162+
*/
163+
class HyperwalletVerificationDocumentCollection {
164+
165+
public function __construct(HyperwalletVerificationDocument ...$documents) {
166+
$this->documents = $documents;
167+
}
168+
169+
public function getDocuments() {
170+
return $this->documents;
171+
}
172+
173+
public function getIterator() : ArrayIterator {
174+
return new ArrayIterator($this->documents);
175+
}
176+
177+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
namespace Hyperwallet\Model;
3+
4+
abstract class RejectReason {
5+
const DOCUMENT_EXPIRED = 0;
6+
const DOCUMENT_NOT_RELATED_TO_PROFILE = 1;
7+
const DOCUMENT_NOT_READABLE = 2;
8+
const DOCUMENT_NOT_DECISIVE = 3;
9+
const DOCUMENT_NOT_COMPLETE = 4;
10+
const DOCUMENT_CORRECTION_REQUIRED = 5;
11+
const DOCUMENT_NOT_VALID_WITH_NOTES = 6;
12+
const DOCUMENT_TYPE_NOT_VALID = 7;
13+
}
14+
15+
16+
/**
17+
* Represents a V4 HyperwalletVerificationDocumentReason
18+
*
19+
* @property RejectReason $name The reason for rejection
20+
* @property string $description The description of the rejection
21+
*
22+
* @package Hyperwallet\Model
23+
*/
24+
class HyperwalletVerificationDocumentReason extends BaseModel {
25+
26+
/**
27+
* @internal
28+
*
29+
* Read only fields
30+
*
31+
* @var string[]
32+
*/
33+
private static $READ_ONLY_FIELDS = array('name', 'description');
34+
35+
/**
36+
* Creates a instance of HyperwalletVerificationReason
37+
*
38+
* @param string[] $properties The default properties
39+
*/
40+
public function __construct(array $properties = array()) {
41+
parent::__construct(self::$READ_ONLY_FIELDS, $properties);
42+
}
43+
44+
/**
45+
* Get the Rejection Reason
46+
*
47+
* @return RejectReason
48+
*/
49+
public function getName() {
50+
return $this->name;
51+
}
52+
53+
/**
54+
* Get the description
55+
*
56+
* @return string
57+
*/
58+
public function getDescription() {
59+
return $this->description;
60+
}
61+
}
62+
63+
/**
64+
* Represents a V4 HyperwalletVerificationDocumentReasonsCollection
65+
*
66+
* @property array $reasons The list of reasons
67+
*
68+
* @package Hyperwallet\Model
69+
*/
70+
class HyperwalletVerificationDocumentReasonCollection {
71+
72+
public function __construct(HyperwalletVerificationDocumentReason ...$reasons) {
73+
$this->reasons = $reasons;
74+
}
75+
76+
public function getReasons() {
77+
return $this->reasons;
78+
}
79+
80+
public function getIterator() : ArrayIterator {
81+
return new ArrayIterator($this->reasons);
82+
}
83+
84+
}

src/Hyperwallet/Model/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* @property string $language The user language
4747
* @property string $programToken The users program token
4848
* @property string $verificationStatus The status of user verification
49-
* @property array $documents The array of documents returned for document upload
49+
* @property HyperwalletVerificationDocumentCollection $documents The array of documents of type HyperwalletVerificationDocument returned for document upload
5050
*
5151
* @package Hyperwallet\Model
5252
*/

0 commit comments

Comments
 (0)