pub mod delegated;
pub mod types;
#[allow(unused_imports)]
use types::*;
#[derive(Clone)]
pub struct WalletsClient {
client: crate::client::Client,
}
impl WalletsClient {
pub fn new(client: crate::client::Client) -> Self {
WalletsClient { client }
}
pub async fn abort_transaction(
&self,
wallet_id: String,
transaction_id: String,
) -> Result<AbortTransactionResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/transactions/{}/abort",
urlencoding::encode(&wallet_id),
urlencoding::encode(&transaction_id)
);
self.client
.request::<AbortTransactionResponse>(reqwest::Method::PUT, &path, None, true)
.await
}
pub async fn abort_transfer(
&self,
wallet_id: String,
transfer_id: String,
) -> Result<AbortTransferResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/transfers/{}/abort",
urlencoding::encode(&wallet_id),
urlencoding::encode(&transfer_id)
);
self.client
.request::<AbortTransferResponse>(reqwest::Method::PUT, &path, None, true)
.await
}
pub async fn activate_wallet(
&self,
wallet_id: String,
body: ActivateWalletRequest,
) -> Result<ActivateWalletResponse, crate::error::Error> {
let path = format!("/wallets/{}/activate", urlencoding::encode(&wallet_id));
let body = serde_json::to_value(&body)?;
self.client
.request::<ActivateWalletResponse>(reqwest::Method::POST, &path, Some(&body), true)
.await
}
pub async fn list_transactions(
&self,
wallet_id: String,
query: Option<ListTransactionsQuery>,
) -> Result<ListTransactionsResponse, crate::error::Error> {
let mut path = format!("/wallets/{}/transactions", urlencoding::encode(&wallet_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::<ListTransactionsResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn sign_and_broadcast_transaction(
&self,
wallet_id: String,
body: SignAndBroadcastTransactionRequest,
) -> Result<SignAndBroadcastTransactionResponse, crate::error::Error> {
let path = format!("/wallets/{}/transactions", urlencoding::encode(&wallet_id));
let body = serde_json::to_value(&body)?;
self.client
.request::<SignAndBroadcastTransactionResponse>(
reqwest::Method::POST,
&path,
Some(&body),
true,
)
.await
}
pub async fn cancel_transaction(
&self,
wallet_id: String,
transaction_id: String,
) -> Result<CancelTransactionResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/transactions/{}/cancel",
urlencoding::encode(&wallet_id),
urlencoding::encode(&transaction_id)
);
self.client
.request::<CancelTransactionResponse>(reqwest::Method::POST, &path, None, true)
.await
}
pub async fn cancel_transfer(
&self,
wallet_id: String,
transfer_id: String,
) -> Result<CancelTransferResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/transfers/{}/cancel",
urlencoding::encode(&wallet_id),
urlencoding::encode(&transfer_id)
);
self.client
.request::<CancelTransferResponse>(reqwest::Method::POST, &path, None, true)
.await
}
pub async fn proxy_arequest_to_the_canton_ledger_api(
&self,
wallet_id: String,
body: ProxyARequestToTheCantonLedgerApiRequest,
) -> Result<serde_json::Value, crate::error::Error> {
let path = format!(
"/wallets/{}/canton/ledger-api",
urlencoding::encode(&wallet_id)
);
let body = serde_json::to_value(&body)?;
self.client
.request::<serde_json::Value>(reqwest::Method::POST, &path, Some(&body), false)
.await
}
pub async fn speed_up_transaction(
&self,
wallet_id: String,
transaction_id: String,
) -> Result<SpeedUpTransactionResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/transactions/{}/speed-up",
urlencoding::encode(&wallet_id),
urlencoding::encode(&transaction_id)
);
self.client
.request::<SpeedUpTransactionResponse>(reqwest::Method::POST, &path, None, true)
.await
}
pub async fn speed_up_transfer(
&self,
wallet_id: String,
transfer_id: String,
) -> Result<SpeedUpTransferResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/transfers/{}/speed-up",
urlencoding::encode(&wallet_id),
urlencoding::encode(&transfer_id)
);
self.client
.request::<SpeedUpTransferResponse>(reqwest::Method::POST, &path, None, true)
.await
}
pub async fn list_wallets(
&self,
query: Option<ListWalletsQuery>,
) -> Result<ListWalletsResponse, crate::error::Error> {
let mut path = String::from("/wallets");
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 let Some(v) = &query.owner {
q.push(format!("owner={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.owner_id {
q.push(format!("ownerId={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.owner_username {
q.push(format!(
"ownerUsername={}",
urlencoding::encode(&v.to_string())
));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<ListWalletsResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn create_wallet(
&self,
body: CreateWalletRequest,
) -> Result<CreateWalletResponse, crate::error::Error> {
let path = String::from("/wallets");
let body = serde_json::to_value(&body)?;
self.client
.request::<CreateWalletResponse>(reqwest::Method::POST, &path, Some(&body), true)
.await
}
pub async fn get_transaction(
&self,
wallet_id: String,
transaction_id: String,
) -> Result<GetTransactionResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/transactions/{}",
urlencoding::encode(&wallet_id),
urlencoding::encode(&transaction_id)
);
self.client
.request::<GetTransactionResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn get_transfer(
&self,
wallet_id: String,
transfer_id: String,
) -> Result<GetTransferResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/transfers/{}",
urlencoding::encode(&wallet_id),
urlencoding::encode(&transfer_id)
);
self.client
.request::<GetTransferResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn get_wallet(
&self,
wallet_id: String,
) -> Result<GetWalletResponse, crate::error::Error> {
let path = format!("/wallets/{}", urlencoding::encode(&wallet_id));
self.client
.request::<GetWalletResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn update_wallet(
&self,
wallet_id: String,
body: UpdateWalletRequest,
) -> Result<UpdateWalletResponse, crate::error::Error> {
let path = format!("/wallets/{}", urlencoding::encode(&wallet_id));
let body = serde_json::to_value(&body)?;
self.client
.request::<UpdateWalletResponse>(reqwest::Method::PUT, &path, Some(&body), true)
.await
}
pub async fn get_wallet_assets(
&self,
wallet_id: String,
query: Option<GetWalletAssetsQuery>,
) -> Result<GetWalletAssetsResponse, crate::error::Error> {
let mut path = format!("/wallets/{}/assets", urlencoding::encode(&wallet_id));
if let Some(query) = &query {
let mut q: Vec<String> = Vec::new();
if let Some(v) = &query.net_worth {
q.push(format!("netWorth={}", urlencoding::encode(&v.to_string())));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<GetWalletAssetsResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn get_wallet_history(
&self,
wallet_id: String,
query: Option<GetWalletHistoryQuery>,
) -> Result<GetWalletHistoryResponse, crate::error::Error> {
let mut path = format!("/wallets/{}/history", urlencoding::encode(&wallet_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 let Some(v) = &query.direction {
q.push(format!("direction={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.kind {
q.push(format!("kind={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.contract {
q.push(format!("contract={}", urlencoding::encode(&v.to_string())));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<GetWalletHistoryResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn get_wallet_nfts(
&self,
wallet_id: String,
) -> Result<GetWalletNftsResponse, crate::error::Error> {
let path = format!("/wallets/{}/nfts", urlencoding::encode(&wallet_id));
self.client
.request::<GetWalletNftsResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn import_wallet(
&self,
body: ImportWalletRequest,
) -> Result<ImportWalletResponse, crate::error::Error> {
let path = String::from("/wallets/import");
let body = serde_json::to_value(&body)?;
self.client
.request::<ImportWalletResponse>(reqwest::Method::POST, &path, Some(&body), true)
.await
}
pub async fn list_transfers(
&self,
wallet_id: String,
query: Option<ListTransfersQuery>,
) -> Result<ListTransfersResponse, crate::error::Error> {
let mut path = format!("/wallets/{}/transfers", urlencoding::encode(&wallet_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::<ListTransfersResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn transfer_asset(
&self,
wallet_id: String,
body: TransferAssetRequest,
) -> Result<TransferAssetResponse, crate::error::Error> {
let path = format!("/wallets/{}/transfers", urlencoding::encode(&wallet_id));
let body = serde_json::to_value(&body)?;
self.client
.request::<TransferAssetResponse>(reqwest::Method::POST, &path, Some(&body), true)
.await
}
pub async fn tag_wallet(
&self,
wallet_id: String,
body: TagWalletRequest,
) -> Result<TagWalletResponse, crate::error::Error> {
let path = format!("/wallets/{}/tags", urlencoding::encode(&wallet_id));
let body = serde_json::to_value(&body)?;
self.client
.request::<TagWalletResponse>(reqwest::Method::PUT, &path, Some(&body), true)
.await
}
pub async fn untag_wallet(
&self,
wallet_id: String,
body: UntagWalletRequest,
) -> Result<UntagWalletResponse, crate::error::Error> {
let path = format!("/wallets/{}/tags", urlencoding::encode(&wallet_id));
let body = serde_json::to_value(&body)?;
self.client
.request::<UntagWalletResponse>(reqwest::Method::DELETE, &path, Some(&body), true)
.await
}
pub async fn get_offer(
&self,
wallet_id: String,
offer_id: String,
) -> Result<GetOfferResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/offers/{}",
urlencoding::encode(&wallet_id),
urlencoding::encode(&offer_id)
);
self.client
.request::<GetOfferResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn list_offers(
&self,
wallet_id: String,
query: Option<ListOffersQuery>,
) -> Result<ListOffersResponse, crate::error::Error> {
let mut path = format!("/wallets/{}/offers", urlencoding::encode(&wallet_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::<ListOffersResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn accept_offer(
&self,
wallet_id: String,
offer_id: String,
) -> Result<AcceptOfferResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/offers/{}/accept",
urlencoding::encode(&wallet_id),
urlencoding::encode(&offer_id)
);
self.client
.request::<AcceptOfferResponse>(reqwest::Method::PUT, &path, None, true)
.await
}
pub async fn reject_offer(
&self,
wallet_id: String,
offer_id: String,
) -> Result<RejectOfferResponse, crate::error::Error> {
let path = format!(
"/wallets/{}/offers/{}/reject",
urlencoding::encode(&wallet_id),
urlencoding::encode(&offer_id)
);
self.client
.request::<RejectOfferResponse>(reqwest::Method::PUT, &path, None, true)
.await
}
pub async fn list_org_wallet_history(
&self,
query: Option<ListOrgWalletHistoryQuery>,
) -> Result<serde_json::Value, crate::error::Error> {
let mut path = String::from("/wallets/all/history");
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())
));
}
q.push(format!(
"startTime={}",
urlencoding::encode(&query.start_time.to_string())
));
q.push(format!(
"endTime={}",
urlencoding::encode(&query.end_time.to_string())
));
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<serde_json::Value>(reqwest::Method::GET, &path, None, false)
.await
}
}