text
stringlengths
70
351k
source
stringclasses
4 values
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/file_storage/aws_s3.rs | crate: external_services use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{ operation::{ delete_object::DeleteObjectError, get_object::GetObjectError, put_object::PutObjectError, }, Client, }; use aws_sdk_sts::config::Region; use common_utils::{errors::CustomResult, ext_traits::ConfigExt}; use error_stack::ResultExt; use super::InvalidFileStorageConfig; use crate::file_storage::{FileStorageError, FileStorageInterface}; /// Validates the AWS S3 file storage configuration. pub(super) fn validate(&self) -> Result<(), InvalidFileStorageConfig> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/no_encryption/implementers.rs | crate: external_services use common_utils::errors::CustomResult; use hyperswitch_interfaces::{ encryption_interface::{EncryptionError, EncryptionManagementInterface}, secrets_interface::{SecretManagementInterface, SecretsManagementError}, }; async fn decrypt(&self, input: &[u8]) -> CustomResult<Vec<u8>, EncryptionError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/no_encryption/implementers.rs | crate: external_services use common_utils::errors::CustomResult; use hyperswitch_interfaces::{ encryption_interface::{EncryptionError, EncryptionManagementInterface}, secrets_interface::{SecretManagementInterface, SecretsManagementError}, }; async fn encrypt(&self, input: &[u8]) -> CustomResult<Vec<u8>, EncryptionError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/aws_kms/core.rs | crate: external_services use std::time::Instant; use aws_sdk_kms::{config::Region, primitives::Blob, Client}; use common_utils::errors::CustomResult; use router_env::logger; use crate::{consts, metrics}; /// Encrypts the provided String data using the AWS KMS SDK. We assume that /// the SDK has the values required to interact with the AWS KMS APIs (`AWS_ACCESS_KEY_ID` and /// `AWS_SECRET_ACCESS_KEY`) either set in environment variables, or that the SDK is running in /// a machine that is able to assume an IAM role. pub async fn encrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, AwsKmsError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/aws_kms/core.rs | crate: external_services use std::time::Instant; use aws_sdk_kms::{config::Region, primitives::Blob, Client}; use common_utils::errors::CustomResult; use error_stack::{report, ResultExt}; use router_env::logger; use crate::{consts, metrics}; /// Decrypts the provided base64-encoded encrypted data using the AWS KMS SDK. We assume that /// the SDK has the values required to interact with the AWS KMS APIs (`AWS_ACCESS_KEY_ID` and /// `AWS_SECRET_ACCESS_KEY`) either set in environment variables, or that the SDK is running in /// a machine that is able to assume an IAM role. pub async fn decrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, AwsKmsError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/aws_kms/core.rs | crate: external_services use std::time::Instant; use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::{config::Region, primitives::Blob, Client}; use base64::Engine; use common_utils::errors::CustomResult; use error_stack::{report, ResultExt}; use router_env::logger; use crate::{consts, metrics}; async fn check_aws_kms_decrypt() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/aws_kms/core.rs | crate: external_services use std::time::Instant; use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::{config::Region, primitives::Blob, Client}; use base64::Engine; use common_utils::errors::CustomResult; use error_stack::{report, ResultExt}; use router_env::logger; use crate::{consts, metrics}; async fn check_aws_kms_encryption() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/aws_kms/core.rs | crate: external_services use std::time::Instant; use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::{config::Region, primitives::Blob, Client}; use base64::Engine; use common_utils::errors::CustomResult; use error_stack::{report, ResultExt}; use router_env::logger; use crate::{consts, metrics}; /// Verifies that the [`AwsKmsClient`] configuration is usable. pub fn validate(&self) -> Result<(), &'static str> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/external_services/src/aws_kms/core.rs | crate: external_services use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::{config::Region, primitives::Blob, Client}; /// Constructs a new AWS KMS client. pub async fn new(config: &AwsKmsConfig) -> Self { let region_provider = RegionProviderChain::first_try(Region::new(config.region.clone())); let sdk_config = aws_config::from_env().region(region_provider).load().await; Self { inner_client: Client::new(&sdk_config), key_id: config.key_id.clone(), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/elimination_based_client.rs | crate: external_services use api_models::routing::{ EliminationAnalyserConfig as EliminationConfig, RoutableConnectorChoice, RoutableConnectorChoiceWithBucketName, }; use common_utils::{ext_traits::OptionExt, transformers::ForeignTryFrom}; pub use elimination_rate::{ elimination_analyser_client::EliminationAnalyserClient, EliminationBucketConfig, EliminationRequest, EliminationResponse, InvalidateBucketRequest, InvalidateBucketResponse, LabelWithBucketName, UpdateEliminationBucketRequest, UpdateEliminationBucketResponse, }; use router_env::{instrument, logger, tracing}; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; use crate::grpc_client::{self, GrpcHeaders}; async fn update_elimination_bucket_config( &self, id: String, params: String, report: Vec<RoutableConnectorChoiceWithBucketName>, configs: Option<EliminationConfig>, headers: GrpcHeaders, ) -> DynamicRoutingResult<UpdateEliminationBucketResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/elimination_based_client.rs | crate: external_services use api_models::routing::{ EliminationAnalyserConfig as EliminationConfig, RoutableConnectorChoice, RoutableConnectorChoiceWithBucketName, }; use common_utils::{ext_traits::OptionExt, transformers::ForeignTryFrom}; pub use elimination_rate::{ elimination_analyser_client::EliminationAnalyserClient, EliminationBucketConfig, EliminationRequest, EliminationResponse, InvalidateBucketRequest, InvalidateBucketResponse, LabelWithBucketName, UpdateEliminationBucketRequest, UpdateEliminationBucketResponse, }; use router_env::{instrument, logger, tracing}; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; use crate::grpc_client::{self, GrpcHeaders}; async fn perform_elimination_routing( &self, id: String, params: String, label_input: Vec<RoutableConnectorChoice>, configs: Option<EliminationConfig>, headers: GrpcHeaders, ) -> DynamicRoutingResult<EliminationResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/elimination_based_client.rs | crate: external_services use api_models::routing::{ EliminationAnalyserConfig as EliminationConfig, RoutableConnectorChoice, RoutableConnectorChoiceWithBucketName, }; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; fn foreign_try_from(config: EliminationConfig) -> Result<Self, Self::Error> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/elimination_based_client.rs | crate: external_services pub use elimination_rate::{ elimination_analyser_client::EliminationAnalyserClient, EliminationBucketConfig, EliminationRequest, EliminationResponse, InvalidateBucketRequest, InvalidateBucketResponse, LabelWithBucketName, UpdateEliminationBucketRequest, UpdateEliminationBucketResponse, }; use router_env::{instrument, logger, tracing}; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; use crate::grpc_client::{self, GrpcHeaders}; async fn invalidate_elimination_bucket( &self, id: String, headers: GrpcHeaders, ) -> DynamicRoutingResult<InvalidateBucketResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs | crate: external_services use api_models::routing::{ CurrentBlockThreshold, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus, SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody, SuccessRateSpecificityLevel, }; use common_utils::{ext_traits::OptionExt, transformers::ForeignTryFrom}; use router_env::{instrument, logger, tracing}; pub use success_rate::{ success_rate_calculator_client::SuccessRateCalculatorClient, CalGlobalSuccessRateConfig, CalGlobalSuccessRateRequest, CalGlobalSuccessRateResponse, CalSuccessRateConfig, CalSuccessRateRequest, CalSuccessRateResponse, CurrentBlockThreshold as DynamicCurrentThreshold, InvalidateWindowsRequest, InvalidateWindowsResponse, LabelWithStatus, SuccessRateSpecificityLevel as ProtoSpecificityLevel, UpdateSuccessRateWindowConfig, UpdateSuccessRateWindowRequest, UpdateSuccessRateWindowResponse, }; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; use crate::grpc_client::{self, GrpcHeaders}; async fn calculate_entity_and_global_success_rate( &self, id: String, success_rate_based_config: SuccessBasedRoutingConfig, params: String, label_input: Vec<RoutableConnectorChoice>, headers: GrpcHeaders, ) -> DynamicRoutingResult<CalGlobalSuccessRateResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs | crate: external_services use api_models::routing::{ CurrentBlockThreshold, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus, SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody, SuccessRateSpecificityLevel, }; use common_utils::{ext_traits::OptionExt, transformers::ForeignTryFrom}; use router_env::{instrument, logger, tracing}; pub use success_rate::{ success_rate_calculator_client::SuccessRateCalculatorClient, CalGlobalSuccessRateConfig, CalGlobalSuccessRateRequest, CalGlobalSuccessRateResponse, CalSuccessRateConfig, CalSuccessRateRequest, CalSuccessRateResponse, CurrentBlockThreshold as DynamicCurrentThreshold, InvalidateWindowsRequest, InvalidateWindowsResponse, LabelWithStatus, SuccessRateSpecificityLevel as ProtoSpecificityLevel, UpdateSuccessRateWindowConfig, UpdateSuccessRateWindowRequest, UpdateSuccessRateWindowResponse, }; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; use crate::grpc_client::{self, GrpcHeaders}; async fn update_success_rate( &self, id: String, success_rate_based_config: SuccessBasedRoutingConfig, params: String, label_input: Vec<RoutableConnectorChoiceWithStatus>, headers: GrpcHeaders, ) -> DynamicRoutingResult<UpdateSuccessRateWindowResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs | crate: external_services use api_models::routing::{ CurrentBlockThreshold, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus, SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody, SuccessRateSpecificityLevel, }; use common_utils::{ext_traits::OptionExt, transformers::ForeignTryFrom}; use router_env::{instrument, logger, tracing}; pub use success_rate::{ success_rate_calculator_client::SuccessRateCalculatorClient, CalGlobalSuccessRateConfig, CalGlobalSuccessRateRequest, CalGlobalSuccessRateResponse, CalSuccessRateConfig, CalSuccessRateRequest, CalSuccessRateResponse, CurrentBlockThreshold as DynamicCurrentThreshold, InvalidateWindowsRequest, InvalidateWindowsResponse, LabelWithStatus, SuccessRateSpecificityLevel as ProtoSpecificityLevel, UpdateSuccessRateWindowConfig, UpdateSuccessRateWindowRequest, UpdateSuccessRateWindowResponse, }; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; use crate::grpc_client::{self, GrpcHeaders}; async fn calculate_success_rate( &self, id: String, success_rate_based_config: SuccessBasedRoutingConfig, params: String, label_input: Vec<RoutableConnectorChoice>, headers: GrpcHeaders, ) -> DynamicRoutingResult<CalSuccessRateResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs | crate: external_services use api_models::routing::{ CurrentBlockThreshold, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus, SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody, SuccessRateSpecificityLevel, }; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; fn foreign_try_from(config: SuccessBasedRoutingConfigBody) -> Result<Self, Self::Error> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs | crate: external_services use api_models::routing::{ CurrentBlockThreshold, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus, SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody, SuccessRateSpecificityLevel, }; pub use success_rate::{ success_rate_calculator_client::SuccessRateCalculatorClient, CalGlobalSuccessRateConfig, CalGlobalSuccessRateRequest, CalGlobalSuccessRateResponse, CalSuccessRateConfig, CalSuccessRateRequest, CalSuccessRateResponse, CurrentBlockThreshold as DynamicCurrentThreshold, InvalidateWindowsRequest, InvalidateWindowsResponse, LabelWithStatus, SuccessRateSpecificityLevel as ProtoSpecificityLevel, UpdateSuccessRateWindowConfig, UpdateSuccessRateWindowRequest, UpdateSuccessRateWindowResponse, }; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; fn foreign_try_from(config: SuccessBasedRoutingConfigBody) -> Result<Self, Self::Error> { Ok(Self { min_aggregates_size: config .min_aggregates_size .get_required_value("min_aggregate_size") .change_context(DynamicRoutingError::MissingRequiredField { field: "min_aggregates_size".to_string(), })?, default_success_rate: config .default_success_rate .get_required_value("default_success_rate") .change_context(DynamicRoutingError::MissingRequiredField { field: "default_success_rate".to_string(), })?, specificity_level: match config.specificity_level { SuccessRateSpecificityLevel::Merchant => Some(ProtoSpecificityLevel::Entity.into()), SuccessRateSpecificityLevel::Global => Some(ProtoSpecificityLevel::Global.into()), }, }) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs | crate: external_services use api_models::routing::{ CurrentBlockThreshold, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus, SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody, SuccessRateSpecificityLevel, }; pub use success_rate::{ success_rate_calculator_client::SuccessRateCalculatorClient, CalGlobalSuccessRateConfig, CalGlobalSuccessRateRequest, CalGlobalSuccessRateResponse, CalSuccessRateConfig, CalSuccessRateRequest, CalSuccessRateResponse, CurrentBlockThreshold as DynamicCurrentThreshold, InvalidateWindowsRequest, InvalidateWindowsResponse, LabelWithStatus, SuccessRateSpecificityLevel as ProtoSpecificityLevel, UpdateSuccessRateWindowConfig, UpdateSuccessRateWindowRequest, UpdateSuccessRateWindowResponse, }; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; fn foreign_try_from(current_threshold: CurrentBlockThreshold) -> Result<Self, Self::Error> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs | crate: external_services use api_models::routing::{ CurrentBlockThreshold, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus, SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody, SuccessRateSpecificityLevel, }; use router_env::{instrument, logger, tracing}; pub use success_rate::{ success_rate_calculator_client::SuccessRateCalculatorClient, CalGlobalSuccessRateConfig, CalGlobalSuccessRateRequest, CalGlobalSuccessRateResponse, CalSuccessRateConfig, CalSuccessRateRequest, CalSuccessRateResponse, CurrentBlockThreshold as DynamicCurrentThreshold, InvalidateWindowsRequest, InvalidateWindowsResponse, LabelWithStatus, SuccessRateSpecificityLevel as ProtoSpecificityLevel, UpdateSuccessRateWindowConfig, UpdateSuccessRateWindowRequest, UpdateSuccessRateWindowResponse, }; use super::{Client, DynamicRoutingError, DynamicRoutingResult}; use crate::grpc_client::{self, GrpcHeaders}; async fn invalidate_success_rate_routing_keys( &self, id: String, headers: GrpcHeaders, ) -> DynamicRoutingResult<InvalidateWindowsResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/ses.rs | crate: external_services use std::time::{Duration, SystemTime}; use aws_sdk_sesv2::{ config::Region, operation::send_email::SendEmailError, types::{Body, Content, Destination, EmailContent, Message}, Client, }; use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder; use common_utils::{errors::CustomResult, pii}; use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString}; async fn send_email( &self, recipient: pii::Email, subject: String, body: Self::RichText, proxy_url: Option<&String>, ) -> EmailResult<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/ses.rs | crate: external_services use std::time::{Duration, SystemTime}; use aws_sdk_sesv2::{ config::Region, operation::send_email::SendEmailError, types::{Body, Content, Destination, EmailContent, Message}, Client, }; use aws_sdk_sts::config::Credentials; use common_utils::{errors::CustomResult, pii}; use error_stack::{report, ResultExt}; use router_env::logger; use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString}; /// A helper function to create ses client pub async fn create_client( conf: &EmailSettings, ses_config: &SESConfig, proxy_url: Option<impl AsRef<str>>, ) -> CustomResult<Client, AwsSesError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/ses.rs | crate: external_services use aws_sdk_sesv2::{ config::Region, operation::send_email::SendEmailError, types::{Body, Content, Destination, EmailContent, Message}, Client, }; use common_utils::{errors::CustomResult, pii}; use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString}; fn convert_to_rich_text( &self, intermediate_string: IntermediateString, ) -> CustomResult<Self::RichText, EmailError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/ses.rs | crate: external_services use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder; use common_utils::{errors::CustomResult, pii}; use hyper::Uri; fn get_proxy_connector( proxy_url: impl AsRef<str>, ) -> CustomResult<hyper_proxy::ProxyConnector<hyper::client::HttpConnector>, AwsSesError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/ses.rs | crate: external_services use aws_sdk_sesv2::{ config::Region, operation::send_email::SendEmailError, types::{Body, Content, Destination, EmailContent, Message}, Client, }; use aws_sdk_sts::config::Credentials; use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder; use common_utils::{errors::CustomResult, pii}; fn get_shared_config( region: String, proxy_url: Option<impl AsRef<str>>, ) -> CustomResult<aws_config::ConfigLoader, AwsSesError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/ses.rs | crate: external_services use aws_sdk_sesv2::{ config::Region, operation::send_email::SendEmailError, types::{Body, Content, Destination, EmailContent, Message}, Client, }; use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder; use router_env::logger; use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString}; /// Constructs a new AwsSes client pub async fn create( conf: &EmailSettings, ses_config: &SESConfig, proxy_url: Option<impl AsRef<str>>, ) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/ses.rs | crate: external_services use std::time::{Duration, SystemTime}; use aws_sdk_sesv2::{ config::Region, operation::send_email::SendEmailError, types::{Body, Content, Destination, EmailContent, Message}, Client, }; use aws_sdk_sts::config::Credentials; use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder; use common_utils::{errors::CustomResult, pii}; use error_stack::{report, ResultExt}; use hyper::Uri; use masking::PeekInterface; use router_env::logger; use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString}; /// Validation for the SES client specific configs pub fn validate(&self) -> Result<(), &'static str> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/no_email.rs | crate: external_services use common_utils::{errors::CustomResult, pii}; use router_env::logger; use crate::email::{EmailClient, EmailError, EmailResult, IntermediateString}; async fn send_email( &self, _recipient: pii::Email, _subject: String, _body: Self::RichText, _proxy_url: Option<&String>, ) -> EmailResult<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/email/no_email.rs | crate: external_services /// Constructs a new client when email is disabled pub async fn create() -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/euclid_macros/src/lib.rs | crate: euclid_macros use proc_macro::TokenStream; pub fn knowledge(ts: TokenStream) -> TokenStream { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/euclid_macros/src/lib.rs | crate: euclid_macros use proc_macro::TokenStream; pub fn enum_nums(ts: TokenStream) -> TokenStream { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/strategy.rs | crate: masking use core::fmt; fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/abs.rs | crate: masking use crate::Secret; fn switch_strategy(self) -> Self::Output { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/abs.rs | crate: masking fn expose(self) -> S { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/abs.rs | crate: masking fn expose_option(self) -> Option<S> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/cassandra.rs | crate: masking use scylla::{ deserialize::DeserializeValue, frame::response::result::ColumnType, serialize::{ value::SerializeValue, writers::{CellWriter, WrittenCellProof}, SerializationError, }, }; fn deserialize( column_type: &'metadata ColumnType<'metadata>, v: Option<scylla::deserialize::FrameSlice<'frame>>, ) -> Result<Self, scylla::deserialize::DeserializationError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/cassandra.rs | crate: masking use scylla::{ deserialize::DeserializeValue, frame::response::result::ColumnType, serialize::{ value::SerializeValue, writers::{CellWriter, WrittenCellProof}, SerializationError, }, }; fn type_check(column_type: &ColumnType<'_>) -> Result<(), scylla::deserialize::TypeCheckError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/cassandra.rs | crate: masking use scylla::{ deserialize::DeserializeValue, frame::response::result::ColumnType, serialize::{ value::SerializeValue, writers::{CellWriter, WrittenCellProof}, SerializationError, }, }; fn serialize<'b>( &self, column_type: &ColumnType<'_>, writer: CellWriter<'b>, ) -> Result<WrittenCellProof<'b>, SerializationError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/masking/src/diesel.rs | crate: masking use diesel::{ backend::Backend, deserialize::{self, FromSql, Queryable}, expression::AsExpression, internal::derives::as_expression::Bound, serialize::{self, Output, ToSql}, sql_types, }; fn as_expression(self) -> Self::Expression { Bound::new(self) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/diesel.rs | crate: masking use diesel::{ backend::Backend, deserialize::{self, FromSql, Queryable}, expression::AsExpression, internal::derives::as_expression::Bound, serialize::{self, Output, ToSql}, sql_types, }; fn as_expression(self) -> Self::Expression { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/masking/src/diesel.rs | crate: masking use diesel::{ backend::Backend, deserialize::{self, FromSql, Queryable}, expression::AsExpression, internal::derives::as_expression::Bound, serialize::{self, Output, ToSql}, sql_types, }; fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result<Self> { S::from_sql(bytes).map(|raw| raw.into()) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/diesel.rs | crate: masking use diesel::{ backend::Backend, deserialize::{self, FromSql, Queryable}, expression::AsExpression, internal::derives::as_expression::Bound, serialize::{self, Output, ToSql}, sql_types, }; fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/masking/src/string.rs | crate: masking use alloc::{ str::FromStr, string::{String, ToString}, }; fn from_str(src: &str) -> Result<Self, Self::Err> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/masking/src/string.rs | crate: masking use alloc::{ str::FromStr, string::{String, ToString}, }; fn from_str(src: &str) -> Result<Self, Self::Err> { Ok(Self::new(src.to_string())) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/types.rs | crate: analytics use super::query::QueryBuildingError; use crate::errors::AnalyticsError; fn switch(&self) -> AnalyticsError { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/types.rs | crate: analytics use super::query::QueryBuildingError; pub type FiltersResult<T> = CustomResult<T, FiltersError>; fn switch(&self) -> FiltersError { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/types.rs | crate: analytics use super::query::QueryBuildingError; pub type MetricsResult<T> = CustomResult<T, MetricsError>; fn switch(&self) -> MetricsError { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/types.rs | crate: analytics fn get_table_engine(_table: AnalyticsCollection) -> TableEngine { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/types.rs | crate: analytics pub type MetricsResult<T> = CustomResult<T, MetricsError>; pub type FiltersResult<T> = CustomResult<T, FiltersError>; fn as_ref(&self) -> &T { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/search.rs | crate: analytics use serde_json::Value; pub fn convert_to_value<T: Into<Value>>(items: Vec<T>) -> Vec<Value> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/search.rs | crate: analytics use api_models::analytics::search::{ GetGlobalSearchRequest, GetSearchRequestWithIndex, GetSearchResponse, OpenMsearchOutput, OpensearchOutput, SearchIndex, SearchStatus, }; use common_utils::errors::{CustomResult, ReportSwitchExt}; use router_env::tracing; use serde_json::Value; use crate::{ enums::AuthInfo, opensearch::{OpenSearchClient, OpenSearchError, OpenSearchQuery, OpenSearchQueryBuilder}, }; pub async fn search_results( client: &OpenSearchClient, req: GetSearchRequestWithIndex, search_params: Vec<AuthInfo>, ) -> CustomResult<GetSearchResponse, OpenSearchError> { { OpensearchOutput::Success(success) => Ok(GetSearchResponse { count: success.hits.total.value, index: req.index, hits: success .hits .hits .into_iter() .map(|hit| hit.source) .collect(), status: SearchStatus::Success, }),<|fim_suffix|> <|fim_middle|> OpensearchOutput::Error(error) => { tracing::error!( index = ?req.index, error_response = ?error, "Search error" ); Ok(GetSearchResponse { count: 0, index: req.index, hits: Vec::new(), status: SearchStatus::Failure, }) } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/search.rs | crate: analytics use api_models::analytics::search::{ GetGlobalSearchRequest, GetSearchRequestWithIndex, GetSearchResponse, OpenMsearchOutput, OpensearchOutput, SearchIndex, SearchStatus, }; use common_utils::errors::{CustomResult, ReportSwitchExt}; use router_env::tracing; use serde_json::Value; use crate::{ enums::AuthInfo, opensearch::{OpenSearchClient, OpenSearchError, OpenSearchQuery, OpenSearchQueryBuilder}, }; pub async fn msearch_results( client: &OpenSearchClient, req: GetGlobalSearchRequest, search_params: Vec<AuthInfo>, indexes: Vec<SearchIndex>, ) -> CustomResult<Vec<GetSearchResponse>, OpenSearchError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_dispute_dimensions() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_dispute_metrics_info() -> Vec<NameDescription> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_api_event_metrics_info() -> Vec<NameDescription> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_auth_event_metrics_info() -> Vec<NameDescription> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_sdk_event_metrics_info() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_frm_metrics_info() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_refund_metrics_info() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_payment_intent_metrics_info() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_payment_metrics_info() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_api_event_dimensions() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_sdk_event_dimensions() -> Vec<NameDescription> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_frm_dimensions() -> Vec<NameDescription> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_refund_dimensions() -> Vec<NameDescription> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_auth_event_dimensions() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_payment_intent_dimensions() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/utils.rs | crate: analytics use api_models::analytics::{ api_event::{ApiEventDimensions, ApiEventMetrics}, auth_events::{AuthEventDimensions, AuthEventMetrics}, disputes::{DisputeDimensions, DisputeMetrics}, frm::{FrmDimensions, FrmMetrics}, payment_intents::{PaymentIntentDimensions, PaymentIntentMetrics}, payments::{PaymentDimensions, PaymentMetrics}, refunds::{RefundDimensions, RefundMetrics}, sdk_events::{SdkEventDimensions, SdkEventMetrics}, NameDescription, }; pub fn get_payment_dimensions() -> Vec<NameDescription> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/metrics/request.rs | crate: analytics use std::time; pub async fn record_operation_time<F, R, T>( future: F, metric: &once_cell::sync::Lazy<router_env::opentelemetry::metrics::Histogram<f64>>, metric_name: &T, source: &crate::AnalyticsProvider, ) -> R where F: futures::Future<Output = R>, T: ToString, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/api_event/types.rs | crate: analytics use api_models::analytics::api_event::{ApiEventDimensions, ApiEventFilters}; use crate::{ query::{QueryBuilder, QueryFilter, QueryResult, ToSql}, types::{AnalyticsCollection, AnalyticsDataSource}, }; fn set_filter_clause(&self, builder: &mut QueryBuilder<T>) -> QueryResult<()> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/hyperswitch_interfaces/src/conversion_impls.rs | crate: hyperswitch_interfaces use common_utils::{errors::CustomResult, id_type}; use hyperswitch_domain_models::{ payment_address::PaymentAddress, router_data::{self, RouterData}, router_data_v2::{ flow_common_types::{ AccessTokenFlowData, BillingConnectorPaymentsSyncFlowData, DisputesFlowData, ExternalAuthenticationFlowData, FilesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData, RevenueRecoveryRecordBackData, UasFlowData, WebhookSourceVerifyData, }, RouterDataV2, }, }; use crate::{connector_integration_interface::RouterDataConversion, errors::ConnectorError}; fn to_old_router_data( new_router_data: RouterDataV2<T, Self, Req, Resp>, ) -> CustomResult<RouterData<T, Req, Resp>, ConnectorError> where Self: Sized, { let Self { merchant_id, payment_id, attempt_id, payment_method, connector_meta_data, amount_captured, minor_amount_captured, connector_request_reference_id, dispute_id, } = new_router_data.resource_common_data; let mut router_data = get_default_router_data( new_router_data.tenant_id.clone(), "Disputes", new_router_data.request, new_router_data.response, ); router_data.merchant_id = merchant_id; router_data.payment_id = payment_id; router_data.attempt_id = attempt_id; router_data.payment_method = payment_method; router_data.connector_meta_data = connector_meta_data; router_data.amount_captured = amount_captured; router_data.minor_amount_captured = minor_amount_captured; router_data.connector_request_reference_id = connector_request_reference_id; router_data.dispute_id = Some(dispute_id); Ok(router_data) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_interfaces/src/conversion_impls.rs | crate: hyperswitch_interfaces use common_utils::{errors::CustomResult, id_type}; use hyperswitch_domain_models::{ payment_address::PaymentAddress, router_data::{self, RouterData}, router_data_v2::{ flow_common_types::{ AccessTokenFlowData, BillingConnectorPaymentsSyncFlowData, DisputesFlowData, ExternalAuthenticationFlowData, FilesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData, RevenueRecoveryRecordBackData, UasFlowData, WebhookSourceVerifyData, }, RouterDataV2, }, }; fn get_default_router_data<F, Req, Resp>( tenant_id: id_type::TenantId, flow_name: &str, request: Req, response: Result<Resp, router_data::ErrorResponse>, ) -> RouterData<F, Req, Resp> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_interfaces/src/conversion_impls.rs | crate: hyperswitch_interfaces use common_utils::{errors::CustomResult, id_type}; use hyperswitch_domain_models::{ payment_address::PaymentAddress, router_data::{self, RouterData}, router_data_v2::{ flow_common_types::{ AccessTokenFlowData, BillingConnectorPaymentsSyncFlowData, DisputesFlowData, ExternalAuthenticationFlowData, FilesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData, RevenueRecoveryRecordBackData, UasFlowData, WebhookSourceVerifyData, }, RouterDataV2, }, }; use crate::{connector_integration_interface::RouterDataConversion, errors::ConnectorError}; fn to_old_router_data( new_router_data: RouterDataV2<T, Self, Req, Resp>, ) -> CustomResult<RouterData<T, Req, Resp>, ConnectorError> where Self: Sized, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/hyperswitch_interfaces/src/conversion_impls.rs | crate: hyperswitch_interfaces use common_utils::{errors::CustomResult, id_type}; use hyperswitch_domain_models::{ payment_address::PaymentAddress, router_data::{self, RouterData}, router_data_v2::{ flow_common_types::{ AccessTokenFlowData, BillingConnectorPaymentsSyncFlowData, DisputesFlowData, ExternalAuthenticationFlowData, FilesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData, RevenueRecoveryRecordBackData, UasFlowData, WebhookSourceVerifyData, }, RouterDataV2, }, }; use crate::{connector_integration_interface::RouterDataConversion, errors::ConnectorError}; fn from_old_router_data( old_router_data: &RouterData<T, Req, Resp>, ) -> CustomResult<RouterDataV2<T, Self, Req, Resp>, ConnectorError> where Self: Sized, { let resource_common_data = Self {}; Ok(RouterDataV2 { flow: std::marker::PhantomData, tenant_id: old_router_data.tenant_id.clone(), resource_common_data, connector_auth_type: old_router_data.connector_auth_type.clone(), request: old_router_data.request.clone(), response: old_router_data.response.clone(), }) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_interfaces/src/conversion_impls.rs | crate: hyperswitch_interfaces use common_utils::{errors::CustomResult, id_type}; use hyperswitch_domain_models::{ payment_address::PaymentAddress, router_data::{self, RouterData}, router_data_v2::{ flow_common_types::{ AccessTokenFlowData, BillingConnectorPaymentsSyncFlowData, DisputesFlowData, ExternalAuthenticationFlowData, FilesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData, RevenueRecoveryRecordBackData, UasFlowData, WebhookSourceVerifyData, }, RouterDataV2, }, }; use crate::{connector_integration_interface::RouterDataConversion, errors::ConnectorError}; fn from_old_router_data( old_router_data: &RouterData<T, Req, Resp>, ) -> CustomResult<RouterDataV2<T, Self, Req, Resp>, ConnectorError> where Self: Sized, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_interfaces/src/conversion_impls.rs | crate: hyperswitch_interfaces fn get_irrelevant_id_string(id_name: &str, flow_name: &str) -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_interfaces/src/secrets_interface/secret_state.rs | crate: hyperswitch_interfaces use std::marker::PhantomData; /// Transition the secret state from `SecuredSecret` to `RawSecret` pub fn transition_state( mut self, decryptor_fn: impl FnOnce(T) -> T, ) -> SecretStateContainer<T, RawSecret> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_interfaces/src/secrets_interface/secret_state.rs | crate: hyperswitch_interfaces pub fn get_inner(&self) -> &T { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_interfaces/src/api/files.rs | crate: hyperswitch_interfaces use crate::{ api::{ConnectorCommon, ConnectorIntegration}, errors, }; /// fn validate_file_upload fn validate_file_upload( &self, _purpose: FilePurpose, _file_size: i32, _file_type: mime::Mime, ) -> common_utils::errors::CustomResult<(), errors::ConnectorError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_interfaces/src/api/files_v2.rs | crate: hyperswitch_interfaces use crate::api::{errors, files::FilePurpose, ConnectorCommon, ConnectorIntegrationV2}; /// fn validate_file_upload_v2 fn validate_file_upload_v2( &self, _purpose: FilePurpose, _file_size: i32, _file_type: mime::Mime, ) -> common_utils::errors::CustomResult<(), errors::ConnectorError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/cache.rs | crate: router use std::sync::Arc; use router::{configs::settings::Settings, routes, services}; use storage_impl::redis::cache::{self, CacheKey}; async fn invalidate_existing_cache_success() { {// Arrange<|fim_suffix|> <|fim_middle|> assert!(cache::ACCOUNTS_CACHE .get_val::<String>(CacheKey { key: cache_key, prefix: String::default() }) .await .is_none());}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/cache.rs | crate: router use storage_impl::redis::cache::{self, CacheKey}; async fn invalidate_non_existing_cache_success() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/refunds.rs | crate: router use utils::{mk_service, AppClient}; async fn refunds_todo() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/refunds.rs | crate: router use utils::{mk_service, AppClient}; async fn refund_create_fail_adyen() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/refunds.rs | crate: router use utils::{mk_service, AppClient}; async fn refund_create_fail_stripe() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/health_check.rs | crate: router use utils::{mk_service, AppClient}; async fn health_check() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use serde_json::{json, Value}; fn mk_connector(connector_name: &str, api_key: &str) -> Value { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use serde_json::{json, Value}; fn mk_refund(payment_id: &common_utils::id_type::PaymentId, amount: usize) -> Value { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use actix_http::{body::MessageBody, Request}; use actix_web::{ dev::{Service, ServiceResponse}, test::{call_and_read_body_json, TestRequest}, }; pub async fn health<S, B>(&self, app: &S) -> String where S: Service<Request, Response = ServiceResponse<B>, Error = actix_web::Error>, B: MessageBody, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router pub fn user(&self, authkey: &str) -> AppClient<User> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router pub fn admin(&self, authkey: &str) -> AppClient<Admin> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use actix_http::{body::MessageBody, Request}; use actix_web::{ dev::{Service, ServiceResponse}, test::{call_and_read_body_json, TestRequest}, }; use serde::{de::DeserializeOwned, Deserialize}; pub async fn create_refund<T: DeserializeOwned, S, B>( &self, app: &S, payment_id: &common_utils::id_type::PaymentId, amount: usize, ) -> T where S: Service<Request, Response = ServiceResponse<B>, Error = actix_web::Error>, B: MessageBody, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use actix_http::{body::MessageBody, Request}; use actix_web::{ dev::{Service, ServiceResponse}, test::{call_and_read_body_json, TestRequest}, }; use serde::{de::DeserializeOwned, Deserialize}; pub async fn create_payment<T: DeserializeOwned, S, B>( &self, app: &S, amount: i64, amount_to_capture: i32, ) -> T where S: Service<Request, Response = ServiceResponse<B>, Error = actix_web::Error>, B: MessageBody, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use actix_http::{body::MessageBody, Request}; use actix_web::{ dev::{Service, ServiceResponse}, test::{call_and_read_body_json, TestRequest}, }; use serde::{de::DeserializeOwned, Deserialize}; pub async fn create_connector<T: DeserializeOwned, S, B>( &self, app: &S, merchant_id: &common_utils::id_type::MerchantId, connector_name: &str, api_key: &str, ) -> T where S: Service<Request, Response = ServiceResponse<B>, Error = actix_web::Error>, B: MessageBody, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use actix_http::{body::MessageBody, Request}; use actix_web::{ dev::{Service, ServiceResponse}, test::{call_and_read_body_json, TestRequest}, }; use serde::{de::DeserializeOwned, Deserialize}; pub async fn create_merchant_account<T: DeserializeOwned, S, B>( &self, app: &S, merchant_id: impl Into<Option<String>>, ) -> T where S: Service<Request, Response = ServiceResponse<B>, Error = actix_web::Error>, B: MessageBody, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router pub fn guest() -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use actix_http::{body::MessageBody, Request}; use actix_web::{ dev::{Service, ServiceResponse}, test::{call_and_read_body_json, TestRequest}, }; use router::{configs::settings::Settings, routes::AppState, services}; use tokio::sync::{oneshot, OnceCell}; pub async fn mk_service( ) -> impl Service<Request, Response = ServiceResponse<impl MessageBody>, Error = actix_web::Error> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router async fn stripemock() -> Option<String> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router pub async fn setup() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/tests/utils.rs | crate: router use router::{configs::settings::Settings, routes::AppState, services}; use tokio::sync::{oneshot, OnceCell}; async fn spawn_server() -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments