1
1
import argparse
2
2
import os
3
3
import sys
4
+ from typing import Union , List
4
5
5
- from bunq . sdk . context import ApiEnvironmentType
6
- from bunq .sdk .exception import BunqException
7
- from bunq .sdk .model .generated import endpoint
8
- from bunq .sdk .model .generated import object_
6
+ from bunq import ApiEnvironmentType
7
+ from bunq .sdk .exception . bunq_exception import BunqException
8
+ from bunq .sdk .model .generated . endpoint import UserPerson , UserCompany , UserLight , MonetaryAccountBank , Card
9
+ from bunq .sdk .model .generated . object_ import Pointer , LabelMonetaryAccount
9
10
10
11
11
12
class ShareLib (object ):
@@ -56,11 +57,7 @@ def parse_all_option(cls):
56
57
return parser .parse_args ()
57
58
58
59
@classmethod
59
- def determine_environment_type_from_all_option (cls , all_option ):
60
- """
61
- :rtype: ApiEnvironmentType
62
- """
63
-
60
+ def determine_environment_type_from_all_option (cls , all_option ) -> ApiEnvironmentType :
64
61
if all_option .production :
65
62
cls .environment_type = ApiEnvironmentType .PRODUCTION
66
63
else :
@@ -69,11 +66,7 @@ def determine_environment_type_from_all_option(cls, all_option):
69
66
return cls .environment_type
70
67
71
68
@classmethod
72
- def determine_amount_from_all_option_or_std_in (cls , all_option ):
73
- """
74
- :rtype: str
75
- """
76
-
69
+ def determine_amount_from_all_option_or_std_in (cls , all_option ) -> str :
77
70
if all_option .amount :
78
71
return all_option .amount
79
72
else :
@@ -82,11 +75,7 @@ def determine_amount_from_all_option_or_std_in(cls, all_option):
82
75
return sys .stdin .readline ().strip ()
83
76
84
77
@classmethod
85
- def determine_description_from_all_option_or_std_in (cls , all_option ):
86
- """
87
- :rtype: str
88
- """
89
-
78
+ def determine_description_from_all_option_or_std_in (cls , all_option ) -> str :
90
79
if all_option .description :
91
80
return all_option .description
92
81
else :
@@ -95,11 +84,7 @@ def determine_description_from_all_option_or_std_in(cls, all_option):
95
84
return sys .stdin .readline ().strip ()
96
85
97
86
@classmethod
98
- def determine_recipient_from_all_option_or_std_in (cls , all_option ):
99
- """
100
- :rtype: str
101
-
102
- """
87
+ def determine_recipient_from_all_option_or_std_in (cls , all_option ) -> str :
103
88
if all_option .recipient :
104
89
return all_option .recipient
105
90
else :
@@ -112,11 +97,7 @@ def determine_recipient_from_all_option_or_std_in(cls, all_option):
112
97
return sys .stdin .readline ().strip ()
113
98
114
99
@classmethod
115
- def determine_card_id_from_all_option_or_std_in (cls , all_option ):
116
- """
117
- :rtype: str
118
- """
119
-
100
+ def determine_card_id_from_all_option_or_std_in (cls , all_option ) -> str :
120
101
if all_option .card_id :
121
102
return all_option .card_id
122
103
else :
@@ -125,11 +106,7 @@ def determine_card_id_from_all_option_or_std_in(cls, all_option):
125
106
return sys .stdin .readline ().strip ()
126
107
127
108
@classmethod
128
- def determine_account_id_from_all_option_or_std_in (cls , all_option ):
129
- """
130
- :rtype: str
131
- """
132
-
109
+ def determine_account_id_from_all_option_or_std_in (cls , all_option ) -> str :
133
110
if all_option .account_id :
134
111
return all_option .account_id
135
112
else :
@@ -138,11 +115,7 @@ def determine_account_id_from_all_option_or_std_in(cls, all_option):
138
115
return sys .stdin .readline ().strip ()
139
116
140
117
@classmethod
141
- def determine_callback_url_from_all_option_or_std_in (cls , all_option ):
142
- """
143
- :rtype: str
144
- """
145
-
118
+ def determine_callback_url_from_all_option_or_std_in (cls , all_option ) -> str :
146
119
if all_option .callback_url :
147
120
return all_option .callback_url
148
121
else :
@@ -151,11 +124,7 @@ def determine_callback_url_from_all_option_or_std_in(cls, all_option):
151
124
pass
152
125
153
126
@classmethod
154
- def determine_name_from_all_option_or_std_in (cls , all_option ):
155
- """
156
- :rtype: str
157
- """
158
-
127
+ def determine_name_from_all_option_or_std_in (cls , all_option ) -> str :
159
128
if all_option .name :
160
129
return all_option .name
161
130
else :
@@ -190,12 +159,7 @@ def print_header(cls):
190
159
""" )
191
160
192
161
@classmethod
193
- def print_user (cls , user ):
194
- """
195
-
196
- :param user: UserPerson|UserCompany|UserLight
197
- """
198
-
162
+ def print_user (cls , user : Union [UserPerson , UserCompany , UserLight ]):
199
163
print (cls ._ECHO_USER )
200
164
print (f'''
201
165
┌───────────────────┬────────────────────────────────────────────────────
@@ -205,22 +169,14 @@ def print_user(cls, user):
205
169
└───────────────────┴────────────────────────────────────────────────────''' )
206
170
207
171
@classmethod
208
- def print_all_monetary_account_bank (cls , all_monetary_account_bank ):
209
- """
210
- :type all_monetary_account_bank: list[endpoint.MonetaryAccountBank]
211
- """
212
-
172
+ def print_all_monetary_account_bank (cls , all_monetary_account_bank : List [MonetaryAccountBank ]):
213
173
print (cls ._ECHO_MONETARY_ACCOUNT )
214
174
215
175
for monetary_account_bank in all_monetary_account_bank :
216
176
cls .print_monetary_account_bank (monetary_account_bank )
217
177
218
178
@classmethod
219
- def print_monetary_account_bank (cls , monetary_account_bank ):
220
- """
221
- :param monetary_account_bank: MonetaryAccountBank
222
- """
223
-
179
+ def print_monetary_account_bank (cls , monetary_account_bank : MonetaryAccountBank ):
224
180
pointer_iban = cls .get_first_pointer_iban (monetary_account_bank )
225
181
226
182
print (f'''
@@ -239,11 +195,7 @@ def print_monetary_account_bank(cls, monetary_account_bank):
239
195
f' └───────────────────┴────────────────────────────────────────────────────' )
240
196
241
197
@classmethod
242
- def get_first_pointer_iban (cls , monetary_account_bank ):
243
- """
244
- :rtype: object_.Pointer
245
- """
246
-
198
+ def get_first_pointer_iban (cls , monetary_account_bank ) -> Pointer :
247
199
for alias in monetary_account_bank .alias :
248
200
if alias .type_ == cls ._POINTER_TYPE_IBAN :
249
201
return alias
@@ -253,7 +205,7 @@ def get_first_pointer_iban(cls, monetary_account_bank):
253
205
@classmethod
254
206
def print_all_payment (cls , all_payment ):
255
207
"""
256
- :type all_payment: list[endpoint. Payment]
208
+ :type all_payment: list[Payment]
257
209
"""
258
210
259
211
print (cls ._ECHO_PAYMENT )
@@ -264,7 +216,7 @@ def print_all_payment(cls, all_payment):
264
216
@classmethod
265
217
def print_payment (cls , payment ):
266
218
"""
267
- :type payment: endpoint. Payment
219
+ :type payment: Payment
268
220
"""
269
221
270
222
print (f'''
@@ -281,7 +233,7 @@ def print_payment(cls, payment):
281
233
@classmethod
282
234
def print_all_request (cls , all_request ):
283
235
"""
284
- :type all_request: list[endpoint. RequestInquiry]
236
+ :type all_request: list[RequestInquiry]
285
237
"""
286
238
287
239
print (cls ._ECHO_REQUEST )
@@ -292,7 +244,7 @@ def print_all_request(cls, all_request):
292
244
@classmethod
293
245
def print_request (cls , request ):
294
246
"""
295
- :type request: endpoint. RequestInquiry
247
+ :type request: RequestInquiry
296
248
"""
297
249
298
250
print (f'''
@@ -311,8 +263,8 @@ def print_request(cls, request):
311
263
@classmethod
312
264
def print_all_card (cls , all_card , all_monetary_account ):
313
265
"""
314
- :param all_card: list(endpoint. Card)
315
- :param all_monetary_account: list[endpoint. MonetaryAccountBank]
266
+ :param all_card: list(Card)
267
+ :param all_monetary_account: list[MonetaryAccountBank]
316
268
"""
317
269
318
270
print (cls ._ECHO_CARD )
@@ -321,12 +273,7 @@ def print_all_card(cls, all_card, all_monetary_account):
321
273
cls .print_card (card , all_monetary_account )
322
274
323
275
@classmethod
324
- def print_card (cls , card , all_monetary_account ):
325
- """
326
- :type card: endpoint.Card
327
- :type all_monetary_account: list[endpoint.MonetaryAccountBank]
328
- """
329
-
276
+ def print_card (cls , card : Card , all_monetary_account : List [MonetaryAccountBank ]):
330
277
if card .label_monetary_account_current is None :
331
278
linked_account = 'No account linked yet.'
332
279
else :
@@ -335,7 +282,7 @@ def print_card(cls, card, all_monetary_account):
335
282
all_monetary_account
336
283
)
337
284
linked_account = f'{ monetary_account .description } ' \
338
- f'({ card .label_monetary_account_current .label_monetary_account .iban } )'
285
+ f'({ card .label_monetary_account_current .label_monetary_account .iban } )'
339
286
340
287
print (f'''
341
288
┌───────────────────┬────────────────────────────────────────────────────
@@ -351,13 +298,8 @@ def print_card(cls, card, all_monetary_account):
351
298
└───────────────────┴────────────────────────────────────────────────────''' )
352
299
353
300
@classmethod
354
- def get_monetary_account_from_label (cls , label_monetary_account_current ,
355
- all_monetary_account ):
356
- """
357
- :type label_monetary_account_current: object_.LabelMonetaryAccount
358
- :type all_monetary_account: list[endpoint.MonetaryAccountBank]
359
- """
360
-
301
+ def get_monetary_account_from_label (cls , label_monetary_account_current : LabelMonetaryAccount ,
302
+ all_monetary_account : List [MonetaryAccountBank ]):
361
303
iban_label = label_monetary_account_current .iban
362
304
363
305
for monetary_account in all_monetary_account :
@@ -370,13 +312,8 @@ def get_monetary_account_from_label(cls, label_monetary_account_current,
370
312
return None
371
313
372
314
@staticmethod
373
- def print_all_user_alias (all_user_alias ):
374
- """
375
- :type all_user_alias: list[object_.Pointer]
376
- """
377
-
378
- print ("\n " + " You can use these login credentials to login in to "
379
- "the bunq sandbox app." )
315
+ def print_all_user_alias (all_user_alias : List [Pointer ]):
316
+ print ("\n " + " You can use these login credentials to login in to the bunq sandbox app." )
380
317
381
318
for alias in all_user_alias :
382
319
print (f'''
0 commit comments