ferrisgram 0.2.1

An elegent rust client for the Telegram Bot API.
Documentation
// WARNING: THIS CODE IS AUTOGENERATED.
// DO NOT EDIT!!!

#![allow(clippy::too_many_arguments)]
use serde::Serialize;

use crate::error::Result;
use crate::Bot;

impl Bot {
    /// Refunds a successful payment in Telegram Stars. Returns True on success.
    /// <https://core.telegram.org/bots/api#refundstarpayment>
    pub fn refund_star_payment(
        &self,
        user_id: i64,
        telegram_payment_charge_id: String,
    ) -> RefundStarPaymentBuilder {
        RefundStarPaymentBuilder::new(self, user_id, telegram_payment_charge_id)
    }
}

#[derive(Serialize)]
pub struct RefundStarPaymentBuilder<'a> {
    #[serde(skip)]
    bot: &'a Bot,
    /// Identifier of the user whose payment will be refunded
    pub user_id: i64,
    /// Telegram payment identifier
    pub telegram_payment_charge_id: String,
}

impl<'a> RefundStarPaymentBuilder<'a> {
    pub fn new(bot: &'a Bot, user_id: i64, telegram_payment_charge_id: String) -> Self {
        Self {
            bot,
            user_id,
            telegram_payment_charge_id,
        }
    }

    pub fn user_id(mut self, user_id: i64) -> Self {
        self.user_id = user_id;
        self
    }

    pub fn telegram_payment_charge_id(mut self, telegram_payment_charge_id: String) -> Self {
        self.telegram_payment_charge_id = telegram_payment_charge_id;
        self
    }

    pub async fn send(self) -> Result<bool> {
        let form = serde_json::to_value(&self)?;
        self.bot.get("refundStarPayment", Some(&form)).await
    }
}