text
stringlengths
70
351k
source
stringclasses
4 values
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types/primitive_wrappers.rs | crate: common_utils fn from(value: bool) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types/authentication.rs | crate: common_utils /// Get string representation of enclosed ID type pub fn to_str(&self) -> &str { { Self::Payment(id) => id.get_string_repr(),<|fim_suffix|> <|fim_middle|> Self::PaymentMethodSession(id) => id.get_string_repr(), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/organization.rs | crate: common_utils use crate::errors::{CustomResult, ValidationError}; /// Get an organization id from String pub fn try_from_string(org_id: String) -> CustomResult<Self, ValidationError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/profile.rs | crate: common_utils fn from(val: ProfileId) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/profile.rs | crate: common_utils use std::str::FromStr; fn from_str(s: &str) -> Result<Self, Self::Err> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/profile.rs | crate: common_utils fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/merchant_connector_account.rs | crate: common_utils use crate::errors::{CustomResult, ValidationError}; /// Get a merchant connector account id from String pub fn wrap(merchant_connector_account_id: String) -> CustomResult<Self, ValidationError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use crate::{ consts::{CELL_IDENTIFIER_LENGTH, MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH}, errors, generate_time_ordered_id, id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError}, }; fn test_global_id_deser_error() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils fn test_global_id_deser() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils fn test_global_id_from_string() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils fn test_global_id_generate() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils fn test_cell_id_from_str() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use diesel::{backend::Backend, deserialize::FromSql, serialize::ToSql, sql_types}; fn to_sql<'b>( &'b self, out: &mut diesel::serialize::Output<'b, '_, DB>, ) -> diesel::serialize::Result { self.0 .0 .0.to_sql(out) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use crate::{ consts::{CELL_IDENTIFIER_LENGTH, MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH}, errors, generate_time_ordered_id, id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError}, }; pub(crate) fn get_string_repr(&self) -> &str { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use crate::{ consts::{CELL_IDENTIFIER_LENGTH, MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH}, errors, generate_time_ordered_id, id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError}, }; pub(crate) fn from_string( input_string: std::borrow::Cow<'static, str>, ) -> Result<Self, GlobalIdError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use crate::{ consts::{CELL_IDENTIFIER_LENGTH, MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH}, errors, generate_time_ordered_id, id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError}, }; /// Create a new global id from entity and cell information /// The entity prefix is used to identify the entity, `cus` for customers, `pay`` for payments etc. pub fn generate(cell_id: &CellId, entity: GlobalEntity) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils /// Get the string representation of the cell id fn get_string_repr(&self) -> &str { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use error_stack::ResultExt; use crate::{ consts::{CELL_IDENTIFIER_LENGTH, MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH}, errors, generate_time_ordered_id, id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError}, }; /// Create a new cell id from a string pub fn from_string( input_string: impl AsRef<str>, ) -> error_stack::Result<Self, errors::ValidationError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use crate::{ consts::{CELL_IDENTIFIER_LENGTH, MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH}, errors, generate_time_ordered_id, id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError}, }; /// Create a new cell id from a string fn from_str(cell_id_string: impl AsRef<str>) -> Result<Self, CellIdError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use crate::{ consts::{CELL_IDENTIFIER_LENGTH, MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH}, errors, generate_time_ordered_id, id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError}, }; fn from(error: AlphaNumericIdError) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils use crate::{ consts::{CELL_IDENTIFIER_LENGTH, MAX_GLOBAL_ID_LENGTH, MIN_GLOBAL_ID_LENGTH}, errors, generate_time_ordered_id, id_type::{AlphaNumericId, AlphaNumericIdError, LengthId, LengthIdError}, }; fn from(error: LengthIdError) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id.rs | crate: common_utils fn prefix(self) -> &'static str { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils fn from_str(s: &str) -> Result<Self, Self::Err> { let cow_string = std::borrow::Cow::Owned(s.to_string()); Self::try_from(cow_string) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils fn from(val: PaymentId) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils use crate::{ errors::{CustomResult, ValidationError}, generate_id_with_default_len, id_type::{AlphaNumericId, LengthId}, }; /// Wrap a string inside PaymentId pub fn wrap(payment_id_string: String) -> CustomResult<Self, ValidationError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils use crate::{ errors::{CustomResult, ValidationError}, generate_id_with_default_len, id_type::{AlphaNumericId, LengthId}, }; /// Generate a test payment id with prefix test_ pub fn generate_test_payment_id_for_sample_data() -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils /// Get external authentication request poll id pub fn get_external_authentication_request_poll_id(&self) -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils /// Generate a key for pm_auth pub fn get_pm_auth_key(&self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils use crate::{ errors::{CustomResult, ValidationError}, generate_id_with_default_len, id_type::{AlphaNumericId, LengthId}, }; /// Generate a client id for the payment id pub fn generate_client_secret(&self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils /// Get the attempt id for the payment id based on the attempt count pub fn get_attempt_id(&self, attempt_count: i16) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils use crate::{ errors::{CustomResult, ValidationError}, generate_id_with_default_len, id_type::{AlphaNumericId, LengthId}, }; /// Get payment id in the format of irrelevant_payment_id_in_{ <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/payment.rs | crate: common_utils /// Get the hash key to be stored in redis pub fn get_hash_key_for_kv_store(&self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/api_key.rs | crate: common_utils /// Generate Api Key Id from prefix pub fn generate_key_id(prefix: &'static str) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils fn to_sql<'b>( &'b self, out: &mut diesel::serialize::Output<'b, '_, DB>, ) -> diesel::serialize::Result { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils fn build(row: Self::Row) -> diesel::deserialize::Result<Self> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils use crate::{ errors::CustomResult, id_type::global_id::{CellId, GlobalEntity, GlobalId}, }; fn from_sql(value: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> { let global_id = GlobalId::from_sql(value)?; Ok(Self(global_id)) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils use crate::{ errors::CustomResult, id_type::global_id::{CellId, GlobalEntity, GlobalId}, }; /// Construct a new GlobalPaymentMethodId from a string pub fn generate_from_string(value: String) -> CustomResult<Self, GlobalPaymentMethodIdError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils use error_stack::ResultExt; use crate::{ errors::CustomResult, id_type::global_id::{CellId, GlobalEntity, GlobalId}, }; /// Create a new GlobalPaymentMethodId from cell id information pub fn generate(cell_id: &CellId) -> error_stack::Result<Self, GlobalPaymentMethodIdError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils use crate::{ errors::CustomResult, id_type::global_id::{CellId, GlobalEntity, GlobalId}, }; fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::PaymentMethodSession { payment_method_session_id: self.clone(), }) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils /// Construct a redis key from the id to be stored in redis pub fn get_redis_key(&self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils /// Get the string representation of the id pub fn get_string_repr(&self) -> &str { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs | crate: common_utils use error_stack::ResultExt; use crate::{ errors::CustomResult, id_type::global_id::{CellId, GlobalEntity, GlobalId}, }; /// Create a new GlobalPaymentMethodSessionId from cell id information pub fn generate( cell_id: &CellId, ) -> error_stack::Result<Self, GlobalPaymentMethodSessionIdError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/refunds.rs | crate: common_utils use error_stack::ResultExt; use crate::{errors, generate_id_with_default_len, generate_time_ordered_id_without_prefix, types}; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/refunds.rs | crate: common_utils use crate::{errors, generate_id_with_default_len, generate_time_ordered_id_without_prefix, types}; /// Generate a new GlobalRefundId from a cell id pub fn generate(cell_id: &crate::id_type::CellId) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/id_type/global_id/refunds.rs | crate: common_utils /// Get string representation of the id pub fn get_string_repr(&self) -> &str { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use serde_json::Value; fn test_get_common_mandate_reference_with_payments_and_payouts_details() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use serde_json::Value; fn test_get_common_mandate_reference_payouts_only() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use serde_json::Value; fn test_get_common_mandate_reference_payments_only() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use common_enums::enums::MerchantStorageScheme; use common_utils::{crypto::Encryptable, encryption::Encryption, types::keymanager::ToEncryptable}; use common_utils::{ crypto::OptionalEncryptableValue, errors::{CustomResult, ParsingError, ValidationError}, id_type, pii, type_name, types::keymanager, }; use diesel_models::{enums as storage_enums, PaymentMethodUpdate}; use serde_json::Value; use crate::{ address::Address, payment_method_data as domain_payment_method_data, type_encryption::OptionalEncryptableJsonType, }; fn get_payment_method_with_mandate_data( mandate_data: Option<serde_json::Value>, ) -> PaymentMethod { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use api_models::payment_methods::PaymentMethodsData; use common_enums::enums::MerchantStorageScheme; use common_utils::{crypto::Encryptable, encryption::Encryption, types::keymanager::ToEncryptable}; use common_utils::{ crypto::OptionalEncryptableValue, errors::{CustomResult, ParsingError, ValidationError}, id_type, pii, type_name, types::keymanager, }; use diesel_models::{enums as storage_enums, PaymentMethodUpdate}; use error_stack::ResultExt; use masking::{PeekInterface, Secret}; use rustc_hash::FxHashMap; use serde_json::Value; use time::PrimitiveDateTime; use crate::{ address::Address, payment_method_data as domain_payment_method_data, type_encryption::OptionalEncryptableJsonType, }; use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; async fn convert_back( state: &keymanager::KeyManagerState, storage_model: Self::DstType, key: &Secret<Vec<u8>>, key_manager_identifier: keymanager::Identifier, ) -> CustomResult<Self, ValidationError> where Self: Sized, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::OptionalEncryptableValue, errors::{CustomResult, ParsingError, ValidationError}, id_type, pii, type_name, types::keymanager, }; use crate::{ address::Address, payment_method_data as domain_payment_method_data, type_encryption::OptionalEncryptableJsonType, }; use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use serde_json::Value; fn test_get_common_mandate_reference_invalid_data() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models fn test_get_common_mandate_reference_empty_details() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; pub fn apply_changeset(self, update_session: PaymentMethodsSessionUpdateInternal) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models fn from(update: PaymentMethodsSessionUpdateEnum) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use common_enums::enums::MerchantStorageScheme; use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; pub fn set_payment_method_subtype( &mut self, payment_method_subtype: common_enums::PaymentMethodType, ) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use common_enums::enums::MerchantStorageScheme; use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; pub fn set_payment_method_type(&mut self, payment_method_type: common_enums::PaymentMethod) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::OptionalEncryptableValue, errors::{CustomResult, ParsingError, ValidationError}, id_type, pii, type_name, types::keymanager, }; use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; pub fn get_common_mandate_reference(&self) -> Result<CommonMandateReference, ParsingError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use diesel_models::{enums as storage_enums, PaymentMethodUpdate}; use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; pub fn get_payment_method_subtype(&self) -> Option<storage_enums::PaymentMethodType> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use diesel_models::{enums as storage_enums, PaymentMethodUpdate}; use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; pub fn get_payment_method_type(&self) -> Option<storage_enums::PaymentMethod> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::OptionalEncryptableValue, errors::{CustomResult, ParsingError, ValidationError}, id_type, pii, type_name, types::keymanager, }; use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; pub fn get_id(&self) -> &id_type::GlobalPaymentMethodId { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models pub fn generate(id: String) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_methods.rs | crate: hyperswitch_domain_models use crate::{ mandates::{self, CommonMandateReference}, merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; pub fn get_string_repr(&self) -> &String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_address.rs | crate: hyperswitch_domain_models use crate::address::Address; pub fn new( shipping: Option<Address>, billing: Option<Address>, payment_method_billing: Option<Address>, should_unify_address: Option<bool>, ) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_address.rs | crate: hyperswitch_domain_models use crate::address::Address; pub fn get_payment_billing(&self) -> Option<&Address> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_address.rs | crate: hyperswitch_domain_models use crate::address::Address; pub fn get_request_payment_method_billing(&self) -> Option<&Address> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_address.rs | crate: hyperswitch_domain_models use crate::address::Address; /// Unify the billing details from `payment_method_data.[payment_method_data].billing details`. /// Here the `self` takes precedence pub fn unify_with_payment_data_billing( self, other_payment_method_billing: Option<Address>, ) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_address.rs | crate: hyperswitch_domain_models use crate::address::Address; /// Unify the billing details from `payment_method_data.[payment_method_data].billing details`. /// Here the fields passed in payment_method_data_billing takes precedence pub fn unify_with_payment_method_data_billing( self, payment_method_data_billing: Option<Address>, ) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_address.rs | crate: hyperswitch_domain_models use crate::address::Address; pub fn get_payment_method_billing(&self) -> Option<&Address> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payment_address.rs | crate: hyperswitch_domain_models use crate::address::Address; pub fn get_shipping(&self) -> Option<&Address> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::{OptionalEncryptableName, OptionalEncryptableValue}, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, pii, type_name, types::keymanager::{self}, }; fn from(merchant_account_update: MerchantAccountUpdate) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_account.rs | crate: hyperswitch_domain_models fn from(item: MerchantAccountSetter) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::{OptionalEncryptableName, OptionalEncryptableValue}, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, pii, type_name, types::keymanager::{self}, }; use diesel_models::{ enums::MerchantStorageScheme, merchant_account::MerchantAccountUpdateInternal, }; use router_env::logger; pub fn get_compatible_connector(&self) -> Option<api_models::enums::Connector> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::{OptionalEncryptableName, OptionalEncryptableValue}, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, pii, type_name, types::keymanager::{self}, }; /// Get the organization_id from MerchantAccount pub fn get_org_id(&self) -> &common_utils::id_type::OrganizationId { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::{OptionalEncryptableName, OptionalEncryptableValue}, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, pii, type_name, types::keymanager::{self}, }; /// Get the unique identifier of MerchantAccount pub fn get_id(&self) -> &common_utils::id_type::MerchantId { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::{OptionalEncryptableName, OptionalEncryptableValue}, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, pii, type_name, types::keymanager::{self}, }; use error_stack::ResultExt; use masking::{PeekInterface, Secret}; use crate::type_encryption::{crypto_operation, AsyncLift, CryptoOperation}; async fn convert_back( state: &keymanager::KeyManagerState, item: Self::DstType, key: &Secret<Vec<u8>>, key_manager_identifier: keymanager::Identifier, ) -> CustomResult<Self, ValidationError> where Self: Sized, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payouts.rs | crate: hyperswitch_domain_models use common_utils::{consts, id_type}; fn from(value: api_models::payouts::PayoutListFilterConstraints) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payouts.rs | crate: hyperswitch_domain_models use common_utils::{consts, id_type}; fn from(value: common_utils::types::TimeRange) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payouts.rs | crate: hyperswitch_domain_models use common_utils::{consts, id_type}; fn from(value: api_models::payouts::PayoutListConstraints) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; fn from(merchant_connector_account_update: MerchantConnectorAccountUpdate) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; use masking::{PeekInterface, Secret}; use crate::{ mandates::CommonMandateReference, router_data, type_encryption::{crypto_operation, CryptoOperation}, }; async fn convert_back( state: &KeyManagerState, other: Self::DstType, key: &Secret<Vec<u8>>, _key_manager_identifier: Identifier, ) -> CustomResult<Self, ValidationError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; use diesel_models::merchant_connector_account::{ BillingAccountReference as DieselBillingAccountReference, MerchantConnectorAccountFeatureMetadata as DieselMerchantConnectorAccountFeatureMetadata, RevenueRecoveryMetadata as DieselRevenueRecoveryMetadata, }; use diesel_models::{enums, merchant_connector_account::MerchantConnectorAccountUpdateInternal}; use crate::errors::{self, api_error_response}; async fn convert(self) -> CustomResult<Self::DstType, ValidationError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use std::collections::HashMap; /// This functions flattens the payment methods enabled from the connector accounts /// Retains the connector name and payment method in every flattened element pub fn from_payment_connectors_list(payment_connectors: Vec<MerchantConnectorAccount>) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use std::collections::HashMap; use diesel_models::merchant_connector_account::{ BillingAccountReference as DieselBillingAccountReference, MerchantConnectorAccountFeatureMetadata as DieselMerchantConnectorAccountFeatureMetadata, RevenueRecoveryMetadata as DieselRevenueRecoveryMetadata, }; fn from(feature_metadata: DieselMerchantConnectorAccountFeatureMetadata) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use diesel_models::merchant_connector_account::{ BillingAccountReference as DieselBillingAccountReference, MerchantConnectorAccountFeatureMetadata as DieselMerchantConnectorAccountFeatureMetadata, RevenueRecoveryMetadata as DieselRevenueRecoveryMetadata, }; fn from(feature_metadata: MerchantConnectorAccountFeatureMetadata) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use std::collections::HashMap; use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; use crate::errors::{self, api_error_response}; fn validate( hash_map: &HashMap<id_type::MerchantConnectorAccountId, String>, ) -> Result<(), api_error_response::ApiErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use std::collections::HashMap; use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; use crate::errors::{self, api_error_response}; pub fn new( hash_map: HashMap<id_type::MerchantConnectorAccountId, String>, ) -> Result<Self, api_error_response::ApiErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; use crate::errors::{self, api_error_response}; pub fn get_payment_merchant_connector_account_id_using_account_reference_id( &self, account_reference_id: String, ) -> Option<id_type::MerchantConnectorAccountId> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use crate::errors::{self, api_error_response}; pub fn get_connector_name_as_string(&self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use masking::{PeekInterface, Secret}; use serde_json::Value; use crate::errors::{self, api_error_response}; pub fn get_connector_wallets_details(&self) -> Option<Secret<Value>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use std::collections::HashMap; use common_utils::transformers::ForeignTryFrom; use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; use diesel_models::merchant_connector_account::{ BillingAccountReference as DieselBillingAccountReference, MerchantConnectorAccountFeatureMetadata as DieselMerchantConnectorAccountFeatureMetadata, RevenueRecoveryMetadata as DieselRevenueRecoveryMetadata, }; use diesel_models::{enums, merchant_connector_account::MerchantConnectorAccountUpdateInternal}; use error_stack::ResultExt; use masking::{PeekInterface, Secret}; use rustc_hash::FxHashMap; use serde_json::Value; use super::behaviour; use crate::errors::{self, api_error_response}; use crate::{ mandates::CommonMandateReference, router_data, type_encryption::{crypto_operation, CryptoOperation}, }; pub fn get_connector_account_details( &self, ) -> error_stack::Result<router_data::ConnectorAuthType, common_utils::errors::ParsingError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use crate::errors::{self, api_error_response}; pub fn is_disabled(&self) -> bool { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; use crate::errors::{self, api_error_response}; pub fn get_metadata(&self) -> Option<pii::SecretSerdeValue> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use crate::errors::{self, api_error_response}; pub fn get_connector_test_mode(&self) -> Option<bool> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_connector_account.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::Encryptable, date_time, encryption::Encryption, errors::{CustomResult, ValidationError}, ext_traits::ValueExt, id_type, pii, type_name, types::keymanager::{Identifier, KeyManagerState, ToEncryptable}, }; use crate::errors::{self, api_error_response}; pub fn get_id(&self) -> id_type::MerchantConnectorAccountId { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/configs.rs | crate: hyperswitch_domain_models use common_enums::ApplicationError; /// function to satisfy connector param validation macro pub fn validate(&self, _parent_field: &str) -> Result<(), ApplicationError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/bulk_tokenization.rs | crate: hyperswitch_domain_models use api_models::{payment_methods as payment_methods_api, payments as payments_api}; use common_utils::{ errors, ext_traits::OptionExt, id_type, pii, transformers::{ForeignFrom, ForeignTryFrom}, }; use error_stack::report; use crate::{ address::{Address, AddressDetails, PhoneDetails}, router_request_types::CustomerDetails, }; fn foreign_try_from(record: CardNetworkTokenizeRecord) -> Result<Self, Self::Error> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/bulk_tokenization.rs | crate: hyperswitch_domain_models use api_models::{payment_methods as payment_methods_api, payments as payments_api}; use crate::{ address::{Address, AddressDetails, PhoneDetails}, router_request_types::CustomerDetails, }; fn foreign_from(req: payments_api::PhoneDetails) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/bulk_tokenization.rs | crate: hyperswitch_domain_models use api_models::{payment_methods as payment_methods_api, payments as payments_api}; use crate::{ address::{Address, AddressDetails, PhoneDetails}, router_request_types::CustomerDetails, }; fn foreign_from(req: payments_api::AddressDetails) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/bulk_tokenization.rs | crate: hyperswitch_domain_models use api_models::{payment_methods as payment_methods_api, payments as payments_api}; use common_utils::{ errors, ext_traits::OptionExt, id_type, pii, transformers::{ForeignFrom, ForeignTryFrom}, }; use crate::{ address::{Address, AddressDetails, PhoneDetails}, router_request_types::CustomerDetails, }; fn foreign_from(req: payments_api::Address) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments