77 DynamicScenarioBuilder ,
88 create_share_url ,
99)
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+ )
1114
1215load_dotenv (find_dotenv ())
1316
@@ -53,6 +56,34 @@ def get(self, request, *args, **kwargs):
5356 return self .render_to_response (context )
5457
5558
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+
5687class AuthView (TemplateView ):
5788 template_name = "profile.html"
5889
@@ -71,10 +102,18 @@ def get(self, request, *args, **kwargs):
71102 context ["receipt_id" ] = getattr (activity_details , "receipt_id" )
72103 context ["timestamp" ] = getattr (activity_details , "timestamp" )
73104
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
76110 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+ }
78117
79118 selfie = context .get ("selfie" )
80119 if selfie is not None :
0 commit comments