user-context-remote 0.0.85__tar.gz → 0.0.87__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/PKG-INFO +2 -2
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/setup.py +3 -3
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote/src/user_context.py +108 -95
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/PKG-INFO +2 -2
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/README.md +0 -0
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/pyproject.toml +0 -0
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/setup.cfg +0 -0
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote/src/__init__.py +0 -0
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/SOURCES.txt +0 -0
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/dependency_links.txt +0 -0
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/requires.txt +0 -0
- {user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/top_level.txt +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: user-context-remote
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.87
|
|
4
4
|
Summary: PyPI Package for Circles User Context Local/Remote Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/user-context-remote-python-package
|
|
6
6
|
Author: Circles
|
|
7
|
-
Author-email: info@
|
|
7
|
+
Author-email: info@circlez.ai
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: Other/Proprietary License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
@@ -4,10 +4,10 @@ PACKAGE_NAME = "user-context-remote"
|
|
|
4
4
|
package_dir = PACKAGE_NAME.replace("-", "_")
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
|
-
name=
|
|
8
|
-
version='0.0.
|
|
7
|
+
name=PACKAGE_NAME,
|
|
8
|
+
version='0.0.87', # https://pypi.org/project/user-context-remote/
|
|
9
9
|
author="Circles",
|
|
10
|
-
author_email="info@
|
|
10
|
+
author_email="info@circlez.ai",
|
|
11
11
|
description="PyPI Package for Circles User Context Local/Remote Python",
|
|
12
12
|
long_description="This is a package for sharing common user-context-remote functions used in different repositories",
|
|
13
13
|
long_description_content_type="text/markdown",
|
{user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote/src/user_context.py
RENAMED
|
@@ -3,7 +3,7 @@ from http import HTTPStatus
|
|
|
3
3
|
|
|
4
4
|
import requests
|
|
5
5
|
from language_remote.lang_code import LangCode
|
|
6
|
-
from python_sdk_remote.mini_logger import MiniLogger
|
|
6
|
+
from python_sdk_remote.mini_logger import MiniLogger as logger
|
|
7
7
|
from python_sdk_remote.utilities import our_get_env, create_return_http_headers
|
|
8
8
|
from url_remote import action_name_enum, component_name_enum, entity_name_enum
|
|
9
9
|
from url_remote.our_url import OurUrl
|
|
@@ -17,7 +17,7 @@ ENVIORNMENT_NAME = our_get_env("ENVIRONMENT_NAME")
|
|
|
17
17
|
AUTHENTICATION_API_VERSION = 1
|
|
18
18
|
DEFAULT_LANG_CODE = LangCode.ENGLISH
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
# TODO: use data class instead of getter & setters
|
|
21
21
|
class UserContext:
|
|
22
22
|
# TODO Is it a good idea to user UserContext in UserContext?
|
|
23
23
|
_instance = None
|
|
@@ -36,29 +36,27 @@ class UserContext:
|
|
|
36
36
|
self.real_profile_id = None
|
|
37
37
|
self.effective_user_id = None
|
|
38
38
|
self.effective_profile_id = None
|
|
39
|
-
self.lang_code_str: str
|
|
39
|
+
self.lang_code_str: str or None = None
|
|
40
40
|
self.real_first_name = None
|
|
41
41
|
self.real_last_name = None
|
|
42
42
|
self.real_display_name = None
|
|
43
43
|
self.subscription_id = 5 # TODO temp solution, so we can debug
|
|
44
44
|
if user_jwt:
|
|
45
|
-
|
|
45
|
+
validate_user_jwt_response = self._authenticate_by_user_jwt(user_jwt=user_jwt)
|
|
46
46
|
else:
|
|
47
|
-
# TODO identification or identifier?
|
|
48
47
|
user_identifier = user_identifier or our_get_env("PRODUCT_USER_IDENTIFIER")
|
|
49
48
|
password = password or our_get_env("PRODUCT_PASSWORD")
|
|
50
|
-
|
|
49
|
+
validate_user_jwt_response = self._authenticate_by_user_identification_and_password(
|
|
51
50
|
user_identifier=user_identifier, password=password)
|
|
52
51
|
# Populate the private data members with data we received from Authentication Local REST-API https://github.com/circles-zone/authentication-local-restapi-typescript-serverless-com/edit/dev/auth-restapi-serverless-com/src/services/auth-service/auth-service-impl.ts
|
|
53
|
-
|
|
54
|
-
self.__get_user_data_login_response(validate_user_jwt_response=user_context)
|
|
52
|
+
self.__get_user_data_login_response(validate_user_jwt_response=validate_user_jwt_response)
|
|
55
53
|
|
|
56
54
|
@staticmethod
|
|
57
55
|
# Does it support no parameters? Yes
|
|
58
56
|
def login_using_user_identification_and_password(user_identifier: str = None, password: str = None):
|
|
59
57
|
# LOGIN_USING_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME = "login_using_user_identification_and_password"
|
|
60
58
|
# TODO Why commented? Shall we add if (DebugMode)
|
|
61
|
-
#
|
|
59
|
+
# logger.start(LOGIN_USING_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME, object={"user_identifier": user_identifier, "password": password})
|
|
62
60
|
if UserContext._instance is None:
|
|
63
61
|
if user_identifier is None:
|
|
64
62
|
user_identifier = our_get_env("PRODUCT_USER_IDENTIFIER")
|
|
@@ -66,102 +64,98 @@ class UserContext:
|
|
|
66
64
|
password = our_get_env("PRODUCT_PASSWORD")
|
|
67
65
|
if not user_identifier or not password:
|
|
68
66
|
# To support cases with no PRODUCT_USER_IDENTIFIER and PRODUCT_PASSWORD in the deployment.
|
|
69
|
-
|
|
67
|
+
logger.warning(
|
|
70
68
|
"Warning: missing PRODUCT_USER_IDENTIFIER or PRODUCT_PASSWORD in .env file - WARNING -")
|
|
71
69
|
return None
|
|
72
70
|
UserContext._instance = UserContext(
|
|
73
71
|
user_identifier=user_identifier, password=password)
|
|
74
72
|
user = UserContext._instance
|
|
75
|
-
#
|
|
73
|
+
# logger.end(LOGIN_USING_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME,object={"user": str(user)})
|
|
76
74
|
return user
|
|
77
75
|
|
|
78
76
|
@staticmethod
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
LOGIN_USING_USER_JWT_METHOD_NAME = "login_using_user_jwt"
|
|
84
|
-
# MiniLogger.start(LOGIN_USING_USER_JWT_METHOD_NAME ,object={"user_jwt": user_jwt})
|
|
85
|
-
# TODO What if UserContext._instance is None and user_jwt is None? - Shall we use the same code we use in login_using_user_identification_and_password() without code duplications
|
|
86
|
-
if UserContext._instance is None and user_jwt is not None:
|
|
77
|
+
def login_using_user_jwt(user_jwt: str) -> 'UserContext':
|
|
78
|
+
# LOGIN_USING_USER_JWT_METHOD_NAME = "login_using_user_jwt"
|
|
79
|
+
# logger.start(LOGIN_USING_USER_JWT_METHOD_NAME ,object={"user_jwt": user_jwt})
|
|
80
|
+
if UserContext._instance is None:
|
|
87
81
|
UserContext._instance = UserContext(user_jwt=user_jwt)
|
|
88
82
|
user = UserContext._instance
|
|
89
|
-
#
|
|
83
|
+
# logger.end(LOGIN_USING_USER_JWT_METHOD_NAME,object={"user": str(user)})
|
|
90
84
|
return user
|
|
91
85
|
|
|
92
86
|
def _set_real_user_id(self, user_id: int) -> None:
|
|
93
|
-
|
|
94
|
-
#
|
|
87
|
+
# # SET_REAL_USER_ID_METHOD_NAME = "_set_real_user_id"
|
|
88
|
+
# logger.start(SET_REAL_USER_ID_METHOD_NAME,object={"user_id": user_id})
|
|
95
89
|
self.real_user_id = user_id
|
|
96
|
-
#
|
|
90
|
+
# logger.end(SET_REAL_USER_ID_METHOD_NAME)
|
|
97
91
|
|
|
98
92
|
def _set_real_profile_id(self, profile_id: int) -> None:
|
|
99
|
-
|
|
100
|
-
#
|
|
93
|
+
# SET_REAL_PROFILE_ID_METHOD_NAME = "_set_real_profile_id"
|
|
94
|
+
# logger.start(SET_REAL_PROFILE_ID_METHOD_NAME,object={"profile_id": profile_id})
|
|
101
95
|
self.real_profile_id = profile_id
|
|
102
|
-
#
|
|
96
|
+
# logger.end(SET_REAL_PROFILE_ID_METHOD_NAME)
|
|
103
97
|
|
|
104
98
|
def get_real_user_id(self) -> int:
|
|
105
|
-
GET_REAL_USER_ID_METHOD_NAME = "get_real_user_id"
|
|
106
|
-
#
|
|
107
|
-
#
|
|
99
|
+
# GET_REAL_USER_ID_METHOD_NAME = "get_real_user_id"
|
|
100
|
+
# logger.start(GET_REAL_USER_ID_METHOD_NAME)
|
|
101
|
+
# logger.end(GET_REAL_USER_ID_METHOD_NAME,object={"user_id": self.real_user_id})
|
|
108
102
|
return self.real_user_id
|
|
109
103
|
|
|
110
104
|
def get_real_profile_id(self) -> int:
|
|
111
|
-
GET_REAL_PROFILE_ID_METHOD_NAME = "get_real_profile_id"
|
|
112
|
-
#
|
|
113
|
-
#
|
|
105
|
+
# GET_REAL_PROFILE_ID_METHOD_NAME = "get_real_profile_id"
|
|
106
|
+
# logger.start(GET_REAL_PROFILE_ID_METHOD_NAME)
|
|
107
|
+
# logger.end(GET_REAL_PROFILE_ID_METHOD_NAME,object={"user_id": self.real_profile_id})
|
|
114
108
|
return self.real_profile_id
|
|
115
109
|
|
|
116
110
|
def get_effective_profile_preferred_lang_code_string(self) -> str:
|
|
117
|
-
GET_CURENT_LANG_CODE_STRING_METHOD_NAME = "get_effective_profile_preferred_lang_code"
|
|
118
|
-
#
|
|
119
|
-
#
|
|
111
|
+
# GET_CURENT_LANG_CODE_STRING_METHOD_NAME = "get_effective_profile_preferred_lang_code"
|
|
112
|
+
# logger.start(GET_CURENT_LANG_CODE_STRING_METHOD_NAME)
|
|
113
|
+
# logger.end(GET_CURENT_LANG_CODE_STRING_METHOD_NAME,object={"lang_code_string": self.lang_code})
|
|
120
114
|
return self.lang_code_str or DEFAULT_LANG_CODE.value
|
|
121
115
|
|
|
122
116
|
def get_effective_profile_preferred_lang_code(self) -> LangCode:
|
|
123
117
|
return LangCode(self.lang_code_str or DEFAULT_LANG_CODE.value)
|
|
124
118
|
|
|
125
119
|
def _set_effective_profile_preferred_lang_code(self, lang_code: LangCode) -> None:
|
|
126
|
-
|
|
127
|
-
#
|
|
120
|
+
# SET_CURRENT_LANG_CODE_METHOD_NAME = "_set_current_lang_code"
|
|
121
|
+
# logger.start(SET_CURRENT_LANG_CODE_METHOD_NAME,object={"lang_code": lang_code.value})
|
|
128
122
|
self.lang_code_str = lang_code.value
|
|
129
|
-
#
|
|
123
|
+
# logger.end(SET_CURRENT_LANG_CODE_METHOD_NAME)
|
|
130
124
|
|
|
131
125
|
def _set_real_first_name(self, first_name: str) -> None:
|
|
132
|
-
|
|
133
|
-
#
|
|
126
|
+
# SET_REAL_FIRST_NAME_METHOD_NAME = "_set_real_first_name"
|
|
127
|
+
# logger.start(SET_REAL_FIRST_NAME_METHOD_NAME,object={"first_name": first_name})
|
|
134
128
|
self.real_first_name = first_name
|
|
135
|
-
#
|
|
129
|
+
# logger.end(SET_REAL_FIRST_NAME_METHOD_NAME)
|
|
136
130
|
|
|
137
131
|
def _set_real_last_name(self, last_name: str) -> None:
|
|
138
|
-
|
|
139
|
-
#
|
|
132
|
+
# SET_REAL_LAST_NAME_METHOD_NAME = "_set_real_last_name"
|
|
133
|
+
# logger.start(SET_REAL_LAST_NAME_METHOD_NAME,object={"first_name": last_name})
|
|
140
134
|
self.real_last_name = last_name
|
|
141
|
-
#
|
|
135
|
+
# logger.end(SET_REAL_LAST_NAME_METHOD_NAME)
|
|
142
136
|
|
|
143
137
|
def get_real_first_name(self) -> str:
|
|
144
|
-
GET_REAL_FIRST_NAME_METHOD_NAME = "get_real_first_name"
|
|
145
|
-
#
|
|
146
|
-
#
|
|
138
|
+
# GET_REAL_FIRST_NAME_METHOD_NAME = "get_real_first_name"
|
|
139
|
+
# logger.start(GET_REAL_FIRST_NAME_METHOD_NAME)
|
|
140
|
+
# logger.end(GET_REAL_FIRST_NAME_METHOD_NAME,object={"first_name": self.real_first_name})
|
|
147
141
|
return self.real_first_name
|
|
148
142
|
|
|
149
143
|
def get_real_last_name(self) -> str:
|
|
150
|
-
GET_REAL_LAST_NAME_METHOD_NAME = "get_real_last_name"
|
|
151
|
-
#
|
|
152
|
-
#
|
|
144
|
+
# GET_REAL_LAST_NAME_METHOD_NAME = "get_real_last_name"
|
|
145
|
+
# logger.start(GET_REAL_LAST_NAME_METHOD_NAME)
|
|
146
|
+
# logger.end(GET_REAL_LAST_NAME_METHOD_NAME,object={"last_name": self.real_last_name})
|
|
153
147
|
return self.real_last_name
|
|
154
148
|
|
|
155
149
|
def _set_real_name(self, name: str) -> None:
|
|
156
|
-
|
|
157
|
-
#
|
|
150
|
+
# SET_REAL_NAME_METHOD_NAME = "_set_real_name"
|
|
151
|
+
# logger.start(SET_REAL_NAME_METHOD_NAME,object={"first_name": name})
|
|
158
152
|
self.real_display_name = name
|
|
159
|
-
#
|
|
153
|
+
# logger.end(SET_REAL_NAME_METHOD_NAME)
|
|
160
154
|
|
|
161
155
|
def get_real_name(self) -> str:
|
|
162
|
-
GET_REAL_NAME_METHOD_NAME = "get_real_name"
|
|
163
|
-
#
|
|
164
|
-
#
|
|
156
|
+
# GET_REAL_NAME_METHOD_NAME = "get_real_name"
|
|
157
|
+
# logger.start(GET_REAL_NAME_METHOD_NAME)
|
|
158
|
+
# logger.end(GET_REAL_NAME_METHOD_NAME,object={"first_name": self.real_first_name})
|
|
165
159
|
return self.real_display_name
|
|
166
160
|
|
|
167
161
|
def get_user_jwt(self) -> str:
|
|
@@ -183,16 +177,16 @@ class UserContext:
|
|
|
183
177
|
self.subscription_id = subscription_id
|
|
184
178
|
|
|
185
179
|
def get_effective_subscription_id(self) -> int:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
# GET_EFFECTIVE_SUBSCRIPTION_ID_METHOD_NAME = "get_effective_subscription_id"
|
|
181
|
+
# logger.warning("user-context-python-package " + GET_EFFECTIVE_SUBSCRIPTION_ID_METHOD_NAME +
|
|
182
|
+
# " Please make sure get_effective_subscription_id() subscription_id=" + str(
|
|
183
|
+
# self.subscription_id))
|
|
190
184
|
return self.subscription_id
|
|
191
185
|
|
|
192
186
|
def _authenticate_by_user_identification_and_password(self, user_identifier: str,
|
|
193
187
|
password: str) -> requests.Response:
|
|
194
|
-
|
|
195
|
-
|
|
188
|
+
AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME = "_authenticate_by_user_identification_and_password"
|
|
189
|
+
logger.start(AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME, object={
|
|
196
190
|
"userIdentifier": user_identifier, "password": "***"})
|
|
197
191
|
try:
|
|
198
192
|
url_circlez = OurUrl()
|
|
@@ -212,31 +206,49 @@ class UserContext:
|
|
|
212
206
|
data=json.dumps(authentication_login_request_json, separators=(",", ":")), headers=headers
|
|
213
207
|
)
|
|
214
208
|
if authentication_login_response_json.status_code != HTTPStatus.OK:
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
logger.error(AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME +
|
|
210
|
+
" authentication_login_response_json.status_code != HTTPStatus.OK " + authentication_login_response_json.text)
|
|
217
211
|
raise Exception(authentication_login_response_json.text)
|
|
218
212
|
# Maybe there is no "data"
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
logger.info("authentication_login_response_json.json()" + str(authentication_login_response_json))
|
|
214
|
+
logger.info("authentication_login_response_json.json() with json()" + str(
|
|
221
215
|
authentication_login_response_json.json()))
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
MiniLogger.end(_AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME, object={
|
|
216
|
+
self.__process_response(authentication_login_response_json)
|
|
217
|
+
logger.end(AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME, object={
|
|
225
218
|
"user_jwt": self.user_jwt})
|
|
226
219
|
return authentication_login_response_json
|
|
227
220
|
# TODO Catch KeyError: 'data'
|
|
228
221
|
except Exception as exception:
|
|
229
|
-
|
|
222
|
+
logger.exception(
|
|
230
223
|
"Error(Exception): user-context-remote-python _authenticate() " + str(exception))
|
|
231
|
-
|
|
224
|
+
logger.end(AUTHENTICATE_BY_USER_IDENTIFICATION_AND_PASSWORD_METHOD_NAME)
|
|
232
225
|
raise
|
|
233
226
|
|
|
227
|
+
def __process_response(self, authentication_login_response_json):
|
|
228
|
+
try:
|
|
229
|
+
response_json = authentication_login_response_json.json()
|
|
230
|
+
data = response_json.get("data")
|
|
231
|
+
if data is None:
|
|
232
|
+
logger.error("Error: 'data' not found in authentication_login_response_json.json()",
|
|
233
|
+
object={"authentication_login_response_json": authentication_login_response_json.text,
|
|
234
|
+
"response_json": response_json})
|
|
235
|
+
else:
|
|
236
|
+
self.user_jwt = data.get("userJwt")
|
|
237
|
+
if self.user_jwt is None:
|
|
238
|
+
logger.error(
|
|
239
|
+
"Error: 'userJwt' not found in 'data'.",
|
|
240
|
+
object={"data": data,
|
|
241
|
+
"authentication_login_response_json": authentication_login_response_json.text})
|
|
242
|
+
except Exception as exception:
|
|
243
|
+
logger.error(
|
|
244
|
+
"Error(Exception): user-context-remote-python _authenticate() " + str(exception),
|
|
245
|
+
object={"authentication_login_response_json": authentication_login_response_json.text})
|
|
246
|
+
|
|
234
247
|
def _authenticate_by_user_jwt(self, user_jwt: str) -> requests.Response:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
authentication_login_validate_user_jwt_url = url_circlez.endpoint_url(
|
|
248
|
+
AUTHENTICATE_BY_USER_JWT_METHOD_NAME = "_authenticate_by_user_jwt"
|
|
249
|
+
logger.start(AUTHENTICATE_BY_USER_JWT_METHOD_NAME,
|
|
250
|
+
object={"user_jwt": user_jwt})
|
|
251
|
+
authentication_login_validate_user_jwt_url = OurUrl.endpoint_url(
|
|
240
252
|
brand_name=BRAND_NAME,
|
|
241
253
|
environment_name=ENVIORNMENT_NAME,
|
|
242
254
|
component_name=component_name_enum.ComponentName.AUTHENTICATION.value,
|
|
@@ -251,12 +263,12 @@ class UserContext:
|
|
|
251
263
|
data=json.dumps(validate_user_jwt_request_json, separators=(",", ":")), headers=headers
|
|
252
264
|
)
|
|
253
265
|
if authentication_login_validate_user_jwt_response.status_code != HTTPStatus.OK:
|
|
254
|
-
|
|
266
|
+
logger.error(
|
|
255
267
|
"user-context-remote-python-package _authenticate_by_user_jwt() authentication_login_validate_user_jwt_response.status_code != HTTPStatus.OK " + authentication_login_validate_user_jwt_response.text)
|
|
256
268
|
# MiniLoger.end()
|
|
257
269
|
raise Exception(authentication_login_validate_user_jwt_response.text)
|
|
258
|
-
|
|
259
|
-
|
|
270
|
+
logger.end(AUTHENTICATE_BY_USER_JWT_METHOD_NAME,
|
|
271
|
+
object={"validate_user_jwt_response": authentication_login_validate_user_jwt_response})
|
|
260
272
|
return authentication_login_validate_user_jwt_response
|
|
261
273
|
|
|
262
274
|
# Used only in one please
|
|
@@ -264,41 +276,42 @@ class UserContext:
|
|
|
264
276
|
_GET_USER_DATA_LOGIN_RESPONSE_METHOD_NAME = "get_user_data_login_response"
|
|
265
277
|
# validate_user_jwt_response created in Authentication Local REST-API https://github.com/circles-zone/authentication-local-restapi-typescript-serverless-com/edit/dev/auth-restapi-serverless-com/src/services/auth-service/auth-service-impl.ts
|
|
266
278
|
# TODO validate_user_jwt_data_dict
|
|
267
|
-
|
|
279
|
+
response_json = validate_user_jwt_response.json()
|
|
280
|
+
data_dict = response_json.get('data')
|
|
268
281
|
first_name = last_name = None
|
|
269
282
|
if "userDetails" in data_dict:
|
|
270
283
|
# TODO user_details
|
|
271
|
-
|
|
284
|
+
user_details: dict = data_dict.get("userDetails")
|
|
272
285
|
|
|
273
|
-
if "profileId" in
|
|
274
|
-
profile_id =
|
|
286
|
+
if "profileId" in user_details:
|
|
287
|
+
profile_id = user_details.get("profileId")
|
|
275
288
|
self._set_real_profile_id(int(profile_id))
|
|
276
289
|
self._set_effective_profile_id(int(profile_id))
|
|
277
290
|
|
|
278
|
-
if "userId" in
|
|
279
|
-
user_id =
|
|
291
|
+
if "userId" in user_details:
|
|
292
|
+
user_id = user_details.get("userId")
|
|
280
293
|
self._set_effective_user_id(int(user_id))
|
|
281
294
|
self._set_real_user_id(int(user_id))
|
|
282
295
|
|
|
283
|
-
if "profilePreferredLangCode" in
|
|
284
|
-
lang_code =
|
|
296
|
+
if "profilePreferredLangCode" in user_details:
|
|
297
|
+
lang_code = user_details.get("profilePreferredLangCode")
|
|
285
298
|
if lang_code is None: # default lang_code is en
|
|
286
299
|
lang_code = "en"
|
|
287
300
|
# change to lang_code enum object
|
|
288
301
|
lang_code = LangCode(lang_code)
|
|
289
302
|
self._set_effective_profile_preferred_lang_code(lang_code)
|
|
290
303
|
|
|
291
|
-
if "firstName" in
|
|
292
|
-
first_name =
|
|
304
|
+
if "firstName" in user_details:
|
|
305
|
+
first_name = user_details.get("firstName")
|
|
293
306
|
self._set_real_first_name(first_name)
|
|
294
307
|
|
|
295
|
-
if "lastName" in
|
|
296
|
-
last_name =
|
|
308
|
+
if "lastName" in user_details:
|
|
309
|
+
last_name = user_details.get("lastName")
|
|
297
310
|
self._set_real_last_name(last_name)
|
|
298
311
|
|
|
299
|
-
if "subscriptionId" in
|
|
300
|
-
subscription_id =
|
|
301
|
-
|
|
312
|
+
if "subscriptionId" in user_details:
|
|
313
|
+
subscription_id = user_details.get("subscriptionId")
|
|
314
|
+
logger.end(
|
|
302
315
|
_GET_USER_DATA_LOGIN_RESPONSE_METHOD_NAME + " Got subscription_id from the cloud. subscription_id=" +
|
|
303
316
|
str(subscription_id), object={"subscription_id": subscription_id})
|
|
304
317
|
self._set_effective_subscription_id(subscription_id)
|
|
@@ -307,7 +320,7 @@ class UserContext:
|
|
|
307
320
|
name = first_name + " " + last_name
|
|
308
321
|
else:
|
|
309
322
|
# If first_name and last_name are not available, use the email as the name
|
|
310
|
-
name =
|
|
323
|
+
name = user_details.get("email")
|
|
311
324
|
|
|
312
325
|
self._set_real_name(name)
|
|
313
326
|
|
{user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/PKG-INFO
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: user-context-remote
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.87
|
|
4
4
|
Summary: PyPI Package for Circles User Context Local/Remote Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/user-context-remote-python-package
|
|
6
6
|
Author: Circles
|
|
7
|
-
Author-email: info@
|
|
7
|
+
Author-email: info@circlez.ai
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: Other/Proprietary License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote/src/__init__.py
RENAMED
|
File without changes
|
{user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/requires.txt
RENAMED
|
File without changes
|
{user_context_remote-0.0.85 → user_context_remote-0.0.87}/user_context_remote.egg-info/top_level.txt
RENAMED
|
File without changes
|