#![allow(unused_imports)]
use http::Method;
use serde::de::DeserializeOwned;
use serde_json::Value;
use std::collections::BTreeMap;
use crate::common::{config::ConfigurationRestApi, models::RestApiResponse, utils::send_request};
mod apis;
mod models;
pub use apis::*;
pub use models::*;
#[derive(Debug, Clone)]
pub struct RestApi {
configuration: ConfigurationRestApi,
nft_api_client: NftApiClient,
}
impl RestApi {
pub fn new(configuration: ConfigurationRestApi) -> Self {
let nft_api_client = NftApiClient::new(configuration.clone());
Self {
configuration,
nft_api_client,
}
}
pub async fn send_request<R: DeserializeOwned + Send + 'static>(
&self,
endpoint: &str,
method: Method,
query_params: BTreeMap<String, Value>,
body_params: BTreeMap<String, Value>,
) -> anyhow::Result<RestApiResponse<R>> {
send_request::<R>(
&self.configuration,
endpoint,
method,
query_params,
body_params,
None,
false,
)
.await
}
pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
&self,
endpoint: &str,
method: Method,
query_params: BTreeMap<String, Value>,
body_params: BTreeMap<String, Value>,
) -> anyhow::Result<RestApiResponse<R>> {
send_request::<R>(
&self.configuration,
endpoint,
method,
query_params,
body_params,
None,
true,
)
.await
}
pub async fn get_nft_asset(
&self,
params: GetNftAssetParams,
) -> anyhow::Result<RestApiResponse<models::GetNftAssetResponse>> {
self.nft_api_client.get_nft_asset(params).await
}
pub async fn get_nft_deposit_history(
&self,
params: GetNftDepositHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetNftDepositHistoryResponse>> {
self.nft_api_client.get_nft_deposit_history(params).await
}
pub async fn get_nft_transaction_history(
&self,
params: GetNftTransactionHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetNftTransactionHistoryResponse>> {
self.nft_api_client
.get_nft_transaction_history(params)
.await
}
pub async fn get_nft_withdraw_history(
&self,
params: GetNftWithdrawHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetNftWithdrawHistoryResponse>> {
self.nft_api_client.get_nft_withdraw_history(params).await
}
}