7
7
DynamicScenarioBuilder ,
8
8
create_share_url ,
9
9
)
10
- from yoti_python_sdk .dynamic_sharing_service .policy import DynamicPolicyBuilder
10
+ from yoti_python_sdk .dynamic_sharing_service .policy import (
11
+ DynamicPolicyBuilder ,
12
+ SourceConstraintBuilder ,
13
+ )
11
14
12
15
load_dotenv (find_dotenv ())
13
16
@@ -53,6 +56,34 @@ def get(self, request, *args, **kwargs):
53
56
return self .render_to_response (context )
54
57
55
58
59
+ class SourceConstraintsView (TemplateView ):
60
+ template_name = "dynamic-share.html"
61
+
62
+ def get (self , request , * args , ** kwargs ):
63
+ client = Client (YOTI_CLIENT_SDK_ID , YOTI_KEY_FILE_PATH )
64
+ constraint = (
65
+ SourceConstraintBuilder ().with_driving_licence ().with_passport ().build ()
66
+ )
67
+ policy = (
68
+ DynamicPolicyBuilder ()
69
+ .with_full_name (constraints = constraint )
70
+ .with_structured_postal_address (constraints = constraint )
71
+ .build ()
72
+ )
73
+ scenario = (
74
+ DynamicScenarioBuilder ()
75
+ .with_policy (policy )
76
+ .with_callback_endpoint ("/yoti/auth" )
77
+ .build ()
78
+ )
79
+ share = create_share_url (client , scenario )
80
+ context = {
81
+ "yoti_client_sdk_id" : YOTI_CLIENT_SDK_ID ,
82
+ "yoti_share_url" : share .share_url ,
83
+ }
84
+ return self .render_to_response (context )
85
+
86
+
56
87
class AuthView (TemplateView ):
57
88
template_name = "profile.html"
58
89
@@ -71,10 +102,18 @@ def get(self, request, *args, **kwargs):
71
102
context ["receipt_id" ] = getattr (activity_details , "receipt_id" )
72
103
context ["timestamp" ] = getattr (activity_details , "timestamp" )
73
104
74
- # change this string according to the age condition defined in Yoti Hub
75
- age_verified = profile .get_attribute ("age_over:18" )
105
+ # change this number according to the age condition defined in Yoti Hub
106
+ age_verified = profile .find_age_over_verification (18 )
107
+
108
+ # Age verification objects don't have the same properties as an attribute,
109
+ # so for this example we had to mock an object with the same properties
76
110
if age_verified is not None :
77
- context ["age_verified" ] = age_verified
111
+ context ["age_verified" ] = {
112
+ "name" : "age_verified" ,
113
+ "value" : age_verified ,
114
+ "sources" : age_verified .attribute .sources ,
115
+ "verifiers" : age_verified .attribute .verifiers ,
116
+ }
78
117
79
118
selfie = context .get ("selfie" )
80
119
if selfie is not None :
0 commit comments