2
2
namespace YotiSandbox \Http ;
3
3
4
4
use Yoti \Entity \Profile ;
5
- use YotiSandbox \Entity \SandboxAgeVerification ;
6
5
use YotiSandbox \Entity \SandboxAnchor ;
7
6
use YotiSandbox \Entity \SandboxAttribute ;
7
+ use YotiSandbox \Entity \SandboxAgeVerification ;
8
8
9
9
class RequestBuilder
10
10
{
@@ -59,11 +59,11 @@ public function setGivenNames($value, $optional = 'false', array $anchors = [])
59
59
));
60
60
}
61
61
62
- public function setDateOfBirth ($ value , $ optional = 'false ' , array $ anchors = [])
62
+ public function setDateOfBirth (\ DateTime $ dateTime , $ optional = 'false ' , array $ anchors = [])
63
63
{
64
64
$ this ->addAttribute ($ this ->createAttribute (
65
65
Profile::ATTR_DATE_OF_BIRTH ,
66
- $ value ,
66
+ $ dateTime -> format ( ' d-m-Y ' ) ,
67
67
'' ,
68
68
$ optional ,
69
69
$ anchors
@@ -164,13 +164,9 @@ public function setDocumentDetails($value, $optional = 'true', array $anchors =
164
164
));
165
165
}
166
166
167
- public function setAgeVerification (\ DateTime $ dateObj , $ derivation , array $ anchors = [] )
167
+ public function setAgeVerification (SandboxAgeVerification $ ageVerification )
168
168
{
169
- $ this ->addAttribute (new SandboxAgeVerification (
170
- $ dateObj ,
171
- $ derivation ,
172
- $ anchors
173
- ));
169
+ $ this ->addAttribute ($ ageVerification );
174
170
}
175
171
176
172
private function addAttribute (SandboxAttribute $ attribute )
@@ -202,6 +198,17 @@ private function formatAnchors(array $anchors)
202
198
return $ anchorsList ;
203
199
}
204
200
201
+ /**
202
+ * @param string $name
203
+ * @param string $value
204
+ * @param string $derivation
205
+ * Empty value means there is no derivation for this attribute
206
+ * @param string $optional
207
+ * 'false' value means this attribute is required
208
+ * @param array $anchors
209
+ *
210
+ * @return SandboxAttribute
211
+ */
205
212
private function createAttribute ($ name , $ value , $ derivation , $ optional , array $ anchors )
206
213
{
207
214
return new SandboxAttribute ($ name , $ value , $ derivation , $ optional , $ anchors );
@@ -210,7 +217,7 @@ private function createAttribute($name, $value, $derivation, $optional, array $a
210
217
/**
211
218
* @return TokenRequest
212
219
*/
213
- public function getRequest ()
220
+ public function createRequest ()
214
221
{
215
222
return new TokenRequest ($ this ->rememberMeId , $ this ->sandboxAttributes );
216
223
}
0 commit comments