eclinical-requester 1.0.8__py3-none-any.whl → 1.0.10__py3-none-any.whl
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.
- api_requester/__init__.py +1 -1
- api_requester/docs/application.yaml +1 -0
- api_requester/dto/user.py +5 -5
- api_requester/http/authorize.py +6 -7
- api_requester/http/eclinical_requests.py +28 -22
- api_requester/http/sample_headers.py +5 -2
- {eclinical_requester-1.0.8.dist-info → eclinical_requester-1.0.10.dist-info}/METADATA +3 -2
- {eclinical_requester-1.0.8.dist-info → eclinical_requester-1.0.10.dist-info}/RECORD +11 -11
- {eclinical_requester-1.0.8.dist-info → eclinical_requester-1.0.10.dist-info}/WHEEL +1 -1
- {eclinical_requester-1.0.8.dist-info → eclinical_requester-1.0.10.dist-info/licenses}/LICENSE +0 -0
- {eclinical_requester-1.0.8.dist-info → eclinical_requester-1.0.10.dist-info}/top_level.txt +0 -0
api_requester/__init__.py
CHANGED
@@ -2,6 +2,7 @@ serverUrl:
|
|
2
2
|
dev03: http://dev-03-app-01.chengdudev.edetekapps.cn
|
3
3
|
dev04: http://dev-04-app-01.chengdudev.edetekapps.cn
|
4
4
|
dev01: http://dev-01-app-01.chengdudev.edetekapps.cn
|
5
|
+
dev02: http://dev-02-app-01.chengdudev.edetekapps.cn
|
5
6
|
test01: http://test-01-app-01.chengdudev.edetekapps.cn
|
6
7
|
us.dev: https://ec.eclinical-dev.edetekapps.com
|
7
8
|
us.demo: https://ec4.ec4demo.edetekapps.com
|
api_requester/dto/user.py
CHANGED
@@ -24,7 +24,7 @@ class EClinicalUser:
|
|
24
24
|
self.sponsor = sponsor
|
25
25
|
self.study = study
|
26
26
|
self.app_env = app_env
|
27
|
-
self.test_env = str(test_env)
|
27
|
+
self.test_env = str(test_env) if test_env is not None else None
|
28
28
|
self.company = company
|
29
29
|
self.role = role
|
30
30
|
self.external = external
|
@@ -32,8 +32,8 @@ class EClinicalUser:
|
|
32
32
|
|
33
33
|
def __repr__(self):
|
34
34
|
attributes = self.__dict__
|
35
|
-
info =
|
36
|
-
|
37
|
-
if attributes.get(item) is not None
|
38
|
-
|
35
|
+
info = [
|
36
|
+
str(attributes[item]) for item in ["test_env", "username", "role", "company", "sponsor", "study", "app_env"]
|
37
|
+
if attributes.get(item) is not None
|
38
|
+
]
|
39
39
|
return "/".join(info)
|
api_requester/http/authorize.py
CHANGED
@@ -23,8 +23,7 @@ from api_requester.utils.log import Logger
|
|
23
23
|
from api_requester.utils.rsa import encrypt_password
|
24
24
|
|
25
25
|
|
26
|
-
class Authorize(BizBase,
|
27
|
-
CommonSystemEnvServiceImpl):
|
26
|
+
class Authorize(BizBase, AdminAuthService, AdminUserOnBoardApplicationServiceImpl, CommonSystemEnvServiceImpl):
|
28
27
|
|
29
28
|
def __init__(self, user: EClinicalUser):
|
30
29
|
BizBase.__init__(self)
|
@@ -33,7 +32,6 @@ class Authorize(BizBase, SampleHeaders, AdminAuthService, AdminUserOnBoardApplic
|
|
33
32
|
self.user.app = AppEnum.ADMIN.code
|
34
33
|
self.time_mills = time.time()
|
35
34
|
self.user_onboard_dto = UserOnBoardDto(-1)
|
36
|
-
SampleHeaders.__init__(self)
|
37
35
|
AdminAuthService.__init__(self)
|
38
36
|
AdminUserOnBoardApplicationServiceImpl.__init__(self)
|
39
37
|
CommonSystemEnvServiceImpl.__init__(self)
|
@@ -76,7 +74,7 @@ class Authorize(BizBase, SampleHeaders, AdminAuthService, AdminUserOnBoardApplic
|
|
76
74
|
token = response.get("token")
|
77
75
|
else:
|
78
76
|
token = response.get("jwtAuthenticationResponse").get("token")
|
79
|
-
self.add_authorization(token)
|
77
|
+
self.headers = SampleHeaders().add_authorization(token).to_h()
|
80
78
|
self.time_mills = time.time()
|
81
79
|
return response.get("type")
|
82
80
|
|
@@ -86,7 +84,8 @@ class Authorize(BizBase, SampleHeaders, AdminAuthService, AdminUserOnBoardApplic
|
|
86
84
|
self._build_user_onboard_dto(user_onboard_dto)
|
87
85
|
self.user_onboard_dto = user_onboard_dto
|
88
86
|
response = self.on_board(user_onboard_dto)
|
89
|
-
|
87
|
+
token = response.get("token")
|
88
|
+
self.headers = SampleHeaders().add_authorization(token).to_h()
|
90
89
|
|
91
90
|
def _build_user_onboard_dto(self, dto: UserOnBoardDto):
|
92
91
|
onboard_system_list = self.get_user_onboard_application_list(dto.workForCompanyId)
|
@@ -145,13 +144,13 @@ class Authorize(BizBase, SampleHeaders, AdminAuthService, AdminUserOnBoardApplic
|
|
145
144
|
token = response.get("token")
|
146
145
|
else:
|
147
146
|
token = response.get("jwtAuthenticationResponse").get("token")
|
148
|
-
self.add_authorization(token)
|
147
|
+
self.headers = SampleHeaders().add_authorization(token).to_h()
|
149
148
|
self.time_mills = time.time()
|
150
149
|
|
151
150
|
def _entry_portal(self, company_id):
|
152
151
|
response = self.login_portal(CrossUserUserOnBoardDto(companyId=company_id))
|
153
152
|
try:
|
154
153
|
token = response.get("token")
|
155
|
-
self.add_authorization(token)
|
154
|
+
self.headers = SampleHeaders().add_authorization(token).to_h()
|
156
155
|
except BaseException as e:
|
157
156
|
print(e)
|
@@ -5,6 +5,7 @@ LastEditors: xiaodong.li
|
|
5
5
|
LastEditTime: 2023-07-25 13:33:15
|
6
6
|
@Description: eclinical_requests.py
|
7
7
|
"""
|
8
|
+
import copy
|
8
9
|
import os
|
9
10
|
import time
|
10
11
|
from functools import wraps
|
@@ -17,14 +18,15 @@ from api_requester.dto.base_dto import BaseDto, build_file_dto
|
|
17
18
|
from api_requester.dto.biz_base import BizBase
|
18
19
|
from api_requester.http.app_url import AppUrl
|
19
20
|
from api_requester.http.exceptions import ApiResponseException
|
21
|
+
from api_requester.http.sample_headers import SampleHeaders
|
20
22
|
|
21
23
|
|
22
24
|
def get(api):
|
23
25
|
def __wrapper__(func):
|
24
26
|
@url(api)
|
25
27
|
@build_request_data()
|
26
|
-
@init_content_type()
|
27
28
|
@refresh_token()
|
29
|
+
@refresh_headers()
|
28
30
|
@get_request()
|
29
31
|
@http_ok
|
30
32
|
def __inner__(instance: BizBase, *args, **kwargs):
|
@@ -39,8 +41,8 @@ def post(api):
|
|
39
41
|
def __wrapper__(func):
|
40
42
|
@url(api)
|
41
43
|
@build_request_data()
|
42
|
-
@init_content_type()
|
43
44
|
@refresh_token()
|
45
|
+
@refresh_headers()
|
44
46
|
@post_request()
|
45
47
|
@http_ok
|
46
48
|
def __inner__(instance: BizBase, *args, **kwargs):
|
@@ -55,8 +57,8 @@ def delete(api):
|
|
55
57
|
def __wrapper__(func):
|
56
58
|
@url(api)
|
57
59
|
@build_request_data()
|
58
|
-
@init_content_type()
|
59
60
|
@refresh_token()
|
61
|
+
@refresh_headers()
|
60
62
|
@delete_request()
|
61
63
|
@http_ok
|
62
64
|
def __inner__(instance: BizBase, *args, **kwargs):
|
@@ -71,8 +73,8 @@ def put(api):
|
|
71
73
|
def __wrapper__(func):
|
72
74
|
@url(api)
|
73
75
|
@build_request_data()
|
74
|
-
@init_content_type()
|
75
76
|
@refresh_token()
|
77
|
+
@refresh_headers()
|
76
78
|
@put_request()
|
77
79
|
@http_ok
|
78
80
|
def __inner__(instance: BizBase, *args, **kwargs):
|
@@ -85,11 +87,11 @@ def put(api):
|
|
85
87
|
|
86
88
|
def get_request():
|
87
89
|
def __wrapper__(func):
|
88
|
-
def __inner__(instance: BizBase, **kwargs):
|
90
|
+
def __inner__(instance: BizBase, *args, **kwargs):
|
89
91
|
app_url = kwargs.pop("app_url")
|
90
|
-
rsp = requests.get(app_url,
|
92
|
+
rsp = requests.get(app_url, **kwargs)
|
91
93
|
kwargs.update(rsp=rsp)
|
92
|
-
return func(instance, **kwargs)
|
94
|
+
return func(instance, *args, **kwargs)
|
93
95
|
|
94
96
|
return __inner__
|
95
97
|
|
@@ -98,11 +100,11 @@ def get_request():
|
|
98
100
|
|
99
101
|
def post_request():
|
100
102
|
def __wrapper__(func):
|
101
|
-
def __inner__(instance: BizBase, **kwargs):
|
103
|
+
def __inner__(instance: BizBase, *args, **kwargs):
|
102
104
|
app_url = kwargs.pop("app_url")
|
103
|
-
rsp = requests.post(app_url,
|
105
|
+
rsp = requests.post(app_url, **kwargs)
|
104
106
|
kwargs.update(rsp=rsp)
|
105
|
-
return func(instance, **kwargs)
|
107
|
+
return func(instance, *args, **kwargs)
|
106
108
|
|
107
109
|
return __inner__
|
108
110
|
|
@@ -111,11 +113,11 @@ def post_request():
|
|
111
113
|
|
112
114
|
def delete_request():
|
113
115
|
def __wrapper__(func):
|
114
|
-
def __inner__(instance: BizBase, **kwargs):
|
116
|
+
def __inner__(instance: BizBase, *args, **kwargs):
|
115
117
|
app_url = kwargs.pop("app_url")
|
116
|
-
rsp = requests.delete(app_url,
|
118
|
+
rsp = requests.delete(app_url, **kwargs)
|
117
119
|
kwargs.update(rsp=rsp)
|
118
|
-
return func(instance, **kwargs)
|
120
|
+
return func(instance, *args, **kwargs)
|
119
121
|
|
120
122
|
return __inner__
|
121
123
|
|
@@ -124,11 +126,11 @@ def delete_request():
|
|
124
126
|
|
125
127
|
def put_request():
|
126
128
|
def __wrapper__(func):
|
127
|
-
def __inner__(instance: BizBase, **kwargs):
|
129
|
+
def __inner__(instance: BizBase, *args, **kwargs):
|
128
130
|
app_url = kwargs.pop("app_url")
|
129
|
-
rsp = requests.put(app_url,
|
131
|
+
rsp = requests.put(app_url, **kwargs)
|
130
132
|
kwargs.update(rsp=rsp)
|
131
|
-
return func(instance, **kwargs)
|
133
|
+
return func(instance, *args, **kwargs)
|
132
134
|
|
133
135
|
return __inner__
|
134
136
|
|
@@ -146,7 +148,7 @@ def url(api):
|
|
146
148
|
app_url = AppUrl(instance.user.app, instance.user.test_env).external_url(api, **url_kwargs)
|
147
149
|
if app_url is None:
|
148
150
|
raise Exception("The url is null.")
|
149
|
-
kwargs.update(
|
151
|
+
kwargs.update(app_url=app_url)
|
150
152
|
return func(instance, *args, **kwargs)
|
151
153
|
|
152
154
|
return __inner__
|
@@ -197,7 +199,7 @@ def build_request_data():
|
|
197
199
|
multipart_encoder_data.append((k, v))
|
198
200
|
if len(multipart_encoder_data) > 0:
|
199
201
|
data = MultipartEncoder(fields=multipart_encoder_data)
|
200
|
-
kwargs.update(
|
202
|
+
kwargs.update(data=data)
|
201
203
|
return func(instance, *args, **kwargs)
|
202
204
|
|
203
205
|
return __inner__
|
@@ -205,14 +207,17 @@ def build_request_data():
|
|
205
207
|
return __wrapper__
|
206
208
|
|
207
209
|
|
208
|
-
def
|
210
|
+
def refresh_headers():
|
209
211
|
def __wrapper__(func):
|
210
212
|
def __inner__(instance: BizBase, *args, **kwargs):
|
213
|
+
headers = copy.deepcopy(instance.headers)
|
214
|
+
sh = SampleHeaders(headers)
|
211
215
|
if instance.refresh_content_type is True:
|
212
|
-
|
216
|
+
sh.add_content_type("application/json")
|
213
217
|
data = kwargs.get("data")
|
214
218
|
if isinstance(data, MultipartEncoder):
|
215
|
-
|
219
|
+
sh.add_content_type(data.content_type)
|
220
|
+
kwargs.update(headers=sh.to_h())
|
216
221
|
return func(instance, *args, **kwargs)
|
217
222
|
|
218
223
|
return __inner__
|
@@ -234,9 +239,10 @@ def refresh_token():
|
|
234
239
|
|
235
240
|
def http_ok(func):
|
236
241
|
@wraps(func)
|
237
|
-
def _http_ok(instance: BizBase, **kwargs):
|
242
|
+
def _http_ok(instance: BizBase, *args, **kwargs):
|
238
243
|
try:
|
239
244
|
rsp: Response = kwargs.pop("rsp")
|
245
|
+
kwargs.pop("headers")
|
240
246
|
instance.last_kwargs = kwargs
|
241
247
|
instance.last_result = rsp
|
242
248
|
content_type = rsp.headers.get("content-type")
|
@@ -9,8 +9,8 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
class SampleHeaders(object):
|
12
|
-
def __init__(self):
|
13
|
-
self.headers = {"Content-Type": "application/json", "Connection": "close"}
|
12
|
+
def __init__(self, headers=None):
|
13
|
+
self.headers = {"Content-Type": "application/json", "Connection": "close"} if headers is None else headers
|
14
14
|
|
15
15
|
def add_header(self, **kwargs):
|
16
16
|
self.headers.update(kwargs)
|
@@ -21,3 +21,6 @@ class SampleHeaders(object):
|
|
21
21
|
|
22
22
|
def add_authorization(self, token):
|
23
23
|
return self.add_header(Authorization=token)
|
24
|
+
|
25
|
+
def add_content_type(self, content_type):
|
26
|
+
return self.add_header(**{"Content-Type": content_type})
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: eclinical_requester
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.10
|
4
4
|
Summary: edetek api requester
|
5
5
|
Home-page: http://example.com
|
6
6
|
Author: xiaodong.li
|
@@ -20,6 +20,7 @@ Dynamic: classifier
|
|
20
20
|
Dynamic: description
|
21
21
|
Dynamic: description-content-type
|
22
22
|
Dynamic: home-page
|
23
|
+
Dynamic: license-file
|
23
24
|
Dynamic: requires-dist
|
24
25
|
Dynamic: summary
|
25
26
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
api_requester/__init__.py,sha256=
|
1
|
+
api_requester/__init__.py,sha256=voa3D8SKm31uC9BTkWCyrTNfZn2UOBxVTt2I_kSBPMY,176
|
2
2
|
api_requester/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
api_requester/core/call_api.py,sha256=OumIPQSNv5JJeghv_r2tDVzmQCDEsvTS4CEmQNz5dO8,2158
|
4
4
|
api_requester/core/admin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -16,22 +16,22 @@ api_requester/core/common/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
16
16
|
api_requester/core/common/api/system_env_api.py,sha256=Ogrc2vSpbjQBUIr_cUfz-TLX4DD_9eg_PabX433VQuA,634
|
17
17
|
api_requester/core/common/service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
18
|
api_requester/core/common/service/system_env_service.py,sha256=SIKQCG2tIf1s4dUsSiFvOMAgai6JQ-xRP5HJ8MKF3Ts,787
|
19
|
-
api_requester/docs/application.yaml,sha256=
|
19
|
+
api_requester/docs/application.yaml,sha256=_yTaHYLd9CdGfM4ua3qbYOO3x36cWjFEcJmPGDB_Pak,1151
|
20
20
|
api_requester/dto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
api_requester/dto/base_dto.py,sha256=nyBGidUblKE6MSK-yvcVSlYDyqPbIEdXiTOvymcFZp0,6904
|
22
22
|
api_requester/dto/biz_base.py,sha256=4lzf6FoXCNBr0OlxbFryf-7v16wfP3Hv6c7WUh-DgNs,874
|
23
|
-
api_requester/dto/user.py,sha256=
|
23
|
+
api_requester/dto/user.py,sha256=zY3vPS-xaKyFzstig55kwmyfPUuMm5vKRhQQKLDTKf0,1299
|
24
24
|
api_requester/dto/admin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
25
|
api_requester/dto/admin/cross_user_user_on_board_dto.py,sha256=VSsihBthlfJORhhVeumDQxuF0lUj5vsLUcF3131Wi1s,489
|
26
26
|
api_requester/dto/admin/jwt_authentication_request.py,sha256=Wo9xTzpVIUJjkr4nYdnXsB7Q2nu3oFpy36K2aUUSy90,472
|
27
27
|
api_requester/dto/admin/user_on_board_dto.py,sha256=zsCKgnEttnsCkFlXKfuzkXWbvIhfiWv3jEj8jY6GRbQ,692
|
28
28
|
api_requester/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
29
|
api_requester/http/app_url.py,sha256=jTGwxPcu_yts4WZbE9wDl6HqGOB48BdEIGw4Otmo1F0,939
|
30
|
-
api_requester/http/authorize.py,sha256=
|
31
|
-
api_requester/http/eclinical_requests.py,sha256=
|
30
|
+
api_requester/http/authorize.py,sha256=3MWW2n6SEeDz1E_gp3w6yRmcyoJZKsR2ffHiCWwrlvY,7612
|
31
|
+
api_requester/http/eclinical_requests.py,sha256=JUQ7EPeAvspz-J6GvpoVM2kA4hyGN4AP166hyQlmeFM,9640
|
32
32
|
api_requester/http/exceptions.py,sha256=BG0eSOkYT50Qib_PpjSrNWkcv9p9gBanOvXOWrP7Jz8,2685
|
33
33
|
api_requester/http/gateway.py,sha256=Ntnj-3OtyKLoGpkcCczMWQ0-0XrS5J_qkEcc9jB5AUk,3676
|
34
|
-
api_requester/http/sample_headers.py,sha256=
|
34
|
+
api_requester/http/sample_headers.py,sha256=4a2z0ITPvnNhXiX0xZHfcexiRQdkIvEv8YUK-eGRwDU,705
|
35
35
|
api_requester/http/token_manager.py,sha256=sQO4zd3smA0XfmEndBwXs-8rRCmjkEU48S8jWxxXevA,919
|
36
36
|
api_requester/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
37
|
api_requester/utils/constant.py,sha256=l1qhn0TkRhX6YAgJUEpiymtTmi1rSmzJVKdPVpayROs,2422
|
@@ -43,8 +43,8 @@ api_requester/utils/placeholder_replacer.py,sha256=umNGeA1KCQ6Ewzsv1xEehLmHtKkgv
|
|
43
43
|
api_requester/utils/read_file.py,sha256=QRE2hZaPaCo7tyY0fW7c6PLXSmc7Zp1HA-SsN_B-2gs,2325
|
44
44
|
api_requester/utils/rsa.py,sha256=dr2m3a2M_LYu1Us97EEiMcjZAkpn1yWKIOjyYYubZeg,1202
|
45
45
|
api_requester/utils/time_utils.py,sha256=u1hHO0POBhdXaTQ7VGY_2YjaYxwlrWXGb5phP8iLfOY,579
|
46
|
-
eclinical_requester-1.0.
|
47
|
-
eclinical_requester-1.0.
|
48
|
-
eclinical_requester-1.0.
|
49
|
-
eclinical_requester-1.0.
|
50
|
-
eclinical_requester-1.0.
|
46
|
+
eclinical_requester-1.0.10.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
47
|
+
eclinical_requester-1.0.10.dist-info/METADATA,sha256=QkApRVkLEqaBAk2NIiySwE3LoHLI1kz_Hicrp-MTkOc,719
|
48
|
+
eclinical_requester-1.0.10.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
49
|
+
eclinical_requester-1.0.10.dist-info/top_level.txt,sha256=nM6wDThrKcbLCcBGrTBPPtstqV97VyITV-YiKLoUG0U,14
|
50
|
+
eclinical_requester-1.0.10.dist-info/RECORD,,
|
{eclinical_requester-1.0.8.dist-info → eclinical_requester-1.0.10.dist-info/licenses}/LICENSE
RENAMED
File without changes
|
File without changes
|