Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(customer_v2): Add customer V2 delete api #5518

Merged
merged 126 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
8943cf5
feature: add feature flagged domain model and diesel model
Narayanbhat166 Jul 12, 2024
8a5e771
refactor: change order of mirations
Narayanbhat166 Jul 15, 2024
311b59d
chore: create justfile for running commands for v1 and v2 migrations
hrithikesh026 Jul 15, 2024
ab327cd
add support for extra params in migration
hrithikesh026 Jul 15, 2024
fd9dd8e
refactor: add feature flag and make code compile
Narayanbhat166 Jul 16, 2024
e8aa634
Merge branch 'main' into change_mercant_account_domain_model_v2
Narayanbhat166 Jul 17, 2024
df9939e
chore: merge fixes
Narayanbhat166 Jul 17, 2024
0488e98
chore: cargo fmt
Narayanbhat166 Jul 17, 2024
03e43ef
chore: cargo c with merchant_account_v2 feature
Narayanbhat166 Jul 17, 2024
0ac1bc1
chore: cargo clippy
Narayanbhat166 Jul 17, 2024
05083b7
refactor(core): added refactors for v2 customer api
sahkal Jul 17, 2024
a59af16
refactor(core): fixed unused imports and clippy warnings
sahkal Jul 17, 2024
e35a94f
chore: include storage_impl in router
Narayanbhat166 Jul 17, 2024
b36a2d0
refactor(customer): fixed ci checks
sahkal Jul 17, 2024
17017de
refactor(customer):
sahkal Jul 17, 2024
3466b43
chore: add few more just commands
Narayanbhat166 Jul 17, 2024
c26ef09
chore: add comments to justfile
Narayanbhat166 Jul 17, 2024
e02c306
refactor(customer): fixed ci check and multi lifetime issue
sahkal Jul 18, 2024
c2e1431
Merge branch 'main' of https://github.com/juspay/hyperswitch into 584…
sahkal Jul 18, 2024
f605666
chore: fmt
Narayanbhat166 Jul 18, 2024
42362f9
refactor(customer): added new customer_v2 feature flag
sahkal Jul 18, 2024
e6571c7
Refactor(customer): fixed compile issue on result
sahkal Jul 18, 2024
fe6d063
ci: add support for compilation of code changes under v2 feature flag…
prajjwalkumar17 Jul 18, 2024
16a447d
Merge branch 'main' into change_mercant_account_domain_model_v2
Narayanbhat166 Jul 18, 2024
230cd2e
Merge branch 'main' into change_mercant_account_domain_model_v2
Narayanbhat166 Jul 18, 2024
462cc5f
refactor(customer): added extra flags
sahkal Jul 18, 2024
fb6cbf4
refactor(customer): removed oltp
sahkal Jul 18, 2024
245068e
refactor(customer): resolved merge conflicts
sahkal Jul 18, 2024
800edbc
refactor: remove unwanted migrations
Narayanbhat166 Jul 18, 2024
3bb7460
refactor(customer): merged merchant account v2 changes
sahkal Jul 18, 2024
47e10e3
chore: revert hsdev changes
Narayanbhat166 Jul 18, 2024
7ef542c
chore: remove the -c option from jq
Narayanbhat166 Jul 18, 2024
f404db5
chore: add print statement in ci
Narayanbhat166 Jul 18, 2024
bfd2095
chore: add debug statement
Narayanbhat166 Jul 18, 2024
1dc54d6
refactor: refactor script to increase readability
Narayanbhat166 Jul 18, 2024
844515e
chore(ci-checks): simplify if conditions
SanchithHegde Jul 18, 2024
1f3f908
ci(CI-pr): try out Ubuntu 24.04 runners for running MSRV checks
SanchithHegde Jul 18, 2024
6d2cd99
ci(CI-pr): try out Ubuntu 24.04 runners for running stable toolchain …
SanchithHegde Jul 18, 2024
6d5ae58
chore: add v1 in default features for api models
Narayanbhat166 Jul 19, 2024
a9d92ef
chore: remove unused config file
Narayanbhat166 Jul 19, 2024
7b5c2a2
refactor: add v1 feature to hyperswitch interfaces
Narayanbhat166 Jul 19, 2024
4115fe3
chore: add feature flags to openapi
Narayanbhat166 Jul 19, 2024
d69b15a
refactor(customer): added ci checks for customer
sahkal Jul 19, 2024
d1ebdc4
ci: install latest release of `jq` from GitHub releases
SanchithHegde Jul 19, 2024
290bab5
fix: migrations
Narayanbhat166 Jul 19, 2024
128a79b
Merge branch 'main' into change_mercant_account_domain_model_v2
Narayanbhat166 Jul 19, 2024
74393e9
chore: run formatter
hyperswitch-bot[bot] Jul 19, 2024
b2ea69d
fix: merge fixes
Narayanbhat166 Jul 19, 2024
5b33db3
refactor(customer): resolved merge conflicts
sahkal Jul 19, 2024
1b7f0a3
refactor(customer): fixed schema.rs file
sahkal Jul 19, 2024
40fa698
refactor(customer): fixed schema.rs file
sahkal Jul 19, 2024
efca359
refactor(customer): fixed schema file
sahkal Jul 19, 2024
9bc7976
refactor(customer): merged with merchant account v2 branch
sahkal Jul 19, 2024
17ab820
chore: exclude customer_v2 in ci check
sahkal Jul 19, 2024
f9a30e7
chore: fixed ci check failures for payment intent
sahkal Jul 19, 2024
46dc18c
chore: fixed just file for customer_v2 feature
sahkal Jul 19, 2024
b195937
chore: fixed ci checks
sahkal Jul 19, 2024
b5ebf56
Merge branch 'main' into 5841-customer-v2-refactor-customer-create-en…
sahkal Jul 19, 2024
cf7e2aa
chore: fixed merge conflicts
sahkal Jul 22, 2024
052e5fc
chore: fixed merge conflicts
sahkal Jul 22, 2024
418dfb5
chore: fixed Ci apiv2 error
sahkal Jul 22, 2024
696aaaf
chore: fixed ci check errors
sahkal Jul 22, 2024
3ef9915
chore: fixed ci checks
sahkal Jul 22, 2024
c87277e
chore: fixed ci check failures
sahkal Jul 22, 2024
140cd85
chore: fixed ci script error
sahkal Jul 22, 2024
086ad86
refactor(customer): addressed pr comments
sahkal Jul 22, 2024
6379ee7
chore: made v2 customer api compile
sahkal Jul 22, 2024
1f8d794
chore: made v1 import compile
sahkal Jul 22, 2024
e58892f
feat(customer_v2): added diesel model for customer_v2 create
sahkal Jul 24, 2024
7a4174d
feat(customer_v2): added customer_v2 diesel finally made it compile
sahkal Jul 25, 2024
bc70e3c
chore: made diesel model encryption changes
sahkal Jul 25, 2024
aa48c25
chore: resolved merge conflicts
sahkal Jul 25, 2024
1e7f242
refactor
sahkal Jul 26, 2024
6847260
chore: resolved merge conflicts
sahkal Jul 26, 2024
75be67d
chore: fixed migration issue
sahkal Jul 26, 2024
4513c66
chore: fixed migration inconsistency
sahkal Jul 26, 2024
552bd54
chore: fixed schema issue
sahkal Jul 26, 2024
553cc31
chore: fixed migration redo failures
sahkal Jul 26, 2024
3c2722e
chore: fixed clippy issue
sahkal Jul 26, 2024
84110e1
chore: added resurrect for migration ci checks
sahkal Jul 26, 2024
5abf996
chore:added delay for db connection
sahkal Jul 26, 2024
ee1d889
Merge branch 'main' into customer-v2-domain-model
sahkal Jul 26, 2024
f1da670
chore: fixed ci checks for v2 migrations:
sahkal Jul 26, 2024
724a5fb
Merge branch 'customer-v2-domain-model' of https://github.com/juspay/…
sahkal Jul 26, 2024
045f0cf
chore: fixed ci checks for v2 migrations:
sahkal Jul 26, 2024
1d0c539
chore: fixed ci checks for v2 migrations:
sahkal Jul 26, 2024
039b680
chore: fixed ci checks for v2 migrations:
sahkal Jul 26, 2024
e1e8136
chore: fixed ci checks for v2 migrations:
sahkal Jul 26, 2024
0ba34a2
chore: fixed ci checks for v2 migrations:
sahkal Jul 26, 2024
c0fe975
chore: fixed schema error consistency
sahkal Jul 26, 2024
29bfc45
chore: fixed schema consistency issue
sahkal Jul 26, 2024
c72cfd8
chore: fixed schema issue
sahkal Jul 26, 2024
9ae6b47
chore: fixed something hopefully it works crying out loud
sahkal Jul 26, 2024
a07777a
chore: moved customer_v2_endpoint db migration into a single file
sahkal Jul 30, 2024
9b24b1c
feat(customer_v2): added route for customer_v2 update flow
sahkal Jul 31, 2024
7cc3f1b
chore: resolved pr comments
sahkal Aug 1, 2024
7b732ab
chore: unused import fixed for v2
sahkal Aug 1, 2024
ea916cf
chore: resolved merge conflicts
sahkal Aug 1, 2024
8ce9fab
chore: fixed clippy errors
sahkal Aug 1, 2024
ad8b03b
chore: resolved pr comments
sahkal Aug 1, 2024
0a57252
Merge branch 'main' into customer-v2-domain-model
sahkal Aug 1, 2024
251edfb
chore: fixed postman run failures and ci checks
sahkal Aug 2, 2024
ccadd2b
Merge branch 'customer-v2-domain-model' of https://github.com/juspay/…
sahkal Aug 2, 2024
ac23f5a
chore: removed expose_reference function
sahkal Aug 2, 2024
04cd0b5
chore: syned with latest changes
sahkal Aug 2, 2024
dbd1e11
chore: fixed db queries for both v1, and v2
sahkal Aug 2, 2024
6ff9ebc
chore: fixed ci checks
sahkal Aug 2, 2024
5bdcae0
feat(customer_v2): added route for customer_retrieve v2
sahkal Aug 2, 2024
8c284cb
chore: added list customer v2 endpoint
sahkal Aug 2, 2024
bfd49ee
feat(customer_v2): added customer v2 delete end point
sahkal Aug 3, 2024
45ce36d
refactor(customer_v2): resolved merge conflicts
sahkal Aug 29, 2024
3ae250c
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Aug 29, 2024
bb22886
chore: addressed pr comments
sahkal Aug 29, 2024
40d0012
Merge branch '5843-customer-v2-refactor-delete-customer' of https://g…
sahkal Aug 29, 2024
0fc8ed7
chore: addressed pr comments
sahkal Aug 29, 2024
ec18516
chore: fixed clippy failures
sahkal Aug 30, 2024
07fd3d7
refactor(customer_v2): fixed clippy failures
sahkal Aug 30, 2024
c51c111
chore
sahkal Aug 30, 2024
b57222c
chore: customer_v2 fixed hack_v2 failures
sahkal Aug 31, 2024
5bbddc4
chore: fixed hack_v2 clippy failures
sahkal Sep 1, 2024
fc31c23
chore: fixed clippy_v2 failures
sahkal Sep 2, 2024
edee0eb
refactor(customer_v2): addressed pr comments
sahkal Sep 2, 2024
da8dfcb
chore: customer_v2 resolved pr comments
Sep 2, 2024
0daac3a
chore: customer_v2 added delete status in customer domain
Sep 2, 2024
2cbc72d
chore: customer_v2 resolved merge conflicts
sahkal Sep 4, 2024
461994c
chore: customer_v2 fixed clippy errors
sahkal Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -5203,13 +5203,14 @@
"CustomerDeleteResponse": {
"type": "object",
"required": [
"customer_id",
"merchant_reference_id",
"customer_deleted",
"address_deleted",
"payment_methods_deleted"
"payment_methods_deleted",
"id"
],
"properties": {
"customer_id": {
"merchant_reference_id": {
"type": "string",
"description": "The identifier for the customer object",
"example": "cus_y3oqhf46pyzuxjbcn2giaqnb44",
Expand All @@ -5229,6 +5230,10 @@
"type": "boolean",
"description": "Whether payment methods deleted or not",
"example": false
},
"id": {
"type": "string",
"description": "Global id"
}
}
},
Expand Down
21 changes: 21 additions & 0 deletions crates/api_models/src/customers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ impl CustomerId {
}
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[derive(Debug, Deserialize, Serialize, ToSchema)]
pub struct CustomerDeleteResponse {
/// The identifier for the customer object
Expand All @@ -368,6 +369,26 @@ pub struct CustomerDeleteResponse {
pub payment_methods_deleted: bool,
}

#[cfg(all(feature = "v2", feature = "customer_v2"))]
#[derive(Debug, Deserialize, Serialize, ToSchema)]
pub struct CustomerDeleteResponse {
/// The identifier for the customer object
#[schema(value_type = String, max_length = 255, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
pub merchant_reference_id: Option<id_type::CustomerId>,
/// Whether customer was deleted or not
#[schema(example = false)]
pub customer_deleted: bool,
/// Whether address was deleted or not
#[schema(example = false)]
pub address_deleted: bool,
/// Whether payment methods deleted or not
#[schema(example = false)]
pub payment_methods_deleted: bool,
/// Global id
pub id: String,
}

/// The identifier for the customer object. If not provided the customer ID will be autogenerated.
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
#[derive(Debug, Default, Clone, Deserialize, Serialize, ToSchema)]
pub struct CustomerUpdateRequest {
Expand Down
17 changes: 14 additions & 3 deletions crates/api_models/src/events/customer.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use crate::customers::CustomerId;
#[cfg(all(feature = "v2", feature = "customer_v2"))]
use crate::customers::GlobalId;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use crate::customers::{CustomerDeleteResponse, CustomerId};
use crate::customers::{CustomerRequest, CustomerResponse, CustomerUpdateRequest};
use crate::customers::{
CustomerDeleteResponse, CustomerRequest, CustomerResponse, CustomerUpdateRequest,
};

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for CustomerDeleteResponse {
Expand All @@ -15,6 +17,15 @@ impl ApiEventMetric for CustomerDeleteResponse {
}
}

#[cfg(all(feature = "v2", feature = "customer_v2"))]
impl ApiEventMetric for CustomerDeleteResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Customer {
id: self.id.clone(),
})
}
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl ApiEventMetric for CustomerRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Expand Down
30 changes: 25 additions & 5 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ pub mod diesel_exports {
DbAuthenticationType as AuthenticationType, DbBlocklistDataKind as BlocklistDataKind,
DbCaptureMethod as CaptureMethod, DbCaptureStatus as CaptureStatus,
DbConnectorType as ConnectorType, DbCountryAlpha2 as CountryAlpha2, DbCurrency as Currency,
DbDisputeStage as DisputeStage, DbDisputeStatus as DisputeStatus, DbEventType as EventType,
DbFraudCheckStatus as FraudCheckStatus, DbFutureUsage as FutureUsage,
DbIntentStatus as IntentStatus, DbMandateStatus as MandateStatus,
DbPaymentMethodIssuerCode as PaymentMethodIssuerCode, DbPaymentType as PaymentType,
DbRefundStatus as RefundStatus,
DbDeleteStatus as DeleteStatus, DbDisputeStage as DisputeStage,
DbDisputeStatus as DisputeStatus, DbFraudCheckStatus as FraudCheckStatus,
DbFutureUsage as FutureUsage, DbIntentStatus as IntentStatus,
DbMandateStatus as MandateStatus, DbPaymentMethodIssuerCode as PaymentMethodIssuerCode,
DbPaymentType as PaymentType, DbRefundStatus as RefundStatus,
DbRequestIncrementalAuthorization as RequestIncrementalAuthorization,
DbWebhookDeliveryAttempt as WebhookDeliveryAttempt,
};
Expand Down Expand Up @@ -3135,3 +3135,23 @@ pub enum OrderFulfillmentTimeOrigin {
Create,
Confirm,
}

#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum DeleteStatus {
Active,
Redacted,
}
32 changes: 8 additions & 24 deletions crates/diesel_models/src/customers.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// #[cfg(all(feature = "v2", feature = "customer_v2"))]
// use crate::enums::SoftDeleteStatus;
use common_enums::ApiVersion;
use common_utils::{encryption::Encryption, pii, types::Description};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use time::PrimitiveDateTime;

#[cfg(all(feature = "v2", feature = "customer_v2"))]
use crate::enums::DeleteStatus;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use crate::schema::customers;
#[cfg(all(feature = "v2", feature = "customer_v2"))]
Expand Down Expand Up @@ -32,21 +32,6 @@ pub struct CustomerNew {
pub version: ApiVersion,
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl Customer {
pub fn get_customer_id(&self) -> common_utils::id_type::CustomerId {
self.customer_id.clone()
}
}

#[cfg(all(feature = "v2", feature = "customer_v2"))]
impl Customer {
#[allow(clippy::todo)]
pub fn get_customer_id(&self) -> common_utils::id_type::CustomerId {
todo!()
}
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
impl CustomerNew {
pub fn update_storage_scheme(&mut self, storage_scheme: common_enums::MerchantStorageScheme) {
Expand Down Expand Up @@ -77,8 +62,6 @@ impl From<CustomerNew> for Customer {
}
}

// V2 customer

#[cfg(all(feature = "v2", feature = "customer_v2"))]
#[derive(
Clone,
Expand Down Expand Up @@ -107,7 +90,7 @@ pub struct CustomerNew {
pub merchant_reference_id: Option<common_utils::id_type::CustomerId>,
pub default_billing_address: Option<Encryption>,
pub default_shipping_address: Option<Encryption>,
// pub status: Option<SoftDeleteStatus>,
pub status: DeleteStatus,
pub id: String,
}

Expand Down Expand Up @@ -138,8 +121,8 @@ impl From<CustomerNew> for Customer {
default_billing_address: customer_new.default_billing_address,
default_shipping_address: customer_new.default_shipping_address,
id: customer_new.id,
// status: customer_new.status,
version: customer_new.version,
status: customer_new.status,
}
}
}
Expand Down Expand Up @@ -189,7 +172,7 @@ pub struct Customer {
pub merchant_reference_id: Option<common_utils::id_type::CustomerId>,
pub default_billing_address: Option<Encryption>,
pub default_shipping_address: Option<Encryption>,
// pub status: Option<SoftDeleteStatus>,
pub status: DeleteStatus,
pub id: String,
}

Expand Down Expand Up @@ -264,6 +247,7 @@ pub struct CustomerUpdateInternal {
pub updated_by: Option<String>,
pub default_billing_address: Option<Encryption>,
pub default_shipping_address: Option<Encryption>,
pub status: Option<DeleteStatus>,
}

#[cfg(all(feature = "v2", feature = "customer_v2"))]
Expand All @@ -277,10 +261,10 @@ impl CustomerUpdateInternal {
phone_country_code,
metadata,
connector_customer,
// address_id,
default_payment_method_id,
default_billing_address,
default_shipping_address,
status,
..
} = self;

Expand All @@ -293,14 +277,14 @@ impl CustomerUpdateInternal {
metadata: metadata.map_or(source.metadata, Some),
modified_at: common_utils::date_time::now(),
connector_customer: connector_customer.map_or(source.connector_customer, Some),
// address_id: address_id.map_or(source.address_id, Some),
default_payment_method_id: default_payment_method_id
.flatten()
.map_or(source.default_payment_method_id, Some),
default_billing_address: default_billing_address
.map_or(source.default_billing_address, Some),
default_shipping_address: default_shipping_address
.map_or(source.default_shipping_address, Some),
status: status.unwrap_or(source.status),
..source
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/diesel_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ pub mod diesel_exports {
DbCaptureMethod as CaptureMethod, DbCaptureStatus as CaptureStatus,
DbConnectorStatus as ConnectorStatus, DbConnectorType as ConnectorType,
DbCountryAlpha2 as CountryAlpha2, DbCurrency as Currency,
DbDashboardMetadata as DashboardMetadata, DbDisputeStage as DisputeStage,
DbDisputeStatus as DisputeStatus, DbEventClass as EventClass,
DbEventObjectType as EventObjectType, DbEventType as EventType,
DbDashboardMetadata as DashboardMetadata, DbDeleteStatus as DeleteStatus,
DbDisputeStage as DisputeStage, DbDisputeStatus as DisputeStatus,
DbEventClass as EventClass, DbEventObjectType as EventObjectType, DbEventType as EventType,
DbFraudCheckStatus as FraudCheckStatus, DbFraudCheckType as FraudCheckType,
DbFutureUsage as FutureUsage, DbGenericLinkType as GenericLinkType,
DbIntentStatus as IntentStatus, DbMandateStatus as MandateStatus,
Expand Down
6 changes: 6 additions & 0 deletions crates/diesel_models/src/query/mandate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ impl Mandate {
.await
}

//Fix this function once V2 mandate is schema is being built
#[cfg(all(feature = "v2", feature = "customer_v2"))]
pub async fn find_by_global_id(_conn: &PgPooledConn, _id: &str) -> StorageResult<Vec<Self>> {
todo!()
}

pub async fn update_by_merchant_id_mandate_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
Expand Down
10 changes: 10 additions & 0 deletions crates/diesel_models/src/query/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ impl PaymentMethod {
.await
}

// Need to fix this function once we start moving to v2 for payment method
#[cfg(all(feature = "v2", feature = "customer_v2"))]
pub async fn find_by_global_id(
_conn: &PgPooledConn,
_id: &str,
_limit: Option<i64>,
) -> StorageResult<Vec<Self>> {
todo!()
}

pub async fn get_count_by_customer_id_merchant_id_status(
conn: &PgPooledConn,
customer_id: &common_utils::id_type::CustomerId,
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ diesel::table! {
merchant_reference_id -> Nullable<Varchar>,
default_billing_address -> Nullable<Bytea>,
default_shipping_address -> Nullable<Bytea>,
status -> DeleteStatus,
#[max_length = 64]
id -> Varchar,
}
Expand Down
19 changes: 12 additions & 7 deletions crates/hyperswitch_domain_models/src/customer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use api_models::customers::CustomerRequestWithEncryption;
// #[cfg(all(feature = "v2", feature = "customer_v2"))]
// use common_enums::SoftDeleteStatus;
#[cfg(all(feature = "v2", feature = "customer_v2"))]
use common_enums::DeleteStatus;
use common_utils::{
crypto, date_time,
encryption::Encryption,
Expand Down Expand Up @@ -56,9 +56,9 @@ pub struct Customer {
pub merchant_reference_id: Option<id_type::CustomerId>,
pub default_billing_address: Option<Encryption>,
pub default_shipping_address: Option<Encryption>,
// pub status: Option<SoftDeleteStatus>,
pub id: String,
pub version: common_enums::ApiVersion,
pub status: DeleteStatus,
}

#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
Expand Down Expand Up @@ -182,7 +182,7 @@ impl super::behaviour::Conversion for Customer {
default_billing_address: self.default_billing_address.map(Encryption::from),
default_shipping_address: self.default_shipping_address.map(Encryption::from),
version: self.version,
// status: self.status,
status: self.status,
})
}

Expand Down Expand Up @@ -236,7 +236,7 @@ impl super::behaviour::Conversion for Customer {
default_billing_address: item.default_billing_address,
default_shipping_address: item.default_shipping_address,
version: item.version,
// status: item.status,
status: item.status,
})
}

Expand All @@ -259,8 +259,8 @@ impl super::behaviour::Conversion for Customer {
updated_by: self.updated_by,
default_billing_address: self.default_billing_address,
default_shipping_address: self.default_shipping_address,
// status: self.status,
version: crate::consts::API_VERSION,
status: self.status,
})
}
}
Expand All @@ -270,7 +270,7 @@ impl super::behaviour::Conversion for Customer {
pub enum CustomerUpdate {
Update {
name: crypto::OptionalEncryptableName,
email: crypto::OptionalEncryptableEmail,
email: Box<crypto::OptionalEncryptableEmail>,
phone: Box<crypto::OptionalEncryptablePhone>,
description: Option<Description>,
phone_country_code: Option<String>,
Expand All @@ -279,6 +279,7 @@ pub enum CustomerUpdate {
default_billing_address: Option<Encryption>,
default_shipping_address: Option<Encryption>,
default_payment_method_id: Option<Option<String>>,
status: Option<DeleteStatus>,
},
ConnectorCustomer {
connector_customer: Option<pii::SecretSerdeValue>,
Expand All @@ -303,6 +304,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {
default_billing_address,
default_shipping_address,
default_payment_method_id,
status,
} => Self {
name: name.map(Encryption::from),
email: email.map(Encryption::from),
Expand All @@ -316,6 +318,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {
default_shipping_address,
default_payment_method_id,
updated_by: None,
status,
},
CustomerUpdate::ConnectorCustomer { connector_customer } => Self {
connector_customer,
Expand All @@ -330,6 +333,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {
updated_by: None,
default_billing_address: None,
default_shipping_address: None,
status: None,
},
CustomerUpdate::UpdateDefaultPaymentMethod {
default_payment_method_id,
Expand All @@ -346,6 +350,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {
updated_by: None,
default_billing_address: None,
default_shipping_address: None,
status: None,
},
}
}
Expand Down
Loading
Loading