-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathconfig.py
89 lines (68 loc) · 3.04 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import json
import os
from typing import List, Any
from bunq.sdk.model.generated.object_ import Pointer
class Config:
# Delimiter between the IP addresses in the PERMITTED_IPS field.
_DELIMITER_IPS = ","
# Field constants
_FIELD_PERMITTED_IPS = "PERMITTED_IPS"
_FIELD_COUNTER_PARTY_OTHER = "CounterPartyOther"
_FIELD_COUNTER_PARTY_SELF = "CounterPartySelf"
_FIELD_TYPE = "Type"
_FIELD_ALIAS = "Alias"
_FIELD_TAB_USAGE = "TabUsageSingleTest"
_FIELD_CASH_REGISTER_ID = "CASH_REGISTER_ID"
_FIELD_MONETARY_ACCOUNT_ID_1 = "MONETARY_ACCOUNT_ID"
_FIELD_MONETARY_ACCOUNT_ID_2 = "MONETARY_ACCOUNT_ID2"
_FIELD_USER_ID = "USER_ID"
_FIELD_API_KEY = "API_KEY"
_FIELD_ATTACHMENT_PUBLIC = "AttachmentPublicTest"
_FIELD_ATTACHMENT_PATH_IN = "PATH_IN"
_FIELD_ATTACHMENT_DESCRIPTION = "DESCRIPTION"
_FIELD_ATTACHMENT_CONTENT_TYPE = "CONTENT_TYPE"
@classmethod
def get_attachment_content_type(cls) -> str:
return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][cls._FIELD_ATTACHMENT_CONTENT_TYPE]
@classmethod
def get_attachment_description(cls) -> str:
return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][cls._FIELD_ATTACHMENT_DESCRIPTION]
@classmethod
def get_attachment_path_in(cls) -> str:
return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][cls._FIELD_ATTACHMENT_PATH_IN]
@classmethod
def get_api_key(cls) -> str:
return cls._get_config_file()[cls._FIELD_API_KEY]
@classmethod
def get_user_id(cls) -> int:
return int(cls._get_config_file()[cls._FIELD_USER_ID])
@classmethod
def get_monetary_account_id_2(cls) -> int:
return int(cls._get_config_file()[cls._FIELD_MONETARY_ACCOUNT_ID_2])
@classmethod
def get_monetary_account_id_1(cls) -> int:
return int(cls._get_config_file()[cls._FIELD_MONETARY_ACCOUNT_ID_1])
@classmethod
def get_cash_register_id(cls) -> str:
return cls._get_config_file()[cls._FIELD_TAB_USAGE][cls._FIELD_CASH_REGISTER_ID]
@classmethod
def get_pointer_counter_party_self(cls) -> Pointer:
type_ = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_SELF][cls._FIELD_TYPE]
alias = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_SELF][cls._FIELD_ALIAS]
return Pointer(type_, alias)
@classmethod
def get_pointer_counter_party_other(cls) -> Pointer:
type_ = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_OTHER][cls._FIELD_TYPE]
alias = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_OTHER][cls._FIELD_ALIAS]
return Pointer(type_, alias)
@classmethod
def get_permitted_ips(cls) -> List[str]:
permitted_ips_str = cls._get_config_file()[cls._FIELD_PERMITTED_IPS]
if not permitted_ips_str:
return []
return permitted_ips_str.split(cls._DELIMITER_IPS)
@classmethod
def _get_config_file(cls) -> Any:
file_path = os.path.dirname(os.path.realpath(__file__))
with open(file_path + "/assets/config.json", "r") as f:
return json.load(f)