88 MONOBANK_STATEMENT_URI ,
99 MONOBANK_WEBHOOK_URI ,
1010 MONOBANK_CURRENCIES ,
11+ MONOBANK_CURRENCY_CODE_A ,
12+ MONOBANK_CURRENCY_CODE_B ,
1113)
1214
1315
@@ -20,51 +22,73 @@ def __init__(self, token=None):
2022 _mono_statement_uri = MONOBANK_STATEMENT_URI
2123 _mono_webhook_uri = MONOBANK_WEBHOOK_URI
2224 _mono_currencies = MONOBANK_CURRENCIES
25+ _mono_currency_code_a = MONOBANK_CURRENCY_CODE_A
26+ _mono_currency_code_b = MONOBANK_CURRENCY_CODE_B
2327
2428 @property
2529 def token (self ) -> str :
2630 return self ._token
2731
2832 @token .setter
29- def token (self , new_token ):
33+ def token (self , new_token : str ):
3034 self ._token = new_token
3135
3236 @property
3337 def mono_currency_uri (self ) -> str :
3438 return self ._mono_currency_uri
3539
3640 @mono_currency_uri .setter
37- def mono_currency_uri (self , new_uri ):
41+ def mono_currency_uri (self , new_uri : str ):
3842 self ._mono_currency_uri = new_uri
3943
4044 @property
4145 def mono_client_info_uri (self ) -> str :
4246 return self ._mono_client_info_uri
4347
4448 @mono_client_info_uri .setter
45- def mono_client_info_uri (self , new_uri ):
49+ def mono_client_info_uri (self , new_uri : str ):
4650 self ._mono_client_info_uri = new_uri
4751
4852 @property
4953 def mono_statement_uri (self ) -> str :
5054 return self ._mono_statement_uri
5155
5256 @mono_statement_uri .setter
53- def mono_statement_uri (self , new_uri ):
57+ def mono_statement_uri (self , new_uri : str ):
5458 self ._mono_statement_uri = new_uri
5559
5660 @property
5761 def mono_webhook_uri (self ) -> str :
5862 return self ._mono_webhook_uri
5963
6064 @mono_webhook_uri .setter
61- def mono_webhook_uri (self , new_uri ):
65+ def mono_webhook_uri (self , new_uri : str ):
6266 self ._mono_webhook_uri = new_uri
6367
68+ @property
69+ def mono_currency_code_a (self ) -> str :
70+ return self ._mono_currency_code_a
71+
72+ @mono_currency_code_a .setter
73+ def mono_currency_code_a (self , new_code : str ):
74+ self ._mono_currency_code_a = new_code
75+
76+ @property
77+ def mono_currency_code_b (self ) -> str :
78+ return self ._mono_currency_code_b
79+
80+ @mono_currency_code_b .setter
81+ def mono_currency_code_b (self , new_code : str ):
82+ self ._mono_currency_code_b = new_code
83+
6484 @property
6585 def mono_currencies (self ) -> Dict :
6686 return self ._mono_currencies
6787
88+ @mono_currencies .setter
89+ def mono_currencies (self , new_currencies : Dict ):
90+ self ._mono_currencies = new_currencies
91+
6892 @classmethod
6993 def session (cls ) -> requests .sessions .Session :
7094 return requests .Session ()
@@ -103,12 +127,12 @@ def get_currency(self, ccy_pair: str) -> Dict:
103127 code = currencies .get ("code" )
104128 payload = currencies .get ("detail" )
105129 if isinstance (payload , list ):
130+ codeA = self .mono_currency_code_a
131+ codeB = self .mono_currency_code_b
106132 for ccy in payload :
107- if ccy .get ("currencyCodeB" ) == pair .get ("currencyCodeB" ):
133+ if ccy .get (codeB ) == pair .get (codeB ):
108134 for key , value in ccy .items ():
109- if key == "currencyCodeA" and value == pair .get (
110- "currencyCodeA"
111- ):
135+ if key == codeA and value == pair .get (codeA ):
112136 buy = ccy .get ("rateBuy" )
113137 sale = ccy .get ("rateSell" )
114138 if buy is not None and sale is not None :
@@ -124,7 +148,7 @@ def get_currency(self, ccy_pair: str) -> Dict:
124148 except AttributeError :
125149 error_response = {
126150 "code" : 400 ,
127- "detail" : "Please enter a valid query " ,
151+ "detail" : "Incorrect currency pair " ,
128152 "list of acceptable currency pairs" : self .mono_currencies .keys (),
129153 }
130154 return error_response
0 commit comments