text
stringlengths
70
351k
source
stringclasses
4 values
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn list_routing_algorithm_metadata_by_merchant_id( &self, _merchant_id: &common_utils::id_type::MerchantId, _limit: i64, _offset: i64, ) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn list_routing_algorithm_metadata_by_profile_id( &self, _profile_id: &common_utils::id_type::ProfileId, _limit: i64, _offset: i64, ) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id( &self, _algorithm_id: &common_utils::id_type::RoutingId, _profile_id: &common_utils::id_type::ProfileId, ) -> StorageResult<routing_storage::RoutingProfileMetadata> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn find_routing_algorithm_by_algorithm_id_merchant_id( &self, _algorithm_id: &common_utils::id_type::RoutingId, _merchant_id: &common_utils::id_type::MerchantId, ) -> StorageResult<routing_storage::RoutingAlgorithm> { Err(errors::StorageError::MockDbError)? }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn find_routing_algorithm_by_profile_id_algorithm_id( &self, _profile_id: &common_utils::id_type::ProfileId, _algorithm_id: &common_utils::id_type::RoutingId, ) -> StorageResult<routing_storage::RoutingAlgorithm> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn insert_routing_algorithm( &self, _routing_algorithm: routing_storage::RoutingAlgorithm, ) -> StorageResult<routing_storage::RoutingAlgorithm> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn list_routing_algorithm_metadata_by_merchant_id_transaction_type( &self, merchant_id: &common_utils::id_type::MerchantId, transaction_type: &common_enums::TransactionType, limit: i64, offset: i64, ) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn list_routing_algorithm_metadata_by_merchant_id( &self, merchant_id: &common_utils::id_type::MerchantId, limit: i64, offset: i64, ) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn list_routing_algorithm_metadata_by_profile_id( &self, profile_id: &common_utils::id_type::ProfileId, limit: i64, offset: i64, ) -> StorageResult<Vec<routing_storage::RoutingProfileMetadata>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn find_routing_algorithm_metadata_by_algorithm_id_profile_id( &self, algorithm_id: &common_utils::id_type::RoutingId, profile_id: &common_utils::id_type::ProfileId, ) -> StorageResult<routing_storage::RoutingProfileMetadata> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn find_routing_algorithm_by_algorithm_id_merchant_id( &self, algorithm_id: &common_utils::id_type::RoutingId, merchant_id: &common_utils::id_type::MerchantId, ) -> StorageResult<routing_storage::RoutingAlgorithm> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn find_routing_algorithm_by_profile_id_algorithm_id( &self, profile_id: &common_utils::id_type::ProfileId, algorithm_id: &common_utils::id_type::RoutingId, ) -> StorageResult<routing_storage::RoutingAlgorithm> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/routing_algorithm.rs | crate: router use diesel_models::routing_algorithm as routing_storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; type StorageResult<T> = CustomResult<T, errors::StorageError>; async fn insert_routing_algorithm( &self, routing_algorithm: routing_storage::RoutingAlgorithm, ) -> StorageResult<routing_storage::RoutingAlgorithm> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn update_address_by_merchant_id_customer_id( &self, state: &KeyManagerState, customer_id: &id_type::CustomerId, merchant_id: &id_type::MerchantId, address_update: storage_types::AddressUpdate, key_store: &domain::MerchantKeyStore, ) -> CustomResult<Vec<domain::Address>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn update_address_for_payments( &self, state: &KeyManagerState, this: domain::PaymentAddress, address_update: domain::AddressUpdate, _payment_id: id_type::PaymentId, key_store: &domain::MerchantKeyStore, _storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn update_address( &self, state: &KeyManagerState, address_id: String, address_update: storage_types::AddressUpdate, key_store: &domain::MerchantKeyStore, ) -> CustomResult<domain::Address, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn find_address_by_merchant_id_payment_id_address_id( &self, state: &KeyManagerState, _merchant_id: &id_type::MerchantId, _payment_id: &id_type::PaymentId, address_id: &str, key_store: &domain::MerchantKeyStore, _storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn find_address_by_address_id( &self, state: &KeyManagerState, address_id: &str, key_store: &domain::MerchantKeyStore, ) -> CustomResult<domain::Address, errors::StorageError> { match self .addresses .lock() .await .iter() .find(|address| address.address_id == address_id) { Some(address) => address .clone() .convert( state, key_store.key.get_inner(), key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError), None => { return Err( errors::StorageError::ValueNotFound("address not found".to_string()).into(), ) } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn update_address_by_merchant_id_customer_id( &self, state: &KeyManagerState, customer_id: &id_type::CustomerId, merchant_id: &id_type::MerchantId, address: storage_types::AddressUpdate, key_store: &domain::MerchantKeyStore, ) -> CustomResult<Vec<domain::Address>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn insert_address_for_payments( &self, state: &KeyManagerState, _payment_id: &id_type::PaymentId, address: domain::PaymentAddress, key_store: &domain::MerchantKeyStore, _storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn find_address_by_merchant_id_payment_id_address_id( &self, state: &KeyManagerState, merchant_id: &id_type::MerchantId, payment_id: &id_type::PaymentId, address_id: &str, key_store: &domain::MerchantKeyStore, _storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { let conn = connection::pg_connection_read(self).await?; storage_types::Address::find_by_merchant_id_payment_id_address_id( &conn, merchant_id, payment_id, address_id, ) .await .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|address| async { address .convert(state, key_store.key.get_inner(), merchant_id.clone().into()) .await .change_context(errors::StorageError::DecryptionError) }) .await }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn insert_address_for_payments( &self, state: &KeyManagerState, _payment_id: &id_type::PaymentId, address_new: domain::PaymentAddress, key_store: &domain::MerchantKeyStore, _storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn find_address_by_address_id( &self, state: &KeyManagerState, address_id: &str, key_store: &domain::MerchantKeyStore, ) -> CustomResult<domain::Address, errors::StorageError> { { Some(address) => address .clone() .convert( state, key_store.key.get_inner(), key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError),<|fim_suffix|> <|fim_middle|> None => { return Err( errors::StorageError::ValueNotFound("address not found".to_string()).into(), ) } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn insert_address_for_customers( &self, state: &KeyManagerState, address_new: domain::CustomerAddress, key_store: &domain::MerchantKeyStore, ) -> CustomResult<domain::Address, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn insert_address_for_payments( &self, state: &KeyManagerState, _payment_id: &id_type::PaymentId, address_new: domain::PaymentAddress, key_store: &domain::MerchantKeyStore, _storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { let mut addresses = self.addresses.lock().await; let address = Conversion::convert(address_new) .await .change_context(errors::StorageError::EncryptionError)?; addresses.push(address.clone()); address .convert( state, key_store.key.get_inner(), key_store.merchant_id.clone().into(), ) .await .change_context(errors::StorageError::DecryptionError) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn update_address( &self, state: &KeyManagerState, address_id: String, address: storage_types::AddressUpdate, key_store: &domain::MerchantKeyStore, ) -> CustomResult<domain::Address, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/address.rs | crate: router use common_utils::{id_type, types::keymanager::KeyManagerState}; use diesel_models::{address::AddressUpdateInternal, enums::MerchantStorageScheme}; use crate::{ core::errors::{self, CustomResult}, types::{ domain::{ self, behaviour::{Conversion, ReverseConversion}, }, storage as storage_types, }, }; async fn update_address_for_payments( &self, state: &KeyManagerState, this: domain::PaymentAddress, address_update: domain::AddressUpdate, payment_id: id_type::PaymentId, key_store: &domain::MerchantKeyStore, storage_scheme: MerchantStorageScheme, ) -> CustomResult<domain::PaymentAddress, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn find_blocklist_entry_by_merchant_id_fingerprint_id( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn list_blocklist_entries_by_merchant_id( &self, merchant_id: &common_utils::id_type::MerchantId, ) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> { self.diesel_store .list_blocklist_entries_by_merchant_id(merchant_id) .await }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn list_blocklist_entries_by_merchant_id_data_kind( &self, merchant_id: &common_utils::id_type::MerchantId, data_kind: common_enums::BlocklistDataKind, limit: i64, offset: i64, ) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn delete_blocklist_entry_by_merchant_id_fingerprint_id( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn find_blocklist_entry_by_merchant_id_fingerprint_id( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { self.diesel_store .find_blocklist_entry_by_merchant_id_fingerprint_id(merchant_id, fingerprint) .await }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn insert_blocklist_entry( &self, pm_blocklist: storage::BlocklistNew, ) -> CustomResult<storage::Blocklist, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn delete_blocklist_entry_by_merchant_id_fingerprint_id( &self, _merchant_id: &common_utils::id_type::MerchantId, _fingerprint_id: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn list_blocklist_entries_by_merchant_id_data_kind( &self, _merchant_id: &common_utils::id_type::MerchantId, _data_kind: common_enums::BlocklistDataKind, _limit: i64, _offset: i64, ) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn list_blocklist_entries_by_merchant_id( &self, _merchant_id: &common_utils::id_type::MerchantId, ) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn find_blocklist_entry_by_merchant_id_fingerprint_id( &self, _merchant_id: &common_utils::id_type::MerchantId, _fingerprint_id: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn insert_blocklist_entry( &self, _pm_blocklist: storage::BlocklistNew, ) -> CustomResult<storage::Blocklist, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn delete_blocklist_entry_by_merchant_id_fingerprint_id( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint_id: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn list_blocklist_entries_by_merchant_id( &self, merchant_id: &common_utils::id_type::MerchantId, ) -> CustomResult<Vec<storage::Blocklist>, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/blocklist.rs | crate: router use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, db::kafka_store::KafkaStore, types::storage, }; async fn find_blocklist_entry_by_merchant_id_fingerprint_id( &self, merchant_id: &common_utils::id_type::MerchantId, fingerprint_id: &str, ) -> CustomResult<storage::Blocklist, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use masking::Secret; use super::{domain, MockDb}; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn update_user_by_email( &self, user_email: &domain::UserEmail, update_user: storage::UserUpdate, ) -> CustomResult<storage::User, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use masking::Secret; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn update_user_by_user_id( &self, user_id: &str, update_user: storage::UserUpdate, ) -> CustomResult<storage::User, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn insert_user( &self, user_data: storage::UserNew, ) -> CustomResult<storage::User, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use masking::Secret; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn update_user_by_user_id( &self, user_id: &str, update_user: storage::UserUpdate, ) -> CustomResult<storage::User, errors::StorageError> { { storage::UserUpdate::VerifyUser => storage::User { is_verified: true, ..user.to_owned() },<|fim_suffix|> <|fim_middle|> storage::UserUpdate::PasswordUpdate { password } => storage::User { password: Some(password.clone()), last_password_modified_at: Some(common_utils::date_time::now()), ..user.to_owned() }, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn find_users_by_user_ids( &self, _user_ids: Vec<String>, ) -> CustomResult<Vec<storage::User>, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn find_user_by_id( &self, user_id: &str, ) -> CustomResult<storage::User, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use super::{domain, MockDb}; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn find_user_by_email( &self, user_email: &domain::UserEmail, ) -> CustomResult<storage::User, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn find_users_by_user_ids( &self, user_ids: Vec<String>, ) -> CustomResult<Vec<storage::User>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn delete_user_by_user_id( &self, user_id: &str, ) -> CustomResult<bool, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn update_user_by_user_id( &self, user_id: &str, user: storage::UserUpdate, ) -> CustomResult<storage::User, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/db/user.rs | crate: router use diesel_models::user as storage; use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, services::Store, }; async fn insert_user( &self, user_data: storage::UserNew, ) -> CustomResult<storage::User, errors::StorageError> { let conn = connection::pg_connection_write(self).await?; user_data .insert(&conn) .await .map_err(|error| report!(errors::StorageError::from(error))) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use super::{MockDb, Store}; async fn delete_locker_mock_up() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use super::{MockDb, Store}; async fn insert_locker_mock_up() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use super::{MockDb, Store}; async fn find_locker_by_card_id() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, types::storage, }; async fn insert_locker_mock_up( &self, new: storage::LockerMockUpNew, ) -> CustomResult<storage::LockerMockUp, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, types::storage, }; fn create_locker_mock_up_new(locker_ids: LockerMockUpIds) -> storage::LockerMockUpNew { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, types::storage, }; fn create_locker_mock_up_new(locker_ids: LockerMockUpIds) -> storage::LockerMockUpNew { storage::LockerMockUpNew { card_id: locker_ids.card_id, external_id: locker_ids.external_id, card_fingerprint: "card_fingerprint".into(), card_global_fingerprint: "card_global_fingerprint".into(), merchant_id: locker_ids.merchant_id, card_number: "1234123412341234".into(), card_exp_year: "2023".into(), card_exp_month: "06".into(), name_on_card: Some("name_on_card".into()), card_cvc: Some("123".into()), payment_method_id: Some("payment_method_id".into()), customer_id: Some(locker_ids.customer_id), nickname: Some("card_holder_nickname".into()), enc_card_data: Some("enc_card_data".into()), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, types::storage, }; async fn find_locker_by_card_id( &self, card_id: &str, ) -> CustomResult<storage::LockerMockUp, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, types::storage, }; async fn delete_locker_mock_up( &self, card_id: &str, ) -> CustomResult<storage::LockerMockUp, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/db/locker_mock_up.rs | crate: router use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, types::storage, }; async fn insert_locker_mock_up( &self, new: storage::LockerMockUpNew, ) -> CustomResult<storage::LockerMockUp, errors::StorageError> { let conn = connection::pg_connection_write(self).await?; new.insert(&conn) .await .map_err(|error| report!(errors::StorageError::from(error))) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use std::collections::{HashMap, HashSet}; use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn get_refund_status_with_count( &self, _merchant_id: &common_utils::id_type::MerchantId, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, time_range: &common_utils::types::TimeRange, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<(api_models::enums::RefundStatus, i64)>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use std::collections::{HashMap, HashSet}; use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn filter_refund_by_meta_constraints( &self, _merchant_id: &common_utils::id_type::MerchantId, refund_details: &common_utils::types::TimeRange, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn insert_refund( &self, new: storage_types::RefundNew, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_payment_id_merchant_id( &self, payment_id: &common_utils::id_type::PaymentId, merchant_id: &common_utils::id_type::MerchantId, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_connector_refund_id_connector( &self, merchant_id: &common_utils::id_type::MerchantId, connector_refund_id: &str, connector: &str, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_refund_id( &self, merchant_id: &common_utils::id_type::MerchantId, refund_id: &str, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { let database_call = || async { let conn = connection::pg_connection_read(self).await?; storage_types::Refund::find_by_merchant_id_refund_id(&conn, merchant_id, refund_id) .await .map_err(|error| report!(errors::StorageError::from(error))) }; let storage_scheme = Box::pin(decide_storage_scheme::<_, storage_types::Refund>( self, storage_scheme, Op::Find, )) .await; match storage_scheme { enums::MerchantStorageScheme::PostgresOnly => database_call().await, enums::MerchantStorageScheme::RedisKv => { let lookup_id = format!("ref_ref_id_{}_{refund_id}", merchant_id.get_string_repr()); let lookup = fallback_reverse_lookup_not_found!( self.get_lookup_by_lookup_id(&lookup_id, storage_scheme) .await, database_call().await ); let key = PartitionKey::CombinationKey { combination: &lookup.pk_id, }; Box::pin(db_utils::try_redis_get_else_try_database_get( async { Box::pin(kv_wrapper( self, KvOperation::<storage_types::Refund>::HGet(&lookup.sk_id), key, )) .await? .try_into_hget() }, database_call, )) .await } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn update_refund( &self, this: storage_types::Refund, refund: storage_types::RefundUpdate, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_connector_transaction_id( &self, merchant_id: &common_utils::id_type::MerchantId, connector_transaction_id: &str, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_internal_reference_id_merchant_id( &self, internal_reference_id: &str, merchant_id: &common_utils::id_type::MerchantId, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_connector_transaction_id( &self, merchant_id: &common_utils::id_type::MerchantId, connector_transaction_id: &str, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_refund_id( &self, merchant_id: &common_utils::id_type::MerchantId, refund_id: &str, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_id( &self, id: &common_utils::id_type::GlobalRefundId, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_payment_id_merchant_id( &self, payment_id: &common_utils::id_type::PaymentId, merchant_id: &common_utils::id_type::MerchantId, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_connector_refund_id_connector( &self, merchant_id: &common_utils::id_type::MerchantId, connector_refund_id: &str, connector: &str, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_refund_id( &self, merchant_id: &common_utils::id_type::MerchantId, refund_id: &str, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn update_refund( &self, this: storage_types::Refund, refund: storage_types::RefundUpdate, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_connector_transaction_id( &self, merchant_id: &common_utils::id_type::MerchantId, connector_transaction_id: &str, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> { let refunds = self.refunds.lock().await; Ok(refunds .iter() .take_while(|refund| { refund.merchant_id == *merchant_id && refund.get_connector_transaction_id() == connector_transaction_id }) .cloned() .collect::<Vec<_>>()) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_internal_reference_id_merchant_id( &self, internal_reference_id: &str, merchant_id: &common_utils::id_type::MerchantId, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn get_refund_status_with_count( &self, merchant_id: &common_utils::id_type::MerchantId, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, constraints: &common_utils::types::TimeRange, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<(common_enums::RefundStatus, i64)>, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn filter_refund_by_meta_constraints( &self, merchant_id: &common_utils::id_type::MerchantId, refund_details: &common_utils::types::TimeRange, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn get_refund_status_with_count( &self, merchant_id: &common_utils::id_type::MerchantId, profile_id_list: Option<Vec<common_utils::id_type::ProfileId>>, time_range: &api_models::payments::TimeRange, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<Vec<(common_enums::RefundStatus, i64)>, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn filter_refund_by_meta_constraints( &self, merchant_id: &common_utils::id_type::MerchantId, refund_details: &api_models::payments::TimeRange, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/db/refund.rs | crate: router use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn find_refund_by_merchant_id_refund_id( &self, merchant_id: &common_utils::id_type::MerchantId, refund_id: &str, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { let conn = connection::pg_connection_read(self).await?; storage_types::Refund::find_by_merchant_id_refund_id(&conn, merchant_id, refund_id) .await .map_err(|error| report!(errors::StorageError::from(error))) }
ast_fragments
// file: hyperswitch/crates/router/src/db/refund.rs | crate: router use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn insert_refund( &self, new: storage_types::RefundNew, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { let conn = connection::pg_connection_write(self).await?; new.insert(&conn) .await .map_err(|error| report!(errors::StorageError::from(error))) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use std::collections::{HashMap, HashSet}; use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn get_total_count_of_refunds( &self, merchant_id: &common_utils::id_type::MerchantId, refund_details: &refunds::RefundListConstraints, _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<i64, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use std::collections::{HashMap, HashSet}; use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn filter_refund_by_constraints( &self, merchant_id: &common_utils::id_type::MerchantId, refund_details: &refunds::RefundListConstraints, _storage_scheme: enums::MerchantStorageScheme, limit: i64, offset: i64, ) -> CustomResult<Vec<diesel_models::refund::Refund>, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/refund.rs | crate: router use std::collections::{HashMap, HashSet}; use common_utils::types::{ConnectorTransactionIdTrait, MinorUnit}; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; use hyperswitch_domain_models::refunds; use super::MockDb; use crate::{ core::errors::{self, CustomResult}, types::storage::{self as storage_types, enums}, }; async fn insert_refund( &self, new: storage_types::RefundNew, storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult<storage_types::Refund, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn update_payout_link( &self, _payout_link: storage::PayoutLink, _payout_link_update: storage::PayoutLinkUpdate, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn find_payout_link_by_link_id( &self, _generic_link_id: &str, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn update_payout_link( &self, _payout_link: storage::PayoutLink, _payout_link_update: storage::PayoutLinkUpdate, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { // TODO: Implement function for `MockDb` Err(errors::StorageError::MockDbError)? }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn insert_payout_link( &self, _pm_collect_link: storage::GenericLinkNew, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn insert_pm_collect_link( &self, _pm_collect_link: storage::GenericLinkNew, ) -> CustomResult<storage::PaymentMethodCollectLink, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn insert_generic_link( &self, _generic_link: storage::GenericLinkNew, ) -> CustomResult<storage::GenericLinkState, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn find_payout_link_by_link_id( &self, _generic_link_id: &str, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { // TODO: Implement function for `MockDb`x Err(errors::StorageError::MockDbError)? }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn find_pm_collect_link_by_link_id( &self, _generic_link_id: &str, ) -> CustomResult<storage::PaymentMethodCollectLink, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn find_generic_link_by_link_id( &self, _generic_link_id: &str, ) -> CustomResult<storage::GenericLinkState, errors::StorageError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn update_payout_link( &self, payout_link: storage::PayoutLink, payout_link_update: storage::PayoutLinkUpdate, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn insert_payout_link( &self, pm_collect_link: storage::GenericLinkNew, ) -> CustomResult<storage::PayoutLink, errors::StorageError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/db/generic_link.rs | crate: router use error_stack::report; use crate::{ connection, core::errors::{self, CustomResult}, db::MockDb, services::Store, types::storage, }; async fn insert_pm_collect_link( &self, pm_collect_link: storage::GenericLinkNew, ) -> CustomResult<storage::PaymentMethodCollectLink, errors::StorageError> { let conn = connection::pg_connection_write(self).await?; pm_collect_link .insert_pm_collect_link(&conn) .await .map_err(|error| report!(errors::StorageError::from(error))) }
ast_fragments