You've already forked AstralRinth
forked from didirus/AstralRinth
Make changelog in version response optional (#5115)
* Make changelog on version routes optional * fix clippy * fix ci
This commit is contained in:
@@ -13,7 +13,9 @@ const _: () = {
|
||||
use crate::{MuralError, RequestExt};
|
||||
|
||||
impl crate::Client {
|
||||
pub async fn get_all_accounts(&self) -> Result<Vec<Account>, MuralError> {
|
||||
pub async fn get_all_accounts(
|
||||
&self,
|
||||
) -> Result<Vec<Account>, MuralError> {
|
||||
maybe_mock!(self, get_all_accounts());
|
||||
|
||||
self.http_get(|base| format!("{base}/api/accounts"))
|
||||
@@ -21,7 +23,10 @@ const _: () = {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_account(&self, id: AccountId) -> Result<Account, MuralError> {
|
||||
pub async fn get_account(
|
||||
&self,
|
||||
id: AccountId,
|
||||
) -> Result<Account, MuralError> {
|
||||
maybe_mock!(self, get_account(id));
|
||||
|
||||
self.http_get(|base| format!("{base}/api/accounts/{id}"))
|
||||
@@ -43,7 +48,10 @@ const _: () = {
|
||||
|
||||
maybe_mock!(
|
||||
self,
|
||||
create_account(name.as_ref(), description.as_ref().map(AsRef::as_ref))
|
||||
create_account(
|
||||
name.as_ref(),
|
||||
description.as_ref().map(AsRef::as_ref)
|
||||
)
|
||||
);
|
||||
|
||||
let body = Body {
|
||||
@@ -59,7 +67,18 @@ const _: () = {
|
||||
}
|
||||
};
|
||||
|
||||
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, Hash, Deref, Serialize, Deserialize)]
|
||||
#[derive(
|
||||
Debug,
|
||||
Display,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
Deref,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
)]
|
||||
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
|
||||
#[display("{}", _0.hyphenated())]
|
||||
pub struct AccountId(pub Uuid);
|
||||
|
||||
@@ -69,7 +69,8 @@ impl fmt::Display for ApiError {
|
||||
|
||||
if !self.params.is_empty() {
|
||||
lines.push("params:".into());
|
||||
lines.extend(self.params.iter().map(|(k, v)| format!("- {k}: {v}")));
|
||||
lines
|
||||
.extend(self.params.iter().map(|(k, v)| format!("- {k}: {v}")));
|
||||
}
|
||||
|
||||
lines.push(format!("error name: {}", self.name));
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
use {
|
||||
crate::{
|
||||
Account, AccountId, BankDetailsResponse, Counterparty, CounterpartyId, CreateCounterparty,
|
||||
CreatePayout, FiatAndRailCode, FiatFeeRequest, FiatPayoutFee, MuralError, Organization,
|
||||
OrganizationId, PayoutMethod, PayoutMethodDetails, PayoutMethodId, PayoutRequest,
|
||||
PayoutRequestId, PayoutStatusFilter, SearchParams, SearchRequest, SearchResponse,
|
||||
Account, AccountId, BankDetailsResponse, Counterparty, CounterpartyId,
|
||||
CreateCounterparty, CreatePayout, FiatAndRailCode, FiatFeeRequest,
|
||||
FiatPayoutFee, MuralError, Organization, OrganizationId, PayoutMethod,
|
||||
PayoutMethodDetails, PayoutMethodId, PayoutRequest, PayoutRequestId,
|
||||
PayoutStatusFilter, SearchParams, SearchRequest, SearchResponse,
|
||||
TokenFeeRequest, TokenPayoutFee, UpdateCounterparty,
|
||||
transaction::{Transaction, TransactionId},
|
||||
},
|
||||
|
||||
@@ -46,26 +46,40 @@ impl Client {
|
||||
api_url: String::new(),
|
||||
api_key: SecretString::from(String::new()),
|
||||
transfer_api_key: SecretString::from(String::new()),
|
||||
mock: std::sync::Arc::new(arc_swap::ArcSwapOption::from_pointee(mock)),
|
||||
mock: std::sync::Arc::new(arc_swap::ArcSwapOption::from_pointee(
|
||||
mock,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
fn http_req(&self, make_req: impl FnOnce() -> RequestBuilder) -> RequestBuilder {
|
||||
fn http_req(
|
||||
&self,
|
||||
make_req: impl FnOnce() -> RequestBuilder,
|
||||
) -> RequestBuilder {
|
||||
make_req()
|
||||
.bearer_auth(self.api_key.expose_secret())
|
||||
.header("accept", "application/json")
|
||||
.header("content-type", "application/json")
|
||||
}
|
||||
|
||||
pub(crate) fn http_get<U: IntoUrl>(&self, make_url: impl FnOnce(&str) -> U) -> RequestBuilder {
|
||||
pub(crate) fn http_get<U: IntoUrl>(
|
||||
&self,
|
||||
make_url: impl FnOnce(&str) -> U,
|
||||
) -> RequestBuilder {
|
||||
self.http_req(|| self.http.get(make_url(&self.api_url)))
|
||||
}
|
||||
|
||||
pub(crate) fn http_post<U: IntoUrl>(&self, make_url: impl FnOnce(&str) -> U) -> RequestBuilder {
|
||||
pub(crate) fn http_post<U: IntoUrl>(
|
||||
&self,
|
||||
make_url: impl FnOnce(&str) -> U,
|
||||
) -> RequestBuilder {
|
||||
self.http_req(|| self.http.post(make_url(&self.api_url)))
|
||||
}
|
||||
|
||||
pub(crate) fn http_put<U: IntoUrl>(&self, make_url: impl FnOnce(&str) -> U) -> RequestBuilder {
|
||||
pub(crate) fn http_put<U: IntoUrl>(
|
||||
&self,
|
||||
make_url: impl FnOnce(&str) -> U,
|
||||
) -> RequestBuilder {
|
||||
self.http_req(|| self.http.put(make_url(&self.api_url)))
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ const _: () = {
|
||||
pub async fn search_counterparties(
|
||||
&self,
|
||||
params: Option<SearchParams<CounterpartyId>>,
|
||||
) -> Result<SearchResponse<CounterpartyId, Counterparty>, MuralError> {
|
||||
) -> Result<SearchResponse<CounterpartyId, Counterparty>, MuralError>
|
||||
{
|
||||
maybe_mock!(self, search_counterparties(params));
|
||||
|
||||
self.http_post(|base| format!("{base}/api/counterparties/search"))
|
||||
@@ -30,9 +31,11 @@ const _: () = {
|
||||
) -> Result<Counterparty, MuralError> {
|
||||
maybe_mock!(self, get_counterparty(id));
|
||||
|
||||
self.http_get(|base| format!("{base}/api/counterparties/counterparty/{id}"))
|
||||
.send_mural()
|
||||
.await
|
||||
self.http_get(|base| {
|
||||
format!("{base}/api/counterparties/counterparty/{id}")
|
||||
})
|
||||
.send_mural()
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn create_counterparty(
|
||||
@@ -70,15 +73,28 @@ const _: () = {
|
||||
|
||||
let body = Body { counterparty };
|
||||
|
||||
self.http_put(|base| format!("{base}/api/counterparties/counterparty/{id}"))
|
||||
.json(&body)
|
||||
.send_mural()
|
||||
.await
|
||||
self.http_put(|base| {
|
||||
format!("{base}/api/counterparties/counterparty/{id}")
|
||||
})
|
||||
.json(&body)
|
||||
.send_mural()
|
||||
.await
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, Hash, Deref, Serialize, Deserialize)]
|
||||
#[derive(
|
||||
Debug,
|
||||
Display,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
Deref,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
)]
|
||||
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
|
||||
#[display("{}", _0.hyphenated())]
|
||||
pub struct CounterpartyId(pub Uuid);
|
||||
|
||||
@@ -15,7 +15,8 @@ const _: () = {
|
||||
pub async fn search_organizations(
|
||||
&self,
|
||||
req: SearchRequest,
|
||||
) -> Result<SearchResponse<OrganizationId, Organization>, MuralError> {
|
||||
) -> Result<SearchResponse<OrganizationId, Organization>, MuralError>
|
||||
{
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct Body {
|
||||
@@ -41,8 +42,9 @@ const _: () = {
|
||||
|
||||
let query = [
|
||||
req.limit.map(|limit| ("limit", limit.to_string())),
|
||||
req.next_id
|
||||
.map(|next_id| ("nextId", next_id.hyphenated().to_string())),
|
||||
req.next_id.map(|next_id| {
|
||||
("nextId", next_id.hyphenated().to_string())
|
||||
}),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
@@ -75,7 +77,18 @@ const _: () = {
|
||||
}
|
||||
};
|
||||
|
||||
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, Hash, Deref, Serialize, Deserialize)]
|
||||
#[derive(
|
||||
Debug,
|
||||
Display,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
Deref,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
)]
|
||||
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
|
||||
#[display("{}", _0.hyphenated())]
|
||||
pub struct OrganizationId(pub Uuid);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use {
|
||||
crate::{
|
||||
ArsSymbol, BobSymbol, BrlSymbol, ClpSymbol, CopSymbol, CounterpartyId, CrcSymbol,
|
||||
DocumentType, EurSymbol, FiatAccountType, MxnSymbol, PenSymbol, UsdSymbol, WalletDetails,
|
||||
ZarSymbol,
|
||||
ArsSymbol, BobSymbol, BrlSymbol, ClpSymbol, CopSymbol, CounterpartyId,
|
||||
CrcSymbol, DocumentType, EurSymbol, FiatAccountType, MxnSymbol,
|
||||
PenSymbol, UsdSymbol, WalletDetails, ZarSymbol,
|
||||
},
|
||||
chrono::{DateTime, Utc},
|
||||
derive_more::{Deref, Display, Error},
|
||||
@@ -21,7 +21,8 @@ const _: () = {
|
||||
&self,
|
||||
counterparty_id: CounterpartyId,
|
||||
params: Option<SearchParams<PayoutMethodId>>,
|
||||
) -> Result<SearchResponse<PayoutMethodId, PayoutMethod>, MuralError> {
|
||||
) -> Result<SearchResponse<PayoutMethodId, PayoutMethod>, MuralError>
|
||||
{
|
||||
maybe_mock!(self, search_payout_methods(counterparty_id, params));
|
||||
|
||||
self.http_post(|base| {
|
||||
@@ -37,7 +38,10 @@ const _: () = {
|
||||
counterparty_id: CounterpartyId,
|
||||
payout_method_id: PayoutMethodId,
|
||||
) -> Result<PayoutMethod, MuralError> {
|
||||
maybe_mock!(self, get_payout_method(counterparty_id, payout_method_id));
|
||||
maybe_mock!(
|
||||
self,
|
||||
get_payout_method(counterparty_id, payout_method_id)
|
||||
);
|
||||
|
||||
self.http_get(|base| {
|
||||
format!(
|
||||
@@ -63,7 +67,11 @@ const _: () = {
|
||||
|
||||
maybe_mock!(
|
||||
self,
|
||||
create_payout_method(counterparty_id, alias.as_ref(), payout_method)
|
||||
create_payout_method(
|
||||
counterparty_id,
|
||||
alias.as_ref(),
|
||||
payout_method
|
||||
)
|
||||
);
|
||||
|
||||
let body = Body {
|
||||
@@ -72,7 +80,9 @@ const _: () = {
|
||||
};
|
||||
|
||||
self.http_post(|base| {
|
||||
format!("{base}/api/counterparties/{counterparty_id}/payout-methods")
|
||||
format!(
|
||||
"{base}/api/counterparties/{counterparty_id}/payout-methods"
|
||||
)
|
||||
})
|
||||
.json(&body)
|
||||
.send_mural()
|
||||
@@ -121,7 +131,18 @@ pub enum PayoutMethodPixAccountType {
|
||||
BankAccount,
|
||||
}
|
||||
|
||||
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, Hash, Deref, Serialize, Deserialize)]
|
||||
#[derive(
|
||||
Debug,
|
||||
Display,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
Deref,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
)]
|
||||
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
|
||||
#[display("{}", _0.hyphenated())]
|
||||
pub struct PayoutMethodId(pub Uuid);
|
||||
|
||||
@@ -4,7 +4,10 @@ use {
|
||||
std::borrow::Cow,
|
||||
};
|
||||
|
||||
pub fn serialize<S: serde::Serializer>(v: &CountryCode, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
pub fn serialize<S: serde::Serializer>(
|
||||
v: &CountryCode,
|
||||
serializer: S,
|
||||
) -> Result<S::Ok, S::Error> {
|
||||
serializer.serialize_str(v.alpha2)
|
||||
}
|
||||
|
||||
@@ -15,6 +18,8 @@ pub fn deserialize<'de, D: serde::Deserializer<'de>>(
|
||||
rust_iso3166::ALPHA2_MAP
|
||||
.get(&country_code)
|
||||
.copied()
|
||||
.ok_or_else(|| D::Error::custom("invalid ISO 3166 alpha-2 country code"))
|
||||
.ok_or_else(|| {
|
||||
D::Error::custom("invalid ISO 3166 alpha-2 country code")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,14 +5,21 @@ use derive_more::{Deref, Display};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{AccountId, Blockchain, FiatAmount, PayoutId, PayoutRequestId, TokenAmount};
|
||||
use crate::{
|
||||
AccountId, Blockchain, FiatAmount, PayoutId, PayoutRequestId, TokenAmount,
|
||||
};
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
const _: () = {
|
||||
use crate::{Account, MuralError, RequestExt, SearchParams, SearchResponse};
|
||||
use crate::{
|
||||
Account, MuralError, RequestExt, SearchParams, SearchResponse,
|
||||
};
|
||||
|
||||
impl crate::Client {
|
||||
pub async fn get_transaction(&self, id: TransactionId) -> Result<Transaction, MuralError> {
|
||||
pub async fn get_transaction(
|
||||
&self,
|
||||
id: TransactionId,
|
||||
) -> Result<Transaction, MuralError> {
|
||||
maybe_mock!(self, get_transaction(id));
|
||||
|
||||
self.http_get(|base| format!("{base}/api/transactions/{id}"))
|
||||
@@ -27,15 +34,28 @@ const _: () = {
|
||||
) -> Result<SearchResponse<AccountId, Account>, MuralError> {
|
||||
maybe_mock!(self, search_transactions(account_id, params));
|
||||
|
||||
self.http_post(|base| format!("{base}/api/transactions/search/account/{account_id}"))
|
||||
.query(¶ms.map(|p| p.to_query()).unwrap_or_default())
|
||||
.send_mural()
|
||||
.await
|
||||
self.http_post(|base| {
|
||||
format!("{base}/api/transactions/search/account/{account_id}")
|
||||
})
|
||||
.query(¶ms.map(|p| p.to_query()).unwrap_or_default())
|
||||
.send_mural()
|
||||
.await
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, Hash, Deref, Serialize, Deserialize)]
|
||||
#[derive(
|
||||
Debug,
|
||||
Display,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
Deref,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
)]
|
||||
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
|
||||
#[display("{}", _0.hyphenated())]
|
||||
pub struct TransactionId(pub Uuid);
|
||||
|
||||
@@ -5,7 +5,8 @@ macro_rules! display_as_serialize {
|
||||
|
||||
impl fmt::Display for $T {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let value = serde_json::to_value(self).map_err(|_| fmt::Error)?;
|
||||
let value =
|
||||
serde_json::to_value(self).map_err(|_| fmt::Error)?;
|
||||
let value = value.as_str().ok_or(fmt::Error)?;
|
||||
write!(f, "{value}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user