forked from bunq/sdk_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
143 lines (111 loc) · 3.57 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import json
import os
from bunq.sdk.model.generated import object_
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):
"""
:rtype: str
"""
return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][
cls._FIELD_ATTACHMENT_CONTENT_TYPE]
@classmethod
def get_attachment_description(cls):
"""
:rtype: str
"""
return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][
cls._FIELD_ATTACHMENT_DESCRIPTION]
@classmethod
def get_attachment_path_in(cls):
"""
:rtype: str
"""
return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][
cls._FIELD_ATTACHMENT_PATH_IN]
@classmethod
def get_api_key(cls):
"""
:rtype: str
"""
return cls._get_config_file()[cls._FIELD_API_KEY]
@classmethod
def get_user_id(cls):
"""
:rtype: int
"""
return int(cls._get_config_file()[cls._FIELD_USER_ID])
@classmethod
def get_monetary_account_id_2(cls):
"""
:rtype: int
"""
return int(cls._get_config_file()[cls._FIELD_MONETARY_ACCOUNT_ID_2])
@classmethod
def get_monetary_account_id_1(cls):
"""
:rtype: int
"""
return int(cls._get_config_file()[cls._FIELD_MONETARY_ACCOUNT_ID_1])
@classmethod
def get_cash_register_id(cls):
"""
:rtype str
"""
return cls._get_config_file()[cls._FIELD_TAB_USAGE][
cls._FIELD_CASH_REGISTER_ID]
@classmethod
def get_pointer_counter_party_self(cls):
"""
:rtype: 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 object_.Pointer(type_, alias)
@classmethod
def get_pointer_counter_party_other(cls):
"""
:rtype: 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 object_.Pointer(type_, alias)
@classmethod
def get_permitted_ips(cls):
"""
:rtype: 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):
"""
:rtype: json.load
"""
file_path = os.path.dirname(os.path.realpath(__file__))
with open(file_path + "/assets/config.json", "r") as f:
return json.load(f)