Skip to content

Commit 40b5327

Browse files
Moussa Sidibesidibos
authored andcommitted
SDK-676: Include the new endpoints to the examples project
1 parent a3e7174 commit 40b5327

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

examples/profile.php

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
);
1717
$activityDetails = $yotiClient->getActivityDetails($token);
1818
$profile = $activityDetails->getProfile();
19+
$ageVerifications = $profile->getAgeVerifications();
20+
$ageVerification = current($ageVerifications);
1921

2022
$profileAttributes = [
2123
[
@@ -43,6 +45,11 @@
4345
'obj' => $profile->getDateOfBirth(),
4446
'icon' => 'yoti-icon-calendar',
4547
],
48+
[
49+
'name' => 'Age Verification',
50+
'obj' => $ageVerification,
51+
'icon' => 'yoti-icon-calendar',
52+
],
4653
[
4754
'name' => 'Address',
4855
'obj' => $profile->getPostalAddress(),
@@ -66,7 +73,7 @@
6673

6774
// Create selfie image file.
6875
if ($selfie && is_writable(__DIR__)) {
69-
file_put_contents($selfieFileName, $selfie->getValue(), LOCK_EX);
76+
file_put_contents($selfieFileName, $selfie->getValue()->getContent(), LOCK_EX);
7077
}
7178
} catch(\Exception $e) {
7279
header('Location: /error.php?msg='.$e->getMessage());
@@ -78,9 +85,8 @@
7885
<head>
7986
<meta charset="utf-8">
8087
<title>Yoti client example</title>
81-
82-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
8388
<link rel="stylesheet" type="text/css" href="assets/css/profile.css">
89+
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet" />
8490
</head>
8591
<body class="yoti-body">
8692
<main class="yoti-profile-layout">
@@ -139,23 +145,36 @@
139145
</div>
140146

141147
<div class="yoti-attribute-value">
142-
<div class="yoti-attribute-value-text"><?php echo $item['obj']->getValue() ?></div>
148+
<?php
149+
$name = $item['name'];
150+
$attributeObj = $item['obj'];
151+
switch($name) {
152+
case 'Date of birth':
153+
$value = $item['obj']->getValue()->format('d-m-Y');
154+
break;
155+
case 'Age Verification':
156+
$attributeObj = $item['obj']->getAttribute();
157+
$result = $ageVerification->getResult() ? 'Yes' : 'No';
158+
$value = $ageVerification->getChecktype() . ':' . $ageVerification->getAge()
159+
. ' ' . $result;
160+
break;
161+
default:
162+
$value = $item['obj']->getValue();
163+
}
164+
165+
$anchors = $attributeObj->getAnchors();
166+
?>
167+
<div class="yoti-attribute-value-text"><?php echo $value; ?></div>
143168
</div>
144169
<div class="yoti-attribute-anchors-layout">
145170
<div class="yoti-attribute-anchors-head -s-v">S / V</div>
146171
<div class="yoti-attribute-anchors-head -value">Value</div>
147172
<div class="yoti-attribute-anchors-head -subtype">Sub type</div>
148173

149-
<?php foreach($item['obj']->getSources() as $source) : ?>
150-
<div class="yoti-attribute-anchors -s-v">Source</div>
151-
<div class="yoti-attribute-anchors -value"><?php echo $source->getValue() ?></div>
152-
<div class="yoti-attribute-anchors -subtype"><?php echo $source->getSubType() ?></div>
153-
<?php endforeach; ?>
154-
155-
<?php foreach($item['obj']->getVerifiers() as $verifier) : ?>
156-
<div class="yoti-attribute-anchors -s-v">Verifier</div>
157-
<div class="yoti-attribute-anchors -value"><?php echo $verifier->getValue() ?></div>
158-
<div class="yoti-attribute-anchors -subtype"><?php echo $verifier->getSubType() ?></div>
174+
<?php foreach($anchors as $anchor) : ?>
175+
<div class="yoti-attribute-anchors -s-v"><?php echo $anchor->getType(); ?></div>
176+
<div class="yoti-attribute-anchors -value"><?php echo $anchor->getValue() ?></div>
177+
<div class="yoti-attribute-anchors -subtype"><?php echo $anchor->getSubType() ?></div>
159178
<?php endforeach; ?>
160179

161180
</div>

src/Yoti/Entity/Profile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function getDocumentDetails()
134134
public function getAgeVerifications()
135135
{
136136
return isset($this->profileData[self::ATTR_AGE_VERIFICATIONS])
137-
? $this->profileData[self::ATTR_AGE_VERIFICATIONS] : NULL;
137+
? $this->profileData[self::ATTR_AGE_VERIFICATIONS] : [];
138138
}
139139

140140
/**

0 commit comments

Comments
 (0)