id
stringlengths
11
116
type
stringclasses
1 value
granularity
stringclasses
4 values
content
stringlengths
16
477k
metadata
dict
fn_clm_router_create_dispute_new_-931197206101911210
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/dispute fn create_dispute_new(dispute_ids: DisputeNewIds) -> DisputeNew { DisputeNew { dispute_id: dispute_ids.dispute_id, amount: StringMinorUnitForConnector::convert( &StringMinorUnitForConnector, MinorUnit::new(0), Currency::USD, ) .expect("Amount Conversion Error"), currency: "currency".into(), dispute_stage: DisputeStage::Dispute, dispute_status: DisputeStatus::DisputeOpened, payment_id: dispute_ids.payment_id, attempt_id: dispute_ids.attempt_id, merchant_id: dispute_ids.merchant_id, connector_status: "connector_status".into(), connector_dispute_id: dispute_ids.connector_dispute_id, connector_reason: Some("connector_reason".into()), connector_reason_code: Some("connector_reason_code".into()), challenge_required_by: Some(datetime!(2019-01-01 0:00)), connector_created_at: Some(datetime!(2019-01-02 0:00)), connector_updated_at: Some(datetime!(2019-01-03 0:00)), connector: "connector".into(), evidence: Some(Secret::from(Value::String("evidence".into()))), profile_id: Some(common_utils::generate_profile_id_of_default_length()), merchant_connector_id: None, dispute_amount: MinorUnit::new(1040), organization_id: common_utils::id_type::OrganizationId::default(), dispute_currency: Some(Currency::default()), } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 64, "total_crates": null }
fn_clm_router_find_dispute_by_merchant_id_dispute_id_-931197206101911210
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/dispute // Implementation of MockDb for DisputeInterface async fn find_dispute_by_merchant_id_dispute_id( &self, merchant_id: &common_utils::id_type::MerchantId, dispute_id: &str, ) -> CustomResult<storage::Dispute, errors::StorageError> { let locked_disputes = self.disputes.lock().await; locked_disputes .iter() .find(|d| d.merchant_id == *merchant_id && d.dispute_id == dispute_id) .cloned() .ok_or(errors::StorageError::ValueNotFound(format!("No dispute available for merchant_id = {merchant_id:?} and dispute_id = {dispute_id}")) .into()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 55, "total_crates": null }
fn_clm_router_update_dispute_-931197206101911210
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/dispute // Implementation of MockDb for DisputeInterface async fn update_dispute( &self, this: storage::Dispute, dispute: storage::DisputeUpdate, ) -> CustomResult<storage::Dispute, errors::StorageError> { let mut locked_disputes = self.disputes.lock().await; let dispute_to_update = locked_disputes .iter_mut() .find(|d| d.dispute_id == this.dispute_id) .ok_or(errors::StorageError::MockDbError)?; let now = common_utils::date_time::now(); match dispute { storage::DisputeUpdate::Update { dispute_stage, dispute_status, connector_status, connector_reason, connector_reason_code, challenge_required_by, connector_updated_at, } => { if connector_reason.is_some() { dispute_to_update.connector_reason = connector_reason; } if connector_reason_code.is_some() { dispute_to_update.connector_reason_code = connector_reason_code; } if challenge_required_by.is_some() { dispute_to_update.challenge_required_by = challenge_required_by; } if connector_updated_at.is_some() { dispute_to_update.connector_updated_at = connector_updated_at; } dispute_to_update.dispute_stage = dispute_stage; dispute_to_update.dispute_status = dispute_status; dispute_to_update.connector_status = connector_status; } storage::DisputeUpdate::StatusUpdate { dispute_status, connector_status, } => { if let Some(status) = connector_status { dispute_to_update.connector_status = status; } dispute_to_update.dispute_status = dispute_status; } storage::DisputeUpdate::EvidenceUpdate { evidence } => { dispute_to_update.evidence = evidence; } } dispute_to_update.modified_at = now; Ok(dispute_to_update.clone()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 55, "total_crates": null }
fn_clm_router_find_call_back_mapper_by_id_4198098326276175594
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/callback_mapper // Implementation of MockDb for CallbackMapperInterface async fn find_call_back_mapper_by_id( &self, _id: &str, ) -> CustomResult<domain::CallbackMapper, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_insert_call_back_mapper_4198098326276175594
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/callback_mapper // Implementation of MockDb for CallbackMapperInterface async fn insert_call_back_mapper( &self, _call_back_mapper: domain::CallbackMapper, ) -> CustomResult<domain::CallbackMapper, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 11, "total_crates": null }
fn_clm_router_generic_list_roles_by_entity_type_-2005471892323197567
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/role // Implementation of MockDb for RoleInterface async fn generic_list_roles_by_entity_type( &self, payload: storage::ListRolesByEntityPayload, is_lineage_data_required: bool, tenant_id: id_type::TenantId, org_id: id_type::OrganizationId, ) -> CustomResult<Vec<storage::Role>, errors::StorageError> { let roles = self.roles.lock().await; let roles_list: Vec<_> = roles .iter() .filter(|role| match &payload { storage::ListRolesByEntityPayload::Organization => { let entity_in_vec = if is_lineage_data_required { vec![ EntityType::Organization, EntityType::Merchant, EntityType::Profile, ] } else { vec![EntityType::Organization] }; role.tenant_id == tenant_id && role.org_id == org_id && entity_in_vec.contains(&role.entity_type) } storage::ListRolesByEntityPayload::Merchant(merchant_id) => { let entity_in_vec = if is_lineage_data_required { vec![EntityType::Merchant, EntityType::Profile] } else { vec![EntityType::Merchant] }; let matches_merchant = role .merchant_id .as_ref() .is_some_and(|merchant_id_from_role| merchant_id_from_role == merchant_id); role.tenant_id == tenant_id && role.org_id == org_id && (role.scope == RoleScope::Organization || matches_merchant) && entity_in_vec.contains(&role.entity_type) } storage::ListRolesByEntityPayload::Profile(merchant_id, profile_id) => { let entity_in_vec = [EntityType::Profile]; let matches_merchant = role.merchant_id .as_ref() .is_some_and(|merchant_id_from_role| { merchant_id_from_role == merchant_id && role.scope == RoleScope::Merchant }); let matches_profile = role.profile_id .as_ref() .is_some_and(|profile_id_from_role| { profile_id_from_role == profile_id && role.scope == RoleScope::Profile }); role.tenant_id == tenant_id && role.org_id == org_id && (role.scope == RoleScope::Organization || matches_merchant || matches_profile) && entity_in_vec.contains(&role.entity_type) } }) .cloned() .collect(); Ok(roles_list) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 60, "total_crates": null }
fn_clm_router_update_role_by_role_id_-2005471892323197567
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/role // Implementation of MockDb for RoleInterface async fn update_role_by_role_id( &self, role_id: &str, role_update: storage::RoleUpdate, ) -> CustomResult<storage::Role, errors::StorageError> { let mut roles = self.roles.lock().await; roles .iter_mut() .find(|role| role.role_id == role_id) .map(|role| { *role = match role_update { storage::RoleUpdate::UpdateDetails { groups, role_name, last_modified_at, last_modified_by, } => storage::Role { groups: groups.unwrap_or(role.groups.to_owned()), role_name: role_name.unwrap_or(role.role_name.to_owned()), last_modified_by, last_modified_at, ..role.to_owned() }, }; role.to_owned() }) .ok_or( errors::StorageError::ValueNotFound(format!( "No role available for role_id = {role_id}" )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 40, "total_crates": null }
fn_clm_router_list_roles_for_org_by_parameters_-2005471892323197567
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/role // Implementation of MockDb for RoleInterface async fn list_roles_for_org_by_parameters( &self, tenant_id: &id_type::TenantId, org_id: &id_type::OrganizationId, merchant_id: Option<&id_type::MerchantId>, entity_type: Option<EntityType>, limit: Option<u32>, ) -> CustomResult<Vec<storage::Role>, errors::StorageError> { let roles = self.roles.lock().await; let limit_usize = limit.unwrap_or(u32::MAX).try_into().unwrap_or(usize::MAX); let roles_list: Vec<_> = roles .iter() .filter(|role| { let matches_merchant = merchant_id .zip(role.merchant_id.as_ref()) .map(|(merchant_id, role_merchant_id)| merchant_id == role_merchant_id) .unwrap_or(true); matches_merchant && role.org_id == *org_id && role.tenant_id == *tenant_id && Some(role.entity_type) == entity_type }) .take(limit_usize) .cloned() .collect(); Ok(roles_list) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 37, "total_crates": null }
fn_clm_router_find_role_by_role_id_in_lineage_-2005471892323197567
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/role // Implementation of MockDb for RoleInterface async fn find_role_by_role_id_in_lineage( &self, role_id: &str, merchant_id: &id_type::MerchantId, org_id: &id_type::OrganizationId, profile_id: &id_type::ProfileId, tenant_id: &id_type::TenantId, ) -> CustomResult<storage::Role, errors::StorageError> { let roles = self.roles.lock().await; roles .iter() .find(|role| { role.role_id == role_id && (role.tenant_id == *tenant_id) && role.org_id == *org_id && ((role.scope == RoleScope::Organization) || (role .merchant_id .as_ref() .is_some_and(|merchant_id_from_role| { merchant_id_from_role == merchant_id && role.scope == RoleScope::Merchant })) || (role .profile_id .as_ref() .is_some_and(|profile_id_from_role| { profile_id_from_role == profile_id && role.scope == RoleScope::Profile }))) }) .cloned() .ok_or( errors::StorageError::ValueNotFound(format!( "No role available in merchant scope for role_id = {role_id}, \ merchant_id = {merchant_id:?} and org_id = {org_id:?}" )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 36, "total_crates": null }
fn_clm_router_find_by_role_id_org_id_tenant_id_-2005471892323197567
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/role // Implementation of MockDb for RoleInterface async fn find_by_role_id_org_id_tenant_id( &self, role_id: &str, org_id: &id_type::OrganizationId, tenant_id: &id_type::TenantId, ) -> CustomResult<storage::Role, errors::StorageError> { let roles = self.roles.lock().await; roles .iter() .find(|role| { role.role_id == role_id && role.org_id == *org_id && role.tenant_id == *tenant_id }) .cloned() .ok_or( errors::StorageError::ValueNotFound(format!( "No role available in org scope for role_id = {role_id} and org_id = {org_id:?}" )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 31, "total_crates": null }
fn_clm_router_test_concurrent_webhook_insertion_with_redis_lock_5668422208179451742
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/events async fn test_concurrent_webhook_insertion_with_redis_lock( ) -> Result<(), Box<dyn std::error::Error>> { // Test concurrent webhook insertion with a Redis lock to prevent race conditions let conf = Settings::new()?; let tx: tokio::sync::oneshot::Sender<()> = tokio::sync::oneshot::channel().0; let app_state = Box::pin(routes::AppState::with_storage( conf, StorageImpl::PostgresqlTest, tx, Box::new(services::MockApiClient), )) .await; let tenant_id = common_utils::id_type::TenantId::try_from_string("public".to_string())?; let state = Arc::new(app_state) .get_session_state(&tenant_id, None, || {}) .map_err(|_| "failed to get session state")?; let merchant_id = common_utils::id_type::MerchantId::try_from(std::borrow::Cow::from("juspay_merchant"))?; let business_profile_id = common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from("profile1"))?; let key_manager_state = &(&state).into(); let master_key = state.store.get_master_key(); let aes_key = services::generate_aes256_key()?; let merchant_key_store = state .store .insert_merchant_key_store( key_manager_state, domain::MerchantKeyStore { merchant_id: merchant_id.clone(), key: domain::types::crypto_operation( key_manager_state, type_name!(domain::MerchantKeyStore), domain::types::CryptoOperation::Encrypt(aes_key.to_vec().into()), Identifier::Merchant(merchant_id.to_owned()), master_key, ) .await? .try_into_operation()?, created_at: datetime!(2023-02-01 0:00), }, &master_key.to_vec().into(), ) .await?; let merchant_account_to_insert = MerchantAccount::from(MerchantAccountSetter { merchant_id: merchant_id.clone(), merchant_name: None, merchant_details: None, return_url: None, webhook_details: Some(WebhookDetails { webhook_version: None, webhook_username: None, webhook_password: None, webhook_url: Some(masking::Secret::new( "https://example.com/webhooks".to_string(), )), payment_created_enabled: None, payment_succeeded_enabled: Some(true), payment_failed_enabled: None, payment_statuses_enabled: None, refund_statuses_enabled: None, payout_statuses_enabled: None, multiple_webhooks_list: None, }), sub_merchants_enabled: None, parent_merchant_id: None, enable_payment_response_hash: true, payment_response_hash_key: None, redirect_to_merchant_with_http_post: false, publishable_key: "pk_test_11DviC2G2fb3lAJoes1q3A2222233327".to_string(), locker_id: None, storage_scheme: enums::MerchantStorageScheme::PostgresOnly, metadata: None, routing_algorithm: None, primary_business_details: serde_json::json!({ "country": "US", "business": "default" }), intent_fulfillment_time: Some(1), created_at: common_utils::date_time::now(), modified_at: common_utils::date_time::now(), frm_routing_algorithm: None, payout_routing_algorithm: None, organization_id: generate_organization_id_of_default_length(), is_recon_enabled: true, default_profile: None, recon_status: enums::ReconStatus::NotRequested, payment_link_config: None, pm_collect_link_config: None, is_platform_account: false, merchant_account_type: common_enums::MerchantAccountType::Standard, product_type: None, version: common_enums::ApiVersion::V1, }); let merchant_account = state .store .insert_merchant( key_manager_state, merchant_account_to_insert, &merchant_key_store, ) .await?; let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(domain::Context( merchant_account, merchant_key_store.clone(), ))); let merchant_id = merchant_id.clone(); // Clone merchant_id to avoid move let business_profile_to_insert = domain::Profile::from(domain::ProfileSetter { merchant_country_code: None, profile_id: business_profile_id.clone(), merchant_id: merchant_id.clone(), profile_name: "test_concurrent_profile".to_string(), created_at: common_utils::date_time::now(), modified_at: common_utils::date_time::now(), return_url: None, enable_payment_response_hash: true, payment_response_hash_key: None, redirect_to_merchant_with_http_post: false, webhook_details: Some(WebhookDetails { webhook_version: None, webhook_username: None, webhook_password: None, webhook_url: Some(masking::Secret::new( "https://example.com/webhooks".to_string(), )), payment_created_enabled: None, payment_succeeded_enabled: Some(true), payment_failed_enabled: None, payment_statuses_enabled: None, refund_statuses_enabled: None, payout_statuses_enabled: None, multiple_webhooks_list: None, }), metadata: None, routing_algorithm: None, intent_fulfillment_time: None, frm_routing_algorithm: None, payout_routing_algorithm: None, is_recon_enabled: false, applepay_verified_domains: None, payment_link_config: None, session_expiry: None, authentication_connector_details: None, payout_link_config: None, is_extended_card_info_enabled: None, extended_card_info_config: None, is_connector_agnostic_mit_enabled: None, use_billing_as_payment_method_billing: None, collect_shipping_details_from_wallet_connector: None, collect_billing_details_from_wallet_connector: None, outgoing_webhook_custom_http_headers: None, always_collect_billing_details_from_wallet_connector: None, always_collect_shipping_details_from_wallet_connector: None, tax_connector_id: None, is_tax_connector_enabled: false, dynamic_routing_algorithm: None, is_network_tokenization_enabled: false, is_auto_retries_enabled: false, max_auto_retries_enabled: None, always_request_extended_authorization: None, is_click_to_pay_enabled: false, authentication_product_ids: None, card_testing_guard_config: None, card_testing_secret_key: None, is_clear_pan_retries_enabled: false, force_3ds_challenge: false, is_debit_routing_enabled: false, merchant_business_country: None, is_iframe_redirection_enabled: None, is_pre_network_tokenization_enabled: false, merchant_category_code: None, dispute_polling_interval: None, is_manual_retry_enabled: None, always_enable_overcapture: None, external_vault_details: domain::ExternalVaultDetails::Skip, billing_processor_id: None, is_l2_l3_enabled: false, }); let business_profile = state .store .insert_business_profile( key_manager_state, &merchant_key_store.clone(), business_profile_to_insert, ) .await?; // Same inputs for all threads let event_type = enums::EventType::PaymentSucceeded; let event_class = enums::EventClass::Payments; let primary_object_id = Arc::new("concurrent_payment_id".to_string()); let primary_object_type = enums::EventObjectType::PaymentDetails; let payment_id = common_utils::id_type::PaymentId::try_from(std::borrow::Cow::Borrowed( "pay_mbabizu24mvu3mela5njyhpit10", ))?; let primary_object_created_at = Some(common_utils::date_time::now()); let expected_response = api::PaymentsResponse { payment_id, status: IntentStatus::Succeeded, amount: MinorUnit::new(6540), amount_capturable: MinorUnit::new(0), amount_received: None, client_secret: None, created: None, currency: "USD".to_string(), customer_id: None, description: Some("Its my first payment request".to_string()), refunds: None, mandate_id: None, merchant_id, net_amount: MinorUnit::new(6540), connector: None, customer: None, disputes: None, attempts: None, captures: None, mandate_data: None, setup_future_usage: None, off_session: None, capture_on: None, capture_method: None, payment_method: None, payment_method_data: None, payment_token: None, shipping: None, billing: None, order_details: None, email: None, name: None, phone: None, return_url: None, authentication_type: None, statement_descriptor_name: None, statement_descriptor_suffix: None, next_action: None, cancellation_reason: None, error_code: None, error_message: None, unified_code: None, unified_message: None, payment_experience: None, payment_method_type: None, connector_label: None, business_country: None, business_label: None, business_sub_label: None, allowed_payment_method_types: None, ephemeral_key: None, manual_retry_allowed: None, connector_transaction_id: None, frm_message: None, metadata: None, connector_metadata: None, feature_metadata: None, reference_id: None, payment_link: None, profile_id: None, surcharge_details: None, attempt_count: 1, merchant_decision: None, merchant_connector_id: None, incremental_authorization_allowed: None, authorization_count: None, incremental_authorizations: None, external_authentication_details: None, external_3ds_authentication_attempted: None, expires_on: None, fingerprint: None, browser_info: None, payment_method_id: None, payment_method_status: None, updated: None, split_payments: None, frm_metadata: None, merchant_order_reference_id: None, capture_before: None, extended_authorization_applied: None, order_tax_amount: None, connector_mandate_id: None, shipping_cost: None, card_discovery: None, mit_category: None, force_3ds_challenge: None, force_3ds_challenge_trigger: None, issuer_error_code: None, issuer_error_message: None, is_iframe_redirection_enabled: None, whole_connector_response: None, payment_channel: None, network_transaction_id: None, enable_partial_authorization: None, is_overcapture_enabled: None, enable_overcapture: None, network_details: None, is_stored_credential: None, request_extended_authorization: None, }; let content = api_webhooks::OutgoingWebhookContent::PaymentDetails(Box::new(expected_response)); // Run 10 concurrent webhook creations let mut handles = vec![]; for _ in 0..10 { let state_clone = state.clone(); let merchant_context_clone = merchant_context.clone(); let business_profile_clone = business_profile.clone(); let content_clone = content.clone(); let primary_object_id_clone = primary_object_id.clone(); let handle = tokio::spawn(async move { webhooks_core::create_event_and_trigger_outgoing_webhook( state_clone, merchant_context_clone, business_profile_clone, event_type, event_class, (*primary_object_id_clone).to_string(), primary_object_type, content_clone, primary_object_created_at, ) .await .map_err(|e| format!("create_event_and_trigger_outgoing_webhook failed: {e}")) }); handles.push(handle); } // Await all tasks // We give the whole batch 20 s; if they don't finish something is wrong. let results = timeout(Duration::from_secs(20), join_all(handles)) .await .map_err(|_| "tasks hung for >20 s – possible dead-lock / endless retry")?; for res in results { // Any task that panicked or returned Err will make the test fail here. let _ = res.map_err(|e| format!("task panicked: {e}"))?; } // Collect all initial-attempt events for this payment let events = state .store .list_initial_events_by_merchant_id_primary_object_id( key_manager_state, &business_profile.merchant_id, &primary_object_id.clone(), merchant_context.get_merchant_key_store(), ) .await?; assert_eq!( events.len(), 1, "Expected exactly 1 row in events table, found {}", events.len() ); Ok(()) } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 166, "total_crates": null }
fn_clm_router_test_mockdb_event_interface_5668422208179451742
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/events async fn test_mockdb_event_interface() { #[allow(clippy::expect_used)] let mockdb = MockDb::new(&redis_interface::RedisSettings::default()) .await .expect("Failed to create Mock store"); let event_id = "test_event_id"; let (tx, _) = tokio::sync::oneshot::channel(); let app_state = Box::pin(routes::AppState::with_storage( Settings::default(), StorageImpl::PostgresqlTest, tx, Box::new(services::MockApiClient), )) .await; let state = &Arc::new(app_state) .get_session_state( &common_utils::id_type::TenantId::try_from_string("public".to_string()).unwrap(), None, || {}, ) .unwrap(); let merchant_id = common_utils::id_type::MerchantId::try_from(std::borrow::Cow::from("merchant_1")) .unwrap(); let business_profile_id = common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from("profile1")).unwrap(); let payment_id = "test_payment_id"; let key_manager_state = &state.into(); let master_key = mockdb.get_master_key(); mockdb .insert_merchant_key_store( key_manager_state, domain::MerchantKeyStore { merchant_id: merchant_id.clone(), key: domain::types::crypto_operation( key_manager_state, type_name!(domain::MerchantKeyStore), domain::types::CryptoOperation::Encrypt( services::generate_aes256_key().unwrap().to_vec().into(), ), Identifier::Merchant(merchant_id.to_owned()), master_key, ) .await .and_then(|val| val.try_into_operation()) .unwrap(), created_at: datetime!(2023-02-01 0:00), }, &master_key.to_vec().into(), ) .await .unwrap(); let merchant_key_store = mockdb .get_merchant_key_store_by_merchant_id( key_manager_state, &merchant_id, &master_key.to_vec().into(), ) .await .unwrap(); let event1 = mockdb .insert_event( key_manager_state, domain::Event { event_id: event_id.into(), event_type: enums::EventType::PaymentSucceeded, event_class: enums::EventClass::Payments, is_webhook_notified: false, primary_object_id: payment_id.into(), primary_object_type: enums::EventObjectType::PaymentDetails, created_at: common_utils::date_time::now(), merchant_id: Some(merchant_id.to_owned()), business_profile_id: Some(business_profile_id.to_owned()), primary_object_created_at: Some(common_utils::date_time::now()), idempotent_event_id: Some(event_id.into()), initial_attempt_id: Some(event_id.into()), request: None, response: None, delivery_attempt: Some(enums::WebhookDeliveryAttempt::InitialAttempt), metadata: Some(EventMetadata::Payment { payment_id: common_utils::id_type::GlobalPaymentId::try_from( std::borrow::Cow::Borrowed(payment_id), ) .unwrap(), }), is_overall_delivery_successful: Some(false), }, &merchant_key_store, ) .await .unwrap(); assert_eq!(event1.event_id, event_id); let updated_event = mockdb .update_event_by_merchant_id_event_id( key_manager_state, &merchant_id, event_id, domain::EventUpdate::UpdateResponse { is_webhook_notified: true, response: None, }, &merchant_key_store, ) .await .unwrap(); assert!(updated_event.is_webhook_notified); assert_eq!(updated_event.primary_object_id, payment_id); assert_eq!(updated_event.event_id, event_id); }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 90, "total_crates": null }
fn_clm_router_list_initial_events_by_merchant_id_constraints_5668422208179451742
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/events // Implementation of MockDb for EventInterface async fn list_initial_events_by_merchant_id_constraints( &self, state: &KeyManagerState, merchant_id: &common_utils::id_type::MerchantId, created_after: time::PrimitiveDateTime, created_before: time::PrimitiveDateTime, limit: Option<i64>, offset: Option<i64>, event_types: HashSet<common_enums::EventType>, is_delivered: Option<bool>, merchant_key_store: &domain::MerchantKeyStore, ) -> CustomResult<Vec<domain::Event>, errors::StorageError> { let locked_events = self.events.lock().await; let events_iter = locked_events.iter().filter(|event| { let check = event.merchant_id == Some(merchant_id.to_owned()) && event.initial_attempt_id.as_ref() == Some(&event.event_id) && (event.created_at >= created_after) && (event.created_at <= created_before) && (event_types.is_empty() || event_types.contains(&event.event_type)) && (event.is_overall_delivery_successful == is_delivered); check }); let offset: usize = if let Some(offset) = offset { if offset < 0 { Err(errors::StorageError::MockDbError)?; } offset .try_into() .map_err(|_| errors::StorageError::MockDbError)? } else { 0 }; let limit: usize = if let Some(limit) = limit { if limit < 0 { Err(errors::StorageError::MockDbError)?; } limit .try_into() .map_err(|_| errors::StorageError::MockDbError)? } else { usize::MAX }; let events = events_iter .skip(offset) .take(limit) .cloned() .collect::<Vec<_>>(); let mut domain_events = Vec::with_capacity(events.len()); for event in events { let domain_event = event .convert( state, merchant_key_store.key.get_inner(), merchant_key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError)?; domain_events.push(domain_event); } Ok(domain_events) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 58, "total_crates": null }
fn_clm_router_list_initial_events_by_profile_id_constraints_5668422208179451742
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/events // Implementation of MockDb for EventInterface async fn list_initial_events_by_profile_id_constraints( &self, state: &KeyManagerState, profile_id: &common_utils::id_type::ProfileId, created_after: time::PrimitiveDateTime, created_before: time::PrimitiveDateTime, limit: Option<i64>, offset: Option<i64>, event_types: HashSet<common_enums::EventType>, is_delivered: Option<bool>, merchant_key_store: &domain::MerchantKeyStore, ) -> CustomResult<Vec<domain::Event>, errors::StorageError> { let locked_events = self.events.lock().await; let events_iter = locked_events.iter().filter(|event| { let check = event.business_profile_id == Some(profile_id.to_owned()) && event.initial_attempt_id.as_ref() == Some(&event.event_id) && (event.created_at >= created_after) && (event.created_at <= created_before) && (event_types.is_empty() || event_types.contains(&event.event_type)) && (event.is_overall_delivery_successful == is_delivered); check }); let offset: usize = if let Some(offset) = offset { if offset < 0 { Err(errors::StorageError::MockDbError)?; } offset .try_into() .map_err(|_| errors::StorageError::MockDbError)? } else { 0 }; let limit: usize = if let Some(limit) = limit { if limit < 0 { Err(errors::StorageError::MockDbError)?; } limit .try_into() .map_err(|_| errors::StorageError::MockDbError)? } else { usize::MAX }; let events = events_iter .skip(offset) .take(limit) .cloned() .collect::<Vec<_>>(); let mut domain_events = Vec::with_capacity(events.len()); for event in events { let domain_event = event .convert( state, merchant_key_store.key.get_inner(), merchant_key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError)?; domain_events.push(domain_event); } Ok(domain_events) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 58, "total_crates": null }
fn_clm_router_update_event_by_merchant_id_event_id_5668422208179451742
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/events // Implementation of MockDb for EventInterface async fn update_event_by_merchant_id_event_id( &self, state: &KeyManagerState, merchant_id: &common_utils::id_type::MerchantId, event_id: &str, event: domain::EventUpdate, merchant_key_store: &domain::MerchantKeyStore, ) -> CustomResult<domain::Event, errors::StorageError> { let mut locked_events = self.events.lock().await; let event_to_update = locked_events .iter_mut() .find(|event| { event.merchant_id == Some(merchant_id.to_owned()) && event.event_id == event_id }) .ok_or(errors::StorageError::MockDbError)?; match event { domain::EventUpdate::UpdateResponse { is_webhook_notified, response, } => { event_to_update.is_webhook_notified = is_webhook_notified; event_to_update.response = response.map(Into::into); } domain::EventUpdate::OverallDeliveryStatusUpdate { is_overall_delivery_successful, } => { event_to_update.is_overall_delivery_successful = Some(is_overall_delivery_successful) } } event_to_update .clone() .convert( state, merchant_key_store.key.get_inner(), merchant_key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 53, "total_crates": null }
fn_clm_router_update_organization_by_org_id_-1399186736596720942
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/organization // Implementation of super::MockDb for OrganizationInterface async fn update_organization_by_org_id( &self, org_id: &id_type::OrganizationId, update: storage::OrganizationUpdate, ) -> CustomResult<storage::Organization, errors::StorageError> { let mut organizations = self.organizations.lock().await; organizations .iter_mut() .find(|org| org.get_organization_id() == *org_id) .map(|org| match &update { storage::OrganizationUpdate::Update { organization_name, organization_details, metadata, platform_merchant_id, } => { organization_name .as_ref() .map(|org_name| org.set_organization_name(org_name.to_owned())); organization_details.clone_into(&mut org.organization_details); metadata.clone_into(&mut org.metadata); platform_merchant_id.clone_into(&mut org.platform_merchant_id); org } }) .ok_or( errors::StorageError::ValueNotFound(format!( "No organization available for org_id = {org_id:?}", )) .into(), ) .cloned() }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 49, "total_crates": null }
fn_clm_router_find_organization_by_org_id_-1399186736596720942
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/organization // Implementation of super::MockDb for OrganizationInterface async fn find_organization_by_org_id( &self, org_id: &id_type::OrganizationId, ) -> CustomResult<storage::Organization, errors::StorageError> { let organizations = self.organizations.lock().await; organizations .iter() .find(|org| org.get_organization_id() == *org_id) .cloned() .ok_or( errors::StorageError::ValueNotFound(format!( "No organization available for org_id = {org_id:?}", )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 42, "total_crates": null }
fn_clm_router_insert_organization_-1399186736596720942
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/organization // Implementation of super::MockDb for OrganizationInterface async fn insert_organization( &self, organization: storage::OrganizationNew, ) -> CustomResult<storage::Organization, errors::StorageError> { let mut organizations = self.organizations.lock().await; if organizations .iter() .any(|org| org.get_organization_id() == organization.get_organization_id()) { Err(errors::StorageError::DuplicateValue { entity: "org_id", key: None, })? } let org = storage::Organization::new(organization); organizations.push(org.clone()); Ok(org) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 39, "total_crates": null }
fn_clm_router_update_fraud_check_response_with_attempt_id_3601389321012291143
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/fraud_check // Implementation of MockDb for FraudCheckInterface async fn update_fraud_check_response_with_attempt_id( &self, _this: FraudCheck, _fraud_check: FraudCheckUpdate, ) -> CustomResult<FraudCheck, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 20, "total_crates": null }
fn_clm_router_find_fraud_check_by_payment_id_3601389321012291143
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/fraud_check // Implementation of MockDb for FraudCheckInterface async fn find_fraud_check_by_payment_id( &self, _payment_id: common_utils::id_type::PaymentId, _merchant_id: common_utils::id_type::MerchantId, ) -> CustomResult<FraudCheck, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 20, "total_crates": null }
fn_clm_router_find_fraud_check_by_payment_id_if_present_3601389321012291143
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/fraud_check // Implementation of MockDb for FraudCheckInterface async fn find_fraud_check_by_payment_id_if_present( &self, _payment_id: common_utils::id_type::PaymentId, _merchant_id: common_utils::id_type::MerchantId, ) -> CustomResult<Option<FraudCheck>, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 20, "total_crates": null }
fn_clm_router_insert_fraud_check_response_3601389321012291143
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/fraud_check // Implementation of MockDb for FraudCheckInterface async fn insert_fraud_check_response( &self, _new: storage::FraudCheckNew, ) -> CustomResult<FraudCheck, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }
fn_clm_router_test_connector_profile_id_cache_-385092069554860368
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/merchant_connector_account async fn test_connector_profile_id_cache() { let conf = Settings::new().unwrap(); let tx: oneshot::Sender<()> = oneshot::channel().0; let app_state = Box::pin(routes::AppState::with_storage( conf, StorageImpl::PostgresqlTest, tx, Box::new(services::MockApiClient), )) .await; let state = &Arc::new(app_state) .get_session_state( &common_utils::id_type::TenantId::try_from_string("public".to_string()).unwrap(), None, || {}, ) .unwrap(); #[allow(clippy::expect_used)] let db = MockDb::new(&redis_interface::RedisSettings::default()) .await .expect("Failed to create Mock store"); let redis_conn = db.get_redis_conn().unwrap(); let master_key = db.get_master_key(); redis_conn .subscribe("hyperswitch_invalidate") .await .unwrap(); let merchant_id = common_utils::id_type::MerchantId::try_from(std::borrow::Cow::from("test_merchant")) .unwrap(); let connector_label = "stripe_USA"; let id = common_utils::generate_merchant_connector_account_id_of_default_length(); let profile_id = common_utils::id_type::ProfileId::try_from(std::borrow::Cow::from("pro_max_ultra")) .unwrap(); let key_manager_state = &state.into(); db.insert_merchant_key_store( key_manager_state, domain::MerchantKeyStore { merchant_id: merchant_id.clone(), key: domain::types::crypto_operation( key_manager_state, type_name!(domain::MerchantConnectorAccount), domain::types::CryptoOperation::Encrypt( services::generate_aes256_key().unwrap().to_vec().into(), ), Identifier::Merchant(merchant_id.clone()), master_key, ) .await .and_then(|val| val.try_into_operation()) .unwrap(), created_at: datetime!(2023-02-01 0:00), }, &master_key.to_vec().into(), ) .await .unwrap(); let merchant_key = db .get_merchant_key_store_by_merchant_id( key_manager_state, &merchant_id, &master_key.to_vec().into(), ) .await .unwrap(); let mca = domain::MerchantConnectorAccount { id: id.clone(), merchant_id: merchant_id.clone(), connector_name: common_enums::connector_enums::Connector::Stripe, connector_account_details: domain::types::crypto_operation( key_manager_state, type_name!(domain::MerchantConnectorAccount), domain::types::CryptoOperation::Encrypt(serde_json::Value::default().into()), Identifier::Merchant(merchant_key.merchant_id.clone()), merchant_key.key.get_inner().peek(), ) .await .and_then(|val| val.try_into_operation()) .unwrap(), disabled: None, payment_methods_enabled: None, connector_type: ConnectorType::FinOperations, metadata: None, frm_configs: None, connector_label: Some(connector_label.to_string()), created_at: date_time::now(), modified_at: date_time::now(), connector_webhook_details: None, profile_id: profile_id.to_owned(), applepay_verified_domains: None, pm_auth_config: None, status: common_enums::ConnectorStatus::Inactive, connector_wallets_details: Some( domain::types::crypto_operation( key_manager_state, type_name!(domain::MerchantConnectorAccount), domain::types::CryptoOperation::Encrypt(serde_json::Value::default().into()), Identifier::Merchant(merchant_key.merchant_id.clone()), merchant_key.key.get_inner().peek(), ) .await .and_then(|val| val.try_into_operation()) .unwrap(), ), additional_merchant_data: None, version: common_types::consts::API_VERSION, feature_metadata: None, }; db.insert_merchant_connector_account(key_manager_state, mca.clone(), &merchant_key) .await .unwrap(); let find_call = || async { #[cfg(feature = "v1")] let mca = db .find_merchant_connector_account_by_profile_id_connector_name( key_manager_state, profile_id, &mca.connector_name, &merchant_key, ) .await .unwrap(); #[cfg(feature = "v2")] let mca: domain::MerchantConnectorAccount = { todo!() }; Conversion::convert(mca) .await .change_context(errors::StorageError::DecryptionError) }; let _: storage::MerchantConnectorAccount = cache::get_or_populate_in_memory( &db, &format!( "{}_{}", merchant_id.clone().get_string_repr(), profile_id.get_string_repr() ), find_call, &ACCOUNTS_CACHE, ) .await .unwrap(); let delete_call = || async { db.delete_merchant_connector_account_by_id(&id).await }; cache::publish_and_redact( &db, CacheKind::Accounts( format!("{}_{}", merchant_id.get_string_repr(), connector_label).into(), ), delete_call, ) .await .unwrap(); assert!(ACCOUNTS_CACHE .get_val::<domain::MerchantConnectorAccount>(CacheKey { key: format!("{}_{}", merchant_id.get_string_repr(), connector_label), prefix: String::default(), },) .await .is_none()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 144, "total_crates": null }
fn_clm_router_get_access_token_-385092069554860368
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/merchant_connector_account // Implementation of MockDb for ConnectorAccessToken async fn get_access_token( &self, _merchant_id: &common_utils::id_type::MerchantId, _merchant_connector_id_or_connector_name: &str, ) -> CustomResult<Option<types::AccessToken>, errors::StorageError> { Ok(None) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 41, "total_crates": null }
fn_clm_router_set_access_token_-385092069554860368
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/merchant_connector_account // Implementation of MockDb for ConnectorAccessToken async fn set_access_token( &self, _merchant_id: &common_utils::id_type::MerchantId, _merchant_connector_id_or_connector_name: &str, _access_token: types::AccessToken, ) -> CustomResult<(), errors::StorageError> { Ok(()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }
fn_clm_router_insert_blocklist_fingerprint_entry_4550236610161915151
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist_fingerprint // Implementation of KafkaStore for BlocklistFingerprintInterface async fn insert_blocklist_fingerprint_entry( &self, pm_fingerprint_new: storage::BlocklistFingerprintNew, ) -> CustomResult<storage::BlocklistFingerprint, errors::StorageError> { self.diesel_store .insert_blocklist_fingerprint_entry(pm_fingerprint_new) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 13, "total_crates": null }
fn_clm_router_find_blocklist_fingerprint_by_merchant_id_fingerprint_id_4550236610161915151
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist_fingerprint // Implementation of KafkaStore for BlocklistFingerprintInterface async fn find_blocklist_fingerprint_by_merchant_id_fingerprint_id( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint: &str, ) -> CustomResult<storage::BlocklistFingerprint, errors::StorageError> { self.diesel_store .find_blocklist_fingerprint_by_merchant_id_fingerprint_id(merchant_id, fingerprint) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 13, "total_crates": null }
fn_clm_router_get_payment_methods_session_-4957871761298176633
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/payment_method_session // Implementation of MockDb for PaymentMethodsSessionInterface async fn get_payment_methods_session( &self, state: &common_utils::types::keymanager::KeyManagerState, key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore, id: &common_utils::id_type::GlobalPaymentMethodSessionId, ) -> CustomResult< hyperswitch_domain_models::payment_methods::PaymentMethodSession, errors::StorageError, > { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 29, "total_crates": null }
fn_clm_router_update_payment_method_session_-4957871761298176633
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/payment_method_session // Implementation of MockDb for PaymentMethodsSessionInterface async fn update_payment_method_session( &self, state: &common_utils::types::keymanager::KeyManagerState, key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore, id: &common_utils::id_type::GlobalPaymentMethodSessionId, payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodsSessionUpdateEnum, current_session: hyperswitch_domain_models::payment_methods::PaymentMethodSession, ) -> CustomResult< hyperswitch_domain_models::payment_methods::PaymentMethodSession, errors::StorageError, > { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }
fn_clm_router_insert_payment_methods_session_-4957871761298176633
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/payment_method_session // Implementation of MockDb for PaymentMethodsSessionInterface async fn insert_payment_methods_session( &self, state: &common_utils::types::keymanager::KeyManagerState, key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore, payment_methods_session: hyperswitch_domain_models::payment_methods::PaymentMethodSession, validity_in_seconds: i64, ) -> CustomResult<(), errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_find_routing_algorithm_by_profile_id_algorithm_id_8665994011302754384
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/routing_algorithm // Implementation of MockDb for RoutingAlgorithmInterface async fn find_routing_algorithm_by_profile_id_algorithm_id( &self, _profile_id: &common_utils::id_type::ProfileId, _algorithm_id: &common_utils::id_type::RoutingId, ) -> StorageResult<routing_storage::RoutingAlgorithm> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 41, "total_crates": null }
fn_clm_router_insert_routing_algorithm_8665994011302754384
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/routing_algorithm // Implementation of MockDb for RoutingAlgorithmInterface async fn insert_routing_algorithm( &self, _routing_algorithm: routing_storage::RoutingAlgorithm, ) -> StorageResult<routing_storage::RoutingAlgorithm> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 32, "total_crates": null }
fn_clm_router_find_routing_algorithm_by_algorithm_id_merchant_id_8665994011302754384
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/routing_algorithm // Implementation of MockDb for RoutingAlgorithmInterface async fn find_routing_algorithm_by_algorithm_id_merchant_id( &self, _algorithm_id: &common_utils::id_type::RoutingId, _merchant_id: &common_utils::id_type::MerchantId, ) -> StorageResult<routing_storage::RoutingAlgorithm> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 23, "total_crates": null }
fn_clm_router_find_routing_algorithm_metadata_by_algorithm_id_profile_id_8665994011302754384
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/routing_algorithm // Implementation of MockDb for RoutingAlgorithmInterface async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id( &self, _algorithm_id: &common_utils::id_type::RoutingId, _profile_id: &common_utils::id_type::ProfileId, ) -> StorageResult<routing_storage::RoutingProfileMetadata> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 20, "total_crates": null }
fn_clm_router_list_routing_algorithm_metadata_by_profile_id_8665994011302754384
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/routing_algorithm // Implementation of MockDb for RoutingAlgorithmInterface async fn list_routing_algorithm_metadata_by_profile_id( &self, _profile_id: &common_utils::id_type::ProfileId, _limit: i64, _offset: i64, ) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }
fn_clm_router_update_address_by_merchant_id_customer_id_5932286532757547225
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/address // Implementation of MockDb for AddressInterface async fn update_address_by_merchant_id_customer_id( &self, state: &KeyManagerState, customer_id: &id_type::CustomerId, merchant_id: &id_type::MerchantId, address_update: storage_types::AddressUpdate, key_store: &domain::MerchantKeyStore, ) -> CustomResult<Vec<domain::Address>, errors::StorageError> { let updated_addr = self .addresses .lock() .await .iter_mut() .find(|address| { address.customer_id.as_ref() == Some(customer_id) && address.merchant_id == *merchant_id }) .map(|a| { let address_updated = AddressUpdateInternal::from(address_update).create_address(a.clone()); *a = address_updated.clone(); address_updated }); match updated_addr { Some(address) => { let address: domain::Address = address .convert( state, key_store.key.get_inner(), key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError)?; Ok(vec![address]) } None => { Err(errors::StorageError::ValueNotFound("address not found".to_string()).into()) } } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 48, "total_crates": null }
fn_clm_router_find_address_by_merchant_id_payment_id_address_id_5932286532757547225
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/address // Implementation of MockDb for AddressInterface async fn find_address_by_merchant_id_payment_id_address_id( &self, state: &KeyManagerState, _merchant_id: &id_type::MerchantId, _payment_id: &id_type::PaymentId, address_id: &str, key_store: &domain::MerchantKeyStore, _storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { match self .addresses .lock() .await .iter() .find(|address| address.address_id == address_id) { Some(address) => address .clone() .convert( state, key_store.key.get_inner(), key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError), None => { return Err( errors::StorageError::ValueNotFound("address not found".to_string()).into(), ) } } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 47, "total_crates": null }
fn_clm_router_update_address_5932286532757547225
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/address // Implementation of MockDb for AddressInterface async fn update_address( &self, state: &KeyManagerState, address_id: String, address_update: storage_types::AddressUpdate, key_store: &domain::MerchantKeyStore, ) -> CustomResult<domain::Address, errors::StorageError> { let updated_addr = self .addresses .lock() .await .iter_mut() .find(|address| address.address_id == address_id) .map(|a| { let address_updated = AddressUpdateInternal::from(address_update).create_address(a.clone()); *a = address_updated.clone(); address_updated }); match updated_addr { Some(address_updated) => address_updated .convert( state, key_store.key.get_inner(), key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError), None => Err(errors::StorageError::ValueNotFound( "cannot find address to update".to_string(), ) .into()), } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 46, "total_crates": null }
fn_clm_router_update_address_for_payments_5932286532757547225
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/address // Implementation of MockDb for AddressInterface async fn update_address_for_payments( &self, state: &KeyManagerState, this: domain::PaymentAddress, address_update: domain::AddressUpdate, _payment_id: id_type::PaymentId, key_store: &domain::MerchantKeyStore, _storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { let updated_addr = self .addresses .lock() .await .iter_mut() .find(|address| address.address_id == this.address.address_id) .map(|a| { let address_updated = AddressUpdateInternal::from(address_update).create_address(a.clone()); *a = address_updated.clone(); address_updated }); match updated_addr { Some(address_updated) => address_updated .convert( state, key_store.key.get_inner(), key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError), None => Err(errors::StorageError::ValueNotFound( "cannot find address to update".to_string(), ) .into()), } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 46, "total_crates": null }
fn_clm_router_find_address_by_address_id_5932286532757547225
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/address // Implementation of MockDb for AddressInterface async fn find_address_by_address_id( &self, state: &KeyManagerState, address_id: &str, key_store: &domain::MerchantKeyStore, ) -> CustomResult<domain::Address, errors::StorageError> { match self .addresses .lock() .await .iter() .find(|address| address.address_id == address_id) { Some(address) => address .clone() .convert( state, key_store.key.get_inner(), key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError), None => { return Err( errors::StorageError::ValueNotFound("address not found".to_string()).into(), ) } } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 41, "total_crates": null }
fn_clm_router_insert_blocklist_lookup_entry_375570230249695227
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist_lookup // Implementation of KafkaStore for BlocklistLookupInterface async fn insert_blocklist_lookup_entry( &self, blocklist_lookup_entry: storage::BlocklistLookupNew, ) -> CustomResult<storage::BlocklistLookup, errors::StorageError> { self.diesel_store .insert_blocklist_lookup_entry(blocklist_lookup_entry) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 13, "total_crates": null }
fn_clm_router_find_blocklist_lookup_entry_by_merchant_id_fingerprint_375570230249695227
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist_lookup // Implementation of KafkaStore for BlocklistLookupInterface async fn find_blocklist_lookup_entry_by_merchant_id_fingerprint( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint: &str, ) -> CustomResult<storage::BlocklistLookup, errors::StorageError> { self.diesel_store .find_blocklist_lookup_entry_by_merchant_id_fingerprint(merchant_id, fingerprint) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 13, "total_crates": null }
fn_clm_router_delete_blocklist_lookup_entry_by_merchant_id_fingerprint_375570230249695227
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist_lookup // Implementation of KafkaStore for BlocklistLookupInterface async fn delete_blocklist_lookup_entry_by_merchant_id_fingerprint( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint: &str, ) -> CustomResult<storage::BlocklistLookup, errors::StorageError> { self.diesel_store .delete_blocklist_lookup_entry_by_merchant_id_fingerprint(merchant_id, fingerprint) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 13, "total_crates": null }
fn_clm_router_find_blocklist_entry_by_merchant_id_fingerprint_id_-2743262557708595930
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist // Implementation of KafkaStore for BlocklistInterface async fn find_blocklist_entry_by_merchant_id_fingerprint_id( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { self.diesel_store .find_blocklist_entry_by_merchant_id_fingerprint_id(merchant_id, fingerprint) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 28, "total_crates": null }
fn_clm_router_insert_blocklist_entry_-2743262557708595930
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist // Implementation of KafkaStore for BlocklistInterface async fn insert_blocklist_entry( &self, pm_blocklist: storage::BlocklistNew, ) -> CustomResult<storage::Blocklist, errors::StorageError> { self.diesel_store.insert_blocklist_entry(pm_blocklist).await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 19, "total_crates": null }
fn_clm_router_delete_blocklist_entry_by_merchant_id_fingerprint_id_-2743262557708595930
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist // Implementation of KafkaStore for BlocklistInterface async fn delete_blocklist_entry_by_merchant_id_fingerprint_id( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { self.diesel_store .delete_blocklist_entry_by_merchant_id_fingerprint_id(merchant_id, fingerprint) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 19, "total_crates": null }
fn_clm_router_list_blocklist_entries_by_merchant_id_data_kind_-2743262557708595930
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist // Implementation of KafkaStore for BlocklistInterface async fn list_blocklist_entries_by_merchant_id_data_kind( &self, merchant_id: &common_utils::id_type::MerchantId, data_kind: common_enums::BlocklistDataKind, limit: i64, offset: i64, ) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> { self.diesel_store .list_blocklist_entries_by_merchant_id_data_kind(merchant_id, data_kind, limit, offset) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 16, "total_crates": null }
fn_clm_router_list_blocklist_entries_by_merchant_id_-2743262557708595930
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/blocklist // Implementation of KafkaStore for BlocklistInterface async fn list_blocklist_entries_by_merchant_id( &self, merchant_id: &common_utils::id_type::MerchantId, ) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> { self.diesel_store .list_blocklist_entries_by_merchant_id(merchant_id) .await }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 13, "total_crates": null }
fn_clm_router_update_user_by_user_id_-364459924122277886
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user // Implementation of MockDb for UserInterface async fn update_user_by_user_id( &self, user_id: &str, update_user: storage::UserUpdate, ) -> CustomResult<storage::User, errors::StorageError> { let mut users = self.users.lock().await; let last_modified_at = common_utils::date_time::now(); users .iter_mut() .find(|user| user.user_id == user_id) .map(|user| { *user = match &update_user { storage::UserUpdate::VerifyUser => storage::User { last_modified_at, is_verified: true, ..user.to_owned() }, storage::UserUpdate::AccountUpdate { name, is_verified } => storage::User { name: name.clone().map(Secret::new).unwrap_or(user.name.clone()), last_modified_at, is_verified: is_verified.unwrap_or(user.is_verified), ..user.to_owned() }, storage::UserUpdate::TotpUpdate { totp_status, totp_secret, totp_recovery_codes, } => storage::User { last_modified_at, totp_status: totp_status.unwrap_or(user.totp_status), totp_secret: totp_secret.clone().or(user.totp_secret.clone()), totp_recovery_codes: totp_recovery_codes .clone() .or(user.totp_recovery_codes.clone()), ..user.to_owned() }, storage::UserUpdate::PasswordUpdate { password } => storage::User { password: Some(password.clone()), last_password_modified_at: Some(common_utils::date_time::now()), ..user.to_owned() }, storage::UserUpdate::LineageContextUpdate { lineage_context } => { storage::User { last_modified_at, lineage_context: Some(lineage_context.clone()), ..user.to_owned() } } }; user.to_owned() }) .ok_or( errors::StorageError::ValueNotFound(format!( "No user available for user_id = {user_id}" )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 108, "total_crates": null }
fn_clm_router_find_user_by_id_-364459924122277886
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user // Implementation of MockDb for UserInterface async fn find_user_by_id( &self, user_id: &str, ) -> CustomResult<storage::User, errors::StorageError> { let users = self.users.lock().await; users .iter() .find(|user| user.user_id == user_id) .cloned() .ok_or( errors::StorageError::ValueNotFound(format!( "No user available for user_id = {user_id}" )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 106, "total_crates": null }
fn_clm_router_update_user_by_email_-364459924122277886
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user // Implementation of MockDb for UserInterface async fn update_user_by_email( &self, user_email: &domain::UserEmail, update_user: storage::UserUpdate, ) -> CustomResult<storage::User, errors::StorageError> { let mut users = self.users.lock().await; let last_modified_at = common_utils::date_time::now(); users .iter_mut() .find(|user| user.email.eq(user_email.get_inner())) .map(|user| { *user = match &update_user { storage::UserUpdate::VerifyUser => storage::User { last_modified_at, is_verified: true, ..user.to_owned() }, storage::UserUpdate::AccountUpdate { name, is_verified } => storage::User { name: name.clone().map(Secret::new).unwrap_or(user.name.clone()), last_modified_at, is_verified: is_verified.unwrap_or(user.is_verified), ..user.to_owned() }, storage::UserUpdate::TotpUpdate { totp_status, totp_secret, totp_recovery_codes, } => storage::User { last_modified_at, totp_status: totp_status.unwrap_or(user.totp_status), totp_secret: totp_secret.clone().or(user.totp_secret.clone()), totp_recovery_codes: totp_recovery_codes .clone() .or(user.totp_recovery_codes.clone()), ..user.to_owned() }, storage::UserUpdate::PasswordUpdate { password } => storage::User { password: Some(password.clone()), last_password_modified_at: Some(common_utils::date_time::now()), ..user.to_owned() }, storage::UserUpdate::LineageContextUpdate { lineage_context } => { storage::User { last_modified_at, lineage_context: Some(lineage_context.clone()), ..user.to_owned() } } }; user.to_owned() }) .ok_or( errors::StorageError::ValueNotFound(format!( "No user available for user_email = {user_email:?}" )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 73, "total_crates": null }
fn_clm_router_find_user_by_email_-364459924122277886
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user // Implementation of MockDb for UserInterface async fn find_user_by_email( &self, user_email: &domain::UserEmail, ) -> CustomResult<storage::User, errors::StorageError> { let users = self.users.lock().await; users .iter() .find(|user| user.email.eq(user_email.get_inner())) .cloned() .ok_or( errors::StorageError::ValueNotFound(format!( "No user available for email = {user_email:?}" )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 71, "total_crates": null }
fn_clm_router_insert_user_-364459924122277886
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user // Implementation of MockDb for UserInterface async fn insert_user( &self, user_data: storage::UserNew, ) -> CustomResult<storage::User, errors::StorageError> { let mut users = self.users.lock().await; if users .iter() .any(|user| user.email == user_data.email || user.user_id == user_data.user_id) { Err(errors::StorageError::DuplicateValue { entity: "email or user_id", key: None, })? } let time_now = common_utils::date_time::now(); let user = storage::User { user_id: user_data.user_id, email: user_data.email, name: user_data.name, password: user_data.password, is_verified: user_data.is_verified, created_at: user_data.created_at.unwrap_or(time_now), last_modified_at: user_data.created_at.unwrap_or(time_now), totp_status: user_data.totp_status, totp_secret: user_data.totp_secret, totp_recovery_codes: user_data.totp_recovery_codes, last_password_modified_at: user_data.last_password_modified_at, lineage_context: user_data.lineage_context, }; users.push(user.clone()); Ok(user) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 36, "total_crates": null }
fn_clm_router_list_user_roles_by_user_id_-7696117200497858671
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user_role // Implementation of MockDb for UserRoleInterface async fn list_user_roles_by_user_id<'a>( &self, payload: ListUserRolesByUserIdPayload<'a>, ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> { let user_roles = self.user_roles.lock().await; let mut filtered_roles: Vec<_> = user_roles .iter() .filter_map(|role| { let mut filter_condition = role.user_id == payload.user_id; role.org_id .as_ref() .zip(payload.org_id) .inspect(|(role_org_id, org_id)| { filter_condition = filter_condition && role_org_id == org_id }); role.merchant_id.as_ref().zip(payload.merchant_id).inspect( |(role_merchant_id, merchant_id)| { filter_condition = filter_condition && role_merchant_id == merchant_id }, ); role.profile_id.as_ref().zip(payload.profile_id).inspect( |(role_profile_id, profile_id)| { filter_condition = filter_condition && role_profile_id == profile_id }, ); role.entity_id.as_ref().zip(payload.entity_id).inspect( |(role_entity_id, entity_id)| { filter_condition = filter_condition && role_entity_id == entity_id }, ); payload .version .inspect(|ver| filter_condition = filter_condition && ver == &role.version); payload.status.inspect(|status| { filter_condition = filter_condition && status == &role.status }); filter_condition.then(|| role.to_owned()) }) .collect(); if let Some(Ok(limit)) = payload.limit.map(|val| val.try_into()) { filtered_roles = filtered_roles.into_iter().take(limit).collect(); } Ok(filtered_roles) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 118, "total_crates": null }
fn_clm_router_find_user_role_by_user_id_and_lineage_-7696117200497858671
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user_role // Implementation of MockDb for UserRoleInterface async fn find_user_role_by_user_id_and_lineage( &self, user_id: &str, tenant_id: &id_type::TenantId, org_id: &id_type::OrganizationId, merchant_id: &id_type::MerchantId, profile_id: &id_type::ProfileId, version: enums::UserRoleVersion, ) -> CustomResult<storage::UserRole, errors::StorageError> { let user_roles = self.user_roles.lock().await; for user_role in user_roles.iter() { let tenant_level_check = user_role.tenant_id == *tenant_id && user_role.org_id.is_none() && user_role.merchant_id.is_none() && user_role.profile_id.is_none(); let org_level_check = user_role.tenant_id == *tenant_id && user_role.org_id.as_ref() == Some(org_id) && user_role.merchant_id.is_none() && user_role.profile_id.is_none(); let merchant_level_check = user_role.tenant_id == *tenant_id && user_role.org_id.as_ref() == Some(org_id) && user_role.merchant_id.as_ref() == Some(merchant_id) && user_role.profile_id.is_none(); let profile_level_check = user_role.tenant_id == *tenant_id && user_role.org_id.as_ref() == Some(org_id) && user_role.merchant_id.as_ref() == Some(merchant_id) && user_role.profile_id.as_ref() == Some(profile_id); // Check if any condition matches and the version matches if user_role.user_id == user_id && (tenant_level_check || org_level_check || merchant_level_check || profile_level_check) && user_role.version == version { return Ok(user_role.clone()); } } Err(errors::StorageError::ValueNotFound(format!( "No user role available for user_id = {user_id} in the current token hierarchy", )) .into()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 75, "total_crates": null }
fn_clm_router_update_user_role_by_user_id_and_lineage_-7696117200497858671
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user_role // Implementation of MockDb for UserRoleInterface async fn update_user_role_by_user_id_and_lineage( &self, user_id: &str, tenant_id: &id_type::TenantId, org_id: &id_type::OrganizationId, merchant_id: Option<&id_type::MerchantId>, profile_id: Option<&id_type::ProfileId>, update: storage::UserRoleUpdate, version: enums::UserRoleVersion, ) -> CustomResult<storage::UserRole, errors::StorageError> { let mut user_roles = self.user_roles.lock().await; for user_role in user_roles.iter_mut() { let tenant_level_check = user_role.tenant_id == *tenant_id && user_role.org_id.is_none() && user_role.merchant_id.is_none() && user_role.profile_id.is_none(); let org_level_check = user_role.tenant_id == *tenant_id && user_role.org_id.as_ref() == Some(org_id) && user_role.merchant_id.is_none() && user_role.profile_id.is_none(); let merchant_level_check = user_role.tenant_id == *tenant_id && user_role.org_id.as_ref() == Some(org_id) && user_role.merchant_id.as_ref() == merchant_id && user_role.profile_id.is_none(); let profile_level_check = user_role.tenant_id == *tenant_id && user_role.org_id.as_ref() == Some(org_id) && user_role.merchant_id.as_ref() == merchant_id && user_role.profile_id.as_ref() == profile_id; // Check if any condition matches and the version matches if user_role.user_id == user_id && (tenant_level_check || org_level_check || merchant_level_check || profile_level_check) && user_role.version == version { match &update { storage::UserRoleUpdate::UpdateRole { role_id, modified_by, } => { user_role.role_id = role_id.to_string(); user_role.last_modified_by = modified_by.to_string(); } storage::UserRoleUpdate::UpdateStatus { status, modified_by, } => { user_role.status = *status; user_role.last_modified_by = modified_by.to_string(); } } return Ok(user_role.clone()); } } Err( errors::StorageError::ValueNotFound("Cannot find user role to update".to_string()) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 65, "total_crates": null }
fn_clm_router_delete_user_role_by_user_id_and_lineage_-7696117200497858671
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user_role // Implementation of MockDb for UserRoleInterface async fn delete_user_role_by_user_id_and_lineage( &self, user_id: &str, tenant_id: &id_type::TenantId, org_id: &id_type::OrganizationId, merchant_id: &id_type::MerchantId, profile_id: &id_type::ProfileId, version: enums::UserRoleVersion, ) -> CustomResult<storage::UserRole, errors::StorageError> { let mut user_roles = self.user_roles.lock().await; // Find the position of the user role to delete let index = user_roles.iter().position(|role| { let tenant_level_check = role.tenant_id == *tenant_id && role.org_id.is_none() && role.merchant_id.is_none() && role.profile_id.is_none(); let org_level_check = role.tenant_id == *tenant_id && role.org_id.as_ref() == Some(org_id) && role.merchant_id.is_none() && role.profile_id.is_none(); let merchant_level_check = role.tenant_id == *tenant_id && role.org_id.as_ref() == Some(org_id) && role.merchant_id.as_ref() == Some(merchant_id) && role.profile_id.is_none(); let profile_level_check = role.tenant_id == *tenant_id && role.org_id.as_ref() == Some(org_id) && role.merchant_id.as_ref() == Some(merchant_id) && role.profile_id.as_ref() == Some(profile_id); // Check if the user role matches the conditions and the version matches role.user_id == user_id && (tenant_level_check || org_level_check || merchant_level_check || profile_level_check) && role.version == version }); // Remove and return the user role if found match index { Some(idx) => Ok(user_roles.remove(idx)), None => Err(errors::StorageError::ValueNotFound( "Cannot find user role to delete".to_string(), ) .into()), } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 55, "total_crates": null }
fn_clm_router_list_user_roles_by_org_id_-7696117200497858671
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/user_role // Implementation of MockDb for UserRoleInterface async fn list_user_roles_by_org_id<'a>( &self, payload: ListUserRolesByOrgIdPayload<'a>, ) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> { let user_roles = self.user_roles.lock().await; let mut filtered_roles = Vec::new(); for role in user_roles.iter() { let role_org_id = role .org_id .as_ref() .ok_or(report!(errors::StorageError::MockDbError))?; let mut filter_condition = role_org_id == payload.org_id; if let Some(user_id) = payload.user_id { filter_condition = filter_condition && user_id == &role.user_id } role.merchant_id.as_ref().zip(payload.merchant_id).inspect( |(role_merchant_id, merchant_id)| { filter_condition = filter_condition && role_merchant_id == merchant_id }, ); role.profile_id.as_ref().zip(payload.profile_id).inspect( |(role_profile_id, profile_id)| { filter_condition = filter_condition && role_profile_id == profile_id }, ); payload .version .inspect(|ver| filter_condition = filter_condition && ver == &role.version); if filter_condition { filtered_roles.push(role.clone()) } } Ok(filtered_roles) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 42, "total_crates": null }
fn_clm_router_find_locker_by_card_id_-7372035209625592334
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/locker_mock_up async fn find_locker_by_card_id() { #[allow(clippy::expect_used)] let mockdb = MockDb::new(&redis_interface::RedisSettings::default()) .await .expect("Failed to create Mock store"); let created_locker = mockdb .insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds { card_id: "card_1".into(), external_id: "external_1".into(), merchant_id: id_type::MerchantId::default(), customer_id: generate_customer_id_of_default_length(), })) .await .unwrap(); let _ = mockdb .insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds { card_id: "card_2".into(), external_id: "external_1".into(), merchant_id: id_type::MerchantId::default(), customer_id: generate_customer_id_of_default_length(), })) .await; let found_locker = mockdb.find_locker_by_card_id("card_1").await.unwrap(); assert_eq!(created_locker, found_locker) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 42, "total_crates": null }
fn_clm_router_insert_locker_mock_up_-7372035209625592334
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/locker_mock_up async fn insert_locker_mock_up() { #[allow(clippy::expect_used)] let mockdb = MockDb::new(&redis_interface::RedisSettings::default()) .await .expect("Failed to create Mock store"); let created_locker = mockdb .insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds { card_id: "card_1".into(), external_id: "external_1".into(), merchant_id: id_type::MerchantId::default(), customer_id: generate_customer_id_of_default_length(), })) .await .unwrap(); let found_locker = mockdb .lockers .lock() .await .iter() .find(|l| l.card_id == "card_1") .cloned(); assert!(found_locker.is_some()); assert_eq!(created_locker, found_locker.unwrap()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 42, "total_crates": null }
fn_clm_router_delete_locker_mock_up_-7372035209625592334
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/locker_mock_up async fn delete_locker_mock_up() { #[allow(clippy::expect_used)] let mockdb = MockDb::new(&redis_interface::RedisSettings::default()) .await .expect("Failed to create Mock store"); let created_locker = mockdb .insert_locker_mock_up(create_locker_mock_up_new(LockerMockUpIds { card_id: "card_1".into(), external_id: "external_1".into(), merchant_id: id_type::MerchantId::default(), customer_id: generate_customer_id_of_default_length(), })) .await .unwrap(); let deleted_locker = mockdb.delete_locker_mock_up("card_1").await.unwrap(); assert_eq!(created_locker, deleted_locker); let exist = mockdb .lockers .lock() .await .iter() .any(|l| l.card_id == "card_1"); assert!(!exist) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 36, "total_crates": null }
fn_clm_router_create_locker_mock_up_new_-7372035209625592334
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/locker_mock_up fn create_locker_mock_up_new(locker_ids: LockerMockUpIds) -> storage::LockerMockUpNew { storage::LockerMockUpNew { card_id: locker_ids.card_id, external_id: locker_ids.external_id, card_fingerprint: "card_fingerprint".into(), card_global_fingerprint: "card_global_fingerprint".into(), merchant_id: locker_ids.merchant_id, card_number: "1234123412341234".into(), card_exp_year: "2023".into(), card_exp_month: "06".into(), name_on_card: Some("name_on_card".into()), card_cvc: Some("123".into()), payment_method_id: Some("payment_method_id".into()), customer_id: Some(locker_ids.customer_id), nickname: Some("card_holder_nickname".into()), enc_card_data: Some("enc_card_data".into()), } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 32, "total_crates": null }
fn_clm_router_filter_refund_by_constraints_-8180732023236260387
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/refund // Implementation of MockDb for RefundInterface async fn filter_refund_by_constraints( &self, merchant_id: &common_utils::id_type::MerchantId, refund_details: refunds::RefundListConstraints, _storage_scheme: enums::MerchantStorageScheme, limit: i64, offset: i64, ) -> CustomResult<Vec<diesel_models::refund::Refund>, errors::StorageError> { let mut unique_connectors = HashSet::new(); let mut unique_connector_ids = HashSet::new(); let mut unique_currencies = HashSet::new(); let mut unique_statuses = HashSet::new(); // Fill the hash sets with data from refund_details if let Some(connectors) = &refund_details.connector { connectors.iter().for_each(|connector| { unique_connectors.insert(connector); }); } if let Some(connector_id_list) = &refund_details.connector_id_list { connector_id_list.iter().for_each(|unique_connector_id| { unique_connector_ids.insert(unique_connector_id); }); } if let Some(currencies) = &refund_details.currency { currencies.iter().for_each(|currency| { unique_currencies.insert(currency); }); } if let Some(refund_statuses) = &refund_details.refund_status { refund_statuses.iter().for_each(|refund_status| { unique_statuses.insert(refund_status); }); } let refunds = self.refunds.lock().await; let filtered_refunds = refunds .iter() .filter(|refund| refund.merchant_id == *merchant_id) .filter(|refund| { refund_details .payment_id .clone() .is_none_or(|id| id == refund.payment_id) }) .filter(|refund| { refund_details .refund_id .clone() .is_none_or(|id| id == refund.id) }) .filter(|refund| { refund .profile_id .as_ref() .is_some_and(|profile_id| profile_id == &refund_details.profile_id) }) .filter(|refund| { refund.created_at >= refund_details.time_range.map_or( common_utils::date_time::now() - time::Duration::days(60), |range| range.start_time, ) && refund.created_at <= refund_details .time_range .map_or(common_utils::date_time::now(), |range| { range.end_time.unwrap_or_else(common_utils::date_time::now) }) }) .filter(|refund| { refund_details.amount_filter.as_ref().is_none_or(|amount| { refund.refund_amount >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN)) && refund.refund_amount <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX)) }) }) .filter(|refund| { unique_connectors.is_empty() || unique_connectors.contains(&refund.connector) }) .filter(|refund| { unique_connector_ids.is_empty() || refund .connector_id .as_ref() .is_some_and(|id| unique_connector_ids.contains(id)) }) .filter(|refund| { unique_currencies.is_empty() || unique_currencies.contains(&refund.currency) }) .filter(|refund| { unique_statuses.is_empty() || unique_statuses.contains(&refund.refund_status) }) .skip(usize::try_from(offset).unwrap_or_default()) .take(usize::try_from(limit).unwrap_or(MAX_LIMIT)) .cloned() .collect::<Vec<_>>(); Ok(filtered_refunds) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 143, "total_crates": null }
fn_clm_router_get_total_count_of_refunds_-8180732023236260387
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/refund // Implementation of MockDb for RefundInterface async fn get_total_count_of_refunds( &self, merchant_id: &common_utils::id_type::MerchantId, refund_details: refunds::RefundListConstraints, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<i64, errors::StorageError> { let mut unique_connectors = HashSet::new(); let mut unique_connector_ids = HashSet::new(); let mut unique_currencies = HashSet::new(); let mut unique_statuses = HashSet::new(); // Fill the hash sets with data from refund_details if let Some(connectors) = &refund_details.connector { connectors.iter().for_each(|connector| { unique_connectors.insert(connector); }); } if let Some(connector_id_list) = &refund_details.connector_id_list { connector_id_list.iter().for_each(|unique_connector_id| { unique_connector_ids.insert(unique_connector_id); }); } if let Some(currencies) = &refund_details.currency { currencies.iter().for_each(|currency| { unique_currencies.insert(currency); }); } if let Some(refund_statuses) = &refund_details.refund_status { refund_statuses.iter().for_each(|refund_status| { unique_statuses.insert(refund_status); }); } let refunds = self.refunds.lock().await; let filtered_refunds = refunds .iter() .filter(|refund| refund.merchant_id == *merchant_id) .filter(|refund| { refund_details .payment_id .clone() .is_none_or(|id| id == refund.payment_id) }) .filter(|refund| { refund_details .refund_id .clone() .is_none_or(|id| id == refund.id) }) .filter(|refund| { refund .profile_id .as_ref() .is_some_and(|profile_id| profile_id == &refund_details.profile_id) }) .filter(|refund| { refund.created_at >= refund_details.time_range.map_or( common_utils::date_time::now() - time::Duration::days(60), |range| range.start_time, ) && refund.created_at <= refund_details .time_range .map_or(common_utils::date_time::now(), |range| { range.end_time.unwrap_or_else(common_utils::date_time::now) }) }) .filter(|refund| { refund_details.amount_filter.as_ref().is_none_or(|amount| { refund.refund_amount >= MinorUnit::new(amount.start_amount.unwrap_or(i64::MIN)) && refund.refund_amount <= MinorUnit::new(amount.end_amount.unwrap_or(i64::MAX)) }) }) .filter(|refund| { unique_connectors.is_empty() || unique_connectors.contains(&refund.connector) }) .filter(|refund| { unique_connector_ids.is_empty() || refund .connector_id .as_ref() .is_some_and(|id| unique_connector_ids.contains(id)) }) .filter(|refund| { unique_currencies.is_empty() || unique_currencies.contains(&refund.currency) }) .filter(|refund| { unique_statuses.is_empty() || unique_statuses.contains(&refund.refund_status) }) .cloned() .collect::<Vec<_>>(); let filtered_refunds_count = filtered_refunds.len().try_into().unwrap_or_default(); Ok(filtered_refunds_count) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 137, "total_crates": null }
fn_clm_router_update_refund_-8180732023236260387
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/refund // Implementation of MockDb for RefundInterface async fn update_refund( &self, this: diesel_refund::Refund, refund: diesel_refund::RefundUpdate, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<diesel_refund::Refund, errors::StorageError> { self.refunds .lock() .await .iter_mut() .find(|refund| this.merchant_reference_id == refund.merchant_reference_id) .map(|r| { let refund_updated = diesel_refund::RefundUpdateInternal::from(refund).create_refund(r.clone()); *r = refund_updated.clone(); refund_updated }) .ok_or_else(|| { errors::StorageError::ValueNotFound("cannot find refund to update".to_string()) .into() }) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 68, "total_crates": null }
fn_clm_router_filter_refund_by_meta_constraints_-8180732023236260387
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/refund // Implementation of MockDb for RefundInterface async fn filter_refund_by_meta_constraints( &self, _merchant_id: &common_utils::id_type::MerchantId, refund_details: &common_utils::types::TimeRange, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> { let refunds = self.refunds.lock().await; let start_time = refund_details.start_time; let end_time = refund_details .end_time .unwrap_or_else(common_utils::date_time::now); let filtered_refunds = refunds .iter() .filter(|refund| refund.created_at >= start_time && refund.created_at <= end_time) .cloned() .collect::<Vec<diesel_models::refund::Refund>>(); let mut refund_meta_data = api_models::refunds::RefundListMetaData { connector: vec![], currency: vec![], refund_status: vec![], }; let mut unique_connectors = HashSet::new(); let mut unique_currencies = HashSet::new(); let mut unique_statuses = HashSet::new(); for refund in filtered_refunds.into_iter() { unique_connectors.insert(refund.connector); let currency: api_models::enums::Currency = refund.currency; unique_currencies.insert(currency); let status: api_models::enums::RefundStatus = refund.refund_status; unique_statuses.insert(status); } refund_meta_data.connector = unique_connectors.into_iter().collect(); refund_meta_data.currency = unique_currencies.into_iter().collect(); refund_meta_data.refund_status = unique_statuses.into_iter().collect(); Ok(refund_meta_data) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 50, "total_crates": null }
fn_clm_router_get_refund_status_with_count_-8180732023236260387
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/refund // Implementation of MockDb for RefundInterface async fn get_refund_status_with_count( &self, _merchant_id: &common_utils::id_type::MerchantId, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, time_range: &common_utils::types::TimeRange, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<(api_models::enums::RefundStatus, i64)>, errors::StorageError> { let refunds = self.refunds.lock().await; let start_time = time_range.start_time; let end_time = time_range .end_time .unwrap_or_else(common_utils::date_time::now); let filtered_refunds = refunds .iter() .filter(|refund| { refund.created_at >= start_time && refund.created_at <= end_time && profile_id_list .as_ref() .zip(refund.profile_id.as_ref()) .map(|(received_profile_list, received_profile_id)| { received_profile_list.contains(received_profile_id) }) .unwrap_or(true) }) .cloned() .collect::<Vec<diesel_models::refund::Refund>>(); let mut refund_status_counts: HashMap<api_models::enums::RefundStatus, i64> = HashMap::new(); for refund in filtered_refunds { *refund_status_counts .entry(refund.refund_status) .or_insert(0) += 1; } let result: Vec<(api_models::enums::RefundStatus, i64)> = refund_status_counts.into_iter().collect(); Ok(result) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 46, "total_crates": null }
fn_clm_router_find_payment_link_by_payment_link_id_5636514595228268133
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/payment_link // Implementation of MockDb for PaymentLinkInterface async fn find_payment_link_by_payment_link_id( &self, _payment_link_id: &str, ) -> CustomResult<storage::PaymentLink, errors::StorageError> { // TODO: Implement function for `MockDb`x Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 20, "total_crates": null }
fn_clm_router_insert_payment_link_5636514595228268133
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/payment_link // Implementation of MockDb for PaymentLinkInterface async fn insert_payment_link( &self, _payment_link: storage::PaymentLinkNew, ) -> CustomResult<storage::PaymentLink, errors::StorageError> { // TODO: Implement function for `MockDb` Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_list_payment_link_by_merchant_id_5636514595228268133
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/payment_link // Implementation of MockDb for PaymentLinkInterface async fn list_payment_link_by_merchant_id( &self, _merchant_id: &common_utils::id_type::MerchantId, _payment_link_constraints: api_models::payments::PaymentLinkListConstraints, ) -> CustomResult<Vec<storage::PaymentLink>, errors::StorageError> { // TODO: Implement function for `MockDb`x Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_find_payout_link_by_link_id_-441730542381734885
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/generic_link // Implementation of MockDb for GenericLinkInterface async fn find_payout_link_by_link_id( &self, _generic_link_id: &str, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { // TODO: Implement function for `MockDb`x Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }
fn_clm_router_update_payout_link_-441730542381734885
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/generic_link // Implementation of MockDb for GenericLinkInterface async fn update_payout_link( &self, _payout_link: storage::PayoutLink, _payout_link_update: storage::PayoutLinkUpdate, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { // TODO: Implement function for `MockDb` Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }
fn_clm_router_find_pm_collect_link_by_link_id_-441730542381734885
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/generic_link // Implementation of MockDb for GenericLinkInterface async fn find_pm_collect_link_by_link_id( &self, _generic_link_id: &str, ) -> CustomResult<storage::PaymentMethodCollectLink, errors::StorageError> { // TODO: Implement function for `MockDb`x Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_insert_pm_collect_link_-441730542381734885
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/generic_link // Implementation of MockDb for GenericLinkInterface async fn insert_pm_collect_link( &self, _pm_collect_link: storage::GenericLinkNew, ) -> CustomResult<storage::PaymentMethodCollectLink, errors::StorageError> { // TODO: Implement function for `MockDb` Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_insert_payout_link_-441730542381734885
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/generic_link // Implementation of MockDb for GenericLinkInterface async fn insert_payout_link( &self, _pm_collect_link: storage::GenericLinkNew, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { // TODO: Implement function for `MockDb` Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_find_translation_-188363381094823233
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/unified_translations // Implementation of MockDb for UnifiedTranslationsInterface async fn find_translation( &self, _unified_code: String, _unified_message: String, _locale: String, ) -> CustomResult<String, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_add_unfied_translation_-188363381094823233
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/unified_translations // Implementation of MockDb for UnifiedTranslationsInterface async fn add_unfied_translation( &self, _translation: storage::UnifiedTranslationsNew, ) -> CustomResult<storage::UnifiedTranslations, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 11, "total_crates": null }
fn_clm_router_update_translation_-188363381094823233
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/unified_translations // Implementation of MockDb for UnifiedTranslationsInterface async fn update_translation( &self, _unified_code: String, _unified_message: String, _locale: String, _data: storage::UnifiedTranslationsUpdate, ) -> CustomResult<storage::UnifiedTranslations, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 11, "total_crates": null }
fn_clm_router_delete_translation_-188363381094823233
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/unified_translations // Implementation of MockDb for UnifiedTranslationsInterface async fn delete_translation( &self, _unified_code: String, _unified_message: String, _locale: String, ) -> CustomResult<bool, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 11, "total_crates": null }
fn_clm_router_test_mockdb_api_key_interface_2507543647697342289
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/api_keys async fn test_mockdb_api_key_interface() { #[allow(clippy::expect_used)] let mockdb = MockDb::new(&redis_interface::RedisSettings::default()) .await .expect("Failed to create Mock store"); let merchant_id = common_utils::id_type::MerchantId::try_from(Cow::from("merchant1")).unwrap(); let key_id1 = common_utils::id_type::ApiKeyId::try_from(Cow::from("key_id1")).unwrap(); let key_id2 = common_utils::id_type::ApiKeyId::try_from(Cow::from("key_id2")).unwrap(); let non_existent_key_id = common_utils::id_type::ApiKeyId::try_from(Cow::from("does_not_exist")).unwrap(); let key1 = mockdb .insert_api_key(storage::ApiKeyNew { key_id: key_id1.clone(), merchant_id: merchant_id.clone(), name: "Key 1".into(), description: None, hashed_api_key: "hashed_key1".to_string().into(), prefix: "abc".into(), created_at: datetime!(2023-02-01 0:00), expires_at: Some(datetime!(2023-03-01 0:00)), last_used: None, }) .await .unwrap(); mockdb .insert_api_key(storage::ApiKeyNew { key_id: key_id2.clone(), merchant_id: merchant_id.clone(), name: "Key 2".into(), description: None, hashed_api_key: "hashed_key2".to_string().into(), prefix: "abc".into(), created_at: datetime!(2023-03-01 0:00), expires_at: None, last_used: None, }) .await .unwrap(); let found_key1 = mockdb .find_api_key_by_merchant_id_key_id_optional(&merchant_id, &key_id1) .await .unwrap() .unwrap(); assert_eq!(found_key1.key_id, key1.key_id); assert!(mockdb .find_api_key_by_merchant_id_key_id_optional(&merchant_id, &non_existent_key_id) .await .unwrap() .is_none()); mockdb .update_api_key( merchant_id.clone(), key_id1.clone(), storage::ApiKeyUpdate::LastUsedUpdate { last_used: datetime!(2023-02-04 1:11), }, ) .await .unwrap(); let updated_key1 = mockdb .find_api_key_by_merchant_id_key_id_optional(&merchant_id, &key_id1) .await .unwrap() .unwrap(); assert_eq!(updated_key1.last_used, Some(datetime!(2023-02-04 1:11))); assert_eq!( mockdb .list_api_keys_by_merchant_id(&merchant_id, None, None) .await .unwrap() .len(), 2 ); mockdb.revoke_api_key(&merchant_id, &key_id1).await.unwrap(); assert_eq!( mockdb .list_api_keys_by_merchant_id(&merchant_id, None, None) .await .unwrap() .len(), 1 ); }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 60, "total_crates": null }
fn_clm_router_test_api_keys_cache_2507543647697342289
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/api_keys async fn test_api_keys_cache() { let merchant_id = common_utils::id_type::MerchantId::try_from(Cow::from("test_merchant")).unwrap(); #[allow(clippy::expect_used)] let db = MockDb::new(&redis_interface::RedisSettings::default()) .await .expect("Failed to create Mock store"); let redis_conn = db.get_redis_conn().unwrap(); redis_conn .subscribe("hyperswitch_invalidate") .await .unwrap(); let test_key = common_utils::id_type::ApiKeyId::try_from(Cow::from("test_ey")).unwrap(); let api = storage::ApiKeyNew { key_id: test_key.clone(), merchant_id: merchant_id.clone(), name: "My test key".into(), description: None, hashed_api_key: "a_hashed_key".to_string().into(), prefix: "pre".into(), created_at: datetime!(2023-06-01 0:00), expires_at: None, last_used: None, }; let api = db.insert_api_key(api).await.unwrap(); let hashed_api_key = api.hashed_api_key.clone(); let find_call = || async { db.find_api_key_by_hash_optional(hashed_api_key.clone()) .await }; let _: Option<storage::ApiKey> = cache::get_or_populate_in_memory( &db, &format!( "{}_{}", merchant_id.get_string_repr(), hashed_api_key.clone().into_inner() ), find_call, &ACCOUNTS_CACHE, ) .await .unwrap(); let delete_call = || async { db.revoke_api_key(&merchant_id, &api.key_id).await }; cache::publish_and_redact( &db, CacheKind::Accounts( format!( "{}_{}", merchant_id.get_string_repr(), hashed_api_key.clone().into_inner() ) .into(), ), delete_call, ) .await .unwrap(); assert!(ACCOUNTS_CACHE .get_val::<storage::ApiKey>(CacheKey { key: format!( "{}_{}", merchant_id.get_string_repr(), hashed_api_key.into_inner() ), prefix: String::default(), },) .await .is_none()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 46, "total_crates": null }
fn_clm_router_revoke_api_key_2507543647697342289
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/api_keys // Implementation of MockDb for ApiKeyInterface async fn revoke_api_key( &self, merchant_id: &common_utils::id_type::MerchantId, key_id: &common_utils::id_type::ApiKeyId, ) -> CustomResult<bool, errors::StorageError> { let mut locked_api_keys = self.api_keys.lock().await; // find the key to remove, if it exists if let Some(pos) = locked_api_keys .iter() .position(|k| k.merchant_id == *merchant_id && k.key_id == *key_id) { // use `remove` instead of `swap_remove` so we have a consistent order, which might // matter to someone using limit/offset in `list_api_keys_by_merchant_id` locked_api_keys.remove(pos); Ok(true) } else { Ok(false) } }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 37, "total_crates": null }
fn_clm_router_list_api_keys_by_merchant_id_2507543647697342289
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/api_keys // Implementation of MockDb for ApiKeyInterface async fn list_api_keys_by_merchant_id( &self, merchant_id: &common_utils::id_type::MerchantId, limit: Option<i64>, offset: Option<i64>, ) -> CustomResult<Vec<storage::ApiKey>, errors::StorageError> { // mimic the SQL limit/offset behavior let offset: usize = if let Some(offset) = offset { if offset < 0 { Err(errors::StorageError::MockDbError)?; } offset .try_into() .map_err(|_| errors::StorageError::MockDbError)? } else { 0 }; let limit: usize = if let Some(limit) = limit { if limit < 0 { Err(errors::StorageError::MockDbError)?; } limit .try_into() .map_err(|_| errors::StorageError::MockDbError)? } else { usize::MAX }; let keys_for_merchant_id: Vec<storage::ApiKey> = self .api_keys .lock() .await .iter() .filter(|k| k.merchant_id == *merchant_id) .skip(offset) .take(limit) .cloned() .collect(); Ok(keys_for_merchant_id) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 36, "total_crates": null }
fn_clm_router_update_api_key_2507543647697342289
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/api_keys // Implementation of MockDb for ApiKeyInterface async fn update_api_key( &self, merchant_id: common_utils::id_type::MerchantId, key_id: common_utils::id_type::ApiKeyId, api_key: storage::ApiKeyUpdate, ) -> CustomResult<storage::ApiKey, errors::StorageError> { let mut locked_api_keys = self.api_keys.lock().await; // find a key with the given merchant_id and key_id and update, otherwise return an error let key_to_update = locked_api_keys .iter_mut() .find(|k| k.merchant_id == merchant_id && k.key_id == key_id) .ok_or(errors::StorageError::MockDbError)?; match api_key { storage::ApiKeyUpdate::Update { name, description, expires_at, last_used, } => { if let Some(name) = name { key_to_update.name = name; } // only update these fields if the value was Some(_) if description.is_some() { key_to_update.description = description; } if let Some(expires_at) = expires_at { key_to_update.expires_at = expires_at; } if last_used.is_some() { key_to_update.last_used = last_used } } storage::ApiKeyUpdate::LastUsedUpdate { last_used } => { key_to_update.last_used = Some(last_used); } } Ok(key_to_update.clone()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 34, "total_crates": null }
fn_clm_router_insert_metadata_8921144440861676303
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/dashboard_metadata // Implementation of MockDb for DashboardMetadataInterface async fn insert_metadata( &self, metadata: storage::DashboardMetadataNew, ) -> CustomResult<storage::DashboardMetadata, errors::StorageError> { let mut dashboard_metadata = self.dashboard_metadata.lock().await; if dashboard_metadata.iter().any(|metadata_inner| { metadata_inner.user_id == metadata.user_id && metadata_inner.merchant_id == metadata.merchant_id && metadata_inner.org_id == metadata.org_id && metadata_inner.data_key == metadata.data_key }) { Err(errors::StorageError::DuplicateValue { entity: "user_id, merchant_id, org_id and data_key", key: None, })? } let metadata_new = storage::DashboardMetadata { id: i32::try_from(dashboard_metadata.len()) .change_context(errors::StorageError::MockDbError)?, user_id: metadata.user_id, merchant_id: metadata.merchant_id, org_id: metadata.org_id, data_key: metadata.data_key, data_value: metadata.data_value, created_by: metadata.created_by, created_at: metadata.created_at, last_modified_by: metadata.last_modified_by, last_modified_at: metadata.last_modified_at, }; dashboard_metadata.push(metadata_new.clone()); Ok(metadata_new) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 42, "total_crates": null }
fn_clm_router_find_user_scoped_dashboard_metadata_8921144440861676303
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/dashboard_metadata // Implementation of MockDb for DashboardMetadataInterface async fn find_user_scoped_dashboard_metadata( &self, user_id: &str, merchant_id: &id_type::MerchantId, org_id: &id_type::OrganizationId, data_keys: Vec<enums::DashboardMetadata>, ) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> { let dashboard_metadata = self.dashboard_metadata.lock().await; let query_result = dashboard_metadata .iter() .filter(|metadata_inner| { metadata_inner .user_id .clone() .map(|user_id_inner| user_id_inner == user_id) .unwrap_or(false) && metadata_inner.merchant_id == *merchant_id && metadata_inner.org_id == *org_id && data_keys.contains(&metadata_inner.data_key) }) .cloned() .collect::<Vec<storage::DashboardMetadata>>(); if query_result.is_empty() { return Err(errors::StorageError::ValueNotFound(format!( "No dashboard_metadata available for user_id = {user_id},\ merchant_id = {merchant_id:?}, org_id = {org_id:?} and data_keys = {data_keys:?}", )) .into()); } Ok(query_result) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 36, "total_crates": null }
fn_clm_router_find_merchant_scoped_dashboard_metadata_8921144440861676303
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/dashboard_metadata // Implementation of MockDb for DashboardMetadataInterface async fn find_merchant_scoped_dashboard_metadata( &self, merchant_id: &id_type::MerchantId, org_id: &id_type::OrganizationId, data_keys: Vec<enums::DashboardMetadata>, ) -> CustomResult<Vec<storage::DashboardMetadata>, errors::StorageError> { let dashboard_metadata = self.dashboard_metadata.lock().await; let query_result = dashboard_metadata .iter() .filter(|metadata_inner| { metadata_inner.merchant_id == *merchant_id && metadata_inner.org_id == *org_id && data_keys.contains(&metadata_inner.data_key) }) .cloned() .collect::<Vec<storage::DashboardMetadata>>(); if query_result.is_empty() { return Err(errors::StorageError::ValueNotFound(format!( "No dashboard_metadata available for merchant_id = {merchant_id:?},\ org_id = {org_id:?} and data_keyss = {data_keys:?}", )) .into()); } Ok(query_result) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 30, "total_crates": null }
fn_clm_router_delete_user_scoped_dashboard_metadata_by_merchant_id_data_key_8921144440861676303
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/dashboard_metadata // Implementation of MockDb for DashboardMetadataInterface async fn delete_user_scoped_dashboard_metadata_by_merchant_id_data_key( &self, user_id: &str, merchant_id: &id_type::MerchantId, data_key: enums::DashboardMetadata, ) -> CustomResult<storage::DashboardMetadata, errors::StorageError> { let mut dashboard_metadata = self.dashboard_metadata.lock().await; let index_to_remove = dashboard_metadata .iter() .position(|metadata_inner| { metadata_inner.user_id.as_deref() == Some(user_id) && metadata_inner.merchant_id == *merchant_id && metadata_inner.data_key == data_key }) .ok_or(errors::StorageError::ValueNotFound( "No data found".to_string(), ))?; let deleted_value = dashboard_metadata.swap_remove(index_to_remove); Ok(deleted_value) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 30, "total_crates": null }
fn_clm_router_update_metadata_8921144440861676303
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/dashboard_metadata // Implementation of MockDb for DashboardMetadataInterface async fn update_metadata( &self, user_id: Option<String>, merchant_id: id_type::MerchantId, org_id: id_type::OrganizationId, data_key: enums::DashboardMetadata, dashboard_metadata_update: storage::DashboardMetadataUpdate, ) -> CustomResult<storage::DashboardMetadata, errors::StorageError> { let mut dashboard_metadata = self.dashboard_metadata.lock().await; let dashboard_metadata_to_update = dashboard_metadata .iter_mut() .find(|metadata| { metadata.user_id == user_id && metadata.merchant_id == merchant_id && metadata.org_id == org_id && metadata.data_key == data_key }) .ok_or(errors::StorageError::MockDbError)?; match dashboard_metadata_update { storage::DashboardMetadataUpdate::UpdateData { data_key, data_value, last_modified_by, } => { dashboard_metadata_to_update.data_key = data_key; dashboard_metadata_to_update.data_value = data_value; dashboard_metadata_to_update.last_modified_by = last_modified_by; dashboard_metadata_to_update.last_modified_at = common_utils::date_time::now(); } } Ok(dashboard_metadata_to_update.clone()) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 29, "total_crates": null }
fn_clm_router_find_gsm_rule_-2333336074625409355
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/gsm // Implementation of MockDb for GsmInterface async fn find_gsm_rule( &self, _connector: String, _flow: String, _sub_flow: String, _code: String, _message: String, ) -> CustomResult<hyperswitch_domain_models::gsm::GatewayStatusMap, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 23, "total_crates": null }
fn_clm_router_update_gsm_rule_-2333336074625409355
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/gsm // Implementation of MockDb for GsmInterface async fn update_gsm_rule( &self, _connector: String, _flow: String, _sub_flow: String, _code: String, _message: String, _data: hyperswitch_domain_models::gsm::GatewayStatusMappingUpdate, ) -> CustomResult<hyperswitch_domain_models::gsm::GatewayStatusMap, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }
fn_clm_router_delete_gsm_rule_-2333336074625409355
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/gsm // Implementation of MockDb for GsmInterface async fn delete_gsm_rule( &self, _connector: String, _flow: String, _sub_flow: String, _code: String, _message: String, ) -> CustomResult<bool, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }
fn_clm_router_add_gsm_rule_-2333336074625409355
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/gsm // Implementation of MockDb for GsmInterface async fn add_gsm_rule( &self, _rule: hyperswitch_domain_models::gsm::GatewayStatusMap, ) -> CustomResult<hyperswitch_domain_models::gsm::GatewayStatusMap, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 14, "total_crates": null }
fn_clm_router_find_gsm_decision_-2333336074625409355
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/gsm // Implementation of MockDb for GsmInterface async fn find_gsm_decision( &self, _connector: String, _flow: String, _sub_flow: String, _code: String, _message: String, ) -> CustomResult<String, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 11, "total_crates": null }
fn_clm_router_list_hyperswitch_ai_interactions_-9214493923619358096
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/hyperswitch_ai_interaction // Implementation of MockDb for HyperswitchAiInteractionInterface async fn list_hyperswitch_ai_interactions( &self, merchant_id: Option<common_utils::id_type::MerchantId>, limit: i64, offset: i64, ) -> CustomResult<Vec<storage::HyperswitchAiInteraction>, errors::StorageError> { let hyperswitch_ai_interactions = self.hyperswitch_ai_interactions.lock().await; let offset_usize = offset.try_into().unwrap_or_else(|_| { common_utils::consts::DEFAULT_LIST_OFFSET .try_into() .unwrap_or(usize::MIN) }); let limit_usize = limit.try_into().unwrap_or_else(|_| { common_utils::consts::DEFAULT_LIST_LIMIT .try_into() .unwrap_or(usize::MAX) }); let filtered_interactions: Vec<storage::HyperswitchAiInteraction> = hyperswitch_ai_interactions .iter() .filter( |interaction| match (merchant_id.as_ref(), &interaction.merchant_id) { (Some(merchant_id), Some(interaction_merchant_id)) => { interaction_merchant_id == &merchant_id.get_string_repr().to_owned() } (None, _) => true, _ => false, }, ) .skip(offset_usize) .take(limit_usize) .cloned() .collect(); Ok(filtered_interactions) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 50, "total_crates": null }
fn_clm_router_insert_hyperswitch_ai_interaction_-9214493923619358096
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/hyperswitch_ai_interaction // Implementation of MockDb for HyperswitchAiInteractionInterface async fn insert_hyperswitch_ai_interaction( &self, hyperswitch_ai_interaction: storage::HyperswitchAiInteractionNew, ) -> CustomResult<storage::HyperswitchAiInteraction, errors::StorageError> { let mut hyperswitch_ai_interactions = self.hyperswitch_ai_interactions.lock().await; let hyperswitch_ai_interaction = storage::HyperswitchAiInteraction { id: hyperswitch_ai_interaction.id, session_id: hyperswitch_ai_interaction.session_id, user_id: hyperswitch_ai_interaction.user_id, merchant_id: hyperswitch_ai_interaction.merchant_id, profile_id: hyperswitch_ai_interaction.profile_id, org_id: hyperswitch_ai_interaction.org_id, role_id: hyperswitch_ai_interaction.role_id, user_query: hyperswitch_ai_interaction.user_query, response: hyperswitch_ai_interaction.response, database_query: hyperswitch_ai_interaction.database_query, interaction_status: hyperswitch_ai_interaction.interaction_status, created_at: hyperswitch_ai_interaction.created_at, }; hyperswitch_ai_interactions.push(hyperswitch_ai_interaction.clone()); Ok(hyperswitch_ai_interaction) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 20, "total_crates": null }
fn_clm_router_find_authentication_by_merchant_id_authentication_id_3681577837588236071
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/authentication // Implementation of MockDb for AuthenticationInterface async fn find_authentication_by_merchant_id_authentication_id( &self, merchant_id: &common_utils::id_type::MerchantId, authentication_id: &common_utils::id_type::AuthenticationId, ) -> CustomResult<storage::Authentication, errors::StorageError> { let authentications = self.authentications.lock().await; authentications .iter() .find(|a| a.merchant_id == *merchant_id && a.authentication_id == *authentication_id) .ok_or( errors::StorageError::ValueNotFound(format!( "cannot find authentication for authentication_id = {authentication_id:?} and merchant_id = {merchant_id:?}" )).into(), ).cloned() }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 55, "total_crates": null }
fn_clm_router_update_authentication_by_merchant_id_authentication_id_3681577837588236071
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/authentication // Implementation of MockDb for AuthenticationInterface async fn update_authentication_by_merchant_id_authentication_id( &self, previous_state: storage::Authentication, authentication_update: storage::AuthenticationUpdate, ) -> CustomResult<storage::Authentication, errors::StorageError> { let mut authentications = self.authentications.lock().await; let authentication_id = previous_state.authentication_id.clone(); let merchant_id = previous_state.merchant_id.clone(); authentications .iter_mut() .find(|authentication| authentication.authentication_id == authentication_id && authentication.merchant_id == merchant_id) .map(|authentication| { let authentication_update_internal = AuthenticationUpdateInternal::from(authentication_update); let updated_authentication = authentication_update_internal.apply_changeset(previous_state); *authentication = updated_authentication.clone(); updated_authentication }) .ok_or( errors::StorageError::ValueNotFound(format!( "cannot find authentication for authentication_id = {authentication_id:?} and merchant_id = {merchant_id:?}" )) .into(), ) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 47, "total_crates": null }
fn_clm_router_insert_authentication_3681577837588236071
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/authentication // Implementation of MockDb for AuthenticationInterface async fn insert_authentication( &self, authentication: storage::AuthenticationNew, ) -> CustomResult<storage::Authentication, errors::StorageError> { let mut authentications = self.authentications.lock().await; if authentications.iter().any(|authentication_inner| { authentication_inner.authentication_id == authentication.authentication_id }) { Err(errors::StorageError::DuplicateValue { entity: "authentication_id", key: Some( authentication .authentication_id .get_string_repr() .to_string(), ), })? } let authentication = storage::Authentication { created_at: common_utils::date_time::now(), modified_at: common_utils::date_time::now(), authentication_id: authentication.authentication_id, merchant_id: authentication.merchant_id, authentication_status: authentication.authentication_status, authentication_connector: authentication.authentication_connector, connector_authentication_id: authentication.connector_authentication_id, authentication_data: None, payment_method_id: authentication.payment_method_id, authentication_type: authentication.authentication_type, authentication_lifecycle_status: authentication.authentication_lifecycle_status, error_code: authentication.error_code, error_message: authentication.error_message, connector_metadata: authentication.connector_metadata, maximum_supported_version: authentication.maximum_supported_version, threeds_server_transaction_id: authentication.threeds_server_transaction_id, cavv: authentication.cavv, authentication_flow_type: authentication.authentication_flow_type, message_version: authentication.message_version, eci: authentication.eci, trans_status: authentication.trans_status, acquirer_bin: authentication.acquirer_bin, acquirer_merchant_id: authentication.acquirer_merchant_id, three_ds_method_data: authentication.three_ds_method_data, three_ds_method_url: authentication.three_ds_method_url, acs_url: authentication.acs_url, challenge_request: authentication.challenge_request, challenge_request_key: authentication.challenge_request_key, acs_reference_number: authentication.acs_reference_number, acs_trans_id: authentication.acs_trans_id, acs_signed_content: authentication.acs_signed_content, profile_id: authentication.profile_id, payment_id: authentication.payment_id, merchant_connector_id: authentication.merchant_connector_id, ds_trans_id: authentication.ds_trans_id, directory_server_id: authentication.directory_server_id, acquirer_country_code: authentication.acquirer_country_code, service_details: authentication.service_details, organization_id: authentication.organization_id, authentication_client_secret: authentication.authentication_client_secret, force_3ds_challenge: authentication.force_3ds_challenge, psd2_sca_exemption_type: authentication.psd2_sca_exemption_type, return_url: authentication.return_url, amount: authentication.amount, currency: authentication.currency, billing_address: authentication.billing_address, shipping_address: authentication.shipping_address, browser_info: authentication.browser_info, email: authentication.email, profile_acquirer_id: authentication.profile_acquirer_id, challenge_code: authentication.challenge_code, challenge_cancel: authentication.challenge_cancel, challenge_code_reason: authentication.challenge_code_reason, message_extension: authentication.message_extension, }; authentications.push(authentication.clone()); Ok(authentication) }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 35, "total_crates": null }
fn_clm_router_find_authentication_by_merchant_id_connector_authentication_id_3681577837588236071
clm
function
// Repository: hyperswitch // Crate: router // Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration // Module: crates/router/src/db/authentication // Implementation of MockDb for AuthenticationInterface async fn find_authentication_by_merchant_id_connector_authentication_id( &self, _merchant_id: common_utils::id_type::MerchantId, _connector_authentication_id: String, ) -> CustomResult<storage::Authentication, errors::StorageError> { Err(errors::StorageError::MockDbError)? }
{ "crate": "router", "file": null, "file_size": null, "is_async": false, "is_pub": false, "num_enums": null, "num_structs": null, "num_tables": null, "score": 17, "total_crates": null }