mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Replace Currency enum with String, mention XTR special currency in docs
This commit is contained in:
parent
093377e3ff
commit
4b05e9dd69
9 changed files with 50 additions and 387 deletions
|
@ -4041,7 +4041,11 @@ Schema(
|
|||
Param(
|
||||
name: "currency",
|
||||
ty: String,
|
||||
descr: Doc(md: "Three-letter ISO 4217 currency code, see more on currencies"),
|
||||
descr: Doc(md: "Three-letter ISO 4217 currency code, see [more on currencies]. Pass `XTR` for payments in [Telegram Stars]."),
|
||||
md_links: {
|
||||
"more on currencies":"https://core.telegram.org/bots/payments#supported-currencies",
|
||||
"Telegram Stars": "Telegram Stars"
|
||||
}
|
||||
),
|
||||
Param(
|
||||
name: "prices",
|
||||
|
@ -4187,7 +4191,11 @@ Schema(
|
|||
Param(
|
||||
name: "currency",
|
||||
ty: String,
|
||||
descr: Doc(md: "Three-letter ISO 4217 currency code, see more on currencies"),
|
||||
descr: Doc(md: "Three-letter ISO 4217 currency code, see [more on currencies]. Pass `XTR` for payments in [Telegram Stars]."),
|
||||
md_links: {
|
||||
"more on currencies":"https://core.telegram.org/bots/payments#supported-currencies",
|
||||
"Telegram Stars": "Telegram Stars"
|
||||
}
|
||||
),
|
||||
Param(
|
||||
name: "prices",
|
||||
|
|
|
@ -19,7 +19,10 @@ impl_payload! {
|
|||
///
|
||||
/// [Botfather]: https://t.me/botfather
|
||||
pub provider_token: String [into],
|
||||
/// Three-letter ISO 4217 currency code, see more on currencies
|
||||
/// Three-letter ISO 4217 currency code, see [more on currencies]. Pass `XTR` for payments in [Telegram Stars].
|
||||
///
|
||||
/// [more on currencies]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
/// [Telegram Stars]: https://t.me/BotNews/90
|
||||
pub currency: String [into],
|
||||
/// Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
|
||||
pub prices: Vec<LabeledPrice> [collect],
|
||||
|
|
|
@ -26,7 +26,10 @@ impl_payload! {
|
|||
///
|
||||
/// [Botfather]: https://t.me/botfather
|
||||
pub provider_token: String [into],
|
||||
/// Three-letter ISO 4217 currency code, see more on currencies
|
||||
/// Three-letter ISO 4217 currency code, see [more on currencies]. Pass `XTR` for payments in [Telegram Stars].
|
||||
///
|
||||
/// [more on currencies]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
/// [Telegram Stars]: https://t.me/BotNews/90
|
||||
pub currency: String [into],
|
||||
/// Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
|
||||
pub prices: Vec<LabeledPrice> [collect],
|
||||
|
|
|
@ -306,10 +306,9 @@ mod passport_data;
|
|||
mod passport_element_error;
|
||||
mod passport_file;
|
||||
|
||||
pub use non_telegram_types::{country_code::*, currency::*, until_date::*};
|
||||
pub use non_telegram_types::{country_code::*, until_date::*};
|
||||
mod non_telegram_types {
|
||||
pub(super) mod country_code;
|
||||
pub(super) mod currency;
|
||||
pub(crate) mod mime;
|
||||
pub(super) mod until_date;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use reqwest::Url;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{Currency, LabeledPrice, LinkPreviewOptions, MessageEntity, ParseMode};
|
||||
use crate::types::{LabeledPrice, LinkPreviewOptions, MessageEntity, ParseMode};
|
||||
|
||||
/// This object represents the content of a message to be sent as a result of an
|
||||
/// inline query.
|
||||
|
@ -329,10 +329,12 @@ pub struct InputMessageContentInvoice {
|
|||
/// [@Botfather]: https://t.me/Botfather
|
||||
pub provider_token: String,
|
||||
|
||||
/// Three-letter ISO 4217 currency code, see [more on currencies]
|
||||
/// Three-letter ISO 4217 currency code, see [more on currencies]. Pass
|
||||
/// `XTR` for payments in [Telegram Stars].
|
||||
///
|
||||
/// [more on currencies]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
pub currency: Currency,
|
||||
/// [Telegram Stars]: https://t.me/BotNews/90
|
||||
pub currency: String,
|
||||
|
||||
/// Price breakdown, list of components (e.g. product price, tax, discount,
|
||||
/// delivery cost, delivery tax, bonus, etc.)
|
||||
|
@ -396,12 +398,12 @@ pub struct InputMessageContentInvoice {
|
|||
}
|
||||
|
||||
impl InputMessageContentInvoice {
|
||||
pub fn new<T, D, PA, PT, PR>(
|
||||
pub fn new<T, D, PA, PT, C, PR>(
|
||||
title: T,
|
||||
description: D,
|
||||
payload: PA,
|
||||
provider_token: PT,
|
||||
currency: Currency,
|
||||
currency: C,
|
||||
prices: PR,
|
||||
) -> Self
|
||||
where
|
||||
|
@ -409,12 +411,14 @@ impl InputMessageContentInvoice {
|
|||
D: Into<String>,
|
||||
PA: Into<String>,
|
||||
PT: Into<String>,
|
||||
C: Into<String>,
|
||||
PR: IntoIterator<Item = LabeledPrice>,
|
||||
{
|
||||
let title = title.into();
|
||||
let description = description.into();
|
||||
let payload = payload.into();
|
||||
let provider_token = provider_token.into();
|
||||
let currency = currency.into();
|
||||
let prices = prices.into_iter().collect();
|
||||
|
||||
Self {
|
||||
|
@ -474,8 +478,11 @@ impl InputMessageContentInvoice {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn currency(mut self, val: Currency) -> Self {
|
||||
self.currency = val;
|
||||
pub fn currency<T>(mut self, val: T) -> Self
|
||||
where
|
||||
T: Into<String>,
|
||||
{
|
||||
self.currency = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,11 @@ pub struct Invoice {
|
|||
/// invoice.
|
||||
pub start_parameter: String,
|
||||
|
||||
/// Three-letter ISO 4217 currency code.
|
||||
/// Three-letter ISO 4217 currency code, see [more on currencies]. Pass
|
||||
/// `XTR` for payments in [Telegram Stars].
|
||||
///
|
||||
/// [more on currencies]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
/// [Telegram Stars]: https://t.me/BotNews/90
|
||||
pub currency: String,
|
||||
|
||||
/// Total price in the smallest units of the currency (integer, **not**
|
||||
|
|
|
@ -1,365 +0,0 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// ISO 4217 currency.
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Currency {
|
||||
/// United Arab Emirates dirham
|
||||
AED,
|
||||
/// Afghan afghani
|
||||
AFN,
|
||||
/// Albanian lek
|
||||
ALL,
|
||||
/// Armenian dram
|
||||
AMD,
|
||||
/// Netherlands Antillean guilder
|
||||
ANG,
|
||||
/// Angolan kwanza
|
||||
AOA,
|
||||
/// Argentine peso
|
||||
ARS,
|
||||
/// Australian dollar
|
||||
AUD,
|
||||
/// Aruban florin
|
||||
AWG,
|
||||
/// Azerbaijani manat
|
||||
AZN,
|
||||
/// Bosnia and Herzegovina convertible mark
|
||||
BAM,
|
||||
/// Barbados dollar
|
||||
BBD,
|
||||
/// Bangladeshi taka
|
||||
BDT,
|
||||
/// Bulgarian lev
|
||||
BGN,
|
||||
/// Bahraini dinar
|
||||
BHD,
|
||||
/// Burundian franc
|
||||
BIF,
|
||||
/// Bermudian dollar
|
||||
BMD,
|
||||
/// Brunei dollar
|
||||
BND,
|
||||
/// Boliviano
|
||||
BOB,
|
||||
/// Bolivian Mvdol (funds code)
|
||||
BOV,
|
||||
/// Brazilian real
|
||||
BRL,
|
||||
/// Bahamian dollar
|
||||
BSD,
|
||||
/// Bhutanese ngultrum
|
||||
BTN,
|
||||
/// Botswana pula
|
||||
BWP,
|
||||
/// Belarusian ruble
|
||||
BYN,
|
||||
/// Belize dollar
|
||||
BZD,
|
||||
/// Canadian dollar
|
||||
CAD,
|
||||
/// Congolese franc
|
||||
CDF,
|
||||
/// WIR euro (complementary currency)
|
||||
CHE,
|
||||
/// Swiss franc
|
||||
CHF,
|
||||
/// WIR franc (complementary currency)
|
||||
CHW,
|
||||
/// Unidad de Fomento (funds code)
|
||||
CLF,
|
||||
/// Chilean peso
|
||||
CLP,
|
||||
/// Chinese yuan
|
||||
CNY,
|
||||
/// Colombian peso
|
||||
COP,
|
||||
/// Unidad de Valor Real (UVR) (funds code)
|
||||
COU,
|
||||
/// Costa Rican colon
|
||||
CRC,
|
||||
/// Cuban convertible peso
|
||||
CUC,
|
||||
/// Cuban peso
|
||||
CUP,
|
||||
/// Cape Verdean escudo
|
||||
CVE,
|
||||
/// Czech koruna
|
||||
CZK,
|
||||
/// Djiboutian franc
|
||||
DJF,
|
||||
/// Danish krone
|
||||
DKK,
|
||||
/// Dominican peso
|
||||
DOP,
|
||||
/// Algerian dinar
|
||||
DZD,
|
||||
/// Egyptian pound
|
||||
EGP,
|
||||
/// Eritrean nakfa
|
||||
ERN,
|
||||
/// Ethiopian birr
|
||||
ETB,
|
||||
/// Euro
|
||||
EUR,
|
||||
/// Fiji dollar
|
||||
FJD,
|
||||
/// Falkland Islands pound
|
||||
FKP,
|
||||
/// Pound sterling
|
||||
GBP,
|
||||
/// Georgian lari
|
||||
GEL,
|
||||
/// Ghanaian cedi
|
||||
GHS,
|
||||
/// Gibraltar pound
|
||||
GIP,
|
||||
/// Gambian dalasi
|
||||
GMD,
|
||||
/// Guinean franc
|
||||
GNF,
|
||||
/// Guatemalan quetzal
|
||||
GTQ,
|
||||
/// Guyanese dollar
|
||||
GYD,
|
||||
/// Hong Kong dollar
|
||||
HKD,
|
||||
/// Honduran lempira
|
||||
HNL,
|
||||
/// Croatian kuna
|
||||
HRK,
|
||||
/// Haitian gourde
|
||||
HTG,
|
||||
/// Hungarian forint
|
||||
HUF,
|
||||
/// Indonesian rupiah
|
||||
IDR,
|
||||
/// Israeli new shekel
|
||||
ILS,
|
||||
/// Indian rupee
|
||||
INR,
|
||||
/// Iraqi dinar
|
||||
IQD,
|
||||
/// Iranian rial
|
||||
IRR,
|
||||
/// Icelandic króna
|
||||
ISK,
|
||||
/// Jamaican dollar
|
||||
JMD,
|
||||
/// Jordanian dinar
|
||||
JOD,
|
||||
/// Japanese yen
|
||||
JPY,
|
||||
/// Kenyan shilling
|
||||
KES,
|
||||
/// Kyrgyzstani som
|
||||
KGS,
|
||||
/// Cambodian riel
|
||||
KHR,
|
||||
/// Comoro franc
|
||||
KMF,
|
||||
/// North Korean won
|
||||
KPW,
|
||||
/// South Korean won
|
||||
KRW,
|
||||
/// Kuwaiti dinar
|
||||
KWD,
|
||||
/// Cayman Islands dollar
|
||||
KYD,
|
||||
/// Kazakhstani tenge
|
||||
KZT,
|
||||
/// Lao kip
|
||||
LAK,
|
||||
/// Lebanese pound
|
||||
LBP,
|
||||
/// Sri Lankan rupee
|
||||
LKR,
|
||||
/// Liberian dollar
|
||||
LRD,
|
||||
/// Lesotho loti
|
||||
LSL,
|
||||
/// Libyan dinar
|
||||
LYD,
|
||||
/// Moroccan dirham
|
||||
MAD,
|
||||
/// Moldovan leu
|
||||
MDL,
|
||||
/// Malagasy ariary
|
||||
MGA,
|
||||
/// Macedonian denar
|
||||
MKD,
|
||||
/// Myanmar kyat
|
||||
MMK,
|
||||
/// Mongolian tögrög
|
||||
MNT,
|
||||
/// Macanese pataca
|
||||
MOP,
|
||||
/// Mauritanian ouguiya
|
||||
MRU,
|
||||
/// Mauritian rupee
|
||||
MUR,
|
||||
/// Maldivian rufiyaa
|
||||
MVR,
|
||||
/// Malawian kwacha
|
||||
MWK,
|
||||
/// Mexican peso
|
||||
MXN,
|
||||
/// Mexican Unidad de Inversion (UDI) (funds code)
|
||||
MXV,
|
||||
/// Malaysian ringgit
|
||||
MYR,
|
||||
/// Mozambican metical
|
||||
MZN,
|
||||
/// Namibian dollar
|
||||
NAD,
|
||||
/// Nigerian naira
|
||||
NGN,
|
||||
/// Nicaraguan córdoba
|
||||
NIO,
|
||||
/// Norwegian krone
|
||||
NOK,
|
||||
/// Nepalese rupee
|
||||
NPR,
|
||||
/// New Zealand dollar
|
||||
NZD,
|
||||
/// Omani rial
|
||||
OMR,
|
||||
/// Panamanian balboa
|
||||
PAB,
|
||||
/// Peruvian sol
|
||||
PEN,
|
||||
/// Papua New Guinean kina
|
||||
PGK,
|
||||
/// Philippine peso
|
||||
PHP,
|
||||
/// Pakistani rupee
|
||||
PKR,
|
||||
/// Polish złoty
|
||||
PLN,
|
||||
/// Paraguayan guaraní
|
||||
PYG,
|
||||
/// Qatari riyal
|
||||
QAR,
|
||||
/// Romanian leu
|
||||
RON,
|
||||
/// Serbian dinar
|
||||
RSD,
|
||||
/// Russian ruble
|
||||
RUB,
|
||||
/// Rwandan franc
|
||||
RWF,
|
||||
/// Saudi riyal
|
||||
SAR,
|
||||
/// Solomon Islands dollar
|
||||
SBD,
|
||||
/// Seychelles rupee
|
||||
SCR,
|
||||
/// Sudanese pound
|
||||
SDG,
|
||||
/// Swedish krona/kronor
|
||||
SEK,
|
||||
/// Singapore dollar
|
||||
SGD,
|
||||
/// Saint Helena pound
|
||||
SHP,
|
||||
/// Sierra Leonean leone
|
||||
SLL,
|
||||
/// Somali shilling
|
||||
SOS,
|
||||
/// Surinamese dollar
|
||||
SRD,
|
||||
/// South Sudanese pound
|
||||
SSP,
|
||||
/// São Tomé and Príncipe dobra
|
||||
STN,
|
||||
/// Salvadoran colón
|
||||
SVC,
|
||||
/// Syrian pound
|
||||
SYP,
|
||||
/// Swazi lilangeni
|
||||
SZL,
|
||||
/// Thai baht
|
||||
THB,
|
||||
/// Tajikistani somoni
|
||||
TJS,
|
||||
/// Turkmenistan manat
|
||||
TMT,
|
||||
/// Tunisian dinar
|
||||
TND,
|
||||
/// Tongan paʻanga
|
||||
TOP,
|
||||
/// Turkish lira
|
||||
TRY,
|
||||
/// Trinidad and Tobago dollar
|
||||
TTD,
|
||||
/// New Taiwan dollar
|
||||
TWD,
|
||||
/// Tanzanian shilling
|
||||
TZS,
|
||||
/// Ukrainian hryvnia
|
||||
UAH,
|
||||
/// Ugandan shilling
|
||||
UGX,
|
||||
/// United States dollar
|
||||
USD,
|
||||
/// United States dollar (next day) (funds code)
|
||||
USN,
|
||||
/// Uruguay Peso en Unidades Indexadas (URUIURUI) (funds code)
|
||||
UYI,
|
||||
/// Uruguayan peso
|
||||
UYU,
|
||||
/// Unidad previsional
|
||||
UYW,
|
||||
/// Uzbekistan som
|
||||
UZS,
|
||||
/// Venezuelan bolívar soberano
|
||||
VES,
|
||||
/// Vietnamese đồng
|
||||
VND,
|
||||
/// Vanuatu vatu
|
||||
VUV,
|
||||
/// Samoan tala
|
||||
WST,
|
||||
/// CFA franc BEAC
|
||||
XAF,
|
||||
/// Silver (one troy ounce)
|
||||
XAG,
|
||||
/// Gold (one troy ounce)
|
||||
XAU,
|
||||
/// European Composite Unit (EURCO) (bond market unit)
|
||||
XBA,
|
||||
/// European Monetary Unit (E.M.U.-6) (bond market unit)
|
||||
XBB,
|
||||
/// European Unit of Account 9 (E.U.A.-9) (bond market unit)
|
||||
XBC,
|
||||
/// European Unit of Account 17 (E.U.A.-17) (bond market unit)
|
||||
XBD,
|
||||
/// East Caribbean dollar
|
||||
XCD,
|
||||
/// Special drawing rights
|
||||
XDR,
|
||||
/// CFA franc BCEAO
|
||||
XOF,
|
||||
/// Palladium (one troy ounce)
|
||||
XPD,
|
||||
/// CFP franc (franc Pacifique)
|
||||
XPF,
|
||||
/// Platinum (one troy ounce)
|
||||
XPT,
|
||||
/// SUCRE
|
||||
XSU,
|
||||
/// Code reserved for testing
|
||||
XTS,
|
||||
/// ADB Unit of Account
|
||||
XUA,
|
||||
/// No currency
|
||||
XXX,
|
||||
/// Yemeni rial
|
||||
YER,
|
||||
/// South African rand
|
||||
ZAR,
|
||||
/// Zambian kwacha
|
||||
ZMW,
|
||||
/// Zimbabwean dollar
|
||||
ZWL,
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{Currency, OrderInfo, User};
|
||||
use crate::types::{OrderInfo, User};
|
||||
|
||||
/// This object contains information about an incoming pre-checkout query.
|
||||
///
|
||||
|
@ -14,10 +14,12 @@ pub struct PreCheckoutQuery {
|
|||
/// User who sent the query.
|
||||
pub from: User,
|
||||
|
||||
/// Three-letter ISO 4217 [currency] code.
|
||||
/// Three-letter ISO 4217 currency code, see [more on currencies]. Pass
|
||||
/// "XTR" for payments in [Telegram Stars].
|
||||
///
|
||||
/// [currency]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
pub currency: Currency,
|
||||
/// [more on currencies]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
/// [Telegram Stars]: https://t.me/BotNews/90
|
||||
pub currency: String,
|
||||
|
||||
/// Total price in the _smallest units_ of the currency (integer, **not**
|
||||
/// float/double). For example, for a price of `US$ 1.45` pass `amount =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{Currency, OrderInfo};
|
||||
use crate::types::OrderInfo;
|
||||
|
||||
/// This object contains basic information about a successful payment.
|
||||
///
|
||||
|
@ -8,10 +8,12 @@ use crate::types::{Currency, OrderInfo};
|
|||
#[serde_with::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SuccessfulPayment {
|
||||
/// Three-letter ISO 4217 [currency] code.
|
||||
/// Three-letter ISO 4217 currency code, see [more on currencies]. Pass
|
||||
/// "XTR" for payments in [Telegram Stars].
|
||||
///
|
||||
/// [currency]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
pub currency: Currency,
|
||||
/// [more on currencies]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
/// [Telegram Stars]: https://t.me/BotNews/90
|
||||
pub currency: String,
|
||||
|
||||
/// Total price in the smallest units of the currency (integer, not
|
||||
/// float/double). For example, for a price of `US$ 1.45` pass `amount =
|
||||
|
|
Loading…
Reference in a new issue