-
-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add currency enum #1194
Add currency enum #1194
Conversation
✔️ Changelog found.Thank you for adding a description of the changes |
Is it possible to parse the values for this list using Butcher? |
Do you mean automatically add new currencies? |
Yes. |
I think it would be better to add them manually :) |
Please add file name: Currency
description: |
Currencies supported by Telegram Bot API
Source: https://core.telegram.org/bots/payments#supported-currencies
static:
AED: "AED" # United Arab Emirates Dirham
AFN: "AFN" # Afghan Afghani
ALL: "ALL" # Albanian Lek
AMD: "AMD" # Armenian Dram
ARS: "ARS" # Argentine Peso
AUD: "AUD" # Australian Dollar
AZN: "AZN" # Azerbaijani Manat
BAM: "BAM" # Bosnia & Herzegovina Convertible Mark
BDT: "BDT" # Bangladeshi Taka
BGN: "BGN" # Bulgarian Lev
BND: "BND" # Brunei Dollar
BOB: "BOB" # Bolivian Boliviano
BRL: "BRL" # Brazilian Real
BYN: "BYN" # Belarusian ruble
CAD: "CAD" # Canadian Dollar
CHF: "CHF" # Swiss Franc
CLP: "CLP" # Chilean Peso
CNY: "CNY" # Chinese Renminbi Yuan
COP: "COP" # Colombian Peso
CRC: "CRC" # Costa Rican Colón
CZK: "CZK" # Czech Koruna
DKK: "DKK" # Danish Krone
DOP: "DOP" # Dominican Peso
DZD: "DZD" # Algerian Dinar
EGP: "EGP" # Egyptian Pound
ETB: "ETB" # Ethiopian Birr
EUR: "EUR" # Euro
GBP: "GBP" # British Pound
GEL: "GEL" # Georgian Lari
GTQ: "GTQ" # Guatemalan Quetzal
HKD: "HKD" # Hong Kong Dollar
HNL: "HNL" # Honduran Lempira
HRK: "HRK" # Croatian Kuna
HUF: "HUF" # Hungarian Forint
IDR: "IDR" # Indonesian Rupiah
ILS: "ILS" # Israeli New Sheqel
INR: "INR" # Indian Rupee
ISK: "ISK" # Icelandic Króna
JMD: "JMD" # Jamaican Dollar
JPY: "JPY" # Japanese Yen
KES: "KES" # Kenyan Shilling
KGS: "KGS" # Kyrgyzstani Som
KRW: "KRW" # South Korean Won
KZT: "KZT" # Kazakhstani Tenge
LBP: "LBP" # Lebanese Pound
LKR: "LKR" # Sri Lankan Rupee
MAD: "MAD" # Moroccan Dirham
MDL: "MDL" # Moldovan Leu
MNT: "MNT" # Mongolian Tögrög
MUR: "MUR" # Mauritian Rupee
MVR: "MVR" # Maldivian Rufiyaa
MXN: "MXN" # Mexican Peso
MYR: "MYR" # Malaysian Ringgit
MZN: "MZN" # Mozambican Metical
NGN: "NGN" # Nigerian Naira
NIO: "NIO" # Nicaraguan Córdoba
NOK: "NOK" # Norwegian Krone
NPR: "NPR" # Nepalese Rupee
NZD: "NZD" # New Zealand Dollar
PAB: "PAB" # Panamanian Balboa
PEN: "PEN" # Peruvian Nuevo Sol
PHP: "PHP" # Philippine Peso
PKR: "PKR" # Pakistani Rupee
PLN: "PLN" # Polish Złoty
PYG: "PYG" # Paraguayan Guaraní
QAR: "QAR" # Qatari Riyal
RON: "RON" # Romanian Leu
RSD: "RSD" # Serbian Dinar
RUB: "RUB" # Russian Ruble
SAR: "SAR" # Saudi Riyal
SEK: "SEK" # Swedish Krona
SGD: "SGD" # Singapore Dollar
THB: "THB" # Thai Baht
TJS: "TJS" # Tajikistani Somoni
TRY: "TRY" # Turkish Lira
TTD: "TTD" # Trinidad and Tobago Dollar
TWD: "TWD" # New Taiwan Dollar
TZS: "TZS" # Tanzanian Shilling
UAH: "UAH" # Ukrainian Hryvnia
UGX: "UGX" # Ugandan Shilling
USD: "USD" # United States Dollar
UYU: "UYU" # Uruguayan Peso
UZS: "UZS" # Uzbekistani Som
VND: "VND" # Vietnamese Đồng
YER: "YER" # Yemeni Rial
ZAR: "ZAR" # South African Rand
|
It would be nice to generate full objects with title and amount constraints. class Currency(...):
code: str
title: str
min_amount: float | None = None
max_amount: float | None = None
# E.g.:
ALL = Currency(code="ALL", title="Albanian Lek", min_amount=95,86, max_amount=958.637,25) This way I can validate amount provided by user BEFORE I send the value to Telegram API |
but the range of values depends on the dollar exchange rate and is often changing. |
Agree, but the title may help to print the list of choice to user min and max amount fields may be filled and ttl-cached with code owner data ... or not :) |
Codecov Report
@@ Coverage Diff @@
## dev-3.x #1194 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 358 364 +6
Lines 8841 9216 +375
==========================================
+ Hits 8841 9216 +375
Flags with carried forward coverage won't be shown. Click here to find out more.
|
imho in this case it would be better to make sure that the name of the enum element is also their value, nothing more. |
@JrooTJunior im sorry, there is an error in my example - can you replace |
@dsodx, fixed in b9abf70 |
Description
I added Currency enum.
I believe that my PR will be useful, for example, when creating a payment:
Since it excludes, above all, typos.
Type of change
How Has This Been Tested?
Test A:
pytest tests
[OK]Test B: [OK]
Output:
Test Configuration:
Windows 11 22H2
3.11.3
Checklist: