8
8
from bunq .sdk .context .api_context import ApiContext , ApiEnvironmentType
9
9
from bunq .sdk .exception .bunq_exception import BunqException
10
10
from bunq .sdk .http .api_client import ApiClient
11
- from bunq .sdk .model .generated import endpoint
12
11
from bunq .sdk .model .generated .endpoint import SandboxUserPerson
13
12
14
13
__UNIQUE_REQUEST_ID = "uniqueness-is-required"
17
16
__FIELD_RESPONSE = "Response"
18
17
__ENDPOINT_SANDBOX_USER_PERSON = "sandbox-user-person"
19
18
19
+ # Error constants
20
20
_ERROR_COULD_NOT_CREATE_NEW_SANDBOX_USER = "Could not create new sandbox user."
21
+ _ERROR_ALL_FIELD_IS_NULL = 'All fields are null'
21
22
22
23
23
24
def automatic_sandbox_install () -> ApiContext :
24
25
sandbox_user = __generate_new_sandbox_user ()
25
26
26
- return ApiContext .create (ApiEnvironmentType .SANDBOX ,
27
- sandbox_user .api_key ,
28
- socket .gethostname ()
29
- )
27
+ return ApiContext .create (ApiEnvironmentType .SANDBOX , sandbox_user .api_key , socket .gethostname ())
30
28
31
29
32
30
def __generate_new_sandbox_user () -> SandboxUserPerson :
@@ -44,8 +42,7 @@ def __generate_new_sandbox_user() -> SandboxUserPerson:
44
42
45
43
if response .status_code is ApiClient .STATUS_CODE_OK :
46
44
response_json = json .loads (response .text )
47
- return SandboxUserPerson .from_json (
48
- json .dumps (response_json [__FIELD_RESPONSE ][__INDEX_FIRST ][
49
- __FIELD_API_KEY ]))
45
+
46
+ return SandboxUserPerson .from_json (json .dumps (response_json [__FIELD_RESPONSE ][__INDEX_FIRST ][__FIELD_API_KEY ]))
50
47
51
48
raise BunqException (_ERROR_COULD_NOT_CREATE_NEW_SANDBOX_USER )
0 commit comments