mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 12:15:40 +08:00
feat(core): Altered the amount field in DisputePayload to StringMinorUnit (#8131)
Co-authored-by: Sayak Bhattacharya <sayak.b@Sayak-Bhattacharya-G092THXJ34.local>
This commit is contained in:
committed by
GitHub
parent
25dfa0ef60
commit
0476361251
@ -520,7 +520,20 @@ impl Sum for MinorUnit {
|
||||
}
|
||||
|
||||
/// Connector specific types to send
|
||||
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq)]
|
||||
#[derive(
|
||||
Default,
|
||||
Debug,
|
||||
serde::Deserialize,
|
||||
AsExpression,
|
||||
serde::Serialize,
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
ToSchema,
|
||||
PartialOrd,
|
||||
)]
|
||||
#[diesel(sql_type = sql_types::Text)]
|
||||
pub struct StringMinorUnit(String);
|
||||
|
||||
impl StringMinorUnit {
|
||||
@ -544,6 +557,45 @@ impl StringMinorUnit {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for StringMinorUnit {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB> FromSql<sql_types::Text, DB> for StringMinorUnit
|
||||
where
|
||||
DB: Backend,
|
||||
String: FromSql<sql_types::Text, DB>,
|
||||
{
|
||||
fn from_sql(value: DB::RawValue<'_>) -> deserialize::Result<Self> {
|
||||
let val = String::from_sql(value)?;
|
||||
Ok(Self(val))
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB> ToSql<sql_types::Text, DB> for StringMinorUnit
|
||||
where
|
||||
DB: Backend,
|
||||
String: ToSql<sql_types::Text, DB>,
|
||||
{
|
||||
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> diesel::serialize::Result {
|
||||
self.0.to_sql(out)
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB> Queryable<sql_types::Text, DB> for StringMinorUnit
|
||||
where
|
||||
DB: Backend,
|
||||
Self: FromSql<sql_types::Text, DB>,
|
||||
{
|
||||
type Row = Self;
|
||||
|
||||
fn build(row: Self::Row) -> deserialize::Result<Self> {
|
||||
Ok(row)
|
||||
}
|
||||
}
|
||||
|
||||
/// Connector specific types to send
|
||||
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
|
||||
pub struct FloatMajorUnit(f64);
|
||||
|
||||
Reference in New Issue
Block a user