Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrat555 committed Jul 2, 2024
1 parent 13e7b69 commit 669c774
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 42 deletions.
18 changes: 9 additions & 9 deletions src/api_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,15 +1719,6 @@ pub struct UnpinAllForumTopicMessagesParams {
pub message_thread_id: i32,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)]
pub struct GetStarTransactionsParams {
#[builder(setter(into))]
offset: i32,

#[builder(setter(into))]
limit: i32,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)]
pub struct EditGeneralForumTopicParams {
#[builder(setter(into))]
Expand Down Expand Up @@ -2481,6 +2472,15 @@ pub struct AnswerPreCheckoutQueryParams {
pub error_message: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)]
pub struct GetStarTransactionsParams {
#[builder(setter(into))]
offset: u32,

#[builder(setter(into))]
limit: u32,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)]
pub struct RefundStarPaymentParams {
pub user_id: u64,
Expand Down
14 changes: 7 additions & 7 deletions src/api_traits/async_telegram_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,13 @@ pub trait AsyncTelegramApi {
self.request("answerPreCheckoutQuery", Some(params)).await
}

async fn get_star_transactions(
&self,
params: GetStarTransactionsParams,
) -> Result<MethodResponse<StarTransactions>, Self::Error> {
self.request("getStarTransactions", Some(params)).await
}

async fn refund_star_payment(
&self,
params: &RefundStarPaymentParams,
Expand Down Expand Up @@ -1354,13 +1361,6 @@ pub trait AsyncTelegramApi {
.await
}

async fn get_star_transactions(
&self,
params: GetStarTransactionsParams,
) -> Result<MethodResponse<StarTransactions>, Self::Error> {
self.request("getStarTransactions", Some(params)).await
}

async fn request_without_body<T: serde::de::DeserializeOwned>(
&self,
method: &str,
Expand Down
14 changes: 7 additions & 7 deletions src/api_traits/telegram_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,13 @@ pub trait TelegramApi {
self.request("answerPreCheckoutQuery", Some(params))
}

fn get_star_transactions(
&self,
params: GetStarTransactionsParams,
) -> Result<MethodResponse<StarTransactions>, Self::Error> {
self.request("getStarTransactions", Some(params))
}

fn refund_star_payment(
&self,
params: &RefundStarPaymentParams,
Expand Down Expand Up @@ -1291,13 +1298,6 @@ pub trait TelegramApi {
self.request("unpinAllGeneralForumTopicMessages", Some(params))
}

fn get_star_transactions(
&self,
params: GetStarTransactionsParams,
) -> Result<MethodResponse<StarTransactions>, Self::Error> {
self.request("getStarTransactions", Some(params))
}

fn request_without_body<T: serde::de::DeserializeOwned>(
&self,
method: &str,
Expand Down
48 changes: 29 additions & 19 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4096,59 +4096,69 @@ pub struct InaccessibleMessage {
pub date: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum RevenueWithdrawalState {
RevenueWithdrawalStatePending(RevenueWithdrawalStatePending),
RevenueWithdrawalStateSucceeded(RevenueWithdrawalStateSucceeded),
RevenueWithdrawalStateFailed(RevenueWithdrawalStateFailed),
Pending(RevenueWithdrawalStatePending),
Succeeded(RevenueWithdrawalStateSucceeded),
Failed(RevenueWithdrawalStateFailed),
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
#[serde(tag = "pending", rename_all = "snake_case")]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder, Eq)]
pub struct RevenueWithdrawalStatePending {}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
#[serde(tag = "failed", rename_all = "snake_case")]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder, Eq)]
pub struct RevenueWithdrawalStateFailed {}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
#[serde(tag = "succeeded", rename_all = "snake_case")]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder, Eq)]
pub struct RevenueWithdrawalStateSucceeded {
pub date: u64,

#[builder(setter(into))]
pub url: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum TransactionPartner {
TransactionPartnerFragment(TransactionPartnerFragment),
TransactionPartnerUser(TransactionPartnerUser),
TransactionPartnerOther(TransactionPartnerOther),
Fragment(TransactionPartnerFragment),
User(TransactionPartnerUser),
TelegramAds(TransactionPartnerTelegramAds),
Other(TransactionPartnerOther),
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
#[serde(tag = "fragment", rename_all = "snake_case")]
pub struct TransactionPartnerFragment {
pub withdrawal_state: RevenueWithdrawalState,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
#[serde(tag = "user", rename_all = "snake_case")]
pub struct TransactionPartnerUser {
pub user: User,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
#[serde(tag = "other", rename_all = "snake_case")]
pub struct TransactionPartnerTelegramAds {}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct TransactionPartnerOther {}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct StarTransaction {
#[builder(setter(into))]
pub id: String,
pub amount: i32,

pub amount: u32,

pub date: u64,
pub source: TransactionPartner,
pub receiver: TransactionPartner,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub source: Option<TransactionPartner>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub receiver: Option<TransactionPartner>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
Expand Down

0 comments on commit 669c774

Please sign in to comment.