pub mod delegated;
pub mod types;
#[allow(unused_imports)]
use types::*;
#[derive(Clone)]
pub struct FeeSponsorsClient {
client: crate::client::Client,
}
impl FeeSponsorsClient {
pub fn new(client: crate::client::Client) -> Self {
FeeSponsorsClient { client }
}
pub async fn list_fee_sponsors(
&self,
query: Option<ListFeeSponsorsQuery>,
) -> Result<ListFeeSponsorsResponse, crate::error::Error> {
let mut path = String::from("/fee-sponsors");
if let Some(query) = &query {
let mut q: Vec<String> = Vec::new();
if let Some(v) = &query.limit {
q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.pagination_token {
q.push(format!(
"paginationToken={}",
urlencoding::encode(&v.to_string())
));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<ListFeeSponsorsResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn create_fee_sponsor(
&self,
body: CreateFeeSponsorRequest,
) -> Result<CreateFeeSponsorResponse, crate::error::Error> {
let path = String::from("/fee-sponsors");
let body = serde_json::to_value(&body)?;
self.client
.request::<CreateFeeSponsorResponse>(reqwest::Method::POST, &path, Some(&body), true)
.await
}
pub async fn get_fee_sponsor(
&self,
fee_sponsor_id: String,
) -> Result<GetFeeSponsorResponse, crate::error::Error> {
let path = format!("/fee-sponsors/{}", urlencoding::encode(&fee_sponsor_id));
self.client
.request::<GetFeeSponsorResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn delete_fee_sponsor(
&self,
fee_sponsor_id: String,
) -> Result<DeleteFeeSponsorResponse, crate::error::Error> {
let path = format!("/fee-sponsors/{}", urlencoding::encode(&fee_sponsor_id));
self.client
.request::<DeleteFeeSponsorResponse>(reqwest::Method::DELETE, &path, None, true)
.await
}
pub async fn deactivate_fee_sponsor(
&self,
fee_sponsor_id: String,
) -> Result<DeactivateFeeSponsorResponse, crate::error::Error> {
let path = format!(
"/fee-sponsors/{}/deactivate",
urlencoding::encode(&fee_sponsor_id)
);
self.client
.request::<DeactivateFeeSponsorResponse>(reqwest::Method::PUT, &path, None, true)
.await
}
pub async fn activate_fee_sponsor(
&self,
fee_sponsor_id: String,
) -> Result<ActivateFeeSponsorResponse, crate::error::Error> {
let path = format!(
"/fee-sponsors/{}/activate",
urlencoding::encode(&fee_sponsor_id)
);
self.client
.request::<ActivateFeeSponsorResponse>(reqwest::Method::PUT, &path, None, true)
.await
}
pub async fn list_sponsored_fees(
&self,
fee_sponsor_id: String,
query: Option<ListSponsoredFeesQuery>,
) -> Result<ListSponsoredFeesResponse, crate::error::Error> {
let mut path = format!(
"/fee-sponsors/{}/fees",
urlencoding::encode(&fee_sponsor_id)
);
if let Some(query) = &query {
let mut q: Vec<String> = Vec::new();
if let Some(v) = &query.limit {
q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.pagination_token {
q.push(format!(
"paginationToken={}",
urlencoding::encode(&v.to_string())
));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<ListSponsoredFeesResponse>(reqwest::Method::GET, &path, None, false)
.await
}
}