|
| 1 | +# -- coding: utf-8 -- |
| 2 | +# Created by LoginRadius Development Team |
| 3 | +# Copyright 2019 LoginRadius Inc. All rights reserved. |
| 4 | +# |
| 5 | + |
| 6 | + |
| 7 | +class ConsentManagementApi: |
| 8 | + |
| 9 | + def __init__(self, lr_object): |
| 10 | + """ |
| 11 | + :param lr_object: this is the reference to the parent LoginRadius object. |
| 12 | + """ |
| 13 | + self._lr_object = lr_object |
| 14 | + |
| 15 | + def get_consent_logs_by_uid(self, uid): |
| 16 | + """This API is used to get the Consent logs of the user. |
| 17 | + |
| 18 | + Args: |
| 19 | + uid: UID, the unified identifier for each user account |
| 20 | + |
| 21 | + Returns: |
| 22 | + Response containing consent logs |
| 23 | + 18.37 |
| 24 | + """ |
| 25 | + |
| 26 | + if(self._lr_object.is_null_or_whitespace(uid)): |
| 27 | + raise Exception(self._lr_object.get_validation_message("uid")) |
| 28 | + |
| 29 | + query_parameters = {} |
| 30 | + query_parameters["apiKey"] = self._lr_object.get_api_key() |
| 31 | + query_parameters["apiSecret"] = self._lr_object.get_api_secret() |
| 32 | + |
| 33 | + resource_path = "identity/v2/manage/account/" + uid + "/consent/logs" |
| 34 | + return self._lr_object.execute("GET", resource_path, query_parameters, None) |
| 35 | + |
| 36 | + def submit_consent_by_consent_token(self, consent_token, consent_submit_model): |
| 37 | + """This API is to submit consent form using consent token. |
| 38 | + |
| 39 | + Args: |
| 40 | + consent_token: The consent token received after login error 1226 |
| 41 | + consent_submit_model: Model class containing list of multiple consent |
| 42 | + |
| 43 | + Returns: |
| 44 | + Response containing User Profile Data and access token |
| 45 | + 43.1 |
| 46 | + """ |
| 47 | + |
| 48 | + if(self._lr_object.is_null_or_whitespace(consent_token)): |
| 49 | + raise Exception(self._lr_object.get_validation_message("consent_token")) |
| 50 | + if(consent_submit_model is None): |
| 51 | + raise Exception(self._lr_object.get_validation_message("consent_submit_model")) |
| 52 | + |
| 53 | + query_parameters = {} |
| 54 | + query_parameters["apiKey"] = self._lr_object.get_api_key() |
| 55 | + query_parameters["consentToken"] = consent_token |
| 56 | + |
| 57 | + resource_path = "identity/v2/auth/consent" |
| 58 | + return self._lr_object.execute("POST", resource_path, query_parameters, consent_submit_model) |
| 59 | + |
| 60 | + def get_consent_logs(self, access_token): |
| 61 | + """This API is used to fetch consent logs. |
| 62 | + |
| 63 | + Args: |
| 64 | + access_token: Uniquely generated identifier key by LoginRadius that is activated after successful authentication. |
| 65 | + |
| 66 | + Returns: |
| 67 | + Response containing consent logs |
| 68 | + 43.2 |
| 69 | + """ |
| 70 | + |
| 71 | + if(self._lr_object.is_null_or_whitespace(access_token)): |
| 72 | + raise Exception(self._lr_object.get_validation_message("access_token")) |
| 73 | + |
| 74 | + query_parameters = {} |
| 75 | + query_parameters["access_token"] = access_token |
| 76 | + query_parameters["apiKey"] = self._lr_object.get_api_key() |
| 77 | + |
| 78 | + resource_path = "identity/v2/auth/consent/logs" |
| 79 | + return self._lr_object.execute("GET", resource_path, query_parameters, None) |
| 80 | + |
| 81 | + def submit_consent_by_access_token(self, access_token, consent_submit_model): |
| 82 | + """API to provide a way to end user to submit a consent form for particular event type. |
| 83 | + |
| 84 | + Args: |
| 85 | + access_token: Uniquely generated identifier key by LoginRadius that is activated after successful authentication. |
| 86 | + consent_submit_model: Model class containing list of multiple consent |
| 87 | + |
| 88 | + Returns: |
| 89 | + Response containing Definition for Complete profile data |
| 90 | + 43.3 |
| 91 | + """ |
| 92 | + |
| 93 | + if(self._lr_object.is_null_or_whitespace(access_token)): |
| 94 | + raise Exception(self._lr_object.get_validation_message("access_token")) |
| 95 | + if(consent_submit_model is None): |
| 96 | + raise Exception(self._lr_object.get_validation_message("consent_submit_model")) |
| 97 | + |
| 98 | + query_parameters = {} |
| 99 | + query_parameters["access_token"] = access_token |
| 100 | + query_parameters["apiKey"] = self._lr_object.get_api_key() |
| 101 | + |
| 102 | + resource_path = "identity/v2/auth/consent/profile" |
| 103 | + return self._lr_object.execute("POST", resource_path, query_parameters, consent_submit_model) |
| 104 | + |
| 105 | + def verify_consent_by_access_token(self, access_token, event, is_custom): |
| 106 | + """This API is used to check if consent is submitted for a particular event or not. |
| 107 | + |
| 108 | + Args: |
| 109 | + access_token: Uniquely generated identifier key by LoginRadius that is activated after successful authentication. |
| 110 | + event: Allowed events: Login, Register, UpdateProfile, ResetPassword, ChangePassword, emailVerification, AddEmail, RemoveEmail, BlockAccount, DeleteAccount, SetUsername, AssignRoles, UnassignRoles, SetPassword, LinkAccount, UnlinkAccount, UpdatePhoneId, VerifyPhoneNumber, CreateCustomObject, UpdateCustomobject, DeleteCustomObject |
| 111 | + is_custom: true/false |
| 112 | + |
| 113 | + Returns: |
| 114 | + Response containing consent profile |
| 115 | + 43.4 |
| 116 | + """ |
| 117 | + |
| 118 | + if(self._lr_object.is_null_or_whitespace(access_token)): |
| 119 | + raise Exception(self._lr_object.get_validation_message("access_token")) |
| 120 | + |
| 121 | + if(self._lr_object.is_null_or_whitespace(event)): |
| 122 | + raise Exception(self._lr_object.get_validation_message("event")) |
| 123 | + |
| 124 | + query_parameters = {} |
| 125 | + query_parameters["access_token"] = access_token |
| 126 | + query_parameters["apiKey"] = self._lr_object.get_api_key() |
| 127 | + query_parameters["event"] = event |
| 128 | + query_parameters["isCustom"] = is_custom |
| 129 | + |
| 130 | + resource_path = "identity/v2/auth/consent/verify" |
| 131 | + return self._lr_object.execute("GET", resource_path, query_parameters, None) |
| 132 | + |
| 133 | + def update_consent_profile_by_access_token(self, access_token, consent_update_model): |
| 134 | + """This API is to update consents using access token. |
| 135 | + |
| 136 | + Args: |
| 137 | + access_token: Uniquely generated identifier key by LoginRadius that is activated after successful authentication. |
| 138 | + consent_update_model: Model class containg list of multiple consent |
| 139 | + |
| 140 | + Returns: |
| 141 | + Response containing consent profile |
| 142 | + 43.5 |
| 143 | + """ |
| 144 | + |
| 145 | + if(self._lr_object.is_null_or_whitespace(access_token)): |
| 146 | + raise Exception(self._lr_object.get_validation_message("access_token")) |
| 147 | + if(consent_update_model is None): |
| 148 | + raise Exception(self._lr_object.get_validation_message("consent_update_model")) |
| 149 | + |
| 150 | + query_parameters = {} |
| 151 | + query_parameters["access_token"] = access_token |
| 152 | + query_parameters["apiKey"] = self._lr_object.get_api_key() |
| 153 | + |
| 154 | + resource_path = "identity/v2/auth/consent" |
| 155 | + return self._lr_object.execute("PUT", resource_path, query_parameters, consent_update_model) |
0 commit comments