mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
86 lines
2.7 KiB
Rust
86 lines
2.7 KiB
Rust
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
|
|
use time::PrimitiveDateTime;
|
|
|
|
use crate::{encryption::Encryption, enums, schema::address};
|
|
|
|
#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
|
|
#[diesel(table_name = address)]
|
|
pub struct AddressNew {
|
|
pub address_id: String,
|
|
pub city: Option<String>,
|
|
pub country: Option<enums::CountryAlpha2>,
|
|
pub line1: Option<Encryption>,
|
|
pub line2: Option<Encryption>,
|
|
pub line3: Option<Encryption>,
|
|
pub state: Option<Encryption>,
|
|
pub zip: Option<Encryption>,
|
|
pub first_name: Option<Encryption>,
|
|
pub last_name: Option<Encryption>,
|
|
pub phone_number: Option<Encryption>,
|
|
pub country_code: Option<String>,
|
|
pub customer_id: String,
|
|
pub merchant_id: String,
|
|
pub created_at: PrimitiveDateTime,
|
|
pub modified_at: PrimitiveDateTime,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Identifiable, Queryable, frunk::LabelledGeneric)]
|
|
#[diesel(table_name = address)]
|
|
pub struct Address {
|
|
pub id: i32,
|
|
pub address_id: String,
|
|
pub city: Option<String>,
|
|
pub country: Option<enums::CountryAlpha2>,
|
|
pub line1: Option<Encryption>,
|
|
pub line2: Option<Encryption>,
|
|
pub line3: Option<Encryption>,
|
|
pub state: Option<Encryption>,
|
|
pub zip: Option<Encryption>,
|
|
pub first_name: Option<Encryption>,
|
|
pub last_name: Option<Encryption>,
|
|
pub phone_number: Option<Encryption>,
|
|
pub country_code: Option<String>,
|
|
pub created_at: PrimitiveDateTime,
|
|
pub modified_at: PrimitiveDateTime,
|
|
pub customer_id: String,
|
|
pub merchant_id: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
|
|
#[diesel(table_name = address)]
|
|
pub struct AddressUpdateInternal {
|
|
pub city: Option<String>,
|
|
pub country: Option<enums::CountryAlpha2>,
|
|
pub line1: Option<Encryption>,
|
|
pub line2: Option<Encryption>,
|
|
pub line3: Option<Encryption>,
|
|
pub state: Option<Encryption>,
|
|
pub zip: Option<Encryption>,
|
|
pub first_name: Option<Encryption>,
|
|
pub last_name: Option<Encryption>,
|
|
pub phone_number: Option<Encryption>,
|
|
pub country_code: Option<String>,
|
|
pub modified_at: PrimitiveDateTime,
|
|
}
|
|
|
|
impl AddressUpdateInternal {
|
|
pub fn create_address(self, source: Address) -> Address {
|
|
Address {
|
|
city: self.city,
|
|
country: self.country,
|
|
line1: self.line1,
|
|
line2: self.line2,
|
|
line3: self.line3,
|
|
state: self.state,
|
|
zip: self.zip,
|
|
first_name: self.first_name,
|
|
last_name: self.last_name,
|
|
phone_number: self.phone_number,
|
|
country_code: self.country_code,
|
|
modified_at: self.modified_at,
|
|
|
|
..source
|
|
}
|
|
}
|
|
}
|