id
stringlengths 11
116
| type
stringclasses 1
value | granularity
stringclasses 4
values | content
stringlengths 16
477k
| metadata
dict |
|---|---|---|---|---|
fn_clm_router_test_mock_db_merchant_key_store_interface_6292366701882534799
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/merchant_key_store
async fn test_mock_db_merchant_key_store_interface() {
let conf = Settings::new().expect("invalid settings");
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 mock_db = MockDb::new(&redis_interface::RedisSettings::default())
.await
.expect("Failed to create mock DB");
let master_key = mock_db.get_master_key();
let merchant_id =
common_utils::id_type::MerchantId::try_from(Cow::from("merchant1")).unwrap();
let identifier = Identifier::Merchant(merchant_id.clone());
let key_manager_state = &state.into();
let merchant_key1 = mock_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::MerchantKeyStore),
domain::types::CryptoOperation::Encrypt(
services::generate_aes256_key().unwrap().to_vec().into(),
),
identifier.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 found_merchant_key1 = mock_db
.get_merchant_key_store_by_merchant_id(
key_manager_state,
&merchant_id,
&master_key.to_vec().into(),
)
.await
.unwrap();
assert_eq!(found_merchant_key1.merchant_id, merchant_key1.merchant_id);
assert_eq!(found_merchant_key1.key, merchant_key1.key);
let insert_duplicate_merchant_key1_result = mock_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::MerchantKeyStore),
domain::types::CryptoOperation::Encrypt(
services::generate_aes256_key().unwrap().to_vec().into(),
),
identifier.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;
assert!(insert_duplicate_merchant_key1_result.is_err());
let non_existent_merchant_id =
common_utils::id_type::MerchantId::try_from(Cow::from("non_existent")).unwrap();
let find_non_existent_merchant_key_result = mock_db
.get_merchant_key_store_by_merchant_id(
key_manager_state,
&non_existent_merchant_id,
&master_key.to_vec().into(),
)
.await;
assert!(find_non_existent_merchant_key_result.is_err());
let find_merchant_key_with_incorrect_master_key_result = mock_db
.get_merchant_key_store_by_merchant_id(
key_manager_state,
&merchant_id,
&vec![0; 32].into(),
)
.await;
assert!(find_merchant_key_with_incorrect_master_key_result.is_err());
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 102,
"total_crates": null
}
|
fn_clm_router_health_check_db_756930594317680444
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/health_check
// Implementation of MockDb for HealthCheckDbInterface
async fn health_check_db(&self) -> CustomResult<(), errors::HealthCheckDBError> {
Ok(())
}
|
{
"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_new_4465231232114590534
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/kafka_store
// Inherent implementation for KafkaStore
pub async fn new(
store: Store,
mut kafka_producer: KafkaProducer,
tenant_id: TenantID,
tenant_config: &dyn TenantConfig,
) -> Self {
kafka_producer.set_tenancy(tenant_config);
Self {
kafka_producer,
diesel_store: store,
tenant_id,
}
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14465,
"total_crates": null
}
|
fn_clm_router_get_master_key_4465231232114590534
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/kafka_store
// Implementation of KafkaStore for MasterKeyInterface
fn get_master_key(&self) -> &[u8] {
self.diesel_store.get_master_key()
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 235,
"total_crates": null
}
|
fn_clm_router_get_merchant_key_store_by_merchant_id_4465231232114590534
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/kafka_store
// Implementation of KafkaStore for MerchantKeyStoreInterface
async fn get_merchant_key_store_by_merchant_id(
&self,
state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, errors::StorageError> {
self.diesel_store
.get_merchant_key_store_by_merchant_id(state, merchant_id, key)
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 223,
"total_crates": null
}
|
fn_clm_router_get_redis_conn_4465231232114590534
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/kafka_store
// Implementation of KafkaStore for RedisConnInterface
fn get_redis_conn(&self) -> CustomResult<Arc<RedisConnectionPool>, RedisError> {
self.diesel_store.get_redis_conn()
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 205,
"total_crates": null
}
|
fn_clm_router_find_business_profile_by_profile_id_4465231232114590534
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/kafka_store
// Implementation of KafkaStore for ProfileInterface
async fn find_business_profile_by_profile_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_id: &id_type::ProfileId,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.find_business_profile_by_profile_id(key_manager_state, merchant_key_store, profile_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": 151,
"total_crates": null
}
|
fn_clm_router_insert_user_key_store_-7456873319153680255
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user_key_store
// Implementation of MockDb for UserKeyStoreInterface
async fn insert_user_key_store(
&self,
state: &KeyManagerState,
user_key_store: domain::UserKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError> {
let mut locked_user_key_store = self.user_key_store.lock().await;
if locked_user_key_store
.iter()
.any(|user_key| user_key.user_id == user_key_store.user_id)
{
Err(errors::StorageError::DuplicateValue {
entity: "user_key_store",
key: Some(user_key_store.user_id.clone()),
})?;
}
let user_key_store = Conversion::convert(user_key_store)
.await
.change_context(errors::StorageError::MockDbError)?;
locked_user_key_store.push(user_key_store.clone());
let user_id = user_key_store.user_id.clone();
user_key_store
.convert(state, key, keymanager::Identifier::User(user_id))
.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": 38,
"total_crates": null
}
|
fn_clm_router_get_user_key_store_by_user_id_-7456873319153680255
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user_key_store
// Implementation of MockDb for UserKeyStoreInterface
async fn get_user_key_store_by_user_id(
&self,
state: &KeyManagerState,
user_id: &str,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::UserKeyStore, errors::StorageError> {
self.user_key_store
.lock()
.await
.iter()
.find(|user_key_store| user_key_store.user_id == user_id)
.cloned()
.ok_or(errors::StorageError::ValueNotFound(format!(
"No user_key_store is found for user_id={user_id}",
)))?
.convert(state, key, keymanager::Identifier::User(user_id.to_owned()))
.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": 37,
"total_crates": null
}
|
fn_clm_router_get_all_user_key_store_-7456873319153680255
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user_key_store
// Implementation of MockDb for UserKeyStoreInterface
async fn get_all_user_key_store(
&self,
state: &KeyManagerState,
key: &Secret<Vec<u8>>,
_from: u32,
_limit: u32,
) -> CustomResult<Vec<domain::UserKeyStore>, errors::StorageError> {
let user_key_store = self.user_key_store.lock().await;
futures::future::try_join_all(user_key_store.iter().map(|user_key| async {
let user_id = user_key.user_id.clone();
user_key
.to_owned()
.convert(state, key, keymanager::Identifier::User(user_id))
.await
.change_context(errors::StorageError::DecryptionError)
}))
.await
}
|
{
"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_get_ephemeral_key_47112423646915978
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/ephemeral_key
// Implementation of MockDb for EphemeralKeyInterface
async fn get_ephemeral_key(
&self,
key: &str,
) -> CustomResult<EphemeralKey, errors::StorageError> {
match self
.ephemeral_keys
.lock()
.await
.iter()
.find(|ephemeral_key| ephemeral_key.secret.eq(key))
{
Some(ephemeral_key) => Ok(ephemeral_key.clone()),
None => Err(
errors::StorageError::ValueNotFound("ephemeral key 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": 36,
"total_crates": null
}
|
fn_clm_router_create_ephemeral_key_47112423646915978
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/ephemeral_key
// Implementation of MockDb for EphemeralKeyInterface
async fn create_ephemeral_key(
&self,
ek: EphemeralKeyNew,
validity: i64,
) -> CustomResult<EphemeralKey, errors::StorageError> {
let mut ephemeral_keys = self.ephemeral_keys.lock().await;
let created_at = common_utils::date_time::now();
let expires = created_at.saturating_add(validity.hours());
let ephemeral_key = EphemeralKey {
id: ek.id,
merchant_id: ek.merchant_id,
customer_id: ek.customer_id,
created_at: created_at.assume_utc().unix_timestamp(),
expires: expires.assume_utc().unix_timestamp(),
secret: ek.secret,
};
ephemeral_keys.push(ephemeral_key.clone());
Ok(ephemeral_key)
}
|
{
"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_delete_ephemeral_key_47112423646915978
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/ephemeral_key
// Implementation of MockDb for EphemeralKeyInterface
async fn delete_ephemeral_key(
&self,
id: &str,
) -> CustomResult<EphemeralKey, errors::StorageError> {
let mut ephemeral_keys = self.ephemeral_keys.lock().await;
if let Some(pos) = ephemeral_keys.iter().position(|x| (*x.id).eq(id)) {
let ek = ephemeral_keys.remove(pos);
Ok(ek)
} else {
return Err(
errors::StorageError::ValueNotFound("ephemeral key 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": 33,
"total_crates": null
}
|
fn_clm_router_create_client_secret_47112423646915978
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/ephemeral_key
// Implementation of MockDb for ClientSecretInterface
async fn create_client_secret(
&self,
new: ClientSecretTypeNew,
validity: i64,
) -> CustomResult<ClientSecretType, errors::StorageError> {
todo!()
}
|
{
"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_get_client_secret_47112423646915978
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/ephemeral_key
// Implementation of MockDb for ClientSecretInterface
async fn get_client_secret(
&self,
key: &str,
) -> CustomResult<ClientSecretType, errors::StorageError> {
todo!()
}
|
{
"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_reverse_lookup_-6214870044614263181
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/reverse_lookup
// Implementation of MockDb for ReverseLookupInterface
async fn insert_reverse_lookup(
&self,
new: ReverseLookupNew,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<ReverseLookup, errors::StorageError> {
let reverse_lookup_insert = ReverseLookup::from(new);
self.reverse_lookups
.lock()
.await
.push(reverse_lookup_insert.clone());
Ok(reverse_lookup_insert)
}
|
{
"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_get_lookup_by_lookup_id_-6214870044614263181
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/reverse_lookup
// Implementation of MockDb for ReverseLookupInterface
async fn get_lookup_by_lookup_id(
&self,
lookup_id: &str,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<ReverseLookup, errors::StorageError> {
self.reverse_lookups
.lock()
.await
.iter()
.find(|reverse_lookup| reverse_lookup.lookup_id == lookup_id)
.ok_or(
errors::StorageError::ValueNotFound(format!(
"No reverse lookup found for lookup_id = {lookup_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": 28,
"total_crates": null
}
|
fn_clm_router_update_relay_7970011099548000942
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/relay
// Implementation of KafkaStore for RelayInterface
async fn update_relay(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_state: hyperswitch_domain_models::relay::Relay,
relay_update: hyperswitch_domain_models::relay::RelayUpdate,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
self.diesel_store
.update_relay(
key_manager_state,
merchant_key_store,
current_state,
relay_update,
)
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 22,
"total_crates": null
}
|
fn_clm_router_find_relay_by_id_7970011099548000942
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/relay
// Implementation of KafkaStore for RelayInterface
async fn find_relay_by_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
relay_id: &common_utils::id_type::RelayId,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
self.diesel_store
.find_relay_by_id(key_manager_state, merchant_key_store, relay_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": 19,
"total_crates": null
}
|
fn_clm_router_insert_relay_7970011099548000942
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/relay
// Implementation of KafkaStore for RelayInterface
async fn insert_relay(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
new: hyperswitch_domain_models::relay::Relay,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
self.diesel_store
.insert_relay(key_manager_state, merchant_key_store, 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": 16,
"total_crates": null
}
|
fn_clm_router_find_relay_by_profile_id_connector_reference_id_7970011099548000942
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/relay
// Implementation of KafkaStore for RelayInterface
async fn find_relay_by_profile_id_connector_reference_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
connector_reference_id: &str,
) -> CustomResult<hyperswitch_domain_models::relay::Relay, errors::StorageError> {
self.diesel_store
.find_relay_by_profile_id_connector_reference_id(
key_manager_state,
merchant_key_store,
profile_id,
connector_reference_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": 16,
"total_crates": null
}
|
fn_clm_router_find_mandate_by_merchant_id_mandate_id_-711844553000453348
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/mandate
// Implementation of MockDb for MandateInterface
async fn find_mandate_by_merchant_id_mandate_id(
&self,
merchant_id: &id_type::MerchantId,
mandate_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage_types::Mandate, errors::StorageError> {
self.mandates
.lock()
.await
.iter()
.find(|mandate| mandate.merchant_id == *merchant_id && mandate.mandate_id == mandate_id)
.cloned()
.ok_or_else(|| errors::StorageError::ValueNotFound("mandate not found".to_string()))
.map_err(|err| err.into())
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 56,
"total_crates": null
}
|
fn_clm_router_update_mandate_by_merchant_id_mandate_id_-711844553000453348
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/mandate
// Implementation of MockDb for MandateInterface
async fn update_mandate_by_merchant_id_mandate_id(
&self,
merchant_id: &id_type::MerchantId,
mandate_id: &str,
mandate_update: storage_types::MandateUpdate,
_mandate: storage_types::Mandate,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage_types::Mandate, errors::StorageError> {
let mut mandates = self.mandates.lock().await;
match mandates
.iter_mut()
.find(|mandate| mandate.merchant_id == *merchant_id && mandate.mandate_id == mandate_id)
{
Some(mandate) => {
let m_update = diesel_models::MandateUpdateInternal::from(mandate_update);
let updated_mandate = m_update.clone().apply_changeset(mandate.clone());
Ok(updated_mandate)
}
None => {
Err(errors::StorageError::ValueNotFound("mandate 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": 46,
"total_crates": null
}
|
fn_clm_router_find_mandates_by_merchant_id_-711844553000453348
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/mandate
// Implementation of MockDb for MandateInterface
async fn find_mandates_by_merchant_id(
&self,
merchant_id: &id_type::MerchantId,
mandate_constraints: api_models::mandates::MandateListConstraints,
) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {
let mandates = self.mandates.lock().await;
let mandates_iter = mandates.iter().filter(|mandate| {
let mut checker = mandate.merchant_id == *merchant_id;
if let Some(created_time) = mandate_constraints.created_time {
checker &= mandate.created_at == created_time;
}
if let Some(created_time_lt) = mandate_constraints.created_time_lt {
checker &= mandate.created_at < created_time_lt;
}
if let Some(created_time_gt) = mandate_constraints.created_time_gt {
checker &= mandate.created_at > created_time_gt;
}
if let Some(created_time_lte) = mandate_constraints.created_time_lte {
checker &= mandate.created_at <= created_time_lte;
}
if let Some(created_time_gte) = mandate_constraints.created_time_gte {
checker &= mandate.created_at >= created_time_gte;
}
if let Some(connector) = &mandate_constraints.connector {
checker &= mandate.connector == *connector;
}
if let Some(mandate_status) = mandate_constraints.mandate_status {
checker &= mandate.mandate_status == mandate_status;
}
checker
});
#[allow(clippy::as_conversions)]
let offset = (if mandate_constraints.offset.unwrap_or(0) < 0 {
0
} else {
mandate_constraints.offset.unwrap_or(0)
}) as usize;
let mandates: Vec<storage_types::Mandate> = if let Some(limit) = mandate_constraints.limit {
#[allow(clippy::as_conversions)]
mandates_iter
.skip(offset)
.take((if limit < 0 { 0 } else { limit }) as usize)
.cloned()
.collect()
} else {
mandates_iter.skip(offset).cloned().collect()
};
Ok(mandates)
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 38,
"total_crates": null
}
|
fn_clm_router_find_mandate_by_merchant_id_connector_mandate_id_-711844553000453348
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/mandate
// Implementation of MockDb for MandateInterface
async fn find_mandate_by_merchant_id_connector_mandate_id(
&self,
merchant_id: &id_type::MerchantId,
connector_mandate_id: &str,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage_types::Mandate, errors::StorageError> {
self.mandates
.lock()
.await
.iter()
.find(|mandate| {
mandate.merchant_id == *merchant_id
&& mandate.connector_mandate_id == Some(connector_mandate_id.to_string())
})
.cloned()
.ok_or_else(|| errors::StorageError::ValueNotFound("mandate not found".to_string()))
.map_err(|err| err.into())
}
|
{
"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_mandate_by_merchant_id_customer_id_-711844553000453348
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/mandate
// Implementation of MockDb for MandateInterface
async fn find_mandate_by_merchant_id_customer_id(
&self,
merchant_id: &id_type::MerchantId,
customer_id: &id_type::CustomerId,
) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {
return Ok(self
.mandates
.lock()
.await
.iter()
.filter(|mandate| {
mandate.merchant_id == *merchant_id && &mandate.customer_id == customer_id
})
.cloned()
.collect());
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 27,
"total_crates": null
}
|
fn_clm_router_insert_capture_-8510696284726422902
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/capture
// Implementation of MockDb for CaptureInterface
async fn insert_capture(
&self,
capture: types::CaptureNew,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<types::Capture, errors::StorageError> {
let mut captures = self.captures.lock().await;
let capture = types::Capture {
capture_id: capture.capture_id,
payment_id: capture.payment_id,
merchant_id: capture.merchant_id,
status: capture.status,
amount: capture.amount,
currency: capture.currency,
connector: capture.connector,
error_message: capture.error_message,
error_code: capture.error_code,
error_reason: capture.error_reason,
tax_amount: capture.tax_amount,
created_at: capture.created_at,
modified_at: capture.modified_at,
authorized_attempt_id: capture.authorized_attempt_id,
capture_sequence: capture.capture_sequence,
connector_capture_id: capture.connector_capture_id,
connector_response_reference_id: capture.connector_response_reference_id,
processor_capture_data: capture.processor_capture_data,
// Below fields are deprecated. Please add any new fields above this line.
connector_capture_data: None,
};
captures.push(capture.clone());
Ok(capture)
}
|
{
"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_all_captures_by_merchant_id_payment_id_authorized_attempt_id_-8510696284726422902
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/capture
// Implementation of MockDb for CaptureInterface
async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
_payment_id: &common_utils::id_type::PaymentId,
_authorized_attempt_id: &str,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<Vec<types::Capture>, errors::StorageError> {
//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_update_capture_with_capture_id_-8510696284726422902
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/capture
// Implementation of MockDb for CaptureInterface
async fn update_capture_with_capture_id(
&self,
_this: types::Capture,
_capture: types::CaptureUpdate,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<types::Capture, errors::StorageError> {
//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_update_authorization_by_merchant_id_authorization_id_1123148234788202014
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/authorization
// Implementation of MockDb for AuthorizationInterface
async fn update_authorization_by_merchant_id_authorization_id(
&self,
merchant_id: common_utils::id_type::MerchantId,
authorization_id: String,
authorization_update: storage::AuthorizationUpdate,
) -> CustomResult<storage::Authorization, errors::StorageError> {
let mut authorizations = self.authorizations.lock().await;
authorizations
.iter_mut()
.find(|authorization| authorization.authorization_id == authorization_id && authorization.merchant_id == merchant_id)
.map(|authorization| {
let authorization_updated =
AuthorizationUpdateInternal::from(authorization_update)
.create_authorization(authorization.clone());
*authorization = authorization_updated.clone();
authorization_updated
})
.ok_or(
errors::StorageError::ValueNotFound(format!(
"cannot find authorization for authorization_id = {authorization_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": 33,
"total_crates": null
}
|
fn_clm_router_insert_authorization_1123148234788202014
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/authorization
// Implementation of MockDb for AuthorizationInterface
async fn insert_authorization(
&self,
authorization: storage::AuthorizationNew,
) -> CustomResult<storage::Authorization, errors::StorageError> {
let mut authorizations = self.authorizations.lock().await;
if authorizations.iter().any(|authorization_inner| {
authorization_inner.authorization_id == authorization.authorization_id
}) {
Err(errors::StorageError::DuplicateValue {
entity: "authorization_id",
key: None,
})?
}
let authorization = storage::Authorization {
authorization_id: authorization.authorization_id,
merchant_id: authorization.merchant_id,
payment_id: authorization.payment_id,
amount: authorization.amount,
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
status: authorization.status,
error_code: authorization.error_code,
error_message: authorization.error_message,
connector_authorization_id: authorization.connector_authorization_id,
previously_authorized_amount: authorization.previously_authorized_amount,
};
authorizations.push(authorization.clone());
Ok(authorization)
}
|
{
"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_find_all_authorizations_by_merchant_id_payment_id_1123148234788202014
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/authorization
// Implementation of MockDb for AuthorizationInterface
async fn find_all_authorizations_by_merchant_id_payment_id(
&self,
merchant_id: &common_utils::id_type::MerchantId,
payment_id: &common_utils::id_type::PaymentId,
) -> CustomResult<Vec<storage::Authorization>, errors::StorageError> {
let authorizations = self.authorizations.lock().await;
let authorizations_found: Vec<storage::Authorization> = authorizations
.iter()
.filter(|a| a.merchant_id == *merchant_id && a.payment_id == *payment_id)
.cloned()
.collect();
Ok(authorizations_found)
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 24,
"total_crates": null
}
|
fn_clm_router_update_user_authentication_method_9179533398646063075
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user_authentication_method
// Implementation of MockDb for UserAuthenticationMethodInterface
async fn update_user_authentication_method(
&self,
id: &str,
user_authentication_method_update: storage::UserAuthenticationMethodUpdate,
) -> CustomResult<storage::UserAuthenticationMethod, errors::StorageError> {
let mut user_authentication_methods = self.user_authentication_methods.lock().await;
user_authentication_methods
.iter_mut()
.find(|auth_method_inner| auth_method_inner.id == id)
.map(|auth_method_inner| {
*auth_method_inner = match user_authentication_method_update {
storage::UserAuthenticationMethodUpdate::UpdateConfig {
private_config,
public_config,
} => storage::UserAuthenticationMethod {
private_config,
public_config,
last_modified_at: common_utils::date_time::now(),
..auth_method_inner.to_owned()
},
storage::UserAuthenticationMethodUpdate::EmailDomain { email_domain } => {
storage::UserAuthenticationMethod {
email_domain: email_domain.to_owned(),
last_modified_at: common_utils::date_time::now(),
..auth_method_inner.to_owned()
}
}
};
auth_method_inner.to_owned()
})
.ok_or(
errors::StorageError::ValueNotFound(format!(
"No authentication method available for the id = {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": 46,
"total_crates": null
}
|
fn_clm_router_insert_user_authentication_method_9179533398646063075
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user_authentication_method
// Implementation of MockDb for UserAuthenticationMethodInterface
async fn insert_user_authentication_method(
&self,
user_authentication_method: storage::UserAuthenticationMethodNew,
) -> CustomResult<storage::UserAuthenticationMethod, errors::StorageError> {
let mut user_authentication_methods = self.user_authentication_methods.lock().await;
let existing_auth_id = user_authentication_methods
.iter()
.find(|uam| uam.owner_id == user_authentication_method.owner_id)
.map(|uam| uam.auth_id.clone());
let auth_id = existing_auth_id.unwrap_or_else(|| uuid::Uuid::new_v4().to_string());
let user_authentication_method = storage::UserAuthenticationMethod {
id: uuid::Uuid::new_v4().to_string(),
auth_id,
owner_id: user_authentication_method.auth_id,
owner_type: user_authentication_method.owner_type,
auth_type: user_authentication_method.auth_type,
public_config: user_authentication_method.public_config,
private_config: user_authentication_method.private_config,
allow_signup: user_authentication_method.allow_signup,
created_at: user_authentication_method.created_at,
last_modified_at: user_authentication_method.last_modified_at,
email_domain: user_authentication_method.email_domain,
};
user_authentication_methods.push(user_authentication_method.clone());
Ok(user_authentication_method)
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 38,
"total_crates": null
}
|
fn_clm_router_list_user_authentication_methods_for_owner_id_9179533398646063075
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user_authentication_method
// Implementation of MockDb for UserAuthenticationMethodInterface
async fn list_user_authentication_methods_for_owner_id(
&self,
owner_id: &str,
) -> CustomResult<Vec<storage::UserAuthenticationMethod>, errors::StorageError> {
let user_authentication_methods = self.user_authentication_methods.lock().await;
let user_authentication_methods_list: Vec<_> = user_authentication_methods
.iter()
.filter(|auth_method_inner| auth_method_inner.owner_id == owner_id)
.cloned()
.collect();
if user_authentication_methods_list.is_empty() {
return Err(errors::StorageError::ValueNotFound(format!(
"No user authentication method found for owner_id = {owner_id}",
))
.into());
}
Ok(user_authentication_methods_list)
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 33,
"total_crates": null
}
|
fn_clm_router_list_user_authentication_methods_for_auth_id_9179533398646063075
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user_authentication_method
// Implementation of MockDb for UserAuthenticationMethodInterface
async fn list_user_authentication_methods_for_auth_id(
&self,
auth_id: &str,
) -> CustomResult<Vec<storage::UserAuthenticationMethod>, errors::StorageError> {
let user_authentication_methods = self.user_authentication_methods.lock().await;
let user_authentication_methods_list: Vec<_> = user_authentication_methods
.iter()
.filter(|auth_method_inner| auth_method_inner.auth_id == auth_id)
.cloned()
.collect();
if user_authentication_methods_list.is_empty() {
return Err(errors::StorageError::ValueNotFound(format!(
"No user authentication method found for auth_id = {auth_id}",
))
.into());
}
Ok(user_authentication_methods_list)
}
|
{
"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_list_user_authentication_methods_for_email_domain_9179533398646063075
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user_authentication_method
// Implementation of MockDb for UserAuthenticationMethodInterface
async fn list_user_authentication_methods_for_email_domain(
&self,
email_domain: &str,
) -> CustomResult<Vec<storage::UserAuthenticationMethod>, errors::StorageError> {
let user_authentication_methods = self.user_authentication_methods.lock().await;
let user_authentication_methods_list: Vec<_> = user_authentication_methods
.iter()
.filter(|auth_method_inner| auth_method_inner.email_domain == email_domain)
.cloned()
.collect();
Ok(user_authentication_methods_list)
}
|
{
"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_find_file_metadata_by_merchant_id_file_id_851074284746737062
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/file
// Implementation of MockDb for FileMetadataInterface
async fn find_file_metadata_by_merchant_id_file_id(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
_file_id: &str,
) -> CustomResult<storage::FileMetadata, 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": 23,
"total_crates": null
}
|
fn_clm_router_insert_file_metadata_851074284746737062
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/file
// Implementation of MockDb for FileMetadataInterface
async fn insert_file_metadata(
&self,
_file: storage::FileMetadataNew,
) -> CustomResult<storage::FileMetadata, 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_delete_file_metadata_by_merchant_id_file_id_851074284746737062
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/file
// Implementation of MockDb for FileMetadataInterface
async fn delete_file_metadata_by_merchant_id_file_id(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
_file_id: &str,
) -> CustomResult<bool, 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_update_file_metadata_851074284746737062
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/file
// Implementation of MockDb for FileMetadataInterface
async fn update_file_metadata(
&self,
_this: storage::FileMetadata,
_file_metadata: storage::FileMetadataUpdate,
) -> CustomResult<storage::FileMetadata, 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_theme_by_theme_id_-2443885174101991478
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/theme
// Implementation of MockDb for ThemeInterface
async fn find_theme_by_theme_id(
&self,
theme_id: String,
) -> CustomResult<storage::Theme, errors::StorageError> {
let themes = self.themes.lock().await;
themes
.iter()
.find(|theme| theme.theme_id == theme_id)
.cloned()
.ok_or(
errors::StorageError::ValueNotFound(format!("Theme with id {theme_id} not found"))
.into(),
)
}
|
{
"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_check_theme_with_lineage_-2443885174101991478
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/theme
fn check_theme_with_lineage(theme: &storage::Theme, lineage: &ThemeLineage) -> bool {
match lineage {
ThemeLineage::Tenant { tenant_id } => {
&theme.tenant_id == tenant_id
&& theme.org_id.is_none()
&& theme.merchant_id.is_none()
&& theme.profile_id.is_none()
}
ThemeLineage::Organization { tenant_id, org_id } => {
&theme.tenant_id == tenant_id
&& theme
.org_id
.as_ref()
.is_some_and(|org_id_inner| org_id_inner == org_id)
&& theme.merchant_id.is_none()
&& theme.profile_id.is_none()
}
ThemeLineage::Merchant {
tenant_id,
org_id,
merchant_id,
} => {
&theme.tenant_id == tenant_id
&& theme
.org_id
.as_ref()
.is_some_and(|org_id_inner| org_id_inner == org_id)
&& theme
.merchant_id
.as_ref()
.is_some_and(|merchant_id_inner| merchant_id_inner == merchant_id)
&& theme.profile_id.is_none()
}
ThemeLineage::Profile {
tenant_id,
org_id,
merchant_id,
profile_id,
} => {
&theme.tenant_id == tenant_id
&& theme
.org_id
.as_ref()
.is_some_and(|org_id_inner| org_id_inner == org_id)
&& theme
.merchant_id
.as_ref()
.is_some_and(|merchant_id_inner| merchant_id_inner == merchant_id)
&& theme
.profile_id
.as_ref()
.is_some_and(|profile_id_inner| profile_id_inner == profile_id)
}
}
}
|
{
"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_most_specific_theme_in_lineage_-2443885174101991478
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/theme
// Implementation of MockDb for ThemeInterface
async fn find_most_specific_theme_in_lineage(
&self,
lineage: ThemeLineage,
) -> CustomResult<storage::Theme, errors::StorageError> {
let themes = self.themes.lock().await;
let lineages = lineage.get_same_and_higher_lineages();
themes
.iter()
.filter(|theme| {
lineages
.iter()
.any(|lineage| check_theme_with_lineage(theme, lineage))
})
.min_by_key(|theme| theme.entity_type)
.ok_or(
errors::StorageError::ValueNotFound("No theme found in lineage".to_string()).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": 40,
"total_crates": null
}
|
fn_clm_router_find_theme_by_lineage_-2443885174101991478
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/theme
// Implementation of MockDb for ThemeInterface
async fn find_theme_by_lineage(
&self,
lineage: ThemeLineage,
) -> CustomResult<storage::Theme, errors::StorageError> {
let themes = self.themes.lock().await;
themes
.iter()
.find(|theme| check_theme_with_lineage(theme, &lineage))
.cloned()
.ok_or(
errors::StorageError::ValueNotFound(format!(
"Theme with lineage {lineage:?} not found",
))
.into(),
)
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 33,
"total_crates": null
}
|
fn_clm_router_insert_theme_-2443885174101991478
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/theme
// Implementation of MockDb for ThemeInterface
async fn insert_theme(
&self,
new_theme: storage::ThemeNew,
) -> CustomResult<storage::Theme, errors::StorageError> {
let mut themes = self.themes.lock().await;
for theme in themes.iter() {
if new_theme.theme_id == theme.theme_id {
return Err(errors::StorageError::DuplicateValue {
entity: "theme_id",
key: None,
}
.into());
}
if new_theme.tenant_id == theme.tenant_id
&& new_theme.org_id == theme.org_id
&& new_theme.merchant_id == theme.merchant_id
&& new_theme.profile_id == theme.profile_id
{
return Err(errors::StorageError::DuplicateValue {
entity: "lineage",
key: None,
}
.into());
}
}
let theme = storage::Theme {
theme_id: new_theme.theme_id,
tenant_id: new_theme.tenant_id,
org_id: new_theme.org_id,
merchant_id: new_theme.merchant_id,
profile_id: new_theme.profile_id,
created_at: new_theme.created_at,
last_modified_at: new_theme.last_modified_at,
entity_type: new_theme.entity_type,
theme_name: new_theme.theme_name,
email_primary_color: new_theme.email_primary_color,
email_foreground_color: new_theme.email_foreground_color,
email_background_color: new_theme.email_background_color,
email_entity_name: new_theme.email_entity_name,
email_entity_logo_url: new_theme.email_entity_logo_url,
};
themes.push(theme.clone());
Ok(theme)
}
|
{
"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_diesel_error_to_data_error_5035841115351132113
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/sample_data
fn diesel_error_to_data_error(diesel_error: Report<DatabaseError>) -> Report<StorageError> {
let new_err = match diesel_error.current_context() {
DatabaseError::DatabaseConnectionError => StorageError::DatabaseConnectionError,
DatabaseError::NotFound => StorageError::ValueNotFound("Value not found".to_string()),
DatabaseError::UniqueViolation => StorageError::DuplicateValue {
entity: "entity ",
key: None,
},
err => StorageError::DatabaseError(error_stack::report!(*err)),
};
diesel_error.change_context(new_err)
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 82,
"total_crates": null
}
|
fn_clm_router_insert_payment_intents_batch_for_sample_data_5035841115351132113
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/sample_data
// Implementation of storage_impl::MockDb for BatchSampleDataInterface
async fn insert_payment_intents_batch_for_sample_data(
&self,
_state: &KeyManagerState,
_batch: Vec<PaymentIntent>,
_key_store: &MerchantKeyStore,
) -> CustomResult<Vec<PaymentIntent>, StorageError> {
Err(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_payment_attempts_batch_for_sample_data_5035841115351132113
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/sample_data
// Implementation of storage_impl::MockDb for BatchSampleDataInterface
async fn insert_payment_attempts_batch_for_sample_data(
&self,
_batch: Vec<PaymentAttemptBatchNew>,
) -> CustomResult<Vec<PaymentAttempt>, StorageError> {
Err(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_refunds_batch_for_sample_data_5035841115351132113
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/sample_data
// Implementation of storage_impl::MockDb for BatchSampleDataInterface
async fn insert_refunds_batch_for_sample_data(
&self,
_batch: Vec<RefundNew>,
) -> CustomResult<Vec<Refund>, StorageError> {
Err(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_disputes_batch_for_sample_data_5035841115351132113
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/db/user/sample_data
// Implementation of storage_impl::MockDb for BatchSampleDataInterface
async fn insert_disputes_batch_for_sample_data(
&self,
_batch: Vec<DisputeNew>,
) -> CustomResult<Vec<Dispute>, StorageError> {
Err(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_new_-3835928664164353649
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/outgoing_webhook_logs
// Inherent implementation for OutgoingWebhookEvent
pub fn new(
tenant_id: common_utils::id_type::TenantId,
merchant_id: common_utils::id_type::MerchantId,
event_id: String,
event_type: OutgoingWebhookEventType,
content: Option<OutgoingWebhookEventContent>,
error: Option<Value>,
initial_attempt_id: Option<String>,
status_code: Option<u16>,
delivery_attempt: Option<WebhookDeliveryAttempt>,
) -> Self {
Self {
tenant_id,
merchant_id,
event_id,
event_type,
content,
is_error: error.is_some(),
error,
created_at_timestamp: OffsetDateTime::now_utc().unix_timestamp_nanos() / 1_000_000,
initial_attempt_id,
status_code,
delivery_attempt,
}
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14469,
"total_crates": null
}
|
fn_clm_router_get_outgoing_webhook_event_content_-3835928664164353649
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/outgoing_webhook_logs
// Implementation of OutgoingWebhookContent for OutgoingWebhookEventMetric
fn get_outgoing_webhook_event_content(&self) -> Option<OutgoingWebhookEventContent> {
match self {
Self::PaymentDetails(payment_payload) => Some(OutgoingWebhookEventContent::Payment {
payment_id: payment_payload.id.clone(),
content: masking::masked_serialize(&payment_payload)
.unwrap_or(serde_json::json!({"error":"failed to serialize"})),
}),
Self::RefundDetails(refund_payload) => Some(OutgoingWebhookEventContent::Refund {
payment_id: refund_payload.payment_id.clone(),
refund_id: refund_payload.id.clone(),
content: masking::masked_serialize(&refund_payload)
.unwrap_or(serde_json::json!({"error":"failed to serialize"})),
}),
Self::DisputeDetails(dispute_payload) => {
//TODO: add support for dispute outgoing webhook
todo!()
}
Self::MandateDetails(mandate_payload) => Some(OutgoingWebhookEventContent::Mandate {
payment_method_id: mandate_payload.payment_method_id.clone(),
mandate_id: mandate_payload.mandate_id.clone(),
content: masking::masked_serialize(&mandate_payload)
.unwrap_or(serde_json::json!({"error":"failed to serialize"})),
}),
#[cfg(feature = "payouts")]
Self::PayoutDetails(payout_payload) => Some(OutgoingWebhookEventContent::Payout {
payout_id: payout_payload.payout_id.clone(),
content: masking::masked_serialize(&payout_payload)
.unwrap_or(serde_json::json!({"error":"failed to serialize"})),
}),
}
}
|
{
"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_key_-3835928664164353649
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/outgoing_webhook_logs
// Implementation of OutgoingWebhookEvent for KafkaMessage
fn key(&self) -> String {
self.event_id.clone()
}
|
{
"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_event_type_-3835928664164353649
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/outgoing_webhook_logs
// Implementation of OutgoingWebhookEvent for KafkaMessage
fn event_type(&self) -> EventType {
EventType::OutgoingWebhookLogs
}
|
{
"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_new_-8504238267071239946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/api_logs
// Inherent implementation for ApiEvent
pub fn new(
tenant_id: common_utils::id_type::TenantId,
merchant_id: Option<common_utils::id_type::MerchantId>,
api_flow: &impl FlowMetric,
request_id: &RequestId,
latency: u128,
status_code: i64,
request: serde_json::Value,
response: Option<serde_json::Value>,
hs_latency: Option<u128>,
auth_type: AuthenticationType,
error: Option<serde_json::Value>,
event_type: ApiEventsType,
http_req: &HttpRequest,
http_method: &http::Method,
infra_components: Option<serde_json::Value>,
) -> Self {
Self {
tenant_id,
merchant_id,
api_flow: api_flow.to_string(),
created_at_timestamp: OffsetDateTime::now_utc().unix_timestamp_nanos() / 1_000_000,
request_id: request_id.as_hyphenated().to_string(),
latency,
status_code,
request: request.to_string(),
response: response.map(|resp| resp.to_string()),
auth_type,
error,
ip_addr: http_req
.connection_info()
.realip_remote_addr()
.map(ToOwned::to_owned),
user_agent: http_req
.headers()
.get("user-agent")
.and_then(|user_agent_value| user_agent_value.to_str().ok().map(ToOwned::to_owned)),
url_path: http_req.path().to_string(),
event_type,
hs_latency,
http_method: http_method.to_string(),
infra_components,
}
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14503,
"total_crates": null
}
|
fn_clm_router_key_-8504238267071239946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/api_logs
// Implementation of ApiEvent for KafkaMessage
fn key(&self) -> String {
self.request_id.clone()
}
|
{
"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_get_api_event_type_-8504238267071239946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/api_logs
// Implementation of PollId for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Poll {
poll_id: self.poll_id.clone(),
})
}
|
{
"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_event_type_-8504238267071239946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/api_logs
// Implementation of ApiEvent for KafkaMessage
fn event_type(&self) -> EventType {
EventType::ApiLogs
}
|
{
"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_new_8827229566655665347
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/audit_events
// Inherent implementation for AuditEvent
pub fn new(event_type: AuditEventType) -> Self {
Self {
event_type,
created_at: common_utils::date_time::now(),
}
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14465,
"total_crates": null
}
|
fn_clm_router_key_8827229566655665347
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/audit_events
// Implementation of AuditEvent for EventInfo
fn key(&self) -> String {
"event".to_string()
}
|
{
"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_data_8827229566655665347
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/audit_events
// Implementation of AuditEvent for EventInfo
fn data(&self) -> error_stack::Result<Self::Data, events::EventsError> {
Ok(self.clone())
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 25,
"total_crates": null
}
|
fn_clm_router_timestamp_8827229566655665347
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/audit_events
// Implementation of AuditEvent for Event
fn timestamp(&self) -> PrimitiveDateTime {
self.created_at
}
|
{
"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_identifier_8827229566655665347
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/audit_events
// Implementation of AuditEvent for Event
fn identifier(&self) -> String {
let event_type = match &self.event_type {
AuditEventType::Error { .. } => "error",
AuditEventType::PaymentCreated => "payment_created",
AuditEventType::PaymentConfirm { .. } => "payment_confirm",
AuditEventType::ConnectorDecided => "connector_decided",
AuditEventType::ConnectorCalled => "connector_called",
AuditEventType::PaymentCapture { .. } => "payment_capture",
AuditEventType::RefundCreated => "refund_created",
AuditEventType::RefundSuccess => "refund_success",
AuditEventType::RefundFail => "refund_fail",
AuditEventType::PaymentCancelled { .. } => "payment_cancelled",
AuditEventType::PaymentUpdate { .. } => "payment_update",
AuditEventType::PaymentApprove => "payment_approve",
AuditEventType::PaymentCreate => "payment_create",
AuditEventType::PaymentStatus => "payment_status",
AuditEventType::PaymentCompleteAuthorize => "payment_complete_authorize",
AuditEventType::PaymentReject { .. } => "payment_rejected",
};
format!(
"{event_type}-{}",
self.timestamp().assume_utc().unix_timestamp_nanos()
)
}
|
{
"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_key_-2820560986673861594
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/routing_api_logs
// Implementation of RoutingEvent for KafkaMessage
fn key(&self) -> String {
format!(
"{}-{}-{}",
self.get_merchant_id(),
self.get_profile_id(),
self.get_payment_id()
)
}
|
{
"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_event_type_-2820560986673861594
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/routing_api_logs
// Implementation of RoutingEvent for KafkaMessage
fn event_type(&self) -> EventType {
EventType::RoutingApiLogs
}
|
{
"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_key_-405621039151698289
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/connector_api_logs
// Implementation of ConnectorEvent for KafkaMessage
fn key(&self) -> String {
self.request_id.clone()
}
|
{
"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_event_type_-405621039151698289
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/connector_api_logs
// Implementation of ConnectorEvent for KafkaMessage
fn event_type(&self) -> EventType {
EventType::ConnectorApiLogs
}
|
{
"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_log_event_-4194716827507124643
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/event_logger
// Inherent implementation for EventLogger
pub(super) fn log_event<T: KafkaMessage>(&self, event: &T) {
logger::info!(event = ?event.masked_serialize().unwrap_or_else(|e| serde_json::json!({"error": e.to_string()})), event_type =? event.event_type(), event_id =? event.key(), log_type =? "event");
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 159,
"total_crates": null
}
|
fn_clm_router_send_message_-4194716827507124643
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/events/event_logger
// Implementation of EventLogger for MessagingInterface
fn send_message<T>(
&self,
data: T,
metadata: HashMap<String, String>,
_timestamp: PrimitiveDateTime,
) -> error_stack::Result<(), EventsError>
where
T: Message<Class = Self::MessageClass> + ErasedMaskSerialize,
{
logger::info!(event =? data.masked_serialize().unwrap_or_else(|e| serde_json::json!({"error": e.to_string()})), event_type =? data.get_message_class(), event_id =? data.identifier(), log_type =? "event", metadata = ?metadata);
Ok(())
}
|
{
"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_delete_tokenized_data_api_3187858954963520895
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/tokenization
pub async fn delete_tokenized_data_api(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<id_type::GlobalTokenId>,
json_payload: web::Json<api_models::tokenization::DeleteTokenDataRequest>,
) -> HttpResponse {
let flow = Flow::TokenizationDelete;
let payload = json_payload.into_inner();
let session_id = payload.session_id.clone();
let token_id = path.into_inner();
Box::pin(api_service::server_wrap(
flow,
state,
&req,
payload,
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
tokenization::delete_tokenized_data_core(state, merchant_context, &token_id, req)
},
auth::api_or_client_auth(
&auth::V2ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
},
&auth::V2ClientAuth(
common_utils::types::authentication::ResourceId::PaymentMethodSession(session_id),
),
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 36,
"total_crates": null
}
|
fn_clm_router_create_token_vault_api_3187858954963520895
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/tokenization
pub async fn create_token_vault_api(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<api_models::tokenization::GenericTokenizationRequest>,
) -> HttpResponse {
let flow = Flow::TokenizationCreate;
let payload = json_payload.into_inner();
let customer_id = payload.customer_id.clone();
Box::pin(api_service::server_wrap(
flow,
state,
&req,
payload,
|state, auth: auth::AuthenticationData, request, _| async move {
tokenization::create_vault_token_core(
state,
&auth.merchant_account,
&auth.key_store,
request,
)
.await
},
auth::api_or_client_auth(
&auth::V2ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
},
&auth::V2ClientAuth(common_utils::types::authentication::ResourceId::Customer(
customer_id,
)),
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 28,
"total_crates": null
}
|
fn_clm_router_invalidate_3163760276621837443
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/cache
pub async fn invalidate(
state: web::Data<AppState>,
req: HttpRequest,
key: web::Path<String>,
) -> impl Responder {
let flow = Flow::CacheInvalidate;
let key = key.into_inner().to_owned();
api::server_wrap(
flow,
state,
&req,
&key,
|state, _, key, _| cache::invalidate(state, key),
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
)
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
}
|
fn_clm_router_rust_locker_migration_-4552832365783835094
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/locker_migration
pub async fn rust_locker_migration(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<common_utils::id_type::MerchantId>,
) -> HttpResponse {
let flow = Flow::RustLockerMigration;
let merchant_id = path.into_inner();
Box::pin(api::server_wrap(
flow,
state,
&req,
&merchant_id,
|state, _, _, _| locker_migration::rust_locker_migration(state, &merchant_id),
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
}
|
fn_clm_router_from_6933595531568063109
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payment_methods
// Implementation of payment_methods::PaymentMethodIntentConfirm for From<PaymentMethodIntentConfirmInternal>
fn from(item: PaymentMethodIntentConfirmInternal) -> Self {
item.request
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
}
|
fn_clm_router_get_merchant_account_6933595531568063109
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payment_methods
async fn get_merchant_account(
state: &SessionState,
merchant_id: &id_type::MerchantId,
) -> CustomResult<(MerchantKeyStore, domain::MerchantAccount), errors::ApiErrorResponse> {
let key_manager_state = &state.into();
let key_store = state
.store
.get_merchant_key_store_by_merchant_id(
key_manager_state,
merchant_id,
&state.store.get_master_key().to_vec().into(),
)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let merchant_account = state
.store
.find_merchant_account_by_merchant_id(key_manager_state, merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
Ok((key_store, merchant_account))
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2557,
"total_crates": null
}
|
fn_clm_router_insert_6933595531568063109
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payment_methods
// Implementation of None for ParentPaymentMethodToken
pub async fn insert(
&self,
fulfillment_time: i64,
token: PaymentTokenData,
state: &SessionState,
) -> CustomResult<(), errors::ApiErrorResponse> {
let redis_conn = state
.store
.get_redis_conn()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to get redis connection")?;
redis_conn
.serialize_and_set_key_with_expiry(
&self.key_for_token.as_str().into(),
token,
fulfillment_time,
)
.await
.change_context(errors::StorageError::KVError)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to add token in redis")?;
Ok(())
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 1143,
"total_crates": null
}
|
fn_clm_router_migrate_payment_methods_6933595531568063109
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payment_methods
pub async fn migrate_payment_methods(
state: web::Data<AppState>,
req: HttpRequest,
MultipartForm(form): MultipartForm<migration::PaymentMethodsMigrateForm>,
) -> HttpResponse {
let flow = Flow::PaymentMethodsMigrate;
let (merchant_id, records, merchant_connector_ids) =
match form.validate_and_get_payment_method_records() {
Ok((merchant_id, records, merchant_connector_ids)) => {
(merchant_id, records, merchant_connector_ids)
}
Err(e) => return api::log_and_return_error_response(e.into()),
};
Box::pin(api::server_wrap(
flow,
state,
&req,
records,
|state, _, req, _| {
let merchant_id = merchant_id.clone();
let merchant_connector_ids = merchant_connector_ids.clone();
async move {
let (key_store, merchant_account) =
get_merchant_account(&state, &merchant_id).await?;
// Create customers if they are not already present
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(merchant_account.clone(), key_store.clone()),
));
let mut mca_cache = std::collections::HashMap::new();
let customers = Vec::<PaymentMethodCustomerMigrate>::foreign_try_from((
&req,
merchant_id.clone(),
))
.map_err(|e| errors::ApiErrorResponse::InvalidRequestData {
message: e.to_string(),
})?;
for record in &customers {
if let Some(connector_customer_details) = &record.connector_customer_details {
for connector_customer in connector_customer_details {
if !mca_cache.contains_key(&connector_customer.merchant_connector_id) {
let mca = state
.store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
&(&state).into(),
&merchant_id,
&connector_customer.merchant_connector_id,
merchant_context.get_merchant_key_store(),
)
.await
.to_not_found_response(
errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
id: connector_customer.merchant_connector_id.get_string_repr().to_string(),
},
)?;
mca_cache
.insert(connector_customer.merchant_connector_id.clone(), mca);
}
}
}
}
customers::migrate_customers(state.clone(), customers, merchant_context.clone())
.await
.change_context(errors::ApiErrorResponse::InternalServerError)?;
let controller = cards::PmCards {
state: &state,
merchant_context: &merchant_context,
};
Box::pin(migration::migrate_payment_methods(
&(&state).into(),
req,
&merchant_id,
&merchant_context,
merchant_connector_ids,
&controller,
))
.await
}
},
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 81,
"total_crates": null
}
|
fn_clm_router_delete_6933595531568063109
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payment_methods
// Implementation of None for ParentPaymentMethodToken
pub async fn delete(&self, state: &SessionState) -> CustomResult<(), errors::ApiErrorResponse> {
let redis_conn = state
.store
.get_redis_conn()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to get redis connection")?;
match redis_conn
.delete_key(&self.key_for_token.as_str().into())
.await
{
Ok(_) => Ok(()),
Err(err) => {
{
logger::info!("Error while deleting redis key: {:?}", err)
};
Ok(())
}
}
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 60,
"total_crates": null
}
|
fn_clm_router_dummy_connector_refund_1479341466111630946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/dummy_connector
pub async fn dummy_connector_refund(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<types::DummyConnectorRefundRequest>,
path: web::Path<common_utils::id_type::PaymentId>,
) -> impl actix_web::Responder {
let flow = types::Flow::DummyRefundCreate;
let mut payload = json_payload.into_inner();
payload.payment_id = Some(path.into_inner());
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
|state, _: (), req, _| core::refund_payment(state, req),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 20,
"total_crates": null
}
|
fn_clm_router_dummy_connector_complete_payment_1479341466111630946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/dummy_connector
pub async fn dummy_connector_complete_payment(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
path: web::Path<String>,
json_payload: web::Query<types::DummyConnectorPaymentCompleteBody>,
) -> impl actix_web::Responder {
let flow = types::Flow::DummyPaymentComplete;
let attempt_id = path.into_inner();
let payload = types::DummyConnectorPaymentCompleteRequest {
attempt_id,
confirm: json_payload.confirm,
};
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
|state, _: (), req, _| core::payment_complete(state, req),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 18,
"total_crates": null
}
|
fn_clm_router_dummy_connector_payment_1479341466111630946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/dummy_connector
pub async fn dummy_connector_payment(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<types::DummyConnectorPaymentRequest>,
) -> impl actix_web::Responder {
let payload = json_payload.into_inner();
let flow = types::Flow::DummyPaymentCreate;
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
|state, _: (), req, _| core::payment(state, req),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 18,
"total_crates": null
}
|
fn_clm_router_dummy_connector_authorize_payment_1479341466111630946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/dummy_connector
pub async fn dummy_connector_authorize_payment(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
path: web::Path<String>,
) -> impl actix_web::Responder {
let flow = types::Flow::DummyPaymentAuthorize;
let attempt_id = path.into_inner();
let payload = types::DummyConnectorPaymentConfirmRequest { attempt_id };
api::server_wrap(
flow,
state,
&req,
payload,
|state, _: (), req, _| core::payment_authorize(state, req),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
)
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 16,
"total_crates": null
}
|
fn_clm_router_dummy_connector_payment_data_1479341466111630946
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/dummy_connector
pub async fn dummy_connector_payment_data(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
path: web::Path<String>,
) -> impl actix_web::Responder {
let flow = types::Flow::DummyPaymentRetrieve;
let payment_id = path.into_inner();
let payload = types::DummyConnectorPaymentRetrieveRequest { payment_id };
api::server_wrap(
flow,
state,
&req,
payload,
|state, _: (), req, _| core::payment_data(state, req),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
)
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 16,
"total_crates": null
}
|
fn_clm_router_signout_hypersense_token_4789128577296450263
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/hypersense
pub async fn signout_hypersense_token(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<external_service_auth_api::ExternalSignoutTokenRequest>,
) -> HttpResponse {
let flow = Flow::HypersenseSignoutToken;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, _: (), json_payload, _| {
external_service_auth::signout_external_token(state, json_payload)
},
&authentication::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 20,
"total_crates": null
}
|
fn_clm_router_verify_hypersense_token_4789128577296450263
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/hypersense
pub async fn verify_hypersense_token(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<external_service_auth_api::ExternalVerifyTokenRequest>,
) -> HttpResponse {
let flow = Flow::HypersenseVerifyToken;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, _: (), json_payload, _| {
external_service_auth::verify_external_token(
state,
json_payload,
ExternalServiceType::Hypersense,
)
},
&authentication::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 20,
"total_crates": null
}
|
fn_clm_router_get_hypersense_token_4789128577296450263
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/hypersense
pub async fn get_hypersense_token(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
let flow = Flow::HypersenseTokenRequest;
Box::pin(api::server_wrap(
flow,
state,
&req,
(),
|state, user, _, _| {
external_service_auth::generate_external_token(
state,
user,
ExternalServiceType::Hypersense,
)
},
&authentication::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 16,
"total_crates": null
}
|
fn_clm_router_proxy_-8092424799841360434
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/proxy
pub async fn proxy(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
payload: web::Json<api_models::proxy::ProxyRequest>,
) -> impl Responder {
let flow = Flow::Proxy;
Box::pin(api::server_wrap(
flow,
state,
&req,
payload.into_inner(),
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
proxy::proxy_core(state, merchant_context, req)
},
&auth::V2ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
},
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 36,
"total_crates": null
}
|
fn_clm_router_refunds_create_-8416252811489512494
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/refunds
pub async fn refunds_create(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<refunds::RefundsCreateRequest>,
) -> HttpResponse {
let flow = Flow::RefundsCreate;
let global_refund_id =
common_utils::id_type::GlobalRefundId::generate(&state.conf.cell_information.id);
let payload = json_payload.into_inner();
let internal_refund_create_payload =
internal_payload_types::RefundsGenericRequestWithResourceId {
global_refund_id: global_refund_id.clone(),
payment_id: Some(payload.payment_id.clone()),
payload,
};
let auth_type = if state.conf.merchant_id_auth.merchant_id_auth_enabled {
&auth::MerchantIdAuth
} else {
auth::auth_type(
&auth::V2ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
},
&auth::JWTAuth {
permission: Permission::ProfileRefundWrite,
},
req.headers(),
)
};
Box::pin(api::server_wrap(
flow,
state,
&req,
internal_refund_create_payload,
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refund_create_core(
state,
merchant_context,
req.payload,
global_refund_id.clone(),
)
},
auth_type,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 36,
"total_crates": null
}
|
fn_clm_router_refunds_retrieve_with_gateway_creds_-8416252811489512494
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/refunds
pub async fn refunds_retrieve_with_gateway_creds(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<common_utils::id_type::GlobalRefundId>,
payload: web::Json<api_models::refunds::RefundsRetrievePayload>,
) -> HttpResponse {
let flow = match payload.force_sync {
Some(true) => Flow::RefundsRetrieveForceSync,
_ => Flow::RefundsRetrieve,
};
tracing::Span::current().record("flow", flow.to_string());
let refund_request = refunds::RefundsRetrieveRequest {
refund_id: path.into_inner(),
force_sync: payload.force_sync,
merchant_connector_details: payload.merchant_connector_details.clone(),
};
let auth_type = if state.conf.merchant_id_auth.merchant_id_auth_enabled {
&auth::MerchantIdAuth
} else {
auth::auth_type(
&auth::V2ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
},
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
},
req.headers(),
)
};
Box::pin(api::server_wrap(
flow,
state,
&req,
refund_request,
|state, auth: auth::AuthenticationData, refund_request, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refund_retrieve_core_with_refund_id(
state,
merchant_context,
auth.profile,
refund_request,
)
},
auth_type,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 36,
"total_crates": null
}
|
fn_clm_router_refunds_retrieve_-8416252811489512494
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/refunds
pub async fn refunds_retrieve(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<common_utils::id_type::GlobalRefundId>,
query_params: web::Query<api_models::refunds::RefundsRetrieveBody>,
) -> HttpResponse {
let refund_request = refunds::RefundsRetrieveRequest {
refund_id: path.into_inner(),
force_sync: query_params.force_sync,
merchant_connector_details: None,
};
let flow = match query_params.force_sync {
Some(true) => Flow::RefundsRetrieveForceSync,
_ => Flow::RefundsRetrieve,
};
tracing::Span::current().record("flow", flow.to_string());
Box::pin(api::server_wrap(
flow,
state,
&req,
refund_request,
|state, auth: auth::AuthenticationData, refund_request, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refund_retrieve_core_with_refund_id(
state,
merchant_context,
auth.profile,
refund_request,
)
},
auth::auth_type(
&auth::V2ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
},
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
},
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 34,
"total_crates": null
}
|
fn_clm_router_refunds_retrieve_with_body_-8416252811489512494
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/refunds
pub async fn refunds_retrieve_with_body(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<refunds::RefundsRetrieveRequest>,
) -> HttpResponse {
let flow = match json_payload.force_sync {
Some(true) => Flow::RefundsRetrieveForceSync,
_ => Flow::RefundsRetrieve,
};
tracing::Span::current().record("flow", flow.to_string());
Box::pin(api::server_wrap(
flow,
state,
&req,
json_payload.into_inner(),
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refund_response_wrapper(
state,
merchant_context,
auth.profile_id,
req,
refund_retrieve_core_with_refund_id,
)
},
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
}
|
fn_clm_router_refunds_list_profile_-8416252811489512494
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/refunds
pub async fn refunds_list_profile(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<api_models::refunds::RefundListRequest>,
) -> HttpResponse {
let flow = Flow::RefundsList;
Box::pin(api::server_wrap(
flow,
state,
&req,
payload.into_inner(),
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
refund_list(
state,
merchant_context,
auth.profile_id.map(|profile_id| vec![profile_id]),
req,
)
},
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
&auth::JWTAuth {
permission: Permission::ProfileRefundRead,
},
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
}
|
fn_clm_router_deep_health_check_func_5172275968436437890
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/health
async fn deep_health_check_func(
state: app::SessionState,
) -> RouterResponse<RouterHealthCheckResponse> {
logger::info!("Deep health check was called");
logger::debug!("Database health check begin");
let db_status = state.health_check_db().await.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Database",
message,
})
})?;
logger::debug!("Database health check end");
logger::debug!("Redis health check begin");
let redis_status = state.health_check_redis().await.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Redis",
message,
})
})?;
logger::debug!("Redis health check end");
logger::debug!("Locker health check begin");
let locker_status = state.health_check_locker().await.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Locker",
message,
})
})?;
logger::debug!("Locker health check end");
logger::debug!("Analytics health check begin");
#[cfg(feature = "olap")]
let analytics_status = state.health_check_analytics().await.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Analytics",
message,
})
})?;
logger::debug!("Analytics health check end");
logger::debug!("gRPC health check begin");
#[cfg(feature = "dynamic_routing")]
let grpc_health_check = state.health_check_grpc().await.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "gRPC services",
message,
})
})?;
logger::debug!("gRPC health check end");
logger::debug!("Decision Engine health check begin");
#[cfg(feature = "dynamic_routing")]
let decision_engine_health_check =
state
.health_check_decision_engine()
.await
.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Decision Engine service",
message,
})
})?;
logger::debug!("Decision Engine health check end");
logger::debug!("Opensearch health check begin");
#[cfg(feature = "olap")]
let opensearch_status = state.health_check_opensearch().await.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Opensearch",
message,
})
})?;
logger::debug!("Opensearch health check end");
logger::debug!("Outgoing Request health check begin");
let outgoing_check = state.health_check_outgoing().await.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Outgoing Request",
message,
})
})?;
logger::debug!("Outgoing Request health check end");
logger::debug!("Unified Connector Service health check begin");
let unified_connector_service_status = state
.health_check_unified_connector_service()
.await
.map_err(|error| {
let message = error.to_string();
error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Unified Connector Service",
message,
})
})?;
logger::debug!("Unified Connector Service health check end");
let response = RouterHealthCheckResponse {
database: db_status.into(),
redis: redis_status.into(),
vault: locker_status.into(),
#[cfg(feature = "olap")]
analytics: analytics_status.into(),
#[cfg(feature = "olap")]
opensearch: opensearch_status.into(),
outgoing_request: outgoing_check.into(),
#[cfg(feature = "dynamic_routing")]
grpc_health_check,
#[cfg(feature = "dynamic_routing")]
decision_engine: decision_engine_health_check.into(),
unified_connector_service: unified_connector_service_status.into(),
};
Ok(api::ApplicationResponse::Json(response))
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 99,
"total_crates": null
}
|
fn_clm_router_deep_health_check_5172275968436437890
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/health
pub async fn deep_health_check(
state: web::Data<app::AppState>,
request: HttpRequest,
) -> impl actix_web::Responder {
metrics::HEALTH_METRIC.add(1, &[]);
let flow = Flow::DeepHealthCheck;
Box::pin(api::server_wrap(
flow,
state,
&request,
(),
|state, _: (), _, _| deep_health_check_func(state),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 39,
"total_crates": null
}
|
fn_clm_router_health_5172275968436437890
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/health
pub async fn health() -> impl actix_web::Responder {
metrics::HEALTH_METRIC.add(1, &[]);
logger::info!("Health was called");
actix_web::HttpResponse::Ok().body("health is good")
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 17,
"total_crates": null
}
|
fn_clm_router_payouts_confirm_-5579759040077786759
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payouts
pub async fn payouts_confirm(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<payout_types::PayoutCreateRequest>,
path: web::Path<id_type::PayoutId>,
) -> HttpResponse {
let flow = Flow::PayoutsConfirm;
let mut payload = json_payload.into_inner();
let payout_id = path.into_inner();
tracing::Span::current().record("payout_id", payout_id.get_string_repr());
payload.payout_id = Some(payout_id);
payload.confirm = Some(true);
let api_auth = auth::ApiKeyAuth::default();
let (auth_type, _auth_flow) =
match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth) {
Ok(auth) => auth,
Err(e) => return api::log_and_return_error_response(e),
};
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
|state, auth, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
payouts_confirm_core(state, merchant_context, req)
},
&*auth_type,
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 40,
"total_crates": null
}
|
fn_clm_router_payouts_retrieve_-5579759040077786759
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payouts
pub async fn payouts_retrieve(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<id_type::PayoutId>,
query_params: web::Query<payout_types::PayoutRetrieveBody>,
) -> HttpResponse {
let payout_retrieve_request = payout_types::PayoutRetrieveRequest {
payout_id: path.into_inner(),
force_sync: query_params.force_sync.to_owned(),
merchant_id: query_params.merchant_id.to_owned(),
};
let flow = Flow::PayoutsRetrieve;
Box::pin(api::server_wrap(
flow,
state,
&req,
payout_retrieve_request,
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
payouts_retrieve_core(state, merchant_context, auth.profile_id, req)
},
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
},
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 34,
"total_crates": null
}
|
fn_clm_router_payouts_list_profile_-5579759040077786759
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payouts
pub async fn payouts_list_profile(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Query<payout_types::PayoutListConstraints>,
) -> HttpResponse {
let flow = Flow::PayoutsList;
let payload = json_payload.into_inner();
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
payouts_list_core(
state,
merchant_context,
auth.profile_id.map(|profile_id| vec![profile_id]),
req,
)
},
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
},
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
}
|
fn_clm_router_payouts_list_by_filter_profile_-5579759040077786759
|
clm
|
function
|
// Repository: hyperswitch
// Crate: router
// Purpose: Main application server handling HTTP requests, authentication, and business logic orchestration
// Module: crates/router/src/routes/payouts
pub async fn payouts_list_by_filter_profile(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<payout_types::PayoutListFilterConstraints>,
) -> HttpResponse {
let flow = Flow::PayoutsList;
let payload = json_payload.into_inner();
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
|state, auth: auth::AuthenticationData, req, _| {
let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
domain::Context(auth.merchant_account, auth.key_store),
));
payouts_filtered_list_core(
state,
merchant_context,
auth.profile_id.map(|profile_id| vec![profile_id]),
req,
)
},
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth {
is_connected_allowed: false,
is_platform_allowed: false,
}),
&auth::JWTAuth {
permission: Permission::ProfilePayoutRead,
},
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
}
|
{
"crate": "router",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.