text stringlengths 70 351k | source stringclasses 4
values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
&self,
id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<ReverseLookup, errors::StorageError> {
self.diesel_store
.get_lookup_by_lookup_id(id, storage_scheme)
.await
}
}
#[async_trait::async_trait]
impl RoutingAlgorithmInterface for KafkaStore {
async fn insert_routing_algorithm(
&self,
routing_algorithm: storage::RoutingAlgorithm,
) -> CustomResult<storage::RoutingAlgorithm, errors::StorageError> {
self.diesel_store
.insert_routing_algorithm(routing_algorithm)
.await
}
async fn find_routing_algorithm_by_profile_id_algorithm_id(
&self,
profile_id: &id_type::ProfileId,
algorithm_id: &id_type::RoutingId,
async fn insert_routing_algorithm(
&self,
routing_algorithm: storage::RoutingAlgorithm,
) -> CustomResult<storage::RoutingAlgorithm, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
#[async_trait::async_trait]
impl ReverseLookupInterface for KafkaStore {
async fn insert_reverse_lookup(
&self,
new: ReverseLookupNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<ReverseLookup, errors::StorageError> {
self.diesel_store
.insert_reverse_lookup(new, storage_scheme)
.await
}
async fn get_lookup_by_lookup_id(
&self,
id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<ReverseLookup, errors::StorageError> {
self.diesel_store
.get_lookup_by_lookup_id(id, storage_scheme)
.await
}
}
#[async_trait::async_trait]
impl RoutingAlgorithmInterface for KafkaStore {
async fn get_lookup_by_lookup_id(
&self,
id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<ReverseLookup, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
.find_business_profile_by_profile_name_merchant_id(
key_manager_state,
merchant_key_store,
profile_name,
merchant_id,
)
.await
}
}
#[async_trait::async_trait]
impl ReverseLookupInterface for KafkaStore {
async fn insert_reverse_lookup(
&self,
new: ReverseLookupNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<ReverseLookup, errors::StorageError> {
self.diesel_store
.insert_reverse_lookup(new, storage_scheme)
.await
}
async fn get_lookup_by_lookup_id(
&self,
id: &str,
async fn insert_reverse_lookup(
&self,
new: ReverseLookupNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<ReverseLookup, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
async fn list_profile_by_merchant_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
) -> CustomResult<Vec<domain::Profile>, errors::StorageError> {
self.diesel_store
.list_profile_by_merchant_id(key_manager_state, merchant_key_store, merchant_id)
.await
}
async fn find_business_profile_by_profile_name_merchant_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_name: &str,
merchant_id: &id_type::MerchantId,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.find_business_profile_by_profile_name_merchant_id(
key_manager_state,
merchant_key_store,
profile_name,
merchant_id,
async fn find_business_profile_by_profile_name_merchant_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
profile_name: &str,
merchant_id: &id_type::MerchantId,
) -> CustomResult<domain::Profile, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
}
async fn delete_profile_by_profile_id_merchant_id(
&self,
profile_id: &id_type::ProfileId,
merchant_id: &id_type::MerchantId,
) -> CustomResult<bool, errors::StorageError> {
self.diesel_store
.delete_profile_by_profile_id_merchant_id(profile_id, merchant_id)
.await
}
async fn list_profile_by_merchant_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
) -> CustomResult<Vec<domain::Profile>, errors::StorageError> {
self.diesel_store
.list_profile_by_merchant_id(key_manager_state, merchant_key_store, merchant_id)
.await
}
async fn find_business_profile_by_profile_name_merchant_id(
&self,
async fn list_profile_by_merchant_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
) -> CustomResult<Vec<domain::Profile>, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
business_profile_update: domain::ProfileUpdate,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.update_profile_by_profile_id(
key_manager_state,
merchant_key_store,
current_state,
business_profile_update,
)
.await
}
async fn delete_profile_by_profile_id_merchant_id(
&self,
profile_id: &id_type::ProfileId,
merchant_id: &id_type::MerchantId,
) -> CustomResult<bool, errors::StorageError> {
self.diesel_store
.delete_profile_by_profile_id_merchant_id(profile_id, merchant_id)
.await
}
async fn list_profile_by_merchant_id(
&self,
key_manager_state: &KeyManagerState,
async fn delete_profile_by_profile_id_merchant_id(
&self,
profile_id: &id_type::ProfileId,
merchant_id: &id_type::MerchantId,
) -> CustomResult<bool, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
profile_id: &id_type::ProfileId,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.find_business_profile_by_merchant_id_profile_id(
key_manager_state,
merchant_key_store,
merchant_id,
profile_id,
)
.await
}
async fn update_profile_by_profile_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_state: domain::Profile,
business_profile_update: domain::ProfileUpdate,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.update_profile_by_profile_id(
key_manager_state,
merchant_key_store,
current_state,
business_profile_update,
async fn update_profile_by_profile_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
current_state: domain::Profile,
business_profile_update: domain::ProfileUpdate,
) -> CustomResult<domain::Profile, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
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
}
async fn find_business_profile_by_merchant_id_profile_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
profile_id: &id_type::ProfileId,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.find_business_profile_by_merchant_id_profile_id(
key_manager_state,
merchant_key_store,
merchant_id,
profile_id,
async fn find_business_profile_by_merchant_id_profile_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
merchant_id: &id_type::MerchantId,
profile_id: &id_type::ProfileId,
) -> CustomResult<domain::Profile, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
impl ProfileInterface for KafkaStore {
async fn insert_business_profile(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &domain::MerchantKeyStore,
business_profile: domain::Profile,
) -> CustomResult<domain::Profile, errors::StorageError> {
self.diesel_store
.insert_business_profile(key_manager_state, merchant_key_store, business_profile)
.await
}
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
}
async fn find_business_profile_by_merchant_id_profile_id(
&self,
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
}
async fn delete_merchant_key_store_by_merchant_id(
&self,
merchant_id: &id_type::MerchantId,
) -> CustomResult<bool, errors::StorageError> {
self.diesel_store
.delete_merchant_key_store_by_merchant_id(merchant_id)
.await
}
#[cfg(feature = "olap")]
async fn list_multiple_key_stores(
&self,
state: &KeyManagerState,
merchant_ids: Vec<id_type::MerchantId>,
key: &Secret<Vec<u8>>,
) -> CustomResult<Vec<domain::MerchantKeyStore>, errors::StorageError> {
self.diesel_store
.list_multiple_key_stores(state, merchant_ids, key)
.await
}
async fn get_all_key_stores(
&self,
state: &KeyManagerState,
async fn list_multiple_key_stores(
&self,
state: &KeyManagerState,
merchant_ids: Vec<id_type::MerchantId>,
key: &Secret<Vec<u8>>,
) -> CustomResult<Vec<domain::MerchantKeyStore>, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
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
}
async fn delete_merchant_key_store_by_merchant_id(
&self,
merchant_id: &id_type::MerchantId,
) -> CustomResult<bool, errors::StorageError> {
self.diesel_store
.delete_merchant_key_store_by_merchant_id(merchant_id)
.await
}
#[cfg(feature = "olap")]
async fn list_multiple_key_stores(
&self,
state: &KeyManagerState,
async fn delete_merchant_key_store_by_merchant_id(
&self,
merchant_id: &id_type::MerchantId,
) -> CustomResult<bool, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
impl MerchantKeyStoreInterface for KafkaStore {
async fn insert_merchant_key_store(
&self,
state: &KeyManagerState,
merchant_key_store: domain::MerchantKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, errors::StorageError> {
self.diesel_store
.insert_merchant_key_store(state, merchant_key_store, key)
.await
}
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
}
async fn delete_merchant_key_store_by_merchant_id(
&self,
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<(common_enums::RefundStatus, i64)>, errors::StorageError> {
self.diesel_store
.get_refund_status_with_count(merchant_id, profile_id_list, constraints, storage_scheme)
.await
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "refunds_v2"),
feature = "olap"
))]
async fn get_total_count_of_refunds(
&self,
merchant_id: &id_type::MerchantId,
refund_details: &refunds::RefundListConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<i64, errors::StorageError> {
self.diesel_store
.get_total_count_of_refunds(merchant_id, refund_details, storage_scheme)
.await
}
}
#[async_trait::async_trait]
async fn get_total_count_of_refunds(
&self,
merchant_id: &id_type::MerchantId,
refund_details: &refunds::RefundListConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<i64, errors::StorageError> {
self.diesel_store
.get_total_count_of_refunds(merchant_id, refund_details, storage_scheme)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
storage_scheme: MerchantStorageScheme,
) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {
self.diesel_store
.filter_refund_by_meta_constraints(merchant_id, refund_details, storage_scheme)
.await
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "refunds_v2"),
feature = "olap"
))]
async fn get_refund_status_with_count(
&self,
merchant_id: &id_type::MerchantId,
profile_id_list: Option<Vec<id_type::ProfileId>>,
constraints: &common_utils::types::TimeRange,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<(common_enums::RefundStatus, i64)>, errors::StorageError> {
self.diesel_store
.get_refund_status_with_count(merchant_id, profile_id_list, constraints, storage_scheme)
.await
}
#[cfg(all(
async fn get_refund_status_with_count(
&self,
merchant_id: &id_type::MerchantId,
profile_id_list: Option<Vec<id_type::ProfileId>>,
constraints: &common_utils::types::TimeRange,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<(common_enums::RefundStatus, i64)>, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
storage_scheme,
limit,
offset,
)
.await
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "refunds_v2"),
feature = "olap"
))]
async fn filter_refund_by_meta_constraints(
&self,
merchant_id: &id_type::MerchantId,
refund_details: &common_utils::types::TimeRange,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {
self.diesel_store
.filter_refund_by_meta_constraints(merchant_id, refund_details, storage_scheme)
.await
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
async fn filter_refund_by_meta_constraints(
&self,
merchant_id: &id_type::MerchantId,
refund_details: &common_utils::types::TimeRange,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<api_models::refunds::RefundListMetaData, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
.await
{
logger::error!(message="Failed to insert analytics event for Refund Create {refund?}", error_message=?er);
}
Ok(refund)
}
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "refunds_v2"),
feature = "olap"
))]
async fn filter_refund_by_constraints(
&self,
merchant_id: &id_type::MerchantId,
refund_details: &refunds::RefundListConstraints,
storage_scheme: MerchantStorageScheme,
limit: i64,
offset: i64,
) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {
self.diesel_store
.filter_refund_by_constraints(
merchant_id,
refund_details,
storage_scheme,
async fn filter_refund_by_constraints(
&self,
merchant_id: &id_type::MerchantId,
refund_details: &refunds::RefundListConstraints,
storage_scheme: MerchantStorageScheme,
limit: i64,
offset: i64,
) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
#[cfg(all(feature = "v2", feature = "refunds_v2"))]
async fn find_refund_by_id(
&self,
id: &id_type::GlobalRefundId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
self.diesel_store
.find_refund_by_id(id, storage_scheme)
.await
}
async fn insert_refund(
&self,
new: storage::RefundNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
let refund = self.diesel_store.insert_refund(new, storage_scheme).await?;
if let Err(er) = self
.kafka_producer
.log_refund(&refund, None, self.tenant_id.clone())
.await
{
logger::error!(message="Failed to insert analytics event for Refund Create {refund?}", error_message=?er);
async fn insert_refund(
&self,
new: storage::RefundNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {
self.diesel_store
.find_refund_by_merchant_id_connector_transaction_id(
merchant_id,
connector_transaction_id,
storage_scheme,
)
.await
}
#[cfg(all(feature = "v2", feature = "refunds_v2"))]
async fn find_refund_by_id(
&self,
id: &id_type::GlobalRefundId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
self.diesel_store
.find_refund_by_id(id, storage_scheme)
.await
}
async fn insert_refund(
&self,
new: storage::RefundNew,
async fn find_refund_by_id(
&self,
id: &id_type::GlobalRefundId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
if let Err(er) = self
.kafka_producer
.log_refund(&refund, Some(this), self.tenant_id.clone())
.await
{
logger::error!(message="Failed to insert analytics event for Refund Update {refund?}", error_message=?er);
}
Ok(refund)
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
async fn find_refund_by_merchant_id_connector_transaction_id(
&self,
merchant_id: &id_type::MerchantId,
connector_transaction_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {
self.diesel_store
.find_refund_by_merchant_id_connector_transaction_id(
merchant_id,
connector_transaction_id,
storage_scheme,
)
.await
async fn find_refund_by_merchant_id_connector_transaction_id(
&self,
merchant_id: &id_type::MerchantId,
connector_transaction_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
self.diesel_store
.find_refund_by_merchant_id_connector_refund_id_connector(
merchant_id,
connector_refund_id,
connector,
storage_scheme,
)
.await
}
async fn update_refund(
&self,
this: storage::Refund,
refund: storage::RefundUpdate,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
let refund = self
.diesel_store
.update_refund(this.clone(), refund, storage_scheme)
.await?;
if let Err(er) = self
.kafka_producer
async fn update_refund(
&self,
this: storage::Refund,
refund: storage::RefundUpdate,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
async fn find_refund_by_merchant_id_refund_id(
&self,
merchant_id: &id_type::MerchantId,
refund_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
self.diesel_store
.find_refund_by_merchant_id_refund_id(merchant_id, refund_id, storage_scheme)
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
async fn find_refund_by_merchant_id_connector_refund_id_connector(
&self,
merchant_id: &id_type::MerchantId,
connector_refund_id: &str,
connector: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
self.diesel_store
.find_refund_by_merchant_id_connector_refund_id_connector(
merchant_id,
connector_refund_id,
connector,
storage_scheme,
async fn find_refund_by_merchant_id_connector_refund_id_connector(
&self,
merchant_id: &id_type::MerchantId,
connector_refund_id: &str,
connector: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
async fn find_refund_by_payment_id_merchant_id(
&self,
payment_id: &id_type::PaymentId,
merchant_id: &id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {
self.diesel_store
.find_refund_by_payment_id_merchant_id(payment_id, merchant_id, storage_scheme)
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
async fn find_refund_by_merchant_id_refund_id(
&self,
merchant_id: &id_type::MerchantId,
refund_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
self.diesel_store
.find_refund_by_merchant_id_refund_id(merchant_id, refund_id, storage_scheme)
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
async fn find_refund_by_merchant_id_connector_refund_id_connector(
async fn find_refund_by_merchant_id_refund_id(
&self,
merchant_id: &id_type::MerchantId,
refund_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
self.diesel_store
.find_refund_by_internal_reference_id_merchant_id(
internal_reference_id,
merchant_id,
storage_scheme,
)
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
async fn find_refund_by_payment_id_merchant_id(
&self,
payment_id: &id_type::PaymentId,
merchant_id: &id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {
self.diesel_store
.find_refund_by_payment_id_merchant_id(payment_id, merchant_id, storage_scheme)
.await
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
async fn find_refund_by_merchant_id_refund_id(
async fn find_refund_by_payment_id_merchant_id(
&self,
payment_id: &id_type::PaymentId,
merchant_id: &id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Refund>, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
merchant_id,
payment_id,
authorized_attempt_id,
storage_scheme,
)
.await
}
}
#[async_trait::async_trait]
impl RefundInterface for KafkaStore {
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
async fn find_refund_by_internal_reference_id_merchant_id(
&self,
internal_reference_id: &str,
merchant_id: &id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
self.diesel_store
.find_refund_by_internal_reference_id_merchant_id(
internal_reference_id,
merchant_id,
storage_scheme,
)
.await
async fn find_refund_by_internal_reference_id_merchant_id(
&self,
internal_reference_id: &str,
merchant_id: &id_type::MerchantId,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Refund, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
async fn update_capture_with_capture_id(
&self,
this: storage::Capture,
capture: storage::CaptureUpdate,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Capture, errors::StorageError> {
self.diesel_store
.update_capture_with_capture_id(this, capture, storage_scheme)
.await
}
async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(
&self,
merchant_id: &id_type::MerchantId,
payment_id: &id_type::PaymentId,
authorized_attempt_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Capture>, errors::StorageError> {
self.diesel_store
.find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(
merchant_id,
payment_id,
authorized_attempt_id,
storage_scheme,
async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(
&self,
merchant_id: &id_type::MerchantId,
payment_id: &id_type::PaymentId,
authorized_attempt_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Capture>, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
#[async_trait::async_trait]
impl CaptureInterface for KafkaStore {
async fn insert_capture(
&self,
capture: storage::CaptureNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Capture, errors::StorageError> {
self.diesel_store
.insert_capture(capture, storage_scheme)
.await
}
async fn update_capture_with_capture_id(
&self,
this: storage::Capture,
capture: storage::CaptureUpdate,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Capture, errors::StorageError> {
self.diesel_store
.update_capture_with_capture_id(this, capture, storage_scheme)
.await
}
async fn find_all_captures_by_merchant_id_payment_id_authorized_attempt_id(
&self,
async fn update_capture_with_capture_id(
&self,
this: storage::Capture,
capture: storage::CaptureUpdate,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Capture, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
time_upper_limit: PrimitiveDateTime,
status: ProcessTrackerStatus,
limit: Option<i64>,
) -> CustomResult<Vec<storage::ProcessTracker>, errors::StorageError> {
self.diesel_store
.find_processes_by_time_status(time_lower_limit, time_upper_limit, status, limit)
.await
}
}
#[async_trait::async_trait]
impl CaptureInterface for KafkaStore {
async fn insert_capture(
&self,
capture: storage::CaptureNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Capture, errors::StorageError> {
self.diesel_store
.insert_capture(capture, storage_scheme)
.await
}
async fn update_capture_with_capture_id(
&self,
this: storage::Capture,
async fn insert_capture(
&self,
capture: storage::CaptureNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage::Capture, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
self.diesel_store.retry_process(this, schedule_time).await
}
async fn finish_process_with_business_status(
&self,
this: storage::ProcessTracker,
business_status: &'static str,
) -> CustomResult<(), errors::StorageError> {
self.diesel_store
.finish_process_with_business_status(this, business_status)
.await
}
async fn find_processes_by_time_status(
&self,
time_lower_limit: PrimitiveDateTime,
time_upper_limit: PrimitiveDateTime,
status: ProcessTrackerStatus,
limit: Option<i64>,
) -> CustomResult<Vec<storage::ProcessTracker>, errors::StorageError> {
self.diesel_store
.find_processes_by_time_status(time_lower_limit, time_upper_limit, status, limit)
.await
}
}
async fn find_processes_by_time_status(
&self,
time_lower_limit: PrimitiveDateTime,
time_upper_limit: PrimitiveDateTime,
status: ProcessTrackerStatus,
limit: Option<i64>,
) -> CustomResult<Vec<storage::ProcessTracker>, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
#[async_trait::async_trait]
impl ProcessTrackerInterface for KafkaStore {
async fn reinitialize_limbo_processes(
&self,
ids: Vec<String>,
schedule_time: PrimitiveDateTime,
) -> CustomResult<usize, errors::StorageError> {
self.diesel_store
.reinitialize_limbo_processes(ids, schedule_time)
.await
}
async fn find_process_by_id(
&self,
id: &str,
) -> CustomResult<Option<storage::ProcessTracker>, errors::StorageError> {
self.diesel_store.find_process_by_id(id).await
}
async fn update_process(
&self,
this: storage::ProcessTracker,
process: storage::ProcessTrackerUpdate,
) -> CustomResult<storage::ProcessTracker, errors::StorageError> {
self.diesel_store.update_process(this, process).await
async fn find_process_by_id(
&self,
id: &str,
) -> CustomResult<Option<storage::ProcessTracker>, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
&self,
merchant_id: &id_type::MerchantId,
constraints: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
) -> CustomResult<Vec<String>, errors::StorageError> {
self.diesel_store
.filter_active_payout_ids_by_constraints(merchant_id, constraints)
.await
}
}
#[async_trait::async_trait]
impl ProcessTrackerInterface for KafkaStore {
async fn reinitialize_limbo_processes(
&self,
ids: Vec<String>,
schedule_time: PrimitiveDateTime,
) -> CustomResult<usize, errors::StorageError> {
self.diesel_store
.reinitialize_limbo_processes(ids, schedule_time)
.await
}
async fn find_process_by_id(
&self,
id: &str,
async fn reinitialize_limbo_processes(
&self,
ids: Vec<String>,
schedule_time: PrimitiveDateTime,
) -> CustomResult<usize, errors::StorageError> {
self.diesel_store
.reinitialize_limbo_processes(ids, schedule_time)
.await
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
.get_total_count_of_filtered_payouts(
merchant_id,
active_payout_ids,
connector,
currency,
status,
payout_method,
)
.await
}
#[cfg(feature = "olap")]
async fn filter_active_payout_ids_by_constraints(
&self,
merchant_id: &id_type::MerchantId,
constraints: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
) -> CustomResult<Vec<String>, errors::StorageError> {
self.diesel_store
.filter_active_payout_ids_by_constraints(merchant_id, constraints)
.await
}
}
#[async_trait::async_trait]
impl ProcessTrackerInterface for KafkaStore {
async fn filter_active_payout_ids_by_constraints(
&self,
merchant_id: &id_type::MerchantId,
constraints: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
) -> CustomResult<Vec<String>, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
async fn filter_payouts_by_time_range_constraints(
&self,
merchant_id: &id_type::MerchantId,
time_range: &common_utils::types::TimeRange,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Payouts>, errors::StorageError> {
self.diesel_store
.filter_payouts_by_time_range_constraints(merchant_id, time_range, storage_scheme)
.await
}
#[cfg(feature = "olap")]
async fn get_total_count_of_filtered_payouts(
&self,
merchant_id: &id_type::MerchantId,
active_payout_ids: &[String],
connector: Option<Vec<api_models::enums::PayoutConnectors>>,
currency: Option<Vec<enums::Currency>>,
status: Option<Vec<enums::PayoutStatus>>,
payout_method: Option<Vec<enums::PayoutType>>,
) -> CustomResult<i64, errors::StorageError> {
self.diesel_store
.get_total_count_of_filtered_payouts(
merchant_id,
active_payout_ids,
async fn get_total_count_of_filtered_payouts(
&self,
merchant_id: &id_type::MerchantId,
active_payout_ids: &[String],
connector: Option<Vec<api_models::enums::PayoutConnectors>>,
currency: Option<Vec<enums::Currency>>,
status: Option<Vec<enums::PayoutStatus>>,
payout_method: Option<Vec<enums::PayoutType>>,
) -> CustomResult<i64, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
storage::PayoutAttempt,
Option<diesel_models::Customer>,
Option<diesel_models::Address>,
)>,
errors::StorageError,
> {
self.diesel_store
.filter_payouts_and_attempts(merchant_id, filters, storage_scheme)
.await
}
#[cfg(feature = "olap")]
async fn filter_payouts_by_time_range_constraints(
&self,
merchant_id: &id_type::MerchantId,
time_range: &common_utils::types::TimeRange,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Payouts>, errors::StorageError> {
self.diesel_store
.filter_payouts_by_time_range_constraints(merchant_id, time_range, storage_scheme)
.await
}
#[cfg(feature = "olap")]
async fn get_total_count_of_filtered_payouts(
async fn filter_payouts_by_time_range_constraints(
&self,
merchant_id: &id_type::MerchantId,
time_range: &common_utils::types::TimeRange,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Payouts>, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
async fn filter_payouts_by_constraints(
&self,
merchant_id: &id_type::MerchantId,
filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Payouts>, errors::StorageError> {
self.diesel_store
.filter_payouts_by_constraints(merchant_id, filters, storage_scheme)
.await
}
#[cfg(feature = "olap")]
async fn filter_payouts_and_attempts(
&self,
merchant_id: &id_type::MerchantId,
filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<
Vec<(
storage::Payouts,
storage::PayoutAttempt,
Option<diesel_models::Customer>,
Option<diesel_models::Address>,
)>,
errors::StorageError,
async fn filter_payouts_and_attempts(
&self,
merchant_id: &id_type::MerchantId,
filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<
Vec<(
storage::Payouts,
storage::PayoutAttempt,
Option<diesel_models::Customer>,
Option<diesel_models::Address>,
)>,
errors::StorageError,
> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/kafka_store.rs | crate: router
async fn find_optional_payout_by_merchant_id_payout_id(
&self,
merchant_id: &id_type::MerchantId,
payout_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Option<storage::Payouts>, errors::StorageError> {
self.diesel_store
.find_optional_payout_by_merchant_id_payout_id(merchant_id, payout_id, storage_scheme)
.await
}
#[cfg(feature = "olap")]
async fn filter_payouts_by_constraints(
&self,
merchant_id: &id_type::MerchantId,
filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Payouts>, errors::StorageError> {
self.diesel_store
.filter_payouts_by_constraints(merchant_id, filters, storage_scheme)
.await
}
#[cfg(feature = "olap")]
async fn filter_payouts_and_attempts(
async fn filter_payouts_by_constraints(
&self,
merchant_id: &id_type::MerchantId,
filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Payouts>, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/ephemeral_key.rs | crate: router
use crate::{
core::errors::{self, CustomResult},
db::MockDb,
types::storage::ephemeral_key::{EphemeralKey, EphemeralKeyNew},
};
async fn create_ephemeral_key(
&self,
new: EphemeralKeyNew,
validity: i64,
) -> CustomResult<EphemeralKey, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/ephemeral_key.rs | crate: router
use crate::types::storage::ephemeral_key::{ClientSecretType, ClientSecretTypeNew};
use crate::{
core::errors::{self, CustomResult},
db::MockDb,
types::storage::ephemeral_key::{EphemeralKey, EphemeralKeyNew},
};
async fn get_ephemeral_key(
&self,
key: &str,
) -> CustomResult<EphemeralKey, errors::StorageError> {
{
Some(ephemeral_key) => Ok(ephemeral_key.clone()),<|fim_suffix|>
<|fim_middle|>
None => Err(
errors::StorageError::ValueNotFound("ephemeral key not found".to_string()).into(),
),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/ephemeral_key.rs | crate: router
use crate::types::storage::ephemeral_key::{ClientSecretType, ClientSecretTypeNew};
use crate::{
core::errors::{self, CustomResult},
db::MockDb,
types::storage::ephemeral_key::{EphemeralKey, EphemeralKeyNew},
};
async fn delete_client_secret(
&self,
id: &str,
) -> CustomResult<ClientSecretType, errors::StorageError> {
{
RedisError::NotFound => {
err.change_context(errors::StorageError::ValueNotFound(redis_id_key))
}<|fim_suffix|>
<|fim_middle|>
_ => err.change_context(errors::StorageError::KVError),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/ephemeral_key.rs | crate: router
use crate::types::storage::ephemeral_key::{ClientSecretType, ClientSecretTypeNew};
use crate::{
core::errors::{self, CustomResult},
db::MockDb,
types::storage::ephemeral_key::{EphemeralKey, EphemeralKeyNew},
};
async fn delete_client_secret(
&self,
id: &str,
) -> CustomResult<ClientSecretType, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/ephemeral_key.rs | crate: router
use crate::types::storage::ephemeral_key::{ClientSecretType, ClientSecretTypeNew};
use crate::{
core::errors::{self, CustomResult},
db::MockDb,
types::storage::ephemeral_key::{EphemeralKey, EphemeralKeyNew},
};
async fn create_client_secret(
&self,
new: ClientSecretTypeNew,
validity: i64,
) -> CustomResult<ClientSecretType, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
Err(errors::StorageError::MockDbError)?
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/relay.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use diesel_models;
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion};
use super::domain;
use crate::{
connection,
core::errors::{self, CustomResult},
db::kafka_store::KafkaStore,
services::Store,
};
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> {
let conn = connection::pg_connection_read(self).await?;
diesel_models::relay::Relay::find_by_profile_id_connector_reference_id(
&conn,
profile_id,
connector_reference_id,
)
.await
.map_err(|error| report!(errors::StorageError::from(error)))?
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
async fn insert_mandate(
&self,
mandate_new: storage_types::MandateNew,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage_types::Mandate, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
async fn find_mandate_by_global_customer_id(
&self,
customer_id: &id_type::GlobalCustomerId,
) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
async fn find_mandate_by_global_customer_id(
&self,
id: &id_type::GlobalCustomerId,
) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
async fn insert_mandate(
&self,
mandate: storage_types::MandateNew,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage_types::Mandate, errors::StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
async fn find_mandate_by_global_customer_id(
&self,
customer_id: &id_type::GlobalCustomerId,
) -> CustomResult<Vec<storage_types::Mandate>, errors::StorageError> {
let conn = connection::pg_connection_read(self).await?;
storage_types::Mandate::find_by_global_id(&conn, customer_id)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
} | ast_fragments |
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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> {
let conn = connection::pg_connection_read(self).await?;
storage_types::Mandate::find_by_merchant_id_customer_id(&conn, merchant_id, customer_id)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
async fn insert_mandate(
&self,
mut mandate: storage_types::MandateNew,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<storage_types::Mandate, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/mandate.rs | crate: router
use common_utils::id_type;
use crate::{
core::errors::{self, CustomResult},
types::storage::{self as storage_types, enums::MerchantStorageScheme},
};
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 conn = connection::pg_connection_write(self).await?;
let key = PartitionKey::MerchantIdMandateId {
merchant_id,
mandate_id,
};
let field = format!("mandate_{}", mandate_id);
let storage_scheme = Box::pin(decide_storage_scheme::<_, diesel_models::Mandate>(
self,
storage_scheme,
Op::Update(key.clone(), &field, mandate.updated_by.as_deref()),
))
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
storage_types::Mandate::update_by_merchant_id_mandate_id(
&conn,
merchant_id,
mandate_id,
mandate_update.convert_to_mandate_update(storage_scheme),
)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
}
MerchantStorageScheme::RedisKv => {
let key_str = key.to_string();
if let diesel_models::MandateUpdate::ConnectorMandateIdUpdate {
connector_mandate_id: Some(val),
..
} = &mandate_update
{
let rev_lookup = diesel_models::ReverseLookupNew {
sk_id: field.clone(),
pk_id: key_str.clone(),
lookup_id: format!(
"mid_{}_conn_mandate_{}",
merchant_id.get_string_repr(),
val
),
source: "mandate".to_string(),
updated_by: storage_scheme.to_string(),
};
self.insert_reverse_lookup(rev_lookup, storage_scheme)
.await?;
}
let m_update = mandate_update.convert_to_mandate_update(storage_scheme);
let updated_mandate = m_update.clone().apply_changeset(mandate.clone());
let redis_value = serde_json::to_string(&updated_mandate)
.change_context(errors::StorageError::SerializationFailed)?;
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Update {
updatable: Box::new(kv::Updateable::MandateUpdate(
kv::MandateUpdateMems {
orig: mandate,
update_data: m_update,
},
)),
},
};
Box::pin(kv_wrapper::<(), _, _>(
self,
KvOperation::<diesel_models::Mandate>::Hset(
(&field, redis_value),
redis_entry,
),
key,
))
.await
.map_err(|err| err.to_redis_failed_response(&key_str))?
.try_into_hset()
.change_context(errors::StorageError::KVError)?;
Ok(updated_mandate)
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/file.rs | crate: router
use super::{MockDb, Store};
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/file.rs | crate: router
use super::{MockDb, Store};
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
async fn update_file_metadata(
&self,
_this: storage::FileMetadata,
_file_metadata: storage::FileMetadataUpdate,
) -> CustomResult<storage::FileMetadata, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/file.rs | crate: router
use super::{MockDb, Store};
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/file.rs | crate: router
use super::{MockDb, Store};
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
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)?
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/file.rs | crate: router
use super::{MockDb, Store};
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
async fn insert_file_metadata(
&self,
_file: storage::FileMetadataNew,
) -> CustomResult<storage::FileMetadata, errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/file.rs | crate: router
use error_stack::report;
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
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> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/file.rs | crate: router
use error_stack::report;
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
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> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use futures::{future::try_join_all, FutureExt};
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_payment_intents_batch_for_sample_data(
&self,
state: &KeyManagerState,
batch: Vec<PaymentIntent>,
key_store: &MerchantKeyStore,
) -> CustomResult<Vec<PaymentIntent>, StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_payment_attempts_for_sample_data(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<PaymentAttempt>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_disputes_batch_for_sample_data(
&self,
_batch: Vec<DisputeNew>,
) -> CustomResult<Vec<Dispute>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use error_stack::{Report, ResultExt};
use storage_impl::{errors::StorageError, DataModelExt};
fn diesel_error_to_data_error(diesel_error: Report<DatabaseError>) -> Report<StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_disputes_for_sample_data(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<Dispute>, StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_refunds_for_sample_data(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<Refund>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_payment_attempts_for_sample_data(
&self,
_merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<PaymentAttempt>, StorageError> {
Err(StorageError::MockDbError)?
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_payment_intents_for_sample_data(
&self,
_state: &KeyManagerState,
_merchant_id: &common_utils::id_type::MerchantId,
_key_store: &MerchantKeyStore,
) -> CustomResult<Vec<PaymentIntent>, StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_disputes_batch_for_sample_data(
&self,
_batch: Vec<DisputeNew>,
) -> CustomResult<Vec<Dispute>, StorageError> {
Err(StorageError::MockDbError)?
} | ast_fragments |
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_refunds_batch_for_sample_data(
&self,
_batch: Vec<RefundNew>,
) -> CustomResult<Vec<Refund>, StorageError> {
Err(StorageError::MockDbError)?
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use diesel_models::user::sample_data::PaymentAttemptBatchNew;
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_payment_attempts_batch_for_sample_data(
&self,
_batch: Vec<PaymentAttemptBatchNew>,
) -> CustomResult<Vec<PaymentAttempt>, StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_payment_intents_batch_for_sample_data(
&self,
_state: &KeyManagerState,
_batch: Vec<PaymentIntent>,
_key_store: &MerchantKeyStore,
) -> CustomResult<Vec<PaymentIntent>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_disputes_for_sample_data(
&self,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<Dispute>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_refunds_for_sample_data(
&self,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<Refund>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_payment_attempts_for_sample_data(
&self,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<PaymentAttempt>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use common_utils::types::keymanager::KeyManagerState;
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use futures::{future::try_join_all, FutureExt};
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn delete_payment_intents_for_sample_data(
&self,
state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
key_store: &MerchantKeyStore,
) -> CustomResult<Vec<PaymentIntent>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_disputes_batch_for_sample_data(
&self,
batch: Vec<DisputeNew>,
) -> CustomResult<Vec<Dispute>, StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_refunds_batch_for_sample_data(
&self,
batch: Vec<RefundNew>,
) -> CustomResult<Vec<Refund>, StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/db/user/sample_data.rs | crate: router
use diesel_models::user::sample_data::PaymentAttemptBatchNew;
use diesel_models::{
dispute::{Dispute, DisputeNew},
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
refund::{Refund, RefundNew},
};
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
};
use storage_impl::{errors::StorageError, DataModelExt};
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
async fn insert_payment_attempts_batch_for_sample_data(
&self,
batch: Vec<PaymentAttemptBatchNew>,
) -> CustomResult<Vec<PaymentAttempt>, StorageError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/events/outgoing_webhook_logs.rs | crate: router
use serde_json::Value;
fn get_outgoing_webhook_event_content(&self) -> Option<OutgoingWebhookEventContent> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/events/outgoing_webhook_logs.rs | crate: router
use serde_json::Value;
fn get_outgoing_webhook_event_content(&self) -> Option<OutgoingWebhookEventContent> {
{
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"})),
}),<|fim_suffix|>
<|fim_middle|>
#[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"})),
}),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/events/outgoing_webhook_logs.rs | crate: router
use api_models::{enums::EventType as OutgoingWebhookEventType, webhooks::OutgoingWebhookContent};
use common_enums::WebhookDeliveryAttempt;
use serde_json::Value;
use time::OffsetDateTime;
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 {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/events/api_logs.rs | crate: router
use actix_web::HttpRequest;
pub use common_utils::events::{ApiEventMetric, ApiEventsType};
use common_utils::impl_api_event_type;
use router_env::{tracing_actix_web::RequestId, types::FlowMetric};
use time::OffsetDateTime;
use crate::{
core::payments::PaymentsRedirectResponseData,
services::{authentication::AuthenticationType, kafka::KafkaMessage},
types::api::{
AttachEvidenceRequest, Config, ConfigUpdate, CreateFileRequest, DisputeId, FileId, PollId,
},
};
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,
) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/events/api_logs.rs | crate: router
pub use common_utils::events::{ApiEventMetric, ApiEventsType};
use crate::{
core::payments::PaymentsRedirectResponseData,
services::{authentication::AuthenticationType, kafka::KafkaMessage},
types::api::{
AttachEvidenceRequest, Config, ConfigUpdate, CreateFileRequest, DisputeId, FileId, PollId,
},
};
fn get_api_event_type(&self) -> Option<ApiEventsType> {
{
api_models::payments::PaymentIdType::PaymentIntentId(id) => Some(id.clone()),<|fim_suffix|>
<|fim_middle|>
_ => None,
}
} | ast_fragments |
// file: hyperswitch/crates/router/src/events/api_logs.rs | crate: router
pub use common_utils::events::{ApiEventMetric, ApiEventsType};
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Dispute {
dispute_id: self.dispute_id.clone(),
})
} | ast_fragments |
// file: hyperswitch/crates/router/src/events/api_logs.rs | crate: router
use super::EventType;
fn event_type(&self) -> EventType {
EventType::ApiLogs
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/events/event_logger.rs | crate: router
use std::collections::HashMap;
use events::{EventsError, Message, MessagingInterface};
use masking::ErasedMaskSerialize;
use time::PrimitiveDateTime;
use crate::services::{kafka::KafkaMessage, logger};
fn send_message<T>(
&self,
data: T,
metadata: HashMap<String, String>,
_timestamp: PrimitiveDateTime,
) -> error_stack::Result<(), EventsError>
where
T: Message<Class = Self::MessageClass> + ErasedMaskSerialize,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/events/event_logger.rs | crate: router
use std::collections::HashMap;
use events::{EventsError, Message, MessagingInterface};
use masking::ErasedMaskSerialize;
use time::PrimitiveDateTime;
use crate::services::{kafka::KafkaMessage, logger};
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(())
} | ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.