id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
hyperswitch_method_external_services_HashiCorpVault_fetch
clm
method
// hyperswitch/crates/external_services/src/hashicorp_vault/core.rs // impl for HashiCorpVault pub async fn fetch<En, I>(&self, data: String) -> error_stack::Result<I, HashiCorpError> where for<'a> En: Engine< ReturnType<'a, String> = Pin< Box< dyn Future<Output = error_stack::Result<String, HashiCorpError>> + Send + 'a, >, >, > + 'a, I: FromEncoded, { let output = En::read(self, data).await?; I::from_encoded(output).ok_or(error_stack::report!(HashiCorpError::HexDecodingFailed)) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "HashiCorpVault", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "fetch", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsFileStorageConfig_validate
clm
method
// hyperswitch/crates/external_services/src/file_storage/aws_s3.rs // impl for AwsFileStorageConfig pub(super) fn validate(&self) -> Result<(), InvalidFileStorageConfig> { use common_utils::fp_utils::when; when(self.region.is_default_or_empty(), || { Err(InvalidFileStorageConfig("aws s3 region must not be empty")) })?; when(self.bucket_name.is_default_or_empty(), || { Err(InvalidFileStorageConfig( "aws s3 bucket name must not be empty", )) }) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsFileStorageConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsFileStorageClient_new
clm
method
// hyperswitch/crates/external_services/src/file_storage/aws_s3.rs // impl for AwsFileStorageClient pub(super) async fn new(config: &AwsFileStorageConfig) -> 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), bucket_name: config.bucket_name.clone(), } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsFileStorageClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_SecretsManagementConfig_validate
clm
method
// hyperswitch/crates/external_services/src/managers/secrets_management.rs // impl for SecretsManagementConfig pub fn validate(&self) -> Result<(), &'static str> { match self { #[cfg(feature = "aws_kms")] Self::AwsKms { aws_kms } => aws_kms.validate(), #[cfg(feature = "hashicorp-vault")] Self::HashiCorpVault { hc_vault } => hc_vault.validate(), Self::NoEncryption => Ok(()), } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "SecretsManagementConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_SecretsManagementConfig_get_secret_management_client
clm
method
// hyperswitch/crates/external_services/src/managers/secrets_management.rs // impl for SecretsManagementConfig pub async fn get_secret_management_client( &self, ) -> CustomResult<Box<dyn SecretManagementInterface>, SecretsManagementError> { match self { #[cfg(feature = "aws_kms")] Self::AwsKms { aws_kms } => { Ok(Box::new(aws_kms::core::AwsKmsClient::new(aws_kms).await)) } #[cfg(feature = "hashicorp-vault")] Self::HashiCorpVault { hc_vault } => { hashicorp_vault::core::HashiCorpVault::new(hc_vault) .change_context(SecretsManagementError::ClientCreationFailed) .map(|inner| -> Box<dyn SecretManagementInterface> { Box::new(inner) }) } Self::NoEncryption => Ok(Box::new(NoEncryption)), } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "SecretsManagementConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_secret_management_client", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_EncryptionManagementConfig_validate
clm
method
// hyperswitch/crates/external_services/src/managers/encryption_management.rs // impl for EncryptionManagementConfig pub fn validate(&self) -> Result<(), &'static str> { match self { #[cfg(feature = "aws_kms")] Self::AwsKms { aws_kms } => aws_kms.validate(), Self::NoEncryption => Ok(()), } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "EncryptionManagementConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_EncryptionManagementConfig_get_encryption_management_client
clm
method
// hyperswitch/crates/external_services/src/managers/encryption_management.rs // impl for EncryptionManagementConfig pub async fn get_encryption_management_client( &self, ) -> CustomResult<Arc<dyn EncryptionManagementInterface>, EncryptionError> { Ok(match self { #[cfg(feature = "aws_kms")] Self::AwsKms { aws_kms } => Arc::new(aws_kms::core::AwsKmsClient::new(aws_kms).await), Self::NoEncryption => Arc::new(NoEncryption), }) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "EncryptionManagementConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_encryption_management_client", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_NoEncryption_encrypt
clm
method
// hyperswitch/crates/external_services/src/no_encryption/core.rs // impl for NoEncryption pub fn encrypt(&self, data: impl AsRef<[u8]>) -> Vec<u8> { data.as_ref().into() }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "NoEncryption", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "encrypt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_NoEncryption_decrypt
clm
method
// hyperswitch/crates/external_services/src/no_encryption/core.rs // impl for NoEncryption pub fn decrypt(&self, data: impl AsRef<[u8]>) -> Vec<u8> { data.as_ref().into() }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "NoEncryption", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "decrypt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_NoEncryption_encrypt
clm
method
// hyperswitch/crates/external_services/src/no_encryption/core.rs // impl for NoEncryption pub fn encrypt(&self, data: impl AsRef<[u8]>) -> Vec<u8> { data.as_ref().into() }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "NoEncryption", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "encrypt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_NoEncryption_decrypt
clm
method
// hyperswitch/crates/external_services/src/no_encryption/core.rs // impl for NoEncryption pub fn decrypt(&self, data: impl AsRef<[u8]>) -> Vec<u8> { data.as_ref().into() }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "NoEncryption", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "decrypt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsKmsClient_new
clm
method
// hyperswitch/crates/external_services/src/aws_kms/core.rs // impl for AwsKmsClient 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(), } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsKmsClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsKmsClient_decrypt
clm
method
// hyperswitch/crates/external_services/src/aws_kms/core.rs // impl for AwsKmsClient pub async fn decrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, AwsKmsError> { let start = Instant::now(); let data = consts::BASE64_ENGINE .decode(data) .change_context(AwsKmsError::Base64DecodingFailed)?; let ciphertext_blob = Blob::new(data); let decrypt_output = self .inner_client .decrypt() .key_id(&self.key_id) .ciphertext_blob(ciphertext_blob) .send() .await .inspect_err(|error| { // Logging using `Debug` representation of the error as the `Display` // representation does not hold sufficient information. logger::error!(aws_kms_sdk_error=?error, "Failed to AWS KMS decrypt data"); metrics::AWS_KMS_DECRYPTION_FAILURES.add(1, &[]); }) .change_context(AwsKmsError::DecryptionFailed)?; let output = decrypt_output .plaintext .ok_or(report!(AwsKmsError::MissingPlaintextDecryptionOutput)) .and_then(|blob| { String::from_utf8(blob.into_inner()).change_context(AwsKmsError::Utf8DecodingFailed) })?; let time_taken = start.elapsed(); metrics::AWS_KMS_DECRYPT_TIME.record(time_taken.as_secs_f64(), &[]); Ok(output) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsKmsClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "decrypt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsKmsClient_encrypt
clm
method
// hyperswitch/crates/external_services/src/aws_kms/core.rs // impl for AwsKmsClient pub async fn encrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, AwsKmsError> { let start = Instant::now(); let plaintext_blob = Blob::new(data.as_ref()); let encrypted_output = self .inner_client .encrypt() .key_id(&self.key_id) .plaintext(plaintext_blob) .send() .await .inspect_err(|error| { // Logging using `Debug` representation of the error as the `Display` // representation does not hold sufficient information. logger::error!(aws_kms_sdk_error=?error, "Failed to AWS KMS encrypt data"); metrics::AWS_KMS_ENCRYPTION_FAILURES.add(1, &[]); }) .change_context(AwsKmsError::EncryptionFailed)?; let output = encrypted_output .ciphertext_blob .ok_or(AwsKmsError::MissingCiphertextEncryptionOutput) .map(|blob| consts::BASE64_ENGINE.encode(blob.into_inner()))?; let time_taken = start.elapsed(); metrics::AWS_KMS_ENCRYPT_TIME.record(time_taken.as_secs_f64(), &[]); Ok(output) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsKmsClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "encrypt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsKmsConfig_validate
clm
method
// hyperswitch/crates/external_services/src/aws_kms/core.rs // impl for AwsKmsConfig pub fn validate(&self) -> Result<(), &'static str> { use common_utils::{ext_traits::ConfigExt, fp_utils::when}; when(self.key_id.is_default_or_empty(), || { Err("KMS AWS key ID must not be empty") })?; when(self.region.is_default_or_empty(), || { Err("KMS AWS region must not be empty") }) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsKmsConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsKmsClient_decrypt
clm
method
// hyperswitch/crates/external_services/src/aws_kms/core.rs // impl for AwsKmsClient pub async fn decrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, AwsKmsError> { let start = Instant::now(); let data = consts::BASE64_ENGINE .decode(data) .change_context(AwsKmsError::Base64DecodingFailed)?; let ciphertext_blob = Blob::new(data); let decrypt_output = self .inner_client .decrypt() .key_id(&self.key_id) .ciphertext_blob(ciphertext_blob) .send() .await .inspect_err(|error| { // Logging using `Debug` representation of the error as the `Display` // representation does not hold sufficient information. logger::error!(aws_kms_sdk_error=?error, "Failed to AWS KMS decrypt data"); metrics::AWS_KMS_DECRYPTION_FAILURES.add(1, &[]); }) .change_context(AwsKmsError::DecryptionFailed)?; let output = decrypt_output .plaintext .ok_or(report!(AwsKmsError::MissingPlaintextDecryptionOutput)) .and_then(|blob| { String::from_utf8(blob.into_inner()).change_context(AwsKmsError::Utf8DecodingFailed) })?; let time_taken = start.elapsed(); metrics::AWS_KMS_DECRYPT_TIME.record(time_taken.as_secs_f64(), &[]); Ok(output) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsKmsClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "decrypt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsKmsClient_encrypt
clm
method
// hyperswitch/crates/external_services/src/aws_kms/core.rs // impl for AwsKmsClient pub async fn encrypt(&self, data: impl AsRef<[u8]>) -> CustomResult<String, AwsKmsError> { let start = Instant::now(); let plaintext_blob = Blob::new(data.as_ref()); let encrypted_output = self .inner_client .encrypt() .key_id(&self.key_id) .plaintext(plaintext_blob) .send() .await .inspect_err(|error| { // Logging using `Debug` representation of the error as the `Display` // representation does not hold sufficient information. logger::error!(aws_kms_sdk_error=?error, "Failed to AWS KMS encrypt data"); metrics::AWS_KMS_ENCRYPTION_FAILURES.add(1, &[]); }) .change_context(AwsKmsError::EncryptionFailed)?; let output = encrypted_output .ciphertext_blob .ok_or(AwsKmsError::MissingCiphertextEncryptionOutput) .map(|blob| consts::BASE64_ENGINE.encode(blob.into_inner()))?; let time_taken = start.elapsed(); metrics::AWS_KMS_ENCRYPT_TIME.record(time_taken.as_secs_f64(), &[]); Ok(output) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsKmsClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "encrypt", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_JsonValue_into_inner
clm
method
// hyperswitch/crates/external_services/src/superposition/types.rs // impl for JsonValue pub(super) fn into_inner(self) -> serde_json::Value { self.0 }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "JsonValue", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "into_inner", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_SuperpositionClientConfig_validate
clm
method
// hyperswitch/crates/external_services/src/superposition/types.rs // impl for SuperpositionClientConfig pub fn validate(&self) -> Result<(), SuperpositionError> { if !self.enabled { return Ok(()); } when(self.endpoint.is_empty(), || { Err(SuperpositionError::InvalidConfiguration( "Superposition endpoint cannot be empty".to_string(), )) })?; when(url::Url::parse(&self.endpoint).is_err(), || { Err(SuperpositionError::InvalidConfiguration( "Superposition endpoint must be a valid URL".to_string(), )) })?; when(self.token.clone().expose().is_empty(), || { Err(SuperpositionError::InvalidConfiguration( "Superposition token cannot be empty".to_string(), )) })?; when(self.org_id.is_empty(), || { Err(SuperpositionError::InvalidConfiguration( "Superposition org_id cannot be empty".to_string(), )) })?; when(self.workspace_id.is_empty(), || { Err(SuperpositionError::InvalidConfiguration( "Superposition workspace_id cannot be empty".to_string(), )) })?; Ok(()) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "SuperpositionClientConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_ConfigContext_new
clm
method
// hyperswitch/crates/external_services/src/superposition/types.rs // impl for ConfigContext pub fn new() -> Self { Self::default() }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "ConfigContext", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_ConfigContext_with
clm
method
// hyperswitch/crates/external_services/src/superposition/types.rs // impl for ConfigContext pub fn with(mut self, key: &str, value: &str) -> Self { self.values.insert(key.to_string(), value.to_string()); self }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "ConfigContext", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "with", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_DynamicRoutingClientConfig_get_dynamic_routing_connection
clm
method
// hyperswitch/crates/external_services/src/grpc_client/dynamic_routing.rs // impl for DynamicRoutingClientConfig pub fn get_dynamic_routing_connection( self, client: Client, ) -> Result<Option<RoutingStrategy>, Box<dyn std::error::Error>> { match self { Self::Enabled { host, port, .. } => { let uri = format!("http://{host}:{port}").parse::<tonic::transport::Uri>()?; logger::info!("Connection established with dynamic routing gRPC Server"); let (success_rate_client, contract_based_client, elimination_based_client) = ( SuccessRateCalculatorClient::with_origin(client.clone(), uri.clone()), ContractScoreCalculatorClient::with_origin(client.clone(), uri.clone()), EliminationAnalyserClient::with_origin(client, uri), ); Ok(Some(RoutingStrategy { success_rate_client, contract_based_client, elimination_based_client, })) } Self::Disabled => Ok(None), } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "DynamicRoutingClientConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_dynamic_routing_connection", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_RecoveryDeciderClientConfig_validate
clm
method
// hyperswitch/crates/external_services/src/grpc_client/revenue_recovery/recovery_decider_client.rs // impl for RecoveryDeciderClientConfig pub fn validate(&self) -> Result<(), RecoveryDeciderError> { use common_utils::fp_utils::when; when(self.base_url.is_empty(), || { Err(RecoveryDeciderError::ConfigError( "Recovery Decider base URL cannot be empty when configuration is provided" .to_string(), )) }) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "RecoveryDeciderClientConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_RecoveryDeciderClientConfig_get_recovery_decider_connection
clm
method
// hyperswitch/crates/external_services/src/grpc_client/revenue_recovery/recovery_decider_client.rs // impl for RecoveryDeciderClientConfig pub fn get_recovery_decider_connection( &self, hyper_client: Client, ) -> Result<DeciderClient<Client>, Report<RecoveryDeciderError>> { let uri = self .base_url .parse::<tonic::transport::Uri>() .map_err(Report::from) .change_context(RecoveryDeciderError::ConfigError(format!( "Invalid URI: {}", self.base_url )))?; let service_client = DeciderClient::with_origin(hyper_client, uri); Ok(service_client) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "RecoveryDeciderClientConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_recovery_decider_connection", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsSes_create
clm
method
// hyperswitch/crates/external_services/src/email/ses.rs // impl for AwsSes pub async fn create( conf: &EmailSettings, ses_config: &SESConfig, proxy_url: Option<impl AsRef<str>>, ) -> Self { // Build the client initially which will help us know if the email configuration is correct Self::create_client(conf, ses_config, proxy_url) .await .map_err(|error| logger::error!(?error, "Failed to initialize SES Client")) .ok(); Self { sender: conf.sender_email.clone(), ses_config: ses_config.clone(), settings: conf.clone(), } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsSes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsSes_create_client
clm
method
// hyperswitch/crates/external_services/src/email/ses.rs // impl for AwsSes pub async fn create_client( conf: &EmailSettings, ses_config: &SESConfig, proxy_url: Option<impl AsRef<str>>, ) -> CustomResult<Client, AwsSesError> { let sts_config = Self::get_shared_config(conf.aws_region.to_owned(), proxy_url.as_ref())? .load() .await; let role = aws_sdk_sts::Client::new(&sts_config) .assume_role() .role_arn(&ses_config.email_role_arn) .role_session_name(&ses_config.sts_role_session_name) .send() .await .change_context(AwsSesError::AssumeRoleFailure { region: conf.aws_region.to_owned(), role_arn: ses_config.email_role_arn.to_owned(), session_name: ses_config.sts_role_session_name.to_owned(), })?; let creds = role.credentials().ok_or( report!(AwsSesError::TemporaryCredentialsMissing(format!( "{role:?}" ))) .attach_printable("Credentials object not available"), )?; let credentials = Credentials::new( creds.access_key_id(), creds.secret_access_key(), Some(creds.session_token().to_owned()), u64::try_from(creds.expiration().as_nanos()) .ok() .map(Duration::from_nanos) .and_then(|val| SystemTime::UNIX_EPOCH.checked_add(val)), "custom_provider", ); logger::debug!( "Obtained SES temporary credentials with expiry {:?}", credentials.expiry() ); let ses_config = Self::get_shared_config(conf.aws_region.to_owned(), proxy_url)? .credentials_provider(credentials) .load() .await; Ok(Client::new(&ses_config)) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsSes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create_client", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsSes_get_shared_config
clm
method
// hyperswitch/crates/external_services/src/email/ses.rs // impl for AwsSes fn get_shared_config( region: String, proxy_url: Option<impl AsRef<str>>, ) -> CustomResult<aws_config::ConfigLoader, AwsSesError> { let region_provider = Region::new(region); let mut config = aws_config::from_env().region(region_provider); if let Some(proxy_url) = proxy_url { let proxy_connector = Self::get_proxy_connector(proxy_url)?; let http_client = HyperClientBuilder::new().build(proxy_connector); config = config.http_client(http_client); }; Ok(config) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsSes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_shared_config", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_AwsSes_get_proxy_connector
clm
method
// hyperswitch/crates/external_services/src/email/ses.rs // impl for AwsSes fn get_proxy_connector( proxy_url: impl AsRef<str>, ) -> CustomResult<hyper_proxy::ProxyConnector<hyper::client::HttpConnector>, AwsSesError> { let proxy_uri = proxy_url .as_ref() .parse::<Uri>() .attach_printable("Unable to parse the proxy url {proxy_url}") .change_context(AwsSesError::BuildingProxyConnectorFailed)?; let proxy = hyper_proxy::Proxy::new(hyper_proxy::Intercept::All, proxy_uri); hyper_proxy::ProxyConnector::from_proxy(hyper::client::HttpConnector::new(), proxy) .change_context(AwsSesError::BuildingProxyConnectorFailed) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "AwsSes", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_proxy_connector", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_NoEmailClient_create
clm
method
// hyperswitch/crates/external_services/src/email/no_email.rs // impl for NoEmailClient pub async fn create() -> Self { Self {} }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "NoEmailClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_SmtpServer_create_client
clm
method
// hyperswitch/crates/external_services/src/email/smtp.rs // impl for SmtpServer pub fn create_client(&self) -> Result<SmtpTransport, SmtpError> { let host = self.smtp_config.host.clone(); let port = self.smtp_config.port; let timeout = Some(Duration::from_secs(self.smtp_config.timeout)); let credentials = self .smtp_config .username .clone() .zip(self.smtp_config.password.clone()) .map(|(username, password)| { Credentials::new(username.peek().to_owned(), password.peek().to_owned()) }); match &self.smtp_config.connection { SmtpConnection::StartTls => match credentials { Some(credentials) => Ok(SmtpTransport::starttls_relay(&host) .map_err(SmtpError::ConnectionFailure)? .port(port) .timeout(timeout) .credentials(credentials) .build()), None => Ok(SmtpTransport::starttls_relay(&host) .map_err(SmtpError::ConnectionFailure)? .port(port) .timeout(timeout) .build()), }, SmtpConnection::Plaintext => match credentials { Some(credentials) => Ok(SmtpTransport::builder_dangerous(&host) .port(port) .timeout(timeout) .credentials(credentials) .build()), None => Ok(SmtpTransport::builder_dangerous(&host) .port(port) .timeout(timeout) .build()), }, } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "SmtpServer", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create_client", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_SmtpServer_create
clm
method
// hyperswitch/crates/external_services/src/email/smtp.rs // impl for SmtpServer pub async fn create(conf: &EmailSettings, smtp_config: SmtpServerConfig) -> Self { Self { sender: conf.sender_email.clone(), smtp_config: smtp_config.clone(), } }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "SmtpServer", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_external_services_SmtpServer_to_mail_box
clm
method
// hyperswitch/crates/external_services/src/email/smtp.rs // impl for SmtpServer fn to_mail_box(email: String) -> EmailResult<Mailbox> { Ok(Mailbox::new( None, email .parse() .map_err(SmtpError::EmailParsingFailed) .change_context(EmailError::EmailSendingFailure)?, )) }
{ "chunk": null, "crate": "external_services", "enum_name": null, "file_size": null, "for_type": "SmtpServer", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "to_mail_box", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_euclid_macros_ValueType_to_string
clm
method
// hyperswitch/crates/euclid_macros/src/inner/knowledge.rs // impl for ValueType fn to_string(&self, key: &str) -> String { match self { Self::Any => format!("{key}(any)"), Self::EnumVariant(s) => format!("{key}({s})"), Self::Number { number, comparison } => { format!("{key}({comparison}{number})") } } }
{ "chunk": null, "crate": "euclid_macros", "enum_name": null, "file_size": null, "for_type": "ValueType", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "to_string", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_StrongSecret<Secret, MaskingStrategy>_new
clm
method
// hyperswitch/crates/masking/src/strong_secret.rs // impl for StrongSecret<Secret, MaskingStrategy> pub fn new(secret: Secret) -> Self { Self { inner_secret: secret, masking_strategy: PhantomData, } }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "StrongSecret<Secret, MaskingStrategy>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Maskable<T>_into_inner
clm
method
// hyperswitch/crates/masking/src/maskable.rs // impl for Maskable<T> pub fn into_inner(self) -> T { match self { Self::Masked(inner_secret) => inner_secret.expose(), Self::Normal(inner) => inner, } }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Maskable<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "into_inner", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Maskable<T>_new_masked
clm
method
// hyperswitch/crates/masking/src/maskable.rs // impl for Maskable<T> pub fn new_masked(item: Secret<T>) -> Self { Self::Masked(item) }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Maskable<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new_masked", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Maskable<T>_new_normal
clm
method
// hyperswitch/crates/masking/src/maskable.rs // impl for Maskable<T> pub fn new_normal(item: T) -> Self { Self::Normal(item) }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Maskable<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new_normal", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Maskable<T>_is_masked
clm
method
// hyperswitch/crates/masking/src/maskable.rs // impl for Maskable<T> pub fn is_masked(&self) -> bool { matches!(self, Self::Masked(_)) }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Maskable<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "is_masked", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Maskable<T>_is_normal
clm
method
// hyperswitch/crates/masking/src/maskable.rs // impl for Maskable<T> pub fn is_normal(&self) -> bool { matches!(self, Self::Normal(_)) }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Maskable<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "is_normal", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_SecretBytesMut_new
clm
method
// hyperswitch/crates/masking/src/bytes.rs // impl for SecretBytesMut pub fn new(bytes: impl Into<BytesMut>) -> Self { Self(bytes.into()) }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "SecretBytesMut", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Secret<SecretValue, MaskingStrategy>_new
clm
method
// hyperswitch/crates/masking/src/secret.rs // impl for Secret<SecretValue, MaskingStrategy> pub fn new(secret: SecretValue) -> Self { Self { inner_secret: secret, masking_strategy: PhantomData, } }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Secret<SecretValue, MaskingStrategy>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Secret<SecretValue, MaskingStrategy>_zip
clm
method
// hyperswitch/crates/masking/src/secret.rs // impl for Secret<SecretValue, MaskingStrategy> pub fn zip<OtherSecretValue>( self, other: Secret<OtherSecretValue, MaskingStrategy>, ) -> Secret<(SecretValue, OtherSecretValue), MaskingStrategy> where MaskingStrategy: Strategy<OtherSecretValue> + Strategy<(SecretValue, OtherSecretValue)>, { (self.inner_secret, other.inner_secret).into() }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Secret<SecretValue, MaskingStrategy>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "zip", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Secret<SecretValue, MaskingStrategy>_map
clm
method
// hyperswitch/crates/masking/src/secret.rs // impl for Secret<SecretValue, MaskingStrategy> pub fn map<OtherSecretValue>( self, f: impl FnOnce(SecretValue) -> OtherSecretValue, ) -> Secret<OtherSecretValue, MaskingStrategy> where MaskingStrategy: Strategy<OtherSecretValue>, { f(self.inner_secret).into() }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Secret<SecretValue, MaskingStrategy>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "map", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_masking_Secret<SecretValue, MaskingStrategy>_into_strong
clm
method
// hyperswitch/crates/masking/src/secret.rs // impl for Secret<SecretValue, MaskingStrategy> pub fn into_strong(self) -> StrongSecret<SecretValue, MaskingStrategy> where SecretValue: zeroize::DefaultIsZeroes, { StrongSecret::new(self.inner_secret) }
{ "chunk": null, "crate": "masking", "enum_name": null, "file_size": null, "for_type": "Secret<SecretValue, MaskingStrategy>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "into_strong", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_injector_ConnectionConfig_new
clm
method
// hyperswitch/crates/injector/src/types.rs // impl for ConnectionConfig pub fn new(endpoint: String, http_method: HttpMethod) -> Self { Self { endpoint, http_method, headers: HashMap::new(), proxy_url: None, backup_proxy_url: None, client_cert: None, client_key: None, ca_cert: None, insecure: None, cert_password: None, cert_format: None, max_response_size: None, } }
{ "chunk": null, "crate": "injector", "enum_name": null, "file_size": null, "for_type": "ConnectionConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_injector_VaultMetadataError_url_validation_failed
clm
method
// hyperswitch/crates/injector/src/vault_metadata.rs // impl for VaultMetadataError pub fn url_validation_failed(field: &str, url: &str, reason: impl Into<String>) -> Self { Self::UrlValidationFailed { field: field.to_string(), url: url.to_string(), reason: reason.into(), } }
{ "chunk": null, "crate": "injector", "enum_name": null, "file_size": null, "for_type": "VaultMetadataError", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "url_validation_failed", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_injector_VaultMetadataFactory_from_base64_header
clm
method
// hyperswitch/crates/injector/src/vault_metadata.rs // impl for VaultMetadataFactory pub fn from_base64_header( base64_value: &str, ) -> Result<Box<dyn VaultMetadataProcessor>, VaultMetadataError> { // Validate input if base64_value.trim().is_empty() { return Err(VaultMetadataError::EmptyOrMalformedHeader); } // Decode base64 with detailed error context let decoded_bytes = BASE64_ENGINE.decode(base64_value.trim()).map_err(|e| { logger::error!( error = %e, "Failed to decode base64 vault metadata header" ); VaultMetadataError::Base64DecodingFailed(format!("Invalid base64 encoding: {e}")) })?; // Validate decoded size if decoded_bytes.is_empty() { return Err(VaultMetadataError::EmptyOrMalformedHeader); } if decoded_bytes.len() > 1_000_000 { return Err(VaultMetadataError::JsonParsingFailed( "Decoded vault metadata is too large (>1MB)".to_string(), )); } // Parse JSON with detailed error context let metadata: ExternalVaultProxyMetadata = serde_json::from_slice(&decoded_bytes).map_err(|e| { logger::error!( error = %e, "Failed to parse vault metadata JSON" ); VaultMetadataError::JsonParsingFailed(format!("Invalid JSON structure: {e}")) })?; logger::info!( vault_connector = ?metadata.vault_connector(), "Successfully parsed vault metadata from header" ); Ok(Box::new(metadata)) }
{ "chunk": null, "crate": "injector", "enum_name": null, "file_size": null, "for_type": "VaultMetadataFactory", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "from_base64_header", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_SqlxClient_from_conf
clm
method
// hyperswitch/crates/analytics/src/sqlx.rs // impl for SqlxClient pub async fn from_conf(conf: &Database, schema: &str) -> Self { let database_url = conf.get_database_url(schema); #[allow(clippy::expect_used)] let pool = PgPoolOptions::new() .max_connections(conf.pool_size) .acquire_timeout(std::time::Duration::from_secs(conf.connection_timeout)) .connect_lazy(&database_url) .expect("SQLX Pool Creation failed"); Self { pool } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "SqlxClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "from_conf", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_ClickhouseClient_execute_query
clm
method
// hyperswitch/crates/analytics/src/clickhouse.rs // impl for ClickhouseClient async fn execute_query(&self, query: &str) -> ClickhouseResult<Vec<serde_json::Value>> { logger::debug!("Executing query: {query}"); let client = reqwest::Client::new(); let params = CkhQuery { date_time_output_format: String::from("iso"), output_format_json_quote_64bit_integers: 0, database: self.database.clone(), }; let response = client .post(&self.config.host) .query(&params) .basic_auth(self.config.username.clone(), self.config.password.clone()) .body(format!("{query}\nFORMAT JSON")) .send() .await .change_context(ClickhouseError::ConnectionError)?; logger::debug!(clickhouse_response=?response, query=?query, "Clickhouse response"); if response.status() != StatusCode::OK { response.text().await.map_or_else( |er| { Err(ClickhouseError::ResponseError) .attach_printable_lazy(|| format!("Error: {er:?}")) }, |t| Err(report!(ClickhouseError::ResponseNotOK(t))), ) } else { Ok(response .json::<CkhOutput<serde_json::Value>>() .await .change_context(ClickhouseError::ResponseError)? .data) } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "ClickhouseClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "execute_query", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_AnalyticsConfig_get_forex_enabled
clm
method
// hyperswitch/crates/analytics/src/lib.rs // impl for AnalyticsConfig pub fn get_forex_enabled(&self) -> bool { match self { Self::Sqlx { forex_enabled, .. } | Self::Clickhouse { forex_enabled, .. } | Self::CombinedCkh { forex_enabled, .. } | Self::CombinedSqlx { forex_enabled, .. } => *forex_enabled, } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "AnalyticsConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_forex_enabled", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_new
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn new(table: AnalyticsCollection) -> Self { Self { columns: Default::default(), filters: Default::default(), group_by: Default::default(), order_by: Default::default(), having: Default::default(), limit_by: Default::default(), outer_select: Default::default(), top_n: Default::default(), table, distinct: Default::default(), db_type: Default::default(), table_engine: T::get_table_engine(table), } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_select_column
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_select_column(&mut self, column: impl ToSql<T>) -> QueryResult<()> { self.columns.push( column .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing select column")?, ); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_select_column", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_transform_to_sql_values
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn transform_to_sql_values(&mut self, values: &[impl ToSql<T>]) -> QueryResult<String> { let res = values .iter() .map(|i| i.to_sql(&self.table_engine)) .collect::<error_stack::Result<Vec<String>, ParsingError>>() .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing range filter value")? .join(", "); Ok(res) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "transform_to_sql_values", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_top_n_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_top_n_clause( &mut self, columns: &[impl ToSql<T>], count: u64, order_column: impl ToSql<T>, order: Order, ) -> QueryResult<()> where Window<&'static str>: ToSql<T>, { let partition_by_columns = self.transform_to_sql_values(columns)?; let order_by_column = order_column .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing select column")?; self.add_outer_select_column(Window::RowNumber { field: "", partition_by: Some(partition_by_columns.clone()), order_by: Some((order_by_column.clone(), order)), alias: Some("top_n"), })?; self.top_n = Some(TopN { columns: partition_by_columns, count, order_column: order_by_column, order, }); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_top_n_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_set_distinct
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn set_distinct(&mut self) { self.distinct = true }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "set_distinct", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_filter_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_filter_clause( &mut self, key: impl ToSql<T>, value: impl ToSql<T>, ) -> QueryResult<()> { self.add_custom_filter_clause(key, value, FilterTypes::Equal) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_filter_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_bool_filter_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_bool_filter_clause( &mut self, key: impl ToSql<T>, value: impl ToSql<T>, ) -> QueryResult<()> { self.add_custom_filter_clause(key, value, FilterTypes::EqualBool) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_bool_filter_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_negative_filter_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_negative_filter_clause( &mut self, key: impl ToSql<T>, value: impl ToSql<T>, ) -> QueryResult<()> { self.add_custom_filter_clause(key, value, FilterTypes::NotEqual) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_negative_filter_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_custom_filter_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_custom_filter_clause( &mut self, lhs: impl ToSql<T>, rhs: impl ToSql<T>, comparison: FilterTypes, ) -> QueryResult<()> { let filter = Filter::Plain( lhs.to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing filter key")?, comparison, rhs.to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing filter value")?, ); self.add_nested_filter_clause(filter); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_custom_filter_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_nested_filter_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_nested_filter_clause(&mut self, filter: Filter) { match &mut self.filters { Filter::NestedFilter(_, ref mut filters) => filters.push(filter), f @ Filter::Plain(_, _, _) => { self.filters = Filter::NestedFilter(FilterCombinator::And, vec![f.clone(), filter]); } } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_nested_filter_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_filter_in_range_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_filter_in_range_clause( &mut self, key: impl ToSql<T>, values: &[impl ToSql<T>], ) -> QueryResult<()> { let list = values .iter() .map(|i| { // trimming whitespaces from the filter values received in request, to prevent a possibility of an SQL injection i.to_sql(&self.table_engine).map(|s| { let trimmed_str = s.replace(' ', ""); format!("'{trimmed_str}'") }) }) .collect::<error_stack::Result<Vec<String>, ParsingError>>() .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing range filter value")? .join(", "); self.add_custom_filter_clause(key, list, FilterTypes::In) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_filter_in_range_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_group_by_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_group_by_clause(&mut self, column: impl ToSql<T>) -> QueryResult<()> { self.group_by.push( column .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing group by field")?, ); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_group_by_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_order_by_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_order_by_clause( &mut self, column: impl ToSql<T>, order: impl ToSql<T>, ) -> QueryResult<()> { let column_sql = column .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing order by column")?; let order_sql = order .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing order direction")?; self.order_by.push(format!("{column_sql} {order_sql}")); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_order_by_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_set_limit_by
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn set_limit_by(&mut self, limit: u64, columns: &[impl ToSql<T>]) -> QueryResult<()> { let columns = columns .iter() .map(|col| col.to_sql(&self.table_engine)) .collect::<Result<Vec<String>, _>>() .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing LIMIT BY columns")?; self.limit_by = Some(LimitByClause { limit, columns }); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "set_limit_by", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_granularity_in_mins
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_granularity_in_mins(&mut self, granularity: Granularity) -> QueryResult<()> { let interval = match granularity { Granularity::OneMin => "1", Granularity::FiveMin => "5", Granularity::FifteenMin => "15", Granularity::ThirtyMin => "30", Granularity::OneHour => "60", Granularity::OneDay => "1440", }; let _ = self.add_select_column(format!( "toStartOfInterval(created_at, INTERVAL {interval} MINUTE) as time_bucket" )); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_granularity_in_mins", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_get_filter_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> fn get_filter_clause(&self) -> QueryResult<String> { <Filter as ToSql<T>>::to_sql(&self.filters, &self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_filter_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_get_select_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> fn get_select_clause(&self) -> String { self.columns.join(", ") }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_select_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_get_group_by_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> fn get_group_by_clause(&self) -> String { self.group_by.join(", ") }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_group_by_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_get_outer_select_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> fn get_outer_select_clause(&self) -> String { self.outer_select.join(", ") }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_outer_select_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_having_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_having_clause<R>( &mut self, aggregate: Aggregate<R>, filter_type: FilterTypes, value: impl ToSql<T>, ) -> QueryResult<()> where Aggregate<R>: ToSql<T>, { let aggregate = aggregate .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing having aggregate")?; let value = value .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing having value")?; let entry = (aggregate, filter_type, value); if let Some(having) = &mut self.having { having.push(entry); } else { self.having = Some(vec![entry]); } Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_having_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_add_outer_select_column
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn add_outer_select_column(&mut self, column: impl ToSql<T>) -> QueryResult<()> { self.outer_select.push( column .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing outer select column")?, ); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_outer_select_column", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_get_filter_type_clause
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn get_filter_type_clause(&self) -> Option<String> { self.having.as_ref().map(|vec| { vec.iter() .map(|(l, op, r)| filter_type_to_sql(l, *op, r)) .collect::<Vec<String>>() .join(" AND ") }) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_filter_type_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_build_query
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub fn build_query(&mut self) -> QueryResult<String> where Aggregate<&'static str>: ToSql<T>, Window<&'static str>: ToSql<T>, { if self.columns.is_empty() { Err(QueryBuildingError::InvalidQuery( "No select fields provided", ))?; } let mut query = String::from("SELECT "); if self.distinct { query.push_str("DISTINCT "); } query.push_str(&self.get_select_clause()); query.push_str(" FROM "); query.push_str( &self .table .to_sql(&self.table_engine) .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Error serializing table value")?, ); let filter_clause = self.get_filter_clause()?; if !filter_clause.is_empty() { query.push_str(" WHERE "); query.push_str(filter_clause.as_str()); } if !self.group_by.is_empty() { query.push_str(" GROUP BY "); query.push_str(&self.get_group_by_clause()); if let TableEngine::CollapsingMergeTree { sign } = self.table_engine { self.add_having_clause( Aggregate::Count { field: Some(sign), alias: None, }, FilterTypes::Gte, "1", )?; } } if self.having.is_some() { if let Some(condition) = self.get_filter_type_clause() { query.push_str(" HAVING "); query.push_str(condition.as_str()); } } if !self.order_by.is_empty() { query.push_str(" ORDER BY "); query.push_str(&self.order_by.join(", ")); } if let Some(limit_by) = &self.limit_by { query.push_str(&format!(" {limit_by}")); } if !self.outer_select.is_empty() { query.insert_str( 0, format!("SELECT {} FROM (", &self.get_outer_select_clause()).as_str(), ); query.push_str(") _"); } if let Some(top_n) = &self.top_n { query.insert_str(0, "SELECT * FROM ("); query.push_str(format!(") _ WHERE top_n <= {}", top_n.count).as_str()); } logger::debug!(%query); Ok(query) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "build_query", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_QueryBuilder<T>_execute_query
clm
method
// hyperswitch/crates/analytics/src/query.rs // impl for QueryBuilder<T> pub async fn execute_query<R, P>( &mut self, store: &P, ) -> CustomResult<CustomResult<Vec<R>, QueryExecutionError>, QueryBuildingError> where P: LoadRow<R> + AnalyticsDataSource, Aggregate<&'static str>: ToSql<T>, Window<&'static str>: ToSql<T>, { let query = self .build_query() .change_context(QueryBuildingError::SqlSerializeError) .attach_printable("Failed to execute query")?; Ok(store.load_results(query.as_str()).await) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "QueryBuilder<T>", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "execute_query", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchClient_create
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchClient pub async fn create(conf: &OpenSearchConfig) -> CustomResult<Self, OpenSearchError> { let url = Url::parse(&conf.host).map_err(|_| OpenSearchError::ConnectionError)?; let transport = match &conf.auth { OpenSearchAuth::Basic { username, password } => { let credentials = Credentials::Basic(username.clone(), password.clone()); TransportBuilder::new(SingleNodeConnectionPool::new(url)) .cert_validation(CertificateValidation::None) .auth(credentials) .build() .map_err(|_| OpenSearchError::ConnectionError)? } OpenSearchAuth::Aws { region } => { let region_provider = RegionProviderChain::first_try(Region::new(region.clone())); let sdk_config = aws_config::from_env().region(region_provider).load().await; let conn_pool = SingleNodeConnectionPool::new(url); TransportBuilder::new(conn_pool) .auth( sdk_config .clone() .try_into() .map_err(|_| OpenSearchError::ConnectionError)?, ) .service_name("es") .build() .map_err(|_| OpenSearchError::ConnectionError)? } }; Ok(Self { transport: transport.clone(), client: OpenSearch::new(transport), indexes: conf.indexes.clone(), }) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "create", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchClient_search_index_to_opensearch_index
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchClient pub fn search_index_to_opensearch_index(&self, index: SearchIndex) -> String { match index { SearchIndex::PaymentAttempts => self.indexes.payment_attempts.clone(), SearchIndex::PaymentIntents => self.indexes.payment_intents.clone(), SearchIndex::Refunds => self.indexes.refunds.clone(), SearchIndex::Disputes => self.indexes.disputes.clone(), SearchIndex::SessionizerPaymentAttempts => { self.indexes.sessionizer_payment_attempts.clone() } SearchIndex::SessionizerPaymentIntents => { self.indexes.sessionizer_payment_intents.clone() } SearchIndex::SessionizerRefunds => self.indexes.sessionizer_refunds.clone(), SearchIndex::SessionizerDisputes => self.indexes.sessionizer_disputes.clone(), } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "search_index_to_opensearch_index", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchClient_execute
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchClient pub async fn execute( &self, query_builder: OpenSearchQueryBuilder, ) -> CustomResult<Response, OpenSearchError> { match query_builder.query_type { OpenSearchQuery::Msearch(ref indexes) => { let payload = query_builder .construct_payload(indexes) .change_context(OpenSearchError::QueryBuildingError)?; let payload_with_indexes = payload.into_iter().zip(indexes).fold( Vec::new(), |mut payload_with_indexes, (index_hit, index)| { payload_with_indexes.push( json!({"index": self.search_index_to_opensearch_index(*index)}).into(), ); payload_with_indexes.push(JsonBody::new(index_hit.clone())); payload_with_indexes }, ); self.client .msearch(MsearchParts::None) .body(payload_with_indexes) .send() .await .change_context(OpenSearchError::ResponseError) } OpenSearchQuery::Search(index) => { let payload = query_builder .clone() .construct_payload(&[index]) .change_context(OpenSearchError::QueryBuildingError)?; let final_payload = payload.first().unwrap_or(&Value::Null); self.client .search(SearchParts::Index(&[ &self.search_index_to_opensearch_index(index) ])) .from(query_builder.offset.unwrap_or(0)) .size(query_builder.count.unwrap_or(10)) .body(final_payload) .send() .await .change_context(OpenSearchError::ResponseError) } } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchClient", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "execute", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchConfig_validate
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchConfig pub fn validate(&self) -> Result<(), ApplicationError> { use common_utils::{ext_traits::ConfigExt, fp_utils::when}; if !self.enabled { return Ok(()); } when(self.host.is_default_or_empty(), || { Err(ApplicationError::InvalidConfigurationValueError( "Opensearch host must not be empty".into(), )) })?; self.indexes.validate()?; self.auth.validate()?; Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "validate", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchConfig_get_opensearch_client
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchConfig pub async fn get_opensearch_client(&self) -> StorageResult<Option<OpenSearchClient>> { if !self.enabled { return Ok(None); } Ok(Some( OpenSearchClient::create(self) .await .change_context(StorageError::InitializationError)?, )) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchConfig", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_opensearch_client", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_new
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn new(query_type: OpenSearchQuery, query: String, search_params: Vec<AuthInfo>) -> Self { Self { query_type, query, search_params, offset: Default::default(), count: Default::default(), filters: Default::default(), time_range: Default::default(), case_sensitive_fields: HashSet::from([ "customer_email.keyword", "search_tags.keyword", "card_last_4.keyword", "payment_id.keyword", "amount", "customer_id.keyword", ]), } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "new", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_set_offset_n_count
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn set_offset_n_count(&mut self, offset: i64, count: i64) -> QueryResult<()> { self.offset = Some(offset); self.count = Some(count); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "set_offset_n_count", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_set_time_range
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn set_time_range(&mut self, time_range: OpensearchTimeRange) -> QueryResult<()> { self.time_range = Some(time_range); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "set_time_range", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_add_filter_clause
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn add_filter_clause(&mut self, lhs: String, rhs: Vec<Value>) -> QueryResult<()> { self.filters.push((lhs, rhs)); Ok(()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "add_filter_clause", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_get_status_field
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn get_status_field(&self, index: SearchIndex) -> &str { match index { SearchIndex::Refunds | SearchIndex::SessionizerRefunds => "refund_status.keyword", SearchIndex::Disputes | SearchIndex::SessionizerDisputes => "dispute_status.keyword", _ => "status.keyword", } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_status_field", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_get_amount_field
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn get_amount_field(&self, index: SearchIndex) -> &str { match index { SearchIndex::Refunds | SearchIndex::SessionizerRefunds => "refund_amount", SearchIndex::Disputes | SearchIndex::SessionizerDisputes => "dispute_amount", _ => "amount", } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_amount_field", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_build_filter_array
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn build_filter_array( &self, case_sensitive_filters: Vec<&(String, Vec<Value>)>, index: SearchIndex, ) -> Vec<Value> { let mut filter_array = Vec::new(); if !self.query.is_empty() { filter_array.push(json!({ "multi_match": { "type": "phrase", "query": self.query, "lenient": true } })); } let case_sensitive_json_filters = case_sensitive_filters .into_iter() .map(|(k, v)| { let key = if *k == "amount" { self.get_amount_field(index).to_string() } else { k.clone() }; json!({"terms": {key: v}}) }) .collect::<Vec<Value>>(); filter_array.extend(case_sensitive_json_filters); if let Some(ref time_range) = self.time_range { let range = json!(time_range); filter_array.push(json!({ "range": { "@timestamp": range } })); } filter_array }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "build_filter_array", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_build_case_insensitive_filters
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn build_case_insensitive_filters( &self, mut payload: Value, case_insensitive_filters: &[&(String, Vec<Value>)], auth_array: Vec<Value>, index: SearchIndex, ) -> Value { let mut must_array = case_insensitive_filters .iter() .map(|(k, v)| { let key = if *k == "status.keyword" { self.get_status_field(index).to_string() } else { k.clone() }; json!({ "bool": { "must": [ { "bool": { "should": v.iter().map(|value| { json!({ "term": { format!("{}", key): { "value": value, "case_insensitive": true } } }) }).collect::<Vec<Value>>(), "minimum_should_match": 1 } } ] } }) }) .collect::<Vec<Value>>(); must_array.push(json!({ "bool": { "must": [ { "bool": { "should": auth_array, "minimum_should_match": 1 } } ] }})); if let Some(query) = payload.get_mut("query") { if let Some(bool_obj) = query.get_mut("bool") { if let Some(bool_map) = bool_obj.as_object_mut() { bool_map.insert("must".to_string(), Value::Array(must_array)); } } } payload }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "build_case_insensitive_filters", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_build_auth_array
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn build_auth_array(&self) -> Vec<Value> { self.search_params .iter() .map(|user_level| match user_level { AuthInfo::OrgLevel { org_id } => { let must_clauses = vec![json!({ "term": { "organization_id.keyword": { "value": org_id } } })]; json!({ "bool": { "must": must_clauses } }) } AuthInfo::MerchantLevel { org_id, merchant_ids, } => { let must_clauses = vec![ json!({ "term": { "organization_id.keyword": { "value": org_id } } }), json!({ "terms": { "merchant_id.keyword": merchant_ids } }), ]; json!({ "bool": { "must": must_clauses } }) } AuthInfo::ProfileLevel { org_id, merchant_id, profile_ids, } => { let must_clauses = vec![ json!({ "term": { "organization_id.keyword": { "value": org_id } } }), json!({ "term": { "merchant_id.keyword": { "value": merchant_id } } }), json!({ "terms": { "profile_id.keyword": profile_ids } }), ]; json!({ "bool": { "must": must_clauses } }) } }) .collect::<Vec<Value>>() }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "build_auth_array", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_OpenSearchQueryBuilder_construct_payload
clm
method
// hyperswitch/crates/analytics/src/opensearch.rs // impl for OpenSearchQueryBuilder pub fn construct_payload(&self, indexes: &[SearchIndex]) -> QueryResult<Vec<Value>> { let mut query_obj = Map::new(); let bool_obj = Map::new(); let (case_sensitive_filters, case_insensitive_filters): (Vec<_>, Vec<_>) = self .filters .iter() .partition(|(k, _)| self.case_sensitive_fields.contains(k.as_str())); let should_array = self.build_auth_array(); query_obj.insert("bool".to_string(), Value::Object(bool_obj.clone())); let mut sort_obj = Map::new(); sort_obj.insert( "@timestamp".to_string(), json!({ "order": "desc" }), ); Ok(indexes .iter() .map(|index| { let mut payload = json!({ "query": query_obj.clone(), "sort": [ Value::Object(sort_obj.clone()) ] }); let filter_array = self.build_filter_array(case_sensitive_filters.clone(), *index); if !filter_array.is_empty() { payload .get_mut("query") .and_then(|query| query.get_mut("bool")) .and_then(|bool_obj| bool_obj.as_object_mut()) .map(|bool_map| { bool_map.insert("filter".to_string(), Value::Array(filter_array)); }); } payload = self.build_case_insensitive_filters( payload, &case_insensitive_filters, should_array.clone(), *index, ); payload }) .collect::<Vec<Value>>()) }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "OpenSearchQueryBuilder", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "construct_payload", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_PaymentMetricsAccumulator_collect
clm
method
// hyperswitch/crates/analytics/src/payments/accumulator.rs // impl for PaymentMetricsAccumulator pub fn collect(self) -> PaymentMetricsBucketValue { let ( payment_processed_amount, payment_processed_count, payment_processed_amount_without_smart_retries, payment_processed_count_without_smart_retries, payment_processed_amount_in_usd, payment_processed_amount_without_smart_retries_usd, ) = self.processed_amount.collect(); let ( payments_success_rate_distribution, payments_success_rate_distribution_without_smart_retries, payments_success_rate_distribution_with_only_retries, payments_failure_rate_distribution, payments_failure_rate_distribution_without_smart_retries, payments_failure_rate_distribution_with_only_retries, ) = self.payments_distribution.collect(); let (failure_reason_count, failure_reason_count_without_smart_retries) = self.failure_reasons_distribution.collect(); let (debit_routed_transaction_count, debit_routing_savings, debit_routing_savings_in_usd) = self.debit_routing.collect(); PaymentMetricsBucketValue { payment_success_rate: self.payment_success_rate.collect(), payment_count: self.payment_count.collect(), payment_success_count: self.payment_success.collect(), payment_processed_amount, payment_processed_count, payment_processed_amount_without_smart_retries, payment_processed_count_without_smart_retries, avg_ticket_size: self.avg_ticket_size.collect(), payment_error_message: self.payment_error_message.collect(), retries_count: self.retries_count.collect(), retries_amount_processed: self.retries_amount_processed.collect(), connector_success_rate: self.connector_success_rate.collect(), payments_success_rate_distribution, payments_success_rate_distribution_without_smart_retries, payments_success_rate_distribution_with_only_retries, payments_failure_rate_distribution, payments_failure_rate_distribution_without_smart_retries, payments_failure_rate_distribution_with_only_retries, failure_reason_count, failure_reason_count_without_smart_retries, payment_processed_amount_in_usd, payment_processed_amount_without_smart_retries_usd, debit_routed_transaction_count, debit_routing_savings, debit_routing_savings_in_usd, } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "PaymentMetricsAccumulator", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "collect", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_PaymentIntentMetricsAccumulator_collect
clm
method
// hyperswitch/crates/analytics/src/payment_intents/accumulator.rs // impl for PaymentIntentMetricsAccumulator pub fn collect(self) -> PaymentIntentMetricsBucketValue { let ( successful_payments, successful_payments_without_smart_retries, total_payments, payments_success_rate, payments_success_rate_without_smart_retries, ) = self.payments_success_rate.collect(); let ( smart_retried_amount, smart_retried_amount_without_smart_retries, smart_retried_amount_in_usd, smart_retried_amount_without_smart_retries_in_usd, ) = self.smart_retried_amount.collect(); let ( payment_processed_amount, payment_processed_count, payment_processed_amount_without_smart_retries, payment_processed_count_without_smart_retries, payment_processed_amount_in_usd, payment_processed_amount_without_smart_retries_in_usd, ) = self.payment_processed_amount.collect(); let ( payments_success_rate_distribution_without_smart_retries, payments_failure_rate_distribution_without_smart_retries, ) = self.payments_distribution.collect(); PaymentIntentMetricsBucketValue { successful_smart_retries: self.successful_smart_retries.collect(), total_smart_retries: self.total_smart_retries.collect(), smart_retried_amount, smart_retried_amount_in_usd, smart_retried_amount_without_smart_retries, smart_retried_amount_without_smart_retries_in_usd, payment_intent_count: self.payment_intent_count.collect(), successful_payments, successful_payments_without_smart_retries, total_payments, payments_success_rate, payments_success_rate_without_smart_retries, payment_processed_amount, payment_processed_count, payment_processed_amount_without_smart_retries, payment_processed_count_without_smart_retries, payments_success_rate_distribution_without_smart_retries, payments_failure_rate_distribution_without_smart_retries, payment_processed_amount_in_usd, payment_processed_amount_without_smart_retries_in_usd, } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "PaymentIntentMetricsAccumulator", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "collect", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_ActivePaymentsMetricsAccumulator_collect
clm
method
// hyperswitch/crates/analytics/src/active_payments/accumulator.rs // impl for ActivePaymentsMetricsAccumulator pub fn collect(self) -> ActivePaymentsMetricsBucketValue { ActivePaymentsMetricsBucketValue { active_payments: self.active_payments.collect(), } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "ActivePaymentsMetricsAccumulator", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "collect", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_SdkEventMetricsAccumulator_collect
clm
method
// hyperswitch/crates/analytics/src/sdk_events/accumulator.rs // impl for SdkEventMetricsAccumulator pub fn collect(self) -> SdkEventMetricsBucketValue { SdkEventMetricsBucketValue { payment_attempts: self.payment_attempts.collect(), payment_methods_call_count: self.payment_methods_call_count.collect(), average_payment_time: self.average_payment_time.collect(), load_time: self.load_time.collect(), sdk_initiated_count: self.sdk_initiated_count.collect(), sdk_rendered_count: self.sdk_rendered_count.collect(), payment_method_selected_count: self.payment_method_selected_count.collect(), payment_data_filled_count: self.payment_data_filled_count.collect(), } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "SdkEventMetricsAccumulator", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "collect", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_DisputeMetricsAccumulator_collect
clm
method
// hyperswitch/crates/analytics/src/disputes/accumulators.rs // impl for DisputeMetricsAccumulator pub fn collect(self) -> DisputeMetricsBucketValue { let (challenge_rate, won_rate, lost_rate, total_dispute) = self.disputes_status_rate.collect().unwrap_or_default(); DisputeMetricsBucketValue { disputes_challenged: challenge_rate, disputes_won: won_rate, disputes_lost: lost_rate, disputed_amount: self.disputed_amount.collect(), dispute_lost_amount: self.dispute_lost_amount.collect(), total_dispute, } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "DisputeMetricsAccumulator", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "collect", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_FrmMetricsAccumulator_collect
clm
method
// hyperswitch/crates/analytics/src/frm/accumulator.rs // impl for FrmMetricsAccumulator pub fn collect(self) -> FrmMetricsBucketValue { FrmMetricsBucketValue { frm_blocked_rate: self.frm_blocked_rate.collect(), frm_triggered_attempts: self.frm_triggered_attempts.collect(), } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "FrmMetricsAccumulator", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "collect", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_AuthEventMetricsAccumulator_collect
clm
method
// hyperswitch/crates/analytics/src/auth_events/accumulator.rs // impl for AuthEventMetricsAccumulator pub fn collect(self) -> AuthEventMetricsBucketValue { AuthEventMetricsBucketValue { authentication_count: self.authentication_count.collect(), authentication_attempt_count: self.authentication_attempt_count.collect(), authentication_success_count: self.authentication_success_count.collect(), challenge_flow_count: self.challenge_flow_count.collect(), challenge_attempt_count: self.challenge_attempt_count.collect(), challenge_success_count: self.challenge_success_count.collect(), frictionless_flow_count: self.frictionless_flow_count.collect(), frictionless_success_count: self.frictionless_success_count.collect(), error_message_count: self.authentication_error_message.collect(), authentication_funnel: self.authentication_funnel.collect(), authentication_exemption_approved_count: self .authentication_exemption_approved_count .collect(), authentication_exemption_requested_count: self .authentication_exemption_requested_count .collect(), } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "AuthEventMetricsAccumulator", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "collect", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_analytics_RefundMetricsAccumulator_collect
clm
method
// hyperswitch/crates/analytics/src/refunds/accumulator.rs // impl for RefundMetricsAccumulator pub fn collect(self) -> RefundMetricsBucketValue { let (successful_refunds, total_refunds, refund_success_rate) = self.refund_success_rate.collect(); let (refund_processed_amount, refund_processed_count, refund_processed_amount_in_usd) = self.processed_amount.collect(); RefundMetricsBucketValue { successful_refunds, total_refunds, refund_success_rate, refund_count: self.refund_count.collect(), refund_success_count: self.refund_success.collect(), refund_processed_amount, refund_processed_amount_in_usd, refund_processed_count, refund_reason_distribution: self.refund_reason_distribution.collect(), refund_error_message_distribution: self.refund_error_message_distribution.collect(), refund_reason_count: self.refund_reason.collect(), refund_error_message_count: self.refund_error_message.collect(), } }
{ "chunk": null, "crate": "analytics", "enum_name": null, "file_size": null, "for_type": "RefundMetricsAccumulator", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "collect", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_hyperswitch_interfaces_MerchantConnectorAccountType_get_metadata
clm
method
// hyperswitch/crates/hyperswitch_interfaces/src/configs.rs // impl for MerchantConnectorAccountType pub fn get_metadata(&self) -> Option<Secret<serde_json::Value>> { match self { Self::DbVal(val) => val.metadata.to_owned(), Self::CacheVal(val) => val.metadata.to_owned(), } }
{ "chunk": null, "crate": "hyperswitch_interfaces", "enum_name": null, "file_size": null, "for_type": "MerchantConnectorAccountType", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_metadata", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_hyperswitch_interfaces_MerchantConnectorAccountType_get_connector_account_details
clm
method
// hyperswitch/crates/hyperswitch_interfaces/src/configs.rs // impl for MerchantConnectorAccountType pub fn get_connector_account_details(&self) -> serde_json::Value { match self { Self::DbVal(val) => val.connector_account_details.peek().to_owned(), Self::CacheVal(val) => val.connector_account_details.peek().to_owned(), } }
{ "chunk": null, "crate": "hyperswitch_interfaces", "enum_name": null, "file_size": null, "for_type": "MerchantConnectorAccountType", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_connector_account_details", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }
hyperswitch_method_hyperswitch_interfaces_MerchantConnectorAccountType_get_connector_wallets_details
clm
method
// hyperswitch/crates/hyperswitch_interfaces/src/configs.rs // impl for MerchantConnectorAccountType pub fn get_connector_wallets_details(&self) -> Option<Secret<serde_json::Value>> { match self { Self::DbVal(val) => val.connector_wallets_details.as_deref().cloned(), Self::CacheVal(_) => None, } }
{ "chunk": null, "crate": "hyperswitch_interfaces", "enum_name": null, "file_size": null, "for_type": "MerchantConnectorAccountType", "function_name": null, "is_async": null, "is_pub": null, "lines": null, "method_name": "get_connector_wallets_details", "num_enums": null, "num_items": null, "num_structs": null, "repo": "hyperswitch", "start_line": null, "struct_name": null, "total_crates": null, "trait_name": null }