Skip to content

Commit b082834

Browse files
committed
feat(users): obtain product_type from the request body
1 parent d2455bc commit b082834

File tree

3 files changed

+12
-49
lines changed

3 files changed

+12
-49
lines changed

Diff for: crates/api_models/src/user/dashboard_metadata.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,7 @@ pub struct ProdIntent {
103103
pub poc_contact: Option<String>,
104104
pub comments: Option<String>,
105105
pub is_completed: bool,
106-
}
107-
108-
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
109-
pub struct ProdIntentWithProductType {
110-
#[serde(flatten)]
111-
pub prod_intent: ProdIntent,
112-
pub product_type: MerchantProductType,
106+
pub product_type: Option<MerchantProductType>,
113107
}
114108

115109
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]

Diff for: crates/router/src/core/user/dashboard_metadata.rs

+4-34
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::str::FromStr;
22

3-
use api_models::user::dashboard_metadata::{
4-
self as api, GetMultipleMetaDataPayload, ProdIntentWithProductType,
5-
};
3+
use api_models::user::dashboard_metadata::{self as api, GetMultipleMetaDataPayload};
64
#[cfg(feature = "email")]
75
use common_enums::EntityType;
86
use common_utils::pii;
@@ -463,42 +461,14 @@ async fn insert_metadata(
463461
pii::Email::from_str(inner_poc_email)
464462
.change_context(UserErrors::EmailParsingError)?;
465463
}
466-
let key_manager_state = &(state).into();
467-
let merchant_key_store = state
468-
.store
469-
.get_merchant_key_store_by_merchant_id(
470-
key_manager_state,
471-
&user.merchant_id.clone(),
472-
&state.store.get_master_key().to_vec().into(),
473-
)
474-
.await
475-
.change_context(UserErrors::InternalServerError)
476-
.attach_printable("Failed to retrieve merchant key store by merchant_id")?;
477-
let merchant_account = state
478-
.store
479-
.find_merchant_account_by_merchant_id(
480-
key_manager_state,
481-
&user.merchant_id.clone(),
482-
&merchant_key_store,
483-
)
484-
.await
485-
.change_context(UserErrors::InternalServerError)
486-
.attach_printable("Failed to retrieve merchant account by merchant_id")?;
487-
// The product type field in the merchant account table is nullable, and if the corresponding value is null, the default orchestration product type is considered.
488-
let product_type = merchant_account.product_type.unwrap_or_default();
489-
490-
let data_value = ProdIntentWithProductType {
491-
prod_intent: data.clone(),
492-
product_type,
493-
};
494464

495465
let mut metadata = utils::insert_merchant_scoped_metadata_to_db(
496466
state,
497467
user.user_id.clone(),
498468
user.merchant_id.clone(),
499469
user.org_id.clone(),
500470
metadata_key,
501-
data_value.clone(),
471+
data.clone(),
502472
)
503473
.await;
504474

@@ -509,7 +479,7 @@ async fn insert_metadata(
509479
user.merchant_id.clone(),
510480
user.org_id.clone(),
511481
metadata_key,
512-
data_value.clone(),
482+
data.clone(),
513483
)
514484
.await
515485
.change_context(UserErrors::InternalServerError);
@@ -532,7 +502,7 @@ async fn insert_metadata(
532502
.await?;
533503
let email_contents = email_types::BizEmailProd::new(
534504
state,
535-
data_value,
505+
data,
536506
theme.as_ref().map(|theme| theme.theme_id.clone()),
537507
theme
538508
.map(|theme| theme.email_config())

Diff for: crates/router/src/services/email/types.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use api_models::user::dashboard_metadata::ProdIntentWithProductType;
1+
use api_models::user::dashboard_metadata::ProdIntent;
22
use common_enums::{EntityType, MerchantProductType};
33
use common_utils::{errors::CustomResult, pii, types::theme::EmailThemeConfig};
44
use error_stack::ResultExt;
@@ -567,7 +567,7 @@ pub struct BizEmailProd {
567567
impl BizEmailProd {
568568
pub fn new(
569569
state: &SessionState,
570-
data: ProdIntentWithProductType,
570+
data: ProdIntent,
571571
theme_id: Option<String>,
572572
theme_config: EmailThemeConfig,
573573
) -> UserResult<Self> {
@@ -576,18 +576,17 @@ impl BizEmailProd {
576576
state.conf.email.prod_intent_recipient_email.clone(),
577577
)?,
578578
settings: state.conf.clone(),
579-
user_name: data.prod_intent.poc_name.unwrap_or_default().into(),
580-
poc_email: data.prod_intent.poc_email.unwrap_or_default(),
581-
legal_business_name: data.prod_intent.legal_business_name.unwrap_or_default(),
579+
user_name: data.poc_name.unwrap_or_default().into(),
580+
poc_email: data.poc_email.unwrap_or_default(),
581+
legal_business_name: data.legal_business_name.unwrap_or_default(),
582582
business_location: data
583-
.prod_intent
584583
.business_location
585584
.unwrap_or(common_enums::CountryAlpha2::AD)
586585
.to_string(),
587-
business_website: data.prod_intent.business_website.unwrap_or_default(),
586+
business_website: data.business_website.unwrap_or_default(),
588587
theme_id,
589588
theme_config,
590-
product_type: data.product_type,
589+
product_type: data.product_type.unwrap_or_default(),
591590
})
592591
}
593592
}

0 commit comments

Comments
 (0)