Bug: [FIX] Add onboarding_survey enum in dashboard metadata type




diff --git a/crates/api_models/src/user/dashboard_metadata.rs b/crates/api_models/src/user/dashboard_metadata.rs
index 66831c7aeb8..b547a61d450 100644
--- a/crates/api_models/src/user/dashboard_metadata.rs
+++ b/crates/api_models/src/user/dashboard_metadata.rs
@@ -26,6 +26,7 @@ pub enum SetMetaDataRequest {
     IsMultipleConfiguration,
     #[serde(skip)]
     IsChangePasswordRequired,
+    OnboardingSurvey(OnboardingSurvey),
 }
 
 #[derive(Debug, serde::Deserialize, serde::Serialize)]
@@ -46,6 +47,20 @@ pub struct ProcessorConnected {
     pub processor_name: String,
 }
 
+#[derive(Debug, serde::Deserialize, serde::Serialize)]
+pub struct OnboardingSurvey {
+    pub designation: Option<String>,
+    pub about_business: Option<String>,
+    pub business_website: Option<String>,
+    pub hyperswitch_req: Option<String>,
+    pub major_markets: Option<Vec<String>>,
+    pub business_size: Option<String>,
+    pub required_features: Option<Vec<String>>,
+    pub required_processors: Option<Vec<String>>,
+    pub planned_live_date: Option<String>,
+    pub miscellaneous: Option<String>,
+}
+
 #[derive(Debug, serde::Deserialize, serde::Serialize)]
 pub struct ConfiguredRouting {
     pub routing_id: String,
@@ -113,6 +128,7 @@ pub enum GetMetaDataRequest {
     SetupWoocomWebhook,
     IsMultipleConfiguration,
     IsChangePasswordRequired,
+    OnboardingSurvey,
 }
 
 #[derive(Debug, serde::Deserialize, serde::Serialize)]
@@ -150,4 +166,5 @@ pub enum GetMetaDataResponse {
     SetupWoocomWebhook(bool),
     IsMultipleConfiguration(bool),
     IsChangePasswordRequired(bool),
+    OnboardingSurvey(Option<OnboardingSurvey>),
 }
diff --git a/crates/diesel_models/src/enums.rs b/crates/diesel_models/src/enums.rs
index 7d9b6eb57e5..85a7e3d92df 100644
--- a/crates/diesel_models/src/enums.rs
+++ b/crates/diesel_models/src/enums.rs
@@ -348,4 +348,5 @@ pub enum DashboardMetadata {
     SetupWoocomWebhook,
     IsMultipleConfiguration,
     IsChangePasswordRequired,
+    OnboardingSurvey,
 }
diff --git a/crates/router/src/core/user/dashboard_metadata.rs b/crates/router/src/core/user/dashboard_metadata.rs
index bd4b2c3a10d..c3512c32f42 100644
--- a/crates/router/src/core/user/dashboard_metadata.rs
+++ b/crates/router/src/core/user/dashboard_metadata.rs
@@ -112,6 +112,9 @@ fn parse_set_request(data_enum: api::SetMetaDataRequest) -> UserResult<types::Me
         api::SetMetaDataRequest::IsChangePasswordRequired => {
             Ok(types::MetaData::IsChangePasswordRequired(true))
         }
+        api::SetMetaDataRequest::OnboardingSurvey(req) => {
+            Ok(types::MetaData::OnboardingSurvey(req))
+        }
     }
 }
 
@@ -139,6 +142,7 @@ fn parse_get_request(data_enum: api::GetMetaDataRequest) -> DBEnum {
         api::GetMetaDataRequest::SetupWoocomWebhook => DBEnum::SetupWoocomWebhook,
         api::GetMetaDataRequest::IsMultipleConfiguration => DBEnum::IsMultipleConfiguration,
         api::GetMetaDataRequest::IsChangePasswordRequired => DBEnum::IsChangePasswordRequired,
+        api::GetMetaDataRequest::OnboardingSurvey => DBEnum::OnboardingSurvey,
     }
 }
 
@@ -218,6 +222,10 @@ fn into_response(
         DBEnum::IsChangePasswordRequired => Ok(api::GetMetaDataResponse::IsChangePasswordRequired(
             data.is_some(),
         )),
+        DBEnum::OnboardingSurvey => {
+            let resp = utils::deserialize_to_response(data)?;
+            Ok(api::GetMetaDataResponse::OnboardingSurvey(resp))
+        }
     }
 }
 
@@ -548,6 +556,17 @@ async fn insert_metadata(
             )
             .await
         }
+        types::MetaData::OnboardingSurvey(data) => {
+            utils::insert_merchant_scoped_metadata_to_db(
+                state,
+                user.user_id,
+                user.merchant_id,
+                user.org_id,
+                metadata_key,
+                data,
+            )
+            .await
+        }
     }
 }
 
diff --git a/crates/router/src/types/domain/user/dashboard_metadata.rs b/crates/router/src/types/domain/user/dashboard_metadata.rs
index 9c00809238e..665ee1ab022 100644
--- a/crates/router/src/types/domain/user/dashboard_metadata.rs
+++ b/crates/router/src/types/domain/user/dashboard_metadata.rs
@@ -26,6 +26,7 @@ pub enum MetaData {
     SetupWoocomWebhook(bool),
     IsMultipleConfiguration(bool),
     IsChangePasswordRequired(bool),
+    OnboardingSurvey(api::OnboardingSurvey),
 }
 
 impl From<&MetaData> for DBEnum {
@@ -53,6 +54,7 @@ impl From<&MetaData> for DBEnum {
             MetaData::SetupWoocomWebhook(_) => Self::SetupWoocomWebhook,
             MetaData::IsMultipleConfiguration(_) => Self::IsMultipleConfiguration,
             MetaData::IsChangePasswordRequired(_) => Self::IsChangePasswordRequired,
+            MetaData::OnboardingSurvey(_) => Self::OnboardingSurvey,
         }
     }
 }
diff --git a/crates/router/src/utils/user/dashboard_metadata.rs b/crates/router/src/utils/user/dashboard_metadata.rs
index e18a6401173..3979a864944 100644
--- a/crates/router/src/utils/user/dashboard_metadata.rs
+++ b/crates/router/src/utils/user/dashboard_metadata.rs
@@ -214,6 +214,7 @@ pub fn separate_metadata_type_based_on_scope(
             | DBEnum::DownloadWoocom
             | DBEnum::ConfigureWoocom
             | DBEnum::SetupWoocomWebhook
+            | DBEnum::OnboardingSurvey
             | DBEnum::IsMultipleConfiguration => merchant_scoped.push(key),
             DBEnum::Feedback | DBEnum::ProdIntent | DBEnum::IsChangePasswordRequired => {
                 user_scoped.push(key)
diff --git a/migrations/2024-04-12-100908_add_dashboard_metadata_key_onboarding_survey/down.sql b/migrations/2024-04-12-100908_add_dashboard_metadata_key_onboarding_survey/down.sql
new file mode 100644
index 00000000000..c7c9cbeb401
--- /dev/null
+++ b/migrations/2024-04-12-100908_add_dashboard_metadata_key_onboarding_survey/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+SELECT 1;
\ No newline at end of file
diff --git a/migrations/2024-04-12-100908_add_dashboard_metadata_key_onboarding_survey/up.sql b/migrations/2024-04-12-100908_add_dashboard_metadata_key_onboarding_survey/up.sql
new file mode 100644
index 00000000000..6c69d264814
--- /dev/null
+++ b/migrations/2024-04-12-100908_add_dashboard_metadata_key_onboarding_survey/up.sql
@@ -0,0 +1,3 @@
+-- Your SQL goes here
+ALTER TYPE "DashboardMetadata"
+ADD VALUE IF NOT EXISTS 'onboarding_survey';
\ No newline at end of file

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [X] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
Bug Fix: Add support for onboarding_survey enum 


### Additional Changes

- [ ] This PR modifies the API contract
- [X] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->
Until now, we've been utilising Calendly to gather comprehensive information regarding both merchants and users. 
After this PR we will capture all the data from the dashboard and store it in dashboard_metadata for better insights.


## How did you test it?
1. Post OnboardingSurvey enum details  
Request 
``` 
curl --location 'http://localhost:8080/user/data?keys=OnboardingSurvey' \
--header 'Authorization: JWT token' \
--header 'Content-Type: application/json' \
--data '{
    "OnboardingSurvey": {
        "designation": "some designation",
        "business_website": "some business website",
        "about_business": "about business ",
        "major_markets": [
            "Europe"
        ],
        "business_size": "business size",
        "hyperswitch_req": "hyperswitch requirement",
        "required_features": [
            "FRM",
            "Recon"
        ],
        "required_processors": [
            "Stripe"
        ],
        "planned_live_date": "planned live date",
        "miscellaneous": "some comment"
    }
}'
```

2. Get OnboardingSurvey enum details request 
```
curl --location 'http://localhost:8080/user/data?keys=OnboardingSurvey' \
--header 'Authorization: JWT token'
```
Response  
a. If data not present for the user 
`[{"OnboardingSurvey":null}]`
b. If data already present for the user 
```
[
    {
        "OnboardingSurvey": {
            "designation": "some designation",
            "about_business": "about business ",
            "business_website": "some business website",
            "hyperswitch_req": "hyperswitch requirement",
            "major_markets": [
                "Europe"
            ],
            "business_size": "business size",
            "required_features": [
                "FRM",
                "Recon"
            ],
            "required_processors": [
                "Stripe"
            ],
            "planned_live_date": "planned live date",
            "miscellaneous": "some comment"
        }
    }
]
```
## Checklist
<!-- Put an `x` in the boxes that apply -->

- [X] I formatted the code `cargo +nightly fmt --all`
- [X] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
