id stringlengths 11 116 | type stringclasses 1
value | granularity stringclasses 4
values | content stringlengths 16 477k | metadata dict |
|---|---|---|---|---|
fn_clm_payment_methods_create_encrypted_data_7167308969424295553 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/controller
pub async fn create_encrypted_data<T>(
key_manager_state: &keymanager::KeyManagerState,
key_store: &merchant_key_store::MerchantKeyStore,
data: T,
) -> Result<
crypto::Encryptable<Secret<serde_json::Value>>,
error_stack::Report<storage_errors::StorageError>,
>
where
T: Debug + Serialize,
{
let key = key_store.key.get_inner().peek();
let identifier = keymanager::Identifier::Merchant(key_store.merchant_id.clone());
let encoded_data = ext_traits::Encode::encode_to_value(&data)
.change_context(storage_errors::StorageError::SerializationFailed)
.attach_printable("Unable to encode data")?;
let secret_data = Secret::<_, masking::WithType>::new(encoded_data);
let encrypted_data = type_encryption::crypto_operation(
key_manager_state,
type_name!(payment_method::PaymentMethod),
type_encryption::CryptoOperation::Encrypt(secret_data),
identifier.clone(),
key,
)
.await
.and_then(|val| val.try_into_operation())
.change_context(storage_errors::StorageError::EncryptionError)
.attach_printable("Unable to encrypt data")?;
Ok(encrypted_data)
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 124,
"total_crates": null
} |
fn_clm_payment_methods_get_or_insert_payment_method_7167308969424295553 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/controller
async fn get_or_insert_payment_method(
&self,
_req: api::PaymentMethodCreate,
_resp: &mut api::PaymentMethodResponse,
_customer_id: &id_type::CustomerId,
_key_store: &merchant_key_store::MerchantKeyStore,
) -> errors::PmResult<payment_methods::PaymentMethod> {
todo!()
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 9,
"total_crates": null
} |
fn_clm_payment_methods_to_not_found_response_7274269728924300841 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/helpers
// Implementation of error_stack::Result<T, storage_impl::StorageError> for StorageErrorExt<T, api_error_response::ApiErrorResponse>
fn to_not_found_response(
self,
not_found_response: api_error_response::ApiErrorResponse,
) -> error_stack::Result<T, api_error_response::ApiErrorResponse> {
self.map_err(|err| {
let new_err = match err.current_context() {
storage_impl::StorageError::ValueNotFound(_) => not_found_response,
storage_impl::StorageError::CustomerRedacted => {
api_error_response::ApiErrorResponse::CustomerRedacted
}
_ => api_error_response::ApiErrorResponse::InternalServerError,
};
err.change_context(new_err)
})
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 1466,
"total_crates": null
} |
fn_clm_payment_methods_foreign_from_7274269728924300841 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/helpers
// Implementation of api::PaymentMethodResponse for ForeignFrom<(Option<api::CardDetailFromLocker>, domain::PaymentMethod)>
fn foreign_from(
(_card_details, _item): (Option<api::CardDetailFromLocker>, domain::PaymentMethod),
) -> Self {
todo!()
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 212,
"total_crates": null
} |
fn_clm_payment_methods_to_duplicate_response_7274269728924300841 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/helpers
// Implementation of error_stack::Result<T, storage_impl::StorageError> for StorageErrorExt<T, api_error_response::ApiErrorResponse>
fn to_duplicate_response(
self,
duplicate_response: api_error_response::ApiErrorResponse,
) -> error_stack::Result<T, api_error_response::ApiErrorResponse> {
self.map_err(|err| {
let new_err = match err.current_context() {
storage_impl::StorageError::DuplicateValue { .. } => duplicate_response,
_ => api_error_response::ApiErrorResponse::InternalServerError,
};
err.change_context(new_err)
})
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 131,
"total_crates": null
} |
fn_clm_payment_methods_validate_payment_method_type_against_payment_method_7274269728924300841 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/helpers
pub fn validate_payment_method_type_against_payment_method(
payment_method: api_enums::PaymentMethod,
payment_method_type: api_enums::PaymentMethodType,
) -> bool {
match payment_method {
#[cfg(feature = "v1")]
api_enums::PaymentMethod::Card => matches!(
payment_method_type,
api_enums::PaymentMethodType::Credit | api_enums::PaymentMethodType::Debit
),
#[cfg(feature = "v2")]
api_enums::PaymentMethod::Card => matches!(
payment_method_type,
api_enums::PaymentMethodType::Credit
| api_enums::PaymentMethodType::Debit
| api_enums::PaymentMethodType::Card
),
api_enums::PaymentMethod::PayLater => matches!(
payment_method_type,
api_enums::PaymentMethodType::Affirm
| api_enums::PaymentMethodType::Alma
| api_enums::PaymentMethodType::AfterpayClearpay
| api_enums::PaymentMethodType::Klarna
| api_enums::PaymentMethodType::PayBright
| api_enums::PaymentMethodType::Atome
| api_enums::PaymentMethodType::Walley
| api_enums::PaymentMethodType::Breadpay
| api_enums::PaymentMethodType::Flexiti
),
api_enums::PaymentMethod::Wallet => matches!(
payment_method_type,
api_enums::PaymentMethodType::AmazonPay
| api_enums::PaymentMethodType::Bluecode
| api_enums::PaymentMethodType::Paysera
| api_enums::PaymentMethodType::Skrill
| api_enums::PaymentMethodType::ApplePay
| api_enums::PaymentMethodType::GooglePay
| api_enums::PaymentMethodType::Paypal
| api_enums::PaymentMethodType::AliPay
| api_enums::PaymentMethodType::AliPayHk
| api_enums::PaymentMethodType::Dana
| api_enums::PaymentMethodType::MbWay
| api_enums::PaymentMethodType::MobilePay
| api_enums::PaymentMethodType::SamsungPay
| api_enums::PaymentMethodType::Twint
| api_enums::PaymentMethodType::Vipps
| api_enums::PaymentMethodType::TouchNGo
| api_enums::PaymentMethodType::Swish
| api_enums::PaymentMethodType::WeChatPay
| api_enums::PaymentMethodType::GoPay
| api_enums::PaymentMethodType::Gcash
| api_enums::PaymentMethodType::Momo
| api_enums::PaymentMethodType::KakaoPay
| api_enums::PaymentMethodType::Cashapp
| api_enums::PaymentMethodType::Mifinity
| api_enums::PaymentMethodType::Paze
| api_enums::PaymentMethodType::RevolutPay
),
api_enums::PaymentMethod::BankRedirect => matches!(
payment_method_type,
api_enums::PaymentMethodType::Giropay
| api_enums::PaymentMethodType::Ideal
| api_enums::PaymentMethodType::Sofort
| api_enums::PaymentMethodType::Eft
| api_enums::PaymentMethodType::Eps
| api_enums::PaymentMethodType::BancontactCard
| api_enums::PaymentMethodType::Blik
| api_enums::PaymentMethodType::LocalBankRedirect
| api_enums::PaymentMethodType::OnlineBankingThailand
| api_enums::PaymentMethodType::OnlineBankingCzechRepublic
| api_enums::PaymentMethodType::OnlineBankingFinland
| api_enums::PaymentMethodType::OnlineBankingFpx
| api_enums::PaymentMethodType::OnlineBankingPoland
| api_enums::PaymentMethodType::OnlineBankingSlovakia
| api_enums::PaymentMethodType::Przelewy24
| api_enums::PaymentMethodType::Trustly
| api_enums::PaymentMethodType::Bizum
| api_enums::PaymentMethodType::Interac
| api_enums::PaymentMethodType::OpenBankingUk
| api_enums::PaymentMethodType::OpenBankingPIS
),
api_enums::PaymentMethod::BankTransfer => matches!(
payment_method_type,
api_enums::PaymentMethodType::Ach
| api_enums::PaymentMethodType::SepaBankTransfer
| api_enums::PaymentMethodType::Bacs
| api_enums::PaymentMethodType::Multibanco
| api_enums::PaymentMethodType::Pix
| api_enums::PaymentMethodType::Pse
| api_enums::PaymentMethodType::PermataBankTransfer
| api_enums::PaymentMethodType::BcaBankTransfer
| api_enums::PaymentMethodType::BniVa
| api_enums::PaymentMethodType::BriVa
| api_enums::PaymentMethodType::CimbVa
| api_enums::PaymentMethodType::DanamonVa
| api_enums::PaymentMethodType::MandiriVa
| api_enums::PaymentMethodType::LocalBankTransfer
| api_enums::PaymentMethodType::InstantBankTransfer
| api_enums::PaymentMethodType::InstantBankTransferFinland
| api_enums::PaymentMethodType::InstantBankTransferPoland
| api_enums::PaymentMethodType::IndonesianBankTransfer
),
api_enums::PaymentMethod::BankDebit => matches!(
payment_method_type,
api_enums::PaymentMethodType::Ach
| api_enums::PaymentMethodType::Sepa
| api_enums::PaymentMethodType::SepaGuarenteedDebit
| api_enums::PaymentMethodType::Bacs
| api_enums::PaymentMethodType::Becs
),
api_enums::PaymentMethod::Crypto => matches!(
payment_method_type,
api_enums::PaymentMethodType::CryptoCurrency
),
api_enums::PaymentMethod::Reward => matches!(
payment_method_type,
api_enums::PaymentMethodType::Evoucher | api_enums::PaymentMethodType::ClassicReward
),
api_enums::PaymentMethod::RealTimePayment => matches!(
payment_method_type,
api_enums::PaymentMethodType::Fps
| api_enums::PaymentMethodType::DuitNow
| api_enums::PaymentMethodType::PromptPay
| api_enums::PaymentMethodType::VietQr
),
api_enums::PaymentMethod::Upi => matches!(
payment_method_type,
api_enums::PaymentMethodType::UpiCollect
| api_enums::PaymentMethodType::UpiIntent
| api_enums::PaymentMethodType::UpiQr
),
api_enums::PaymentMethod::Voucher => matches!(
payment_method_type,
api_enums::PaymentMethodType::Boleto
| api_enums::PaymentMethodType::Efecty
| api_enums::PaymentMethodType::PagoEfectivo
| api_enums::PaymentMethodType::RedCompra
| api_enums::PaymentMethodType::RedPagos
| api_enums::PaymentMethodType::Indomaret
| api_enums::PaymentMethodType::Alfamart
| api_enums::PaymentMethodType::Oxxo
| api_enums::PaymentMethodType::SevenEleven
| api_enums::PaymentMethodType::Lawson
| api_enums::PaymentMethodType::MiniStop
| api_enums::PaymentMethodType::FamilyMart
| api_enums::PaymentMethodType::Seicomart
| api_enums::PaymentMethodType::PayEasy
),
api_enums::PaymentMethod::GiftCard => {
matches!(
payment_method_type,
api_enums::PaymentMethodType::Givex | api_enums::PaymentMethodType::PaySafeCard
)
}
api_enums::PaymentMethod::CardRedirect => matches!(
payment_method_type,
api_enums::PaymentMethodType::Knet
| api_enums::PaymentMethodType::Benefit
| api_enums::PaymentMethodType::MomoAtm
| api_enums::PaymentMethodType::CardRedirect
),
api_enums::PaymentMethod::OpenBanking => matches!(
payment_method_type,
api_enums::PaymentMethodType::OpenBankingPIS
),
api_enums::PaymentMethod::MobilePayment => matches!(
payment_method_type,
api_enums::PaymentMethodType::DirectCarrierBilling
),
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 16,
"total_crates": null
} |
fn_clm_payment_methods_populate_bin_details_for_payment_method_create_7274269728924300841 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/helpers
pub async fn populate_bin_details_for_payment_method_create(
_card_details: api_models::payment_methods::CardDetail,
_db: &dyn state::PaymentMethodsStorageInterface,
) -> api_models::payment_methods::CardDetail {
todo!()
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 13,
"total_crates": null
} |
fn_clm_payment_methods_from_4164553982633116986 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/state
// Implementation of keymanager::KeyManagerState for From<&PaymentMethodsState>
fn from(state: &PaymentMethodsState) -> Self {
state.key_manager_state.clone()
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2602,
"total_crates": null
} |
fn_clm_payment_methods_find_payment_method_4164553982633116986 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/state
// Inherent implementation for PaymentMethodsState
pub async fn find_payment_method(
&self,
key_store: &merchant_key_store::MerchantKeyStore,
merchant_account: &merchant_account::MerchantAccount,
payment_method_id: String,
) -> CustomResult<pm_domain::PaymentMethod, errors::StorageError> {
let db = &*self.store;
let key_manager_state = &(self.key_manager_state).clone();
match db
.find_payment_method(
key_manager_state,
key_store,
&payment_method_id,
merchant_account.storage_scheme,
)
.await
{
Err(err) if err.current_context().is_db_not_found() => {
db.find_payment_method_by_locker_id(
key_manager_state,
key_store,
&payment_method_id,
merchant_account.storage_scheme,
)
.await
}
Ok(pm) => Ok(pm),
Err(err) => Err(err),
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 124,
"total_crates": null
} |
fn_clm_payment_methods_new_-5194219524170717418 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration
// Inherent implementation for RecordMigrationStatusBuilder
pub fn new() -> Self {
Self {
card_migrated: None,
network_token_migrated: None,
connector_mandate_details_migrated: None,
network_transaction_migrated: None,
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14463,
"total_crates": null
} |
fn_clm_payment_methods_default_-5194219524170717418 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration
// Implementation of RecordMigrationStatusBuilder for Default
fn default() -> Self {
Self::new()
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7705,
"total_crates": null
} |
fn_clm_payment_methods_build_-5194219524170717418 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration
// Inherent implementation for RecordMigrationStatusBuilder
pub fn build(self) -> RecordMigrationStatus {
RecordMigrationStatus {
card_migrated: self.card_migrated,
network_token_migrated: self.network_token_migrated,
connector_mandate_details_migrated: self.connector_mandate_details_migrated,
network_transaction_migrated: self.network_transaction_migrated,
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 582,
"total_crates": null
} |
fn_clm_payment_methods_validate_card_expiry_-5194219524170717418 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration
pub fn validate_card_expiry(
card_exp_month: &masking::Secret<String>,
card_exp_year: &masking::Secret<String>,
) -> errors::CustomResult<(), errors::ApiErrorResponse> {
let exp_month = card_exp_month
.peek()
.to_string()
.parse::<u8>()
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "card_exp_month",
})?;
::cards::CardExpirationMonth::try_from(exp_month).change_context(
errors::ApiErrorResponse::PreconditionFailed {
message: "Invalid Expiry Month".to_string(),
},
)?;
let year_str = card_exp_year.peek().to_string();
validate_card_exp_year(year_str).change_context(
errors::ApiErrorResponse::PreconditionFailed {
message: "Invalid Expiry Year".to_string(),
},
)?;
Ok(())
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 53,
"total_crates": null
} |
fn_clm_payment_methods_validate_and_get_payment_method_records_-5194219524170717418 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration
// Implementation of None for PaymentMethodsMigrateForm
pub fn validate_and_get_payment_method_records(self) -> MigrationValidationResult {
// Step 1: Validate form-level conflicts
let form_has_single_id = self.merchant_connector_id.is_some();
let form_has_multiple_ids = self.merchant_connector_ids.is_some();
if form_has_single_id && form_has_multiple_ids {
return Err(errors::ApiErrorResponse::InvalidRequestData {
message: "Both merchant_connector_id and merchant_connector_ids cannot be provided"
.to_string(),
});
}
// Ensure at least one is provided
if !form_has_single_id && !form_has_multiple_ids {
return Err(errors::ApiErrorResponse::InvalidRequestData {
message: "Either merchant_connector_id or merchant_connector_ids must be provided"
.to_string(),
});
}
// Step 2: Parse CSV
let records = parse_csv(self.file.data.to_bytes()).map_err(|e| {
errors::ApiErrorResponse::PreconditionFailed {
message: e.to_string(),
}
})?;
// Step 3: Validate CSV vs Form conflicts
MerchantConnectorValidator::validate_form_csv_conflicts(
&records,
form_has_single_id,
form_has_multiple_ids,
)?;
// Step 4: Prepare the merchant connector account IDs for return
let mca_ids = if let Some(ref single_id) = self.merchant_connector_id {
Some(vec![(**single_id).clone()])
} else if let Some(ref ids_string) = self.merchant_connector_ids {
let parsed_ids = MerchantConnectorValidator::parse_comma_separated_ids(ids_string)?;
if parsed_ids.is_empty() {
None
} else {
Some(parsed_ids)
}
} else {
None
};
// Step 5: Return the updated structure
Ok((self.merchant_id.clone(), records, mca_ids))
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 48,
"total_crates": null
} |
fn_clm_payment_methods_foreign_try_from_-4474373549320394179 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration/payment_methods
// Implementation of pm_api::CardDetailFromLocker for ForeignTryFrom<(
&api_models::payment_methods::MigrateCardDetail,
Option<cards_info::CardInfo>,
)>
fn foreign_try_from(
(card_details, card_info): (
&api_models::payment_methods::MigrateCardDetail,
Option<cards_info::CardInfo>,
),
) -> Result<Self, Self::Error> {
let (card_isin, last4_digits) =
get_card_bin_and_last4_digits_for_masked_card(card_details.card_number.peek())
.change_context(errors::ApiErrorResponse::InvalidRequestData {
message: "Invalid masked card number".to_string(),
})?;
if let Some(card_bin_info) = card_info {
Ok(Self {
last4_digits: Some(last4_digits.clone()),
issuer_country: card_details
.card_issuing_country
.as_ref()
.map(|c| api_enums::CountryAlpha2::from_str(c))
.transpose()
.ok()
.flatten()
.or(card_bin_info
.card_issuing_country
.as_ref()
.map(|c| api_enums::CountryAlpha2::from_str(c))
.transpose()
.ok()
.flatten()),
card_number: None,
expiry_month: Some(card_details.card_exp_month.clone()),
expiry_year: Some(card_details.card_exp_year.clone()),
card_fingerprint: None,
card_holder_name: card_details.card_holder_name.clone(),
nick_name: card_details.nick_name.clone(),
card_isin: Some(card_isin.clone()),
card_issuer: card_details
.card_issuer
.clone()
.or(card_bin_info.card_issuer),
card_network: card_details
.card_network
.clone()
.or(card_bin_info.card_network),
card_type: card_details.card_type.clone().or(card_bin_info.card_type),
saved_to_locker: false,
})
} else {
Ok(Self {
last4_digits: Some(last4_digits.clone()),
issuer_country: card_details
.card_issuing_country
.as_ref()
.map(|c| api_enums::CountryAlpha2::from_str(c))
.transpose()
.ok()
.flatten(),
card_number: None,
expiry_month: Some(card_details.card_exp_month.clone()),
expiry_year: Some(card_details.card_exp_year.clone()),
card_fingerprint: None,
card_holder_name: card_details.card_holder_name.clone(),
nick_name: card_details.nick_name.clone(),
card_isin: Some(card_isin.clone()),
card_issuer: card_details.card_issuer.clone(),
card_network: card_details.card_network.clone(),
card_type: card_details.card_type.clone(),
saved_to_locker: false,
})
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 516,
"total_crates": null
} |
fn_clm_payment_methods_get_client_secret_or_add_payment_method_for_migration_-4474373549320394179 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration/payment_methods
pub async fn get_client_secret_or_add_payment_method_for_migration(
state: &state::PaymentMethodsState,
req: pm_api::PaymentMethodCreate,
merchant_context: &merchant_context::MerchantContext,
migration_status: &mut migration::RecordMigrationStatusBuilder,
controller: &dyn PaymentMethodsController,
) -> CustomResult<ApplicationResponse<pm_api::PaymentMethodResponse>, errors::ApiErrorResponse> {
let merchant_id = merchant_context.get_merchant_account().get_id();
let customer_id = req.customer_id.clone().get_required_value("customer_id")?;
#[cfg(not(feature = "payouts"))]
let condition = req.card.is_some();
#[cfg(feature = "payouts")]
let condition = req.card.is_some() || req.bank_transfer.is_some() || req.wallet.is_some();
let key_manager_state = &state.into();
let payment_method_billing_address: Option<Encryptable<Secret<serde_json::Value>>> = req
.billing
.clone()
.async_map(|billing| {
create_encrypted_data(
key_manager_state,
merchant_context.get_merchant_key_store(),
billing,
)
})
.await
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to encrypt Payment method billing address")?;
let connector_mandate_details = req
.connector_mandate_details
.clone()
.map(serde_json::to_value)
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)?;
if condition {
Box::pin(save_migration_payment_method(
req,
migration_status,
controller,
))
.await
} else {
let payment_method_id = generate_id(consts::ID_LENGTH, "pm");
let res = controller
.create_payment_method(
&req,
&customer_id,
payment_method_id.as_str(),
None,
merchant_id,
None,
None,
None,
connector_mandate_details.clone(),
Some(enums::PaymentMethodStatus::AwaitingData),
None,
payment_method_billing_address,
None,
None,
None,
None,
Default::default(),
)
.await?;
migration_status.connector_mandate_details_migrated(
connector_mandate_details
.clone()
.and_then(|val| (val != json!({})).then_some(true))
.or_else(|| {
req.connector_mandate_details
.clone()
.and_then(|val| (!val.0.is_empty()).then_some(false))
}),
);
//card is not migrated in this case
migration_status.card_migrated(false);
if res.status == enums::PaymentMethodStatus::AwaitingData {
controller
.add_payment_method_status_update_task(
&res,
enums::PaymentMethodStatus::AwaitingData,
enums::PaymentMethodStatus::Inactive,
merchant_id,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable(
"Failed to add payment method status update task in process tracker",
)?;
}
Ok(ApplicationResponse::Json(
pm_api::PaymentMethodResponse::foreign_from((None, res)),
))
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 94,
"total_crates": null
} |
fn_clm_payment_methods_save_migration_payment_method_-4474373549320394179 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration/payment_methods
pub async fn save_migration_payment_method(
req: pm_api::PaymentMethodCreate,
migration_status: &mut migration::RecordMigrationStatusBuilder,
controller: &dyn PaymentMethodsController,
) -> CustomResult<ApplicationResponse<pm_api::PaymentMethodResponse>, errors::ApiErrorResponse> {
let connector_mandate_details = req
.connector_mandate_details
.clone()
.map(serde_json::to_value)
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)?;
let network_transaction_id = req.network_transaction_id.clone();
let res = controller.add_payment_method(&req).await?;
migration_status.card_migrated(true);
migration_status.network_transaction_id_migrated(
network_transaction_id.and_then(|val| (!val.is_empty_after_trim()).then_some(true)),
);
migration_status.connector_mandate_details_migrated(
connector_mandate_details
.and_then(|val| if val == json!({}) { None } else { Some(true) })
.or_else(|| {
req.connector_mandate_details
.and_then(|val| (!val.0.is_empty()).then_some(false))
}),
);
Ok(res)
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 47,
"total_crates": null
} |
fn_clm_payment_methods_populate_bin_details_for_masked_card_-4474373549320394179 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration/payment_methods
pub async fn populate_bin_details_for_masked_card(
card_details: &api_models::payment_methods::MigrateCardDetail,
db: &dyn state::PaymentMethodsStorageInterface,
payment_method_type: Option<&enums::PaymentMethodType>,
) -> CustomResult<pm_api::CardDetailFromLocker, errors::ApiErrorResponse> {
if let Some(
// Cards
enums::PaymentMethodType::Credit
| enums::PaymentMethodType::Debit
// Wallets
| enums::PaymentMethodType::ApplePay
| enums::PaymentMethodType::GooglePay,
) = payment_method_type {
migration::validate_card_expiry(
&card_details.card_exp_month,
&card_details.card_exp_year,
)?;
}
let card_number = card_details.card_number.clone();
let (card_isin, _last4_digits) = get_card_bin_and_last4_digits_for_masked_card(
card_number.peek(),
)
.change_context(errors::ApiErrorResponse::InvalidRequestData {
message: "Invalid masked card number".to_string(),
})?;
let card_bin_details = if card_details.card_issuer.is_some()
&& card_details.card_network.is_some()
&& card_details.card_type.is_some()
&& card_details.card_issuing_country.is_some()
{
pm_api::CardDetailFromLocker::foreign_try_from((card_details, None))?
} else {
let card_info = db
.get_card_info(&card_isin)
.await
.map_err(|error| logger::error!(card_info_error=?error))
.ok()
.flatten();
pm_api::CardDetailFromLocker::foreign_try_from((card_details, card_info))?
};
Ok(card_bin_details)
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 42,
"total_crates": null
} |
fn_clm_payment_methods_get_card_bin_and_last4_digits_for_masked_card_-4474373549320394179 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/core/migration/payment_methods
pub fn get_card_bin_and_last4_digits_for_masked_card(
masked_card_number: &str,
) -> Result<(String, String), cards::CardNumberValidationErr> {
let last4_digits = masked_card_number
.chars()
.rev()
.take(4)
.collect::<String>()
.chars()
.rev()
.collect::<String>();
let card_isin = masked_card_number.chars().take(6).collect::<String>();
cards::validate::validate_card_number_chars(&card_isin)
.and_then(|_| cards::validate::validate_card_number_chars(&last4_digits))?;
Ok((card_isin, last4_digits))
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 36,
"total_crates": null
} |
fn_clm_payment_methods_new_-4916677146550061978 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/configs/payment_connector_required_fields
// Inherent implementation for RequiredFields
pub fn new(bank_config: &BankRedirectConfig) -> Self {
let cards_required_fields = get_cards_required_fields();
let mut debit_required_fields = cards_required_fields.clone();
debit_required_fields.extend(HashMap::from([
(
Connector::Bankofamerica,
fields(
vec![],
vec![],
[card_basic(), email(), full_name(), billing_address()].concat(),
),
),
(
Connector::Getnet,
fields(
vec![],
vec![],
[card_basic(), vec![RequiredField::CardNetwork]].concat(),
),
),
]));
Self(HashMap::from([
(
enums::PaymentMethod::Card,
PaymentMethodType(HashMap::from([
(
enums::PaymentMethodType::Debit,
ConnectorFields {
fields: cards_required_fields.clone(),
},
),
(
enums::PaymentMethodType::Credit,
ConnectorFields {
fields: debit_required_fields.clone(),
},
),
])),
),
(
enums::PaymentMethod::BankRedirect,
PaymentMethodType(get_bank_redirect_required_fields(bank_config)),
),
(
enums::PaymentMethod::Wallet,
PaymentMethodType(get_wallet_required_fields()),
),
(
enums::PaymentMethod::PayLater,
PaymentMethodType(get_pay_later_required_fields()),
),
(
enums::PaymentMethod::Crypto,
PaymentMethodType(HashMap::from([(
enums::PaymentMethodType::CryptoCurrency,
connectors(vec![(
Connector::Cryptopay,
fields(
vec![],
vec![
RequiredField::CyptoPayCurrency(vec![
"BTC", "LTC", "ETH", "XRP", "XLM", "BCH", "ADA", "SOL", "SHIB",
"TRX", "DOGE", "BNB", "USDT", "USDC", "DAI",
]),
RequiredField::CryptoNetwork,
],
vec![],
),
)]),
)])),
),
(
enums::PaymentMethod::Voucher,
PaymentMethodType(get_voucher_required_fields()),
),
(
enums::PaymentMethod::Upi,
PaymentMethodType(HashMap::from([(
enums::PaymentMethodType::UpiCollect,
connectors(vec![
(
Connector::Razorpay,
fields(
vec![],
vec![],
vec![
RequiredField::UpiCollectVpaId,
RequiredField::BillingEmail,
RequiredField::BillingPhone,
RequiredField::BillingPhoneCountryCode,
],
),
),
(
Connector::Phonepe,
fields(
vec![],
vec![],
vec![
RequiredField::UpiCollectVpaId,
RequiredField::BillingEmail,
RequiredField::BillingPhone,
RequiredField::BillingPhoneCountryCode,
],
),
),
(
Connector::Paytm,
fields(
vec![],
vec![],
vec![
RequiredField::UpiCollectVpaId,
RequiredField::BillingEmail,
RequiredField::BillingPhone,
RequiredField::BillingPhoneCountryCode,
],
),
),
]),
)])),
),
(
enums::PaymentMethod::BankDebit,
PaymentMethodType(get_bank_debit_required_fields()),
),
(
enums::PaymentMethod::BankTransfer,
PaymentMethodType(get_bank_transfer_required_fields()),
),
(
enums::PaymentMethod::GiftCard,
PaymentMethodType(HashMap::from([
(
enums::PaymentMethodType::PaySafeCard,
connectors(vec![(Connector::Adyen, fields(vec![], vec![], vec![]))]),
),
(
enums::PaymentMethodType::Givex,
connectors(vec![(
Connector::Adyen,
fields(
vec![],
vec![RequiredField::GiftCardNumber, RequiredField::GiftCardCvc],
vec![],
),
)]),
),
])),
),
(
enums::PaymentMethod::CardRedirect,
PaymentMethodType(HashMap::from([
(
enums::PaymentMethodType::Benefit,
connectors(vec![(
Connector::Adyen,
fields(
vec![],
vec![
RequiredField::BillingFirstName(
"first_name",
FieldType::UserFullName,
),
RequiredField::BillingLastName(
"last_name",
FieldType::UserFullName,
),
RequiredField::BillingEmail,
RequiredField::BillingPhone,
RequiredField::BillingPhoneCountryCode,
],
vec![],
),
)]),
),
(
enums::PaymentMethodType::Knet,
connectors(vec![(
Connector::Adyen,
fields(
vec![],
vec![
RequiredField::BillingFirstName(
"first_name",
FieldType::UserFullName,
),
RequiredField::BillingLastName(
"last_name",
FieldType::UserFullName,
),
RequiredField::BillingEmail,
RequiredField::BillingPhone,
RequiredField::BillingPhoneCountryCode,
],
vec![],
),
)]),
),
(
enums::PaymentMethodType::MomoAtm,
connectors(vec![(
Connector::Adyen,
fields(
vec![],
vec![
RequiredField::BillingEmail,
RequiredField::BillingPhone,
RequiredField::BillingPhoneCountryCode,
],
vec![],
),
)]),
),
])),
),
(
enums::PaymentMethod::MobilePayment,
PaymentMethodType(HashMap::from([(
enums::PaymentMethodType::DirectCarrierBilling,
connectors(vec![(
Connector::Digitalvirgo,
RequiredFieldFinal {
mandate: HashMap::new(),
non_mandate: HashMap::new(),
common: HashMap::from([
RequiredField::DcbMsisdn.to_tuple(),
RequiredField::DcbClientUid.to_tuple(),
RequiredField::OrderDetailsProductName.to_tuple(),
]),
},
)]),
)])),
),
]))
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14561,
"total_crates": null
} |
fn_clm_payment_methods_default_-4916677146550061978 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/configs/payment_connector_required_fields
// Implementation of RequiredFields for Default
fn default() -> Self {
Self::new(&BankRedirectConfig::default())
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7707,
"total_crates": null
} |
fn_clm_payment_methods_to_tuple_-4916677146550061978 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/configs/payment_connector_required_fields
// Inherent implementation for RequiredField
fn to_tuple(&self) -> (String, RequiredFieldInfo) {
match self {
Self::CardNumber => (
"payment_method_data.card.card_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.card.card_number".to_string(),
display_name: "card_number".to_string(),
field_type: FieldType::UserCardNumber,
value: None,
},
),
Self::CardExpMonth => (
"payment_method_data.card.card_exp_month".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.card.card_exp_month".to_string(),
display_name: "card_exp_month".to_string(),
field_type: FieldType::UserCardExpiryMonth,
value: None,
},
),
Self::CardExpYear => (
"payment_method_data.card.card_exp_year".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.card.card_exp_year".to_string(),
display_name: "card_exp_year".to_string(),
field_type: FieldType::UserCardExpiryYear,
value: None,
},
),
Self::CardCvc => (
"payment_method_data.card.card_cvc".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.card.card_cvc".to_string(),
display_name: "card_cvc".to_string(),
field_type: FieldType::UserCardCvc,
value: None,
},
),
Self::CardNetwork => (
"payment_method_data.card.card_network".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.card.card_network".to_string(),
display_name: "card_network".to_string(),
field_type: FieldType::UserCardNetwork,
value: None,
},
),
Self::BillingUserFirstName => (
"billing.address.first_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.first_name".to_string(),
display_name: "card_holder_name".to_string(),
field_type: FieldType::UserFullName,
value: None,
},
),
Self::BillingUserLastName => (
"billing.address.last_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.last_name".to_string(),
display_name: "card_holder_name".to_string(),
field_type: FieldType::UserFullName,
value: None,
},
),
Self::BillingFirstName(display_name, field_type) => (
"billing.address.first_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.first_name".to_string(),
display_name: display_name.to_string(),
field_type: field_type.clone(),
value: None,
},
),
Self::BillingLastName(display_name, field_type) => (
"billing.address.last_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.last_name".to_string(),
display_name: display_name.to_string(),
field_type: field_type.clone(),
value: None,
},
),
Self::Email => (
"email".to_string(),
RequiredFieldInfo {
required_field: "email".to_string(),
display_name: "email".to_string(),
field_type: FieldType::UserEmailAddress,
value: None,
},
),
Self::BillingEmail => (
"billing.email".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.email".to_string(),
display_name: "email".to_string(),
field_type: FieldType::UserEmailAddress,
value: None,
},
),
Self::BillingPhone => (
"billing.phone.number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.phone.number".to_string(),
display_name: "phone".to_string(),
field_type: FieldType::UserPhoneNumber,
value: None,
},
),
Self::BillingPhoneCountryCode => (
"billing.phone.country_code".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.phone.country_code".to_string(),
display_name: "dialing_code".to_string(),
field_type: FieldType::UserPhoneNumberCountryCode,
value: None,
},
),
Self::BillingAddressLine1 => (
"billing.address.line1".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.line1".to_string(),
display_name: "line1".to_string(),
field_type: FieldType::UserAddressLine1,
value: None,
},
),
Self::BillingAddressLine2 => (
"billing.address.line2".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.line2".to_string(),
display_name: "line2".to_string(),
field_type: FieldType::UserAddressLine2,
value: None,
},
),
Self::BillingAddressCity => (
"billing.address.city".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.city".to_string(),
display_name: "city".to_string(),
field_type: FieldType::UserAddressCity,
value: None,
},
),
Self::BillingAddressState => (
"billing.address.state".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.state".to_string(),
display_name: "state".to_string(),
field_type: FieldType::UserAddressState,
value: None,
},
),
Self::BillingAddressZip => (
"billing.address.zip".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.zip".to_string(),
display_name: "zip".to_string(),
field_type: FieldType::UserAddressPincode,
value: None,
},
),
Self::BillingCountries(countries) => (
"billing.address.country".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.country".to_string(),
display_name: "country".to_string(),
field_type: FieldType::UserCountry {
options: countries.iter().map(|c| c.to_string()).collect(),
},
value: None,
},
),
Self::BillingAddressCountries(countries) => (
"billing.address.country".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.country".to_string(),
display_name: "country".to_string(),
field_type: FieldType::UserAddressCountry {
options: countries.iter().map(|c| c.to_string()).collect(),
},
value: None,
},
),
Self::ShippingFirstName => (
"shipping.address.first_name".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.first_name".to_string(),
display_name: "shipping_first_name".to_string(),
field_type: FieldType::UserShippingName,
value: None,
},
),
Self::ShippingLastName => (
"shipping.address.last_name".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.last_name".to_string(),
display_name: "shipping_last_name".to_string(),
field_type: FieldType::UserShippingName,
value: None,
},
),
Self::ShippingAddressCity => (
"shipping.address.city".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.city".to_string(),
display_name: "city".to_string(),
field_type: FieldType::UserShippingAddressCity,
value: None,
},
),
Self::ShippingAddressState => (
"shipping.address.state".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.state".to_string(),
display_name: "state".to_string(),
field_type: FieldType::UserShippingAddressState,
value: None,
},
),
Self::ShippingAddressZip => (
"shipping.address.zip".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.zip".to_string(),
display_name: "zip".to_string(),
field_type: FieldType::UserShippingAddressPincode,
value: None,
},
),
Self::ShippingCountries(countries) => (
"shipping.address.country".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.country".to_string(),
display_name: "country".to_string(),
field_type: FieldType::UserCountry {
options: countries.iter().map(|c| c.to_string()).collect(),
},
value: None,
},
),
Self::ShippingAddressCountries(countries) => (
"shipping.address.country".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.country".to_string(),
display_name: "country".to_string(),
field_type: FieldType::UserShippingAddressCountry {
options: countries.iter().map(|c| c.to_string()).collect(),
},
value: None,
},
),
Self::ShippingAddressLine1 => (
"shipping.address.line1".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.line1".to_string(),
display_name: "line1".to_string(),
field_type: FieldType::UserShippingAddressLine1,
value: None,
},
),
Self::ShippingAddressLine2 => (
"shipping.address.line2".to_string(),
RequiredFieldInfo {
required_field: "shipping.address.line2".to_string(),
display_name: "line2".to_string(),
field_type: FieldType::UserShippingAddressLine2,
value: None,
},
),
Self::ShippingPhone => (
"shipping.phone.number".to_string(),
RequiredFieldInfo {
required_field: "shipping.phone.number".to_string(),
display_name: "phone_number".to_string(),
field_type: FieldType::UserPhoneNumber,
value: None,
},
),
Self::ShippingPhoneCountryCode => (
"shipping.phone.country_code".to_string(),
RequiredFieldInfo {
required_field: "shipping.phone.country_code".to_string(),
display_name: "dialing_code".to_string(),
field_type: FieldType::UserPhoneNumberCountryCode,
value: None,
},
),
Self::ShippingEmail => (
"shipping.email".to_string(),
RequiredFieldInfo {
required_field: "shipping.email".to_string(),
display_name: "email".to_string(),
field_type: FieldType::UserEmailAddress,
value: None,
},
),
Self::OpenBankingUkIssuer => (
"payment_method_data.bank_redirect.open_banking_uk.issuer".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_redirect.open_banking_uk.issuer"
.to_string(),
display_name: "issuer".to_string(),
field_type: FieldType::UserBank,
value: None,
},
),
Self::OpenBankingCzechRepublicIssuer => (
"payment_method_data.bank_redirect.open_banking_czech_republic.issuer".to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.bank_redirect.open_banking_czech_republic.issuer"
.to_string(),
display_name: "issuer".to_string(),
field_type: FieldType::UserBank,
value: None,
},
),
Self::OpenBankingPolandIssuer => (
"payment_method_data.bank_redirect.online_banking_poland.issuer".to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.bank_redirect.online_banking_poland.issuer".to_string(),
display_name: "issuer".to_string(),
field_type: FieldType::UserBank,
value: None,
},
),
Self::OpenBankingSlovakiaIssuer => (
"payment_method_data.bank_redirect.open_banking_slovakia.issuer".to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.bank_redirect.open_banking_slovakia.issuer".to_string(),
display_name: "issuer".to_string(),
field_type: FieldType::UserBank,
value: None,
},
),
Self::OpenBankingFpxIssuer => (
"payment_method_data.bank_redirect.open_banking_fpx.issuer".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_redirect.open_banking_fpx.issuer"
.to_string(),
display_name: "issuer".to_string(),
field_type: FieldType::UserBank,
value: None,
},
),
Self::OpenBankingThailandIssuer => (
"payment_method_data.bank_redirect.open_banking_thailand.issuer".to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.bank_redirect.open_banking_thailand.issuer".to_string(),
display_name: "issuer".to_string(),
field_type: FieldType::UserBank,
value: None,
},
),
Self::BanContactCardNumber => (
"payment_method_data.bank_redirect.bancontact_card.card_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_redirect.bancontact_card.card_number"
.to_string(),
display_name: "card_number".to_string(),
field_type: FieldType::UserCardNumber,
value: None,
},
),
Self::BanContactCardExpMonth => (
"payment_method_data.bank_redirect.bancontact_card.card_exp_month".to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.bank_redirect.bancontact_card.card_exp_month"
.to_string(),
display_name: "card_exp_month".to_string(),
field_type: FieldType::UserCardExpiryMonth,
value: None,
},
),
Self::BanContactCardExpYear => (
"payment_method_data.bank_redirect.bancontact_card.card_exp_year".to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.bank_redirect.bancontact_card.card_exp_year"
.to_string(),
display_name: "card_exp_year".to_string(),
field_type: FieldType::UserCardExpiryYear,
value: None,
},
),
Self::IdealBankName => (
"payment_method_data.bank_redirect.ideal.bank_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_redirect.ideal.bank_name".to_string(),
display_name: "bank_name".to_string(),
field_type: FieldType::UserBank,
value: None,
},
),
Self::EpsBankName => (
"payment_method_data.bank_redirect.eps.bank_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_redirect.eps.bank_name".to_string(),
display_name: "bank_name".to_string(),
field_type: FieldType::UserBank,
value: None,
},
),
Self::EpsBankOptions(bank) => (
"payment_method_data.bank_redirect.eps.bank_name".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_redirect.eps.bank_name".to_string(),
display_name: "bank_name".to_string(),
field_type: FieldType::UserBankOptions {
options: bank.iter().map(|bank| bank.to_string()).collect(),
},
value: None,
},
),
Self::BlikCode => (
"payment_method_data.bank_redirect.blik.blik_code".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_redirect.blik.blik_code".to_string(),
display_name: "blik_code".to_string(),
field_type: FieldType::UserBlikCode,
value: None,
},
),
Self::MifinityDateOfBirth => (
"payment_method_data.wallet.mifinity.date_of_birth".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.wallet.mifinity.date_of_birth".to_string(),
display_name: "date_of_birth".to_string(),
field_type: FieldType::UserDateOfBirth,
value: None,
},
),
Self::MifinityLanguagePreference(languages) => (
"payment_method_data.wallet.mifinity.language_preference".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.wallet.mifinity.language_preference"
.to_string(),
display_name: "language_preference".to_string(),
field_type: FieldType::LanguagePreference {
options: languages.iter().map(|l| l.to_string()).collect(),
},
value: None,
},
),
Self::CryptoNetwork => (
"payment_method_data.crypto.network".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.crypto.network".to_string(),
display_name: "network".to_string(),
field_type: FieldType::UserCryptoCurrencyNetwork,
value: None,
},
),
Self::CyptoPayCurrency(currencies) => (
"payment_method_data.crypto.pay_currency".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.crypto.pay_currency".to_string(),
display_name: "currency".to_string(),
field_type: FieldType::UserCurrency {
options: currencies.iter().map(|c| c.to_string()).collect(),
},
value: None,
},
),
Self::BoletoSocialSecurityNumber => (
"payment_method_data.voucher.boleto.social_security_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.voucher.boleto.social_security_number"
.to_string(),
display_name: "social_security_number".to_string(),
field_type: FieldType::UserSocialSecurityNumber,
value: None,
},
),
Self::UpiCollectVpaId => (
"payment_method_data.upi.upi_collect.vpa_id".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.upi.upi_collect.vpa_id".to_string(),
display_name: "vpa_id".to_string(),
field_type: FieldType::UserVpaId,
value: None,
},
),
Self::AchBankDebitAccountNumber => (
"payment_method_data.bank_debit.ach_bank_debit.account_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.ach_bank_debit.account_number"
.to_string(),
display_name: "bank_account_number".to_string(),
field_type: FieldType::UserBankAccountNumber,
value: None,
},
),
Self::AchBankDebitRoutingNumber => (
"payment_method_data.bank_debit.ach_bank_debit.routing_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.ach_bank_debit.routing_number"
.to_string(),
display_name: "bank_routing_number".to_string(),
field_type: FieldType::UserBankRoutingNumber,
value: None,
},
),
Self::AchBankDebitBankType(bank_type) => (
"payment_method_data.bank_debit.ach_bank_debit.bank_type".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.ach_bank_debit.bank_type"
.to_string(),
display_name: "bank_type".to_string(),
field_type: FieldType::UserBankType {
options: bank_type.iter().map(|bt| bt.to_string()).collect(),
},
value: None,
},
),
Self::AchBankDebitBankAccountHolderName => (
"payment_method_data.bank_debit.ach_bank_debit.bank_account_holder_name"
.to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.bank_debit.ach_bank_debit.bank_account_holder_name"
.to_string(),
display_name: "bank_account_holder_name".to_string(),
field_type: FieldType::UserBankAccountHolderName,
value: None,
},
),
Self::SepaBankDebitIban => (
"payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.sepa_bank_debit.iban"
.to_string(),
display_name: "iban".to_string(),
field_type: FieldType::UserIban,
value: None,
},
),
Self::BacsBankDebitAccountNumber => (
"payment_method_data.bank_debit.bacs_bank_debit.account_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.bacs_bank_debit.account_number"
.to_string(),
display_name: "bank_account_number".to_string(),
field_type: FieldType::UserBankAccountNumber,
value: None,
},
),
Self::BacsBankDebitSortCode => (
"payment_method_data.bank_debit.bacs_bank_debit.sort_code".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.bacs_bank_debit.sort_code"
.to_string(),
display_name: "bank_sort_code".to_string(),
field_type: FieldType::UserBankSortCode,
value: None,
},
),
Self::BecsBankDebitAccountNumber => (
"payment_method_data.bank_debit.becs_bank_debit.account_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.becs_bank_debit.account_number"
.to_string(),
display_name: "bank_account_number".to_string(),
field_type: FieldType::UserBankAccountNumber,
value: None,
},
),
Self::BecsBankDebitBsbNumber => (
"payment_method_data.bank_debit.becs_bank_debit.bsb_number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.becs_bank_debit.bsb_number"
.to_string(),
display_name: "bsb_number".to_string(),
field_type: FieldType::UserBsbNumber,
value: None,
},
),
Self::BecsBankDebitSortCode => (
"payment_method_data.bank_debit.becs_bank_debit.sort_code".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_debit.becs_bank_debit.sort_code"
.to_string(),
display_name: "bank_sort_code".to_string(),
field_type: FieldType::UserBankSortCode,
value: None,
},
),
Self::PixKey => (
"payment_method_data.bank_transfer.pix.pix_key".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_transfer.pix.pix_key".to_string(),
display_name: "pix_key".to_string(),
field_type: FieldType::UserPixKey,
value: None,
},
),
Self::PixCnpj => (
"payment_method_data.bank_transfer.pix.cnpj".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_transfer.pix.cnpj".to_string(),
display_name: "cnpj".to_string(),
field_type: FieldType::UserCnpj,
value: None,
},
),
Self::PixCpf => (
"payment_method_data.bank_transfer.pix.cpf".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_transfer.pix.cpf".to_string(),
display_name: "cpf".to_string(),
field_type: FieldType::UserCpf,
value: None,
},
),
Self::PixSourceBankAccountId => (
"payment_method_data.bank_transfer.pix.source_bank_account_id".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.bank_transfer.pix.source_bank_account_id"
.to_string(),
display_name: "source_bank_account_id".to_string(),
field_type: FieldType::UserSourceBankAccountId,
value: None,
},
),
Self::GiftCardNumber => (
"payment_method_data.gift_card.number".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.gift_card.givex.number".to_string(),
display_name: "gift_card_number".to_string(),
field_type: FieldType::UserCardNumber,
value: None,
},
),
Self::GiftCardCvc => (
"payment_method_data.gift_card.cvc".to_string(),
RequiredFieldInfo {
required_field: "payment_method_data.gift_card.givex.cvc".to_string(),
display_name: "gift_card_cvc".to_string(),
field_type: FieldType::UserCardCvc,
value: None,
},
),
Self::DcbMsisdn => (
"payment_method_data.mobile_payment.direct_carrier_billing.msisdn".to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.mobile_payment.direct_carrier_billing.msisdn"
.to_string(),
display_name: "mobile_number".to_string(),
field_type: FieldType::UserMsisdn,
value: None,
},
),
Self::DcbClientUid => (
"payment_method_data.mobile_payment.direct_carrier_billing.client_uid".to_string(),
RequiredFieldInfo {
required_field:
"payment_method_data.mobile_payment.direct_carrier_billing.client_uid"
.to_string(),
display_name: "client_identifier".to_string(),
field_type: FieldType::UserClientIdentifier,
value: None,
},
),
Self::OrderDetailsProductName => (
"order_details.0.product_name".to_string(),
RequiredFieldInfo {
required_field: "order_details.0.product_name".to_string(),
display_name: "product_name".to_string(),
field_type: FieldType::OrderDetailsProductName,
value: None,
},
),
Self::Description => (
"description".to_string(),
RequiredFieldInfo {
required_field: "description".to_string(),
display_name: "description".to_string(),
field_type: FieldType::Text,
value: None,
},
),
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 601,
"total_crates": null
} |
fn_clm_payment_methods_get_cards_required_fields_-4916677146550061978 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/configs/payment_connector_required_fields
fn get_cards_required_fields() -> HashMap<Connector, RequiredFieldFinal> {
HashMap::from([
(Connector::Aci, fields(vec![], vec![], card_with_name())),
(Connector::Authipay, fields(vec![], vec![], card_basic())),
(Connector::Adyen, fields(vec![], vec![], card_with_name())),
(Connector::Airwallex, fields(vec![], card_basic(), vec![])),
(
Connector::Authorizedotnet,
fields(vec![], vec![], card_basic()),
),
(
Connector::Bambora,
fields(vec![], [card_with_name(), billing_email()].concat(), vec![]),
),
(
Connector::Bankofamerica,
fields(
vec![],
vec![],
[card_basic(), email(), full_name(), billing_address()].concat(),
),
),
(
Connector::Barclaycard,
fields(
vec![],
vec![],
[card_basic(), email(), full_name(), billing_address()].concat(),
),
),
(Connector::Billwerk, fields(vec![], vec![], card_basic())),
(
Connector::Bluesnap,
fields(
vec![],
[card_basic(), email(), full_name()].concat(),
vec![],
),
),
(Connector::Boku, fields(vec![], vec![], card_basic())),
(Connector::Braintree, fields(vec![], vec![], card_basic())),
(Connector::Celero, fields(vec![], vec![], card_basic())),
(Connector::Checkout, fields(vec![], card_basic(), vec![])),
(
Connector::Coinbase,
fields(vec![], vec![RequiredField::BillingUserFirstName], vec![]),
),
(
Connector::Cybersource,
fields(
vec![],
vec![],
[card_with_name(), billing_email(), billing_address()].concat(),
),
),
(
Connector::Datatrans,
fields(vec![], vec![], [billing_email(), card_with_name()].concat()),
),
(
Connector::Deutschebank,
fields(
vec![],
[
card_basic(),
email(),
billing_address(),
vec![
RequiredField::BillingFirstName("first_name", FieldType::UserFullName),
RequiredField::BillingLastName("last_name", FieldType::UserFullName),
],
]
.concat(),
vec![],
),
),
(
Connector::Dlocal,
fields(
vec![],
[
card_with_name(),
vec![RequiredField::BillingAddressCountries(vec!["ALL"])],
]
.concat(),
vec![],
),
),
#[cfg(feature = "dummy_connector")]
(
Connector::DummyConnector1,
fields(vec![], vec![], card_basic()),
),
#[cfg(feature = "dummy_connector")]
(
Connector::DummyConnector2,
fields(vec![], vec![], card_basic()),
),
#[cfg(feature = "dummy_connector")]
(
Connector::DummyConnector3,
fields(vec![], vec![], card_basic()),
),
#[cfg(feature = "dummy_connector")]
(
Connector::DummyConnector4,
fields(vec![], vec![], card_basic()),
),
#[cfg(feature = "dummy_connector")]
(
Connector::DummyConnector5,
fields(vec![], vec![], card_basic()),
),
#[cfg(feature = "dummy_connector")]
(
Connector::DummyConnector6,
fields(vec![], vec![], card_basic()),
),
#[cfg(feature = "dummy_connector")]
(
Connector::DummyConnector7,
fields(vec![], vec![], card_basic()),
),
(
Connector::Elavon,
fields(vec![], [card_basic(), billing_email()].concat(), vec![]),
),
(Connector::Fiserv, fields(vec![], card_basic(), vec![])),
(
Connector::Fiuu,
fields(
vec![
RequiredField::BillingEmail,
RequiredField::BillingUserFirstName,
],
vec![],
card_basic(),
),
),
(Connector::Forte, fields(vec![], card_with_name(), vec![])),
(Connector::Globalpay, fields(vec![], vec![], card_basic())),
(
Connector::Hipay,
fields(
vec![],
vec![],
[
vec![RequiredField::BillingEmail],
billing_address(),
card_with_name(),
]
.concat(),
),
),
(
Connector::Helcim,
fields(
vec![],
[
card_with_name(),
vec![
RequiredField::BillingAddressZip,
RequiredField::BillingAddressLine1,
],
]
.concat(),
vec![],
),
),
(Connector::Iatapay, fields(vec![], vec![], vec![])),
(Connector::Mollie, fields(vec![], card_with_name(), vec![])),
(Connector::Moneris, fields(vec![], card_basic(), vec![])),
(
Connector::Multisafepay,
fields(
vec![],
vec![],
[
card_with_name(),
vec![
RequiredField::BillingAddressLine1,
RequiredField::BillingAddressLine2,
RequiredField::BillingAddressCity,
RequiredField::BillingAddressZip,
RequiredField::BillingAddressCountries(vec!["ALL"]),
],
]
.concat(),
),
),
(Connector::Nexinets, fields(vec![], vec![], card_basic())),
(
Connector::Nexixpay,
RequiredFieldFinal {
mandate: HashMap::new(),
non_mandate: HashMap::new(),
common: HashMap::from([
RequiredField::CardNumber.to_tuple(),
RequiredField::CardExpMonth.to_tuple(),
RequiredField::CardExpYear.to_tuple(),
RequiredField::BillingFirstName("first_name", FieldType::UserFullName)
.to_tuple(),
RequiredField::BillingLastName("last_name", FieldType::UserFullName).to_tuple(),
]),
},
),
(
Connector::Nmi,
fields(
vec![],
[card_with_name(), vec![RequiredField::BillingAddressZip]].concat(),
vec![],
),
),
(Connector::Noon, fields(vec![], vec![], card_with_name())),
(
Connector::Novalnet,
fields(
vec![],
vec![],
[
vec![
RequiredField::BillingFirstName("first_name", FieldType::UserFullName),
RequiredField::BillingLastName("last_name", FieldType::UserFullName),
],
billing_email(),
]
.concat(),
),
),
(
Connector::Nuvei,
fields(
vec![],
vec![],
[
card_basic(),
vec![
RequiredField::BillingEmail,
RequiredField::BillingCountries(vec!["ALL"]),
RequiredField::BillingFirstName("first_name", FieldType::UserFullName),
RequiredField::BillingLastName("last_name", FieldType::UserFullName),
],
]
.concat(),
),
),
(
Connector::Paybox,
fields(
vec![],
vec![],
[
email(),
card_with_name(),
vec![
RequiredField::BillingAddressLine1,
RequiredField::BillingAddressCity,
RequiredField::BillingAddressZip,
RequiredField::BillingAddressCountries(vec!["ALL"]),
],
]
.concat(),
),
),
(
Connector::Paysafe,
fields(
vec![
RequiredField::BillingAddressCountries(vec!["ALL"]),
RequiredField::BillingEmail,
RequiredField::BillingAddressZip,
RequiredField::BillingAddressState,
],
vec![],
vec![],
),
),
(
Connector::Payload,
fields(
vec![],
vec![],
[
email(),
card_with_name(),
vec![
RequiredField::BillingAddressLine1,
RequiredField::BillingAddressCity,
RequiredField::BillingAddressZip,
RequiredField::BillingAddressState,
RequiredField::BillingAddressCountries(vec!["ALL"]),
],
]
.concat(),
),
),
(
Connector::Payme,
fields(vec![], vec![], [email(), card_with_name()].concat()),
),
(Connector::Paypal, fields(vec![], card_basic(), vec![])),
(Connector::Payu, fields(vec![], card_basic(), vec![])),
(
Connector::Peachpayments,
fields(vec![], vec![], card_with_name()),
),
(
Connector::Powertranz,
fields(vec![], card_with_name(), vec![]),
),
(Connector::Rapyd, fields(vec![], card_with_name(), vec![])),
(Connector::Redsys, fields(vec![], card_basic(), vec![])),
(Connector::Shift4, fields(vec![], card_basic(), vec![])),
(Connector::Silverflow, fields(vec![], vec![], card_basic())),
(Connector::Square, fields(vec![], vec![], card_basic())),
(Connector::Stax, fields(vec![], card_with_name(), vec![])),
(Connector::Stripe, fields(vec![], vec![], card_basic())),
(
Connector::Trustpay,
fields(
vec![],
[
card_with_name(),
vec![
RequiredField::BillingAddressLine1,
RequiredField::BillingAddressCity,
RequiredField::BillingAddressZip,
RequiredField::BillingAddressCountries(vec!["ALL"]),
],
]
.concat(),
vec![],
),
),
(
Connector::Trustpayments,
fields(vec![], vec![], card_basic()),
),
(
Connector::Tesouro,
fields(
vec![],
vec![],
vec![
RequiredField::CardNumber,
RequiredField::CardExpMonth,
RequiredField::CardExpYear,
RequiredField::CardCvc,
],
),
),
(Connector::Tsys, fields(vec![], card_basic(), vec![])),
(
Connector::Wellsfargo,
fields(
vec![],
vec![],
[card_with_name(), email(), billing_address()].concat(),
),
),
(
Connector::Worldline,
fields(
vec![],
[
card_basic(),
vec![RequiredField::BillingAddressCountries(vec!["ALL"])],
]
.concat(),
vec![],
),
),
(
Connector::Worldpay,
fields(
vec![],
vec![],
vec![
RequiredField::CardNumber,
RequiredField::CardExpMonth,
RequiredField::CardExpYear,
RequiredField::BillingUserFirstName,
],
),
),
(
Connector::Worldpayvantiv,
fields(vec![], card_basic(), vec![]),
),
(
Connector::Xendit,
fields(
vec![],
vec![],
[
card_basic(),
vec![
RequiredField::BillingEmail,
RequiredField::BillingPhone,
RequiredField::BillingPhoneCountryCode,
RequiredField::BillingUserFirstName,
RequiredField::BillingUserLastName,
RequiredField::BillingAddressCountries(vec!["ID,PH"]),
],
]
.concat(),
),
),
(
Connector::Zen,
RequiredFieldFinal {
mandate: HashMap::new(),
non_mandate: HashMap::from([
RequiredField::CardNumber.to_tuple(),
RequiredField::CardExpMonth.to_tuple(),
RequiredField::CardExpYear.to_tuple(),
RequiredField::Email.to_tuple(),
]),
common: HashMap::new(),
},
),
])
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 379,
"total_crates": null
} |
fn_clm_payment_methods_connectors_-4916677146550061978 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/configs/payment_connector_required_fields
fn connectors(connectors: Vec<(Connector, RequiredFieldFinal)>) -> ConnectorFields {
ConnectorFields {
fields: connectors.into_iter().collect(),
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 253,
"total_crates": null
} |
fn_clm_payment_methods_convert_to_raw_secret_-3133009782312498959 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/configs/settings
// Implementation of PaymentMethodAuth for SecretsHandler
async fn convert_to_raw_secret(
value: SecretStateContainer<Self, SecuredSecret>,
secret_management_client: &dyn SecretManagementInterface,
) -> CustomResult<SecretStateContainer<Self, RawSecret>, SecretsManagementError> {
let payment_method_auth = value.get_inner();
let pm_auth_key = secret_management_client
.get_secret(payment_method_auth.pm_auth_key.clone())
.await?;
Ok(value.transition_state(|payment_method_auth| Self {
pm_auth_key,
..payment_method_auth
}))
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 70,
"total_crates": null
} |
fn_clm_payment_methods_deserialize_hashset_inner_-3133009782312498959 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/configs/settings
fn deserialize_hashset_inner<T>(value: impl AsRef<str>) -> Result<HashSet<T>, String>
where
T: Eq + std::str::FromStr + std::hash::Hash,
<T as std::str::FromStr>::Err: std::fmt::Display,
{
let (values, errors) = value
.as_ref()
.trim()
.split(',')
.map(|s| {
T::from_str(s.trim()).map_err(|error| {
format!(
"Unable to deserialize `{}` as `{}`: {error}",
s.trim(),
std::any::type_name::<T>()
)
})
})
.fold(
(HashSet::new(), Vec::new()),
|(mut values, mut errors), result| match result {
Ok(t) => {
values.insert(t);
(values, errors)
}
Err(error) => {
errors.push(error);
(values, errors)
}
},
);
if !errors.is_empty() {
Err(format!("Some errors occurred:\n{}", errors.join("\n")))
} else {
Ok(values)
}
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 59,
"total_crates": null
} |
fn_clm_payment_methods_deserialize_hashset_-3133009782312498959 | clm | function | // Repository: hyperswitch
// Crate: payment_methods
// Module: crates/payment_methods/src/configs/settings
fn deserialize_hashset<'a, D, T>(deserializer: D) -> Result<HashSet<T>, D::Error>
where
D: serde::Deserializer<'a>,
T: Eq + std::str::FromStr + std::hash::Hash,
<T as std::str::FromStr>::Err: std::fmt::Display,
{
use serde::de::Error;
deserialize_hashset_inner(<String>::deserialize(deserializer)?).map_err(D::Error::custom)
}
| {
"crate": "payment_methods",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 6,
"total_crates": null
} |
fn_clm_pm_auth_from_-5281437103833621350 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/types
// Implementation of api_models::pm_auth::ExchangeTokenCreateResponse for From<ExchangeTokenResponse>
fn from(value: ExchangeTokenResponse) -> Self {
Self {
access_token: value.access_token,
}
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_pm_auth_get_not_implemented_-5281437103833621350 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/types
// Inherent implementation for ErrorResponse
fn get_not_implemented() -> Self {
Self {
code: "IR_00".to_string(),
message: "This API is under development and will be made available soon.".to_string(),
reason: None,
status_code: http::StatusCode::INTERNAL_SERVER_ERROR.as_u16(),
}
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_pm_auth_build_error_response_-8882305114178002994 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/types/api
fn build_error_response(
&self,
res: auth_types::Response,
) -> CustomResult<auth_types::ErrorResponse, ConnectorError> {
Ok(auth_types::ErrorResponse {
status_code: res.status_code,
code: crate::consts::NO_ERROR_CODE.to_string(),
message: crate::consts::NO_ERROR_MESSAGE.to_string(),
reason: None,
})
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 427,
"total_crates": null
} |
fn_clm_pm_auth_get_url_-8882305114178002994 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/types/api
fn get_url(
&self,
_req: &super::PaymentAuthRouterData<T, Req, Resp>,
_connectors: &auth_types::PaymentMethodAuthConnectors,
) -> CustomResult<String, ConnectorError> {
Ok(String::new())
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 401,
"total_crates": null
} |
fn_clm_pm_auth_get_headers_-8882305114178002994 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/types/api
fn get_headers(
&self,
_req: &super::PaymentAuthRouterData<T, Req, Resp>,
_connectors: &auth_types::PaymentMethodAuthConnectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, ConnectorError> {
Ok(vec![])
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 372,
"total_crates": null
} |
fn_clm_pm_auth_common_get_content_type_-8882305114178002994 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/types/api
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 369,
"total_crates": null
} |
fn_clm_pm_auth_build_headers_-8882305114178002994 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/types/api
fn build_headers(
&self,
_req: &auth_types::PaymentAuthRouterData<Flow, Req, Resp>,
_connectors: &auth_types::PaymentMethodAuthConnectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, ConnectorError> {
Ok(Vec::new())
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 362,
"total_crates": null
} |
fn_clm_pm_auth_build_error_response_-9192987628127507061 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/connector/plaid
// Implementation of Plaid for ConnectorCommon
fn build_error_response(
&self,
res: auth_types::Response,
) -> errors::CustomResult<auth_types::ErrorResponse, errors::ConnectorError> {
let response: plaid::PlaidErrorResponse =
res.response
.parse_struct("PlaidErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
Ok(auth_types::ErrorResponse {
status_code: res.status_code,
code: crate::consts::NO_ERROR_CODE.to_string(),
message: response.error_message,
reason: response.display_message,
})
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 437,
"total_crates": null
} |
fn_clm_pm_auth_get_url_-9192987628127507061 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/connector/plaid
// Implementation of Plaid for ConnectorIntegration<
RecipientCreate,
auth_types::RecipientCreateRequest,
auth_types::RecipientCreateResponse,
>
fn get_url(
&self,
_req: &auth_types::RecipientCreateRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<String, errors::ConnectorError> {
Ok(format!(
"{}{}",
self.base_url(connectors),
"/payment_initiation/recipient/create"
))
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 407,
"total_crates": null
} |
fn_clm_pm_auth_get_headers_-9192987628127507061 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/connector/plaid
// Implementation of Plaid for ConnectorIntegration<
RecipientCreate,
auth_types::RecipientCreateRequest,
auth_types::RecipientCreateResponse,
>
fn get_headers(
&self,
req: &auth_types::RecipientCreateRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 382,
"total_crates": null
} |
fn_clm_pm_auth_common_get_content_type_-9192987628127507061 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/connector/plaid
// Implementation of Plaid for ConnectorCommon
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 377,
"total_crates": null
} |
fn_clm_pm_auth_build_headers_-9192987628127507061 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/connector/plaid
// Implementation of Plaid for ConnectorCommonExt<Flow, Request, Response>
fn build_headers(
&self,
req: &auth_types::PaymentAuthRouterData<Flow, Request, Response>,
_connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
let mut header = vec![(
"Content-Type".to_string(),
self.get_content_type().to_string().into(),
)];
let mut auth = self.get_auth_header(&req.connector_auth_type)?;
header.append(&mut auth);
Ok(header)
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 372,
"total_crates": null
} |
fn_clm_pm_auth_try_from_-8680909621834439539 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/connector/plaid/transformers
// Implementation of PlaidAuthType for TryFrom<&types::ConnectorAuthType>
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
match auth_type {
types::ConnectorAuthType::BodyKey { client_id, secret } => Ok(Self {
client_id: client_id.to_owned(),
secret: secret.to_owned(),
}),
_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
}
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2663,
"total_crates": null
} |
fn_clm_pm_auth_from_-8680909621834439539 | clm | function | // Repository: hyperswitch
// Crate: pm_auth
// Module: crates/pm_auth/src/connector/plaid/transformers
// Implementation of types::PaymentAuthRouterData<F, T, types::RecipientCreateResponse> for From<
types::ResponseRouterData<
F,
PlaidRecipientCreateResponse,
T,
types::RecipientCreateResponse,
>,
>
fn from(
item: types::ResponseRouterData<
F,
PlaidRecipientCreateResponse,
T,
types::RecipientCreateResponse,
>,
) -> Self {
Self {
response: Ok(types::RecipientCreateResponse {
recipient_id: item.response.recipient_id,
}),
..item.data
}
}
| {
"crate": "pm_auth",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_kgraph_utils_build_test_data_5186035463414702477 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/benches/evaluation
fn build_test_data(
total_enabled: usize,
total_pm_types: usize,
) -> hyperswitch_constraint_graph::ConstraintGraph<dir::DirValue> {
use api_models::{admin::*, payment_methods::*};
let mut pms_enabled: Vec<PaymentMethodsEnabled> = Vec::new();
for _ in (0..total_enabled) {
let mut pm_types: Vec<RequestPaymentMethodTypes> = Vec::new();
for _ in (0..total_pm_types) {
pm_types.push(RequestPaymentMethodTypes {
payment_method_type: api_enums::PaymentMethodType::Credit,
payment_experience: None,
card_networks: Some(vec![
api_enums::CardNetwork::Visa,
api_enums::CardNetwork::Mastercard,
]),
accepted_currencies: Some(AcceptedCurrencies::EnableOnly(vec![
api_enums::Currency::USD,
api_enums::Currency::INR,
])),
accepted_countries: None,
minimum_amount: Some(MinorUnit::new(10)),
maximum_amount: Some(MinorUnit::new(1000)),
recurring_enabled: Some(true),
installment_payment_enabled: Some(true),
});
}
pms_enabled.push(PaymentMethodsEnabled {
payment_method: api_enums::PaymentMethod::Card,
payment_method_types: Some(pm_types),
});
}
let profile_id = common_utils::generate_profile_id_of_default_length();
// #[cfg(feature = "v2")]
// let stripe_account = MerchantConnectorResponse {
// connector_type: api_enums::ConnectorType::FizOperations,
// connector_name: "stripe".to_string(),
// id: common_utils::generate_merchant_connector_account_id_of_default_length(),
// connector_account_details: masking::Secret::new(serde_json::json!({})),
// disabled: None,
// metadata: None,
// payment_methods_enabled: Some(pms_enabled),
// connector_label: Some("something".to_string()),
// frm_configs: None,
// connector_webhook_details: None,
// profile_id,
// applepay_verified_domains: None,
// pm_auth_config: None,
// status: api_enums::ConnectorStatus::Inactive,
// additional_merchant_data: None,
// connector_wallets_details: None,
// };
#[cfg(feature = "v1")]
let stripe_account = MerchantConnectorResponse {
connector_type: api_enums::ConnectorType::FizOperations,
connector_name: "stripe".to_string(),
merchant_connector_id:
common_utils::generate_merchant_connector_account_id_of_default_length(),
connector_account_details: masking::Secret::new(serde_json::json!({})),
test_mode: None,
disabled: None,
metadata: None,
payment_methods_enabled: Some(pms_enabled),
business_country: Some(api_enums::CountryAlpha2::US),
business_label: Some("hello".to_string()),
connector_label: Some("something".to_string()),
business_sub_label: Some("something".to_string()),
frm_configs: None,
connector_webhook_details: None,
profile_id,
applepay_verified_domains: None,
pm_auth_config: None,
status: api_enums::ConnectorStatus::Inactive,
additional_merchant_data: None,
connector_wallets_details: None,
};
let config = CountryCurrencyFilter {
connector_configs: HashMap::new(),
default_configs: None,
};
#[cfg(feature = "v1")]
kgraph_utils::mca::make_mca_graph(vec![stripe_account], &config)
.expect("Failed graph construction")
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 56,
"total_crates": null
} |
fn_clm_kgraph_utils_evaluation_5186035463414702477 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/benches/evaluation
fn evaluation(c: &mut Criterion) {
let small_graph = build_test_data(3, 8);
let big_graph = build_test_data(20, 20);
c.bench_function("MCA Small Graph Evaluation", |b| {
b.iter(|| {
small_graph.key_value_analysis(
dirval!(Connector = Stripe),
&graph::AnalysisContext::from_dir_values([
dirval!(Connector = Stripe),
dirval!(PaymentMethod = Card),
dirval!(CardType = Credit),
dirval!(CardNetwork = Visa),
dirval!(PaymentCurrency = BWP),
dirval!(PaymentAmount = 100),
]),
&mut Memoization::new(),
&mut CycleCheck::new(),
None,
);
});
});
c.bench_function("MCA Big Graph Evaluation", |b| {
b.iter(|| {
big_graph.key_value_analysis(
dirval!(Connector = Stripe),
&graph::AnalysisContext::from_dir_values([
dirval!(Connector = Stripe),
dirval!(PaymentMethod = Card),
dirval!(CardType = Credit),
dirval!(CardNetwork = Visa),
dirval!(PaymentCurrency = BWP),
dirval!(PaymentAmount = 100),
]),
&mut Memoization::new(),
&mut CycleCheck::new(),
None,
);
});
});
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 28,
"total_crates": null
} |
fn_clm_kgraph_utils_main_5186035463414702477 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/benches/evaluation
fn main() {}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 0,
"total_crates": null
} |
fn_clm_kgraph_utils_into_context_1515945557120810312 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/transformers
// Implementation of BackendInput for IntoContext
fn into_context(self) -> Result<Vec<dir::DirValue>, KgraphError> {
let mut ctx: Vec<dir::DirValue> = Vec::new();
ctx.push(dir::DirValue::PaymentAmount(NumValue {
number: self.payment.amount,
refinement: None,
}));
ctx.push(dir::DirValue::PaymentCurrency(self.payment.currency));
if let Some(auth_type) = self.payment.authentication_type {
ctx.push(dir::DirValue::AuthenticationType(auth_type));
}
if let Some(capture_method) = self.payment.capture_method {
ctx.push(dir::DirValue::CaptureMethod(capture_method));
}
if let Some(business_country) = self.payment.business_country {
ctx.push(dir::DirValue::BusinessCountry(business_country));
}
if let Some(business_label) = self.payment.business_label {
ctx.push(dir::DirValue::BusinessLabel(StrValue {
value: business_label,
}));
}
if let Some(billing_country) = self.payment.billing_country {
ctx.push(dir::DirValue::BillingCountry(billing_country));
}
if let Some(payment_method) = self.payment_method.payment_method {
ctx.push(dir::DirValue::PaymentMethod(payment_method));
}
if let (Some(pm_type), Some(payment_method)) = (
self.payment_method.payment_method_type,
self.payment_method.payment_method,
) {
ctx.push((pm_type, payment_method).into_dir_value()?)
}
if let Some(card_network) = self.payment_method.card_network {
ctx.push(dir::DirValue::CardNetwork(card_network));
}
if let Some(setup_future_usage) = self.payment.setup_future_usage {
ctx.push(dir::DirValue::SetupFutureUsage(setup_future_usage));
}
if let Some(mandate_acceptance_type) = self.mandate.mandate_acceptance_type {
ctx.push(dir::DirValue::MandateAcceptanceType(
mandate_acceptance_type,
));
}
if let Some(mandate_type) = self.mandate.mandate_type {
ctx.push(dir::DirValue::MandateType(mandate_type));
}
if let Some(payment_type) = self.mandate.payment_type {
ctx.push(dir::DirValue::PaymentType(payment_type));
}
Ok(ctx)
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 69,
"total_crates": null
} |
fn_clm_kgraph_utils_into_dir_value_1515945557120810312 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/transformers
// Implementation of api_enums::Currency for IntoDirValue
fn into_dir_value(self) -> Result<dir::DirValue, KgraphError> {
match self {
Self::AED => Ok(dirval!(PaymentCurrency = AED)),
Self::AFN => Ok(dirval!(PaymentCurrency = AFN)),
Self::ALL => Ok(dirval!(PaymentCurrency = ALL)),
Self::AMD => Ok(dirval!(PaymentCurrency = AMD)),
Self::ANG => Ok(dirval!(PaymentCurrency = ANG)),
Self::AOA => Ok(dirval!(PaymentCurrency = AOA)),
Self::ARS => Ok(dirval!(PaymentCurrency = ARS)),
Self::AUD => Ok(dirval!(PaymentCurrency = AUD)),
Self::AWG => Ok(dirval!(PaymentCurrency = AWG)),
Self::AZN => Ok(dirval!(PaymentCurrency = AZN)),
Self::BAM => Ok(dirval!(PaymentCurrency = BAM)),
Self::BBD => Ok(dirval!(PaymentCurrency = BBD)),
Self::BDT => Ok(dirval!(PaymentCurrency = BDT)),
Self::BGN => Ok(dirval!(PaymentCurrency = BGN)),
Self::BHD => Ok(dirval!(PaymentCurrency = BHD)),
Self::BIF => Ok(dirval!(PaymentCurrency = BIF)),
Self::BMD => Ok(dirval!(PaymentCurrency = BMD)),
Self::BND => Ok(dirval!(PaymentCurrency = BND)),
Self::BOB => Ok(dirval!(PaymentCurrency = BOB)),
Self::BRL => Ok(dirval!(PaymentCurrency = BRL)),
Self::BSD => Ok(dirval!(PaymentCurrency = BSD)),
Self::BTN => Ok(dirval!(PaymentCurrency = BTN)),
Self::BWP => Ok(dirval!(PaymentCurrency = BWP)),
Self::BYN => Ok(dirval!(PaymentCurrency = BYN)),
Self::BZD => Ok(dirval!(PaymentCurrency = BZD)),
Self::CAD => Ok(dirval!(PaymentCurrency = CAD)),
Self::CDF => Ok(dirval!(PaymentCurrency = CDF)),
Self::CHF => Ok(dirval!(PaymentCurrency = CHF)),
Self::CLF => Ok(dirval!(PaymentCurrency = CLF)),
Self::CLP => Ok(dirval!(PaymentCurrency = CLP)),
Self::CNY => Ok(dirval!(PaymentCurrency = CNY)),
Self::COP => Ok(dirval!(PaymentCurrency = COP)),
Self::CRC => Ok(dirval!(PaymentCurrency = CRC)),
Self::CUC => Ok(dirval!(PaymentCurrency = CUC)),
Self::CUP => Ok(dirval!(PaymentCurrency = CUP)),
Self::CVE => Ok(dirval!(PaymentCurrency = CVE)),
Self::CZK => Ok(dirval!(PaymentCurrency = CZK)),
Self::DJF => Ok(dirval!(PaymentCurrency = DJF)),
Self::DKK => Ok(dirval!(PaymentCurrency = DKK)),
Self::DOP => Ok(dirval!(PaymentCurrency = DOP)),
Self::DZD => Ok(dirval!(PaymentCurrency = DZD)),
Self::EGP => Ok(dirval!(PaymentCurrency = EGP)),
Self::ERN => Ok(dirval!(PaymentCurrency = ERN)),
Self::ETB => Ok(dirval!(PaymentCurrency = ETB)),
Self::EUR => Ok(dirval!(PaymentCurrency = EUR)),
Self::FJD => Ok(dirval!(PaymentCurrency = FJD)),
Self::FKP => Ok(dirval!(PaymentCurrency = FKP)),
Self::GBP => Ok(dirval!(PaymentCurrency = GBP)),
Self::GEL => Ok(dirval!(PaymentCurrency = GEL)),
Self::GHS => Ok(dirval!(PaymentCurrency = GHS)),
Self::GIP => Ok(dirval!(PaymentCurrency = GIP)),
Self::GMD => Ok(dirval!(PaymentCurrency = GMD)),
Self::GNF => Ok(dirval!(PaymentCurrency = GNF)),
Self::GTQ => Ok(dirval!(PaymentCurrency = GTQ)),
Self::GYD => Ok(dirval!(PaymentCurrency = GYD)),
Self::HKD => Ok(dirval!(PaymentCurrency = HKD)),
Self::HNL => Ok(dirval!(PaymentCurrency = HNL)),
Self::HRK => Ok(dirval!(PaymentCurrency = HRK)),
Self::HTG => Ok(dirval!(PaymentCurrency = HTG)),
Self::HUF => Ok(dirval!(PaymentCurrency = HUF)),
Self::IDR => Ok(dirval!(PaymentCurrency = IDR)),
Self::ILS => Ok(dirval!(PaymentCurrency = ILS)),
Self::INR => Ok(dirval!(PaymentCurrency = INR)),
Self::IQD => Ok(dirval!(PaymentCurrency = IQD)),
Self::IRR => Ok(dirval!(PaymentCurrency = IRR)),
Self::ISK => Ok(dirval!(PaymentCurrency = ISK)),
Self::JMD => Ok(dirval!(PaymentCurrency = JMD)),
Self::JOD => Ok(dirval!(PaymentCurrency = JOD)),
Self::JPY => Ok(dirval!(PaymentCurrency = JPY)),
Self::KES => Ok(dirval!(PaymentCurrency = KES)),
Self::KGS => Ok(dirval!(PaymentCurrency = KGS)),
Self::KHR => Ok(dirval!(PaymentCurrency = KHR)),
Self::KMF => Ok(dirval!(PaymentCurrency = KMF)),
Self::KPW => Ok(dirval!(PaymentCurrency = KPW)),
Self::KRW => Ok(dirval!(PaymentCurrency = KRW)),
Self::KWD => Ok(dirval!(PaymentCurrency = KWD)),
Self::KYD => Ok(dirval!(PaymentCurrency = KYD)),
Self::KZT => Ok(dirval!(PaymentCurrency = KZT)),
Self::LAK => Ok(dirval!(PaymentCurrency = LAK)),
Self::LBP => Ok(dirval!(PaymentCurrency = LBP)),
Self::LKR => Ok(dirval!(PaymentCurrency = LKR)),
Self::LRD => Ok(dirval!(PaymentCurrency = LRD)),
Self::LSL => Ok(dirval!(PaymentCurrency = LSL)),
Self::LYD => Ok(dirval!(PaymentCurrency = LYD)),
Self::MAD => Ok(dirval!(PaymentCurrency = MAD)),
Self::MDL => Ok(dirval!(PaymentCurrency = MDL)),
Self::MGA => Ok(dirval!(PaymentCurrency = MGA)),
Self::MKD => Ok(dirval!(PaymentCurrency = MKD)),
Self::MMK => Ok(dirval!(PaymentCurrency = MMK)),
Self::MNT => Ok(dirval!(PaymentCurrency = MNT)),
Self::MOP => Ok(dirval!(PaymentCurrency = MOP)),
Self::MRU => Ok(dirval!(PaymentCurrency = MRU)),
Self::MUR => Ok(dirval!(PaymentCurrency = MUR)),
Self::MVR => Ok(dirval!(PaymentCurrency = MVR)),
Self::MWK => Ok(dirval!(PaymentCurrency = MWK)),
Self::MXN => Ok(dirval!(PaymentCurrency = MXN)),
Self::MYR => Ok(dirval!(PaymentCurrency = MYR)),
Self::MZN => Ok(dirval!(PaymentCurrency = MZN)),
Self::NAD => Ok(dirval!(PaymentCurrency = NAD)),
Self::NGN => Ok(dirval!(PaymentCurrency = NGN)),
Self::NIO => Ok(dirval!(PaymentCurrency = NIO)),
Self::NOK => Ok(dirval!(PaymentCurrency = NOK)),
Self::NPR => Ok(dirval!(PaymentCurrency = NPR)),
Self::NZD => Ok(dirval!(PaymentCurrency = NZD)),
Self::OMR => Ok(dirval!(PaymentCurrency = OMR)),
Self::PAB => Ok(dirval!(PaymentCurrency = PAB)),
Self::PEN => Ok(dirval!(PaymentCurrency = PEN)),
Self::PGK => Ok(dirval!(PaymentCurrency = PGK)),
Self::PHP => Ok(dirval!(PaymentCurrency = PHP)),
Self::PKR => Ok(dirval!(PaymentCurrency = PKR)),
Self::PLN => Ok(dirval!(PaymentCurrency = PLN)),
Self::PYG => Ok(dirval!(PaymentCurrency = PYG)),
Self::QAR => Ok(dirval!(PaymentCurrency = QAR)),
Self::RON => Ok(dirval!(PaymentCurrency = RON)),
Self::RSD => Ok(dirval!(PaymentCurrency = RSD)),
Self::RUB => Ok(dirval!(PaymentCurrency = RUB)),
Self::RWF => Ok(dirval!(PaymentCurrency = RWF)),
Self::SAR => Ok(dirval!(PaymentCurrency = SAR)),
Self::SBD => Ok(dirval!(PaymentCurrency = SBD)),
Self::SCR => Ok(dirval!(PaymentCurrency = SCR)),
Self::SDG => Ok(dirval!(PaymentCurrency = SDG)),
Self::SEK => Ok(dirval!(PaymentCurrency = SEK)),
Self::SGD => Ok(dirval!(PaymentCurrency = SGD)),
Self::SHP => Ok(dirval!(PaymentCurrency = SHP)),
Self::SLE => Ok(dirval!(PaymentCurrency = SLE)),
Self::SLL => Ok(dirval!(PaymentCurrency = SLL)),
Self::SOS => Ok(dirval!(PaymentCurrency = SOS)),
Self::SRD => Ok(dirval!(PaymentCurrency = SRD)),
Self::SSP => Ok(dirval!(PaymentCurrency = SSP)),
Self::STD => Ok(dirval!(PaymentCurrency = STD)),
Self::STN => Ok(dirval!(PaymentCurrency = STN)),
Self::SVC => Ok(dirval!(PaymentCurrency = SVC)),
Self::SYP => Ok(dirval!(PaymentCurrency = SYP)),
Self::SZL => Ok(dirval!(PaymentCurrency = SZL)),
Self::THB => Ok(dirval!(PaymentCurrency = THB)),
Self::TJS => Ok(dirval!(PaymentCurrency = TJS)),
Self::TMT => Ok(dirval!(PaymentCurrency = TMT)),
Self::TND => Ok(dirval!(PaymentCurrency = TND)),
Self::TOP => Ok(dirval!(PaymentCurrency = TOP)),
Self::TRY => Ok(dirval!(PaymentCurrency = TRY)),
Self::TTD => Ok(dirval!(PaymentCurrency = TTD)),
Self::TWD => Ok(dirval!(PaymentCurrency = TWD)),
Self::TZS => Ok(dirval!(PaymentCurrency = TZS)),
Self::UAH => Ok(dirval!(PaymentCurrency = UAH)),
Self::UGX => Ok(dirval!(PaymentCurrency = UGX)),
Self::USD => Ok(dirval!(PaymentCurrency = USD)),
Self::UYU => Ok(dirval!(PaymentCurrency = UYU)),
Self::UZS => Ok(dirval!(PaymentCurrency = UZS)),
Self::VES => Ok(dirval!(PaymentCurrency = VES)),
Self::VND => Ok(dirval!(PaymentCurrency = VND)),
Self::VUV => Ok(dirval!(PaymentCurrency = VUV)),
Self::WST => Ok(dirval!(PaymentCurrency = WST)),
Self::XAF => Ok(dirval!(PaymentCurrency = XAF)),
Self::XCD => Ok(dirval!(PaymentCurrency = XCD)),
Self::XOF => Ok(dirval!(PaymentCurrency = XOF)),
Self::XPF => Ok(dirval!(PaymentCurrency = XPF)),
Self::YER => Ok(dirval!(PaymentCurrency = YER)),
Self::ZAR => Ok(dirval!(PaymentCurrency = ZAR)),
Self::ZMW => Ok(dirval!(PaymentCurrency = ZMW)),
Self::ZWL => Ok(dirval!(PaymentCurrency = ZWL)),
}
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 35,
"total_crates": null
} |
fn_clm_kgraph_utils_get_dir_country_dir_value_1515945557120810312 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/transformers
pub fn get_dir_country_dir_value(c: api_enums::Country) -> dir::enums::Country {
match c {
api_enums::Country::Afghanistan => dir::enums::Country::Afghanistan,
api_enums::Country::AlandIslands => dir::enums::Country::AlandIslands,
api_enums::Country::Albania => dir::enums::Country::Albania,
api_enums::Country::Algeria => dir::enums::Country::Algeria,
api_enums::Country::AmericanSamoa => dir::enums::Country::AmericanSamoa,
api_enums::Country::Andorra => dir::enums::Country::Andorra,
api_enums::Country::Angola => dir::enums::Country::Angola,
api_enums::Country::Anguilla => dir::enums::Country::Anguilla,
api_enums::Country::Antarctica => dir::enums::Country::Antarctica,
api_enums::Country::AntiguaAndBarbuda => dir::enums::Country::AntiguaAndBarbuda,
api_enums::Country::Argentina => dir::enums::Country::Argentina,
api_enums::Country::Armenia => dir::enums::Country::Armenia,
api_enums::Country::Aruba => dir::enums::Country::Aruba,
api_enums::Country::Australia => dir::enums::Country::Australia,
api_enums::Country::Austria => dir::enums::Country::Austria,
api_enums::Country::Azerbaijan => dir::enums::Country::Azerbaijan,
api_enums::Country::Bahamas => dir::enums::Country::Bahamas,
api_enums::Country::Bahrain => dir::enums::Country::Bahrain,
api_enums::Country::Bangladesh => dir::enums::Country::Bangladesh,
api_enums::Country::Barbados => dir::enums::Country::Barbados,
api_enums::Country::Belarus => dir::enums::Country::Belarus,
api_enums::Country::Belgium => dir::enums::Country::Belgium,
api_enums::Country::Belize => dir::enums::Country::Belize,
api_enums::Country::Benin => dir::enums::Country::Benin,
api_enums::Country::Bermuda => dir::enums::Country::Bermuda,
api_enums::Country::Bhutan => dir::enums::Country::Bhutan,
api_enums::Country::BoliviaPlurinationalState => {
dir::enums::Country::BoliviaPlurinationalState
}
api_enums::Country::BonaireSintEustatiusAndSaba => {
dir::enums::Country::BonaireSintEustatiusAndSaba
}
api_enums::Country::BosniaAndHerzegovina => dir::enums::Country::BosniaAndHerzegovina,
api_enums::Country::Botswana => dir::enums::Country::Botswana,
api_enums::Country::BouvetIsland => dir::enums::Country::BouvetIsland,
api_enums::Country::Brazil => dir::enums::Country::Brazil,
api_enums::Country::BritishIndianOceanTerritory => {
dir::enums::Country::BritishIndianOceanTerritory
}
api_enums::Country::BruneiDarussalam => dir::enums::Country::BruneiDarussalam,
api_enums::Country::Bulgaria => dir::enums::Country::Bulgaria,
api_enums::Country::BurkinaFaso => dir::enums::Country::BurkinaFaso,
api_enums::Country::Burundi => dir::enums::Country::Burundi,
api_enums::Country::CaboVerde => dir::enums::Country::CaboVerde,
api_enums::Country::Cambodia => dir::enums::Country::Cambodia,
api_enums::Country::Cameroon => dir::enums::Country::Cameroon,
api_enums::Country::Canada => dir::enums::Country::Canada,
api_enums::Country::CaymanIslands => dir::enums::Country::CaymanIslands,
api_enums::Country::CentralAfricanRepublic => dir::enums::Country::CentralAfricanRepublic,
api_enums::Country::Chad => dir::enums::Country::Chad,
api_enums::Country::Chile => dir::enums::Country::Chile,
api_enums::Country::China => dir::enums::Country::China,
api_enums::Country::ChristmasIsland => dir::enums::Country::ChristmasIsland,
api_enums::Country::CocosKeelingIslands => dir::enums::Country::CocosKeelingIslands,
api_enums::Country::Colombia => dir::enums::Country::Colombia,
api_enums::Country::Comoros => dir::enums::Country::Comoros,
api_enums::Country::Congo => dir::enums::Country::Congo,
api_enums::Country::CongoDemocraticRepublic => dir::enums::Country::CongoDemocraticRepublic,
api_enums::Country::CookIslands => dir::enums::Country::CookIslands,
api_enums::Country::CostaRica => dir::enums::Country::CostaRica,
api_enums::Country::CotedIvoire => dir::enums::Country::CotedIvoire,
api_enums::Country::Croatia => dir::enums::Country::Croatia,
api_enums::Country::Cuba => dir::enums::Country::Cuba,
api_enums::Country::Curacao => dir::enums::Country::Curacao,
api_enums::Country::Cyprus => dir::enums::Country::Cyprus,
api_enums::Country::Czechia => dir::enums::Country::Czechia,
api_enums::Country::Denmark => dir::enums::Country::Denmark,
api_enums::Country::Djibouti => dir::enums::Country::Djibouti,
api_enums::Country::Dominica => dir::enums::Country::Dominica,
api_enums::Country::DominicanRepublic => dir::enums::Country::DominicanRepublic,
api_enums::Country::Ecuador => dir::enums::Country::Ecuador,
api_enums::Country::Egypt => dir::enums::Country::Egypt,
api_enums::Country::ElSalvador => dir::enums::Country::ElSalvador,
api_enums::Country::EquatorialGuinea => dir::enums::Country::EquatorialGuinea,
api_enums::Country::Eritrea => dir::enums::Country::Eritrea,
api_enums::Country::Estonia => dir::enums::Country::Estonia,
api_enums::Country::Ethiopia => dir::enums::Country::Ethiopia,
api_enums::Country::FalklandIslandsMalvinas => dir::enums::Country::FalklandIslandsMalvinas,
api_enums::Country::FaroeIslands => dir::enums::Country::FaroeIslands,
api_enums::Country::Fiji => dir::enums::Country::Fiji,
api_enums::Country::Finland => dir::enums::Country::Finland,
api_enums::Country::France => dir::enums::Country::France,
api_enums::Country::FrenchGuiana => dir::enums::Country::FrenchGuiana,
api_enums::Country::FrenchPolynesia => dir::enums::Country::FrenchPolynesia,
api_enums::Country::FrenchSouthernTerritories => {
dir::enums::Country::FrenchSouthernTerritories
}
api_enums::Country::Gabon => dir::enums::Country::Gabon,
api_enums::Country::Gambia => dir::enums::Country::Gambia,
api_enums::Country::Georgia => dir::enums::Country::Georgia,
api_enums::Country::Germany => dir::enums::Country::Germany,
api_enums::Country::Ghana => dir::enums::Country::Ghana,
api_enums::Country::Gibraltar => dir::enums::Country::Gibraltar,
api_enums::Country::Greece => dir::enums::Country::Greece,
api_enums::Country::Greenland => dir::enums::Country::Greenland,
api_enums::Country::Grenada => dir::enums::Country::Grenada,
api_enums::Country::Guadeloupe => dir::enums::Country::Guadeloupe,
api_enums::Country::Guam => dir::enums::Country::Guam,
api_enums::Country::Guatemala => dir::enums::Country::Guatemala,
api_enums::Country::Guernsey => dir::enums::Country::Guernsey,
api_enums::Country::Guinea => dir::enums::Country::Guinea,
api_enums::Country::GuineaBissau => dir::enums::Country::GuineaBissau,
api_enums::Country::Guyana => dir::enums::Country::Guyana,
api_enums::Country::Haiti => dir::enums::Country::Haiti,
api_enums::Country::HeardIslandAndMcDonaldIslands => {
dir::enums::Country::HeardIslandAndMcDonaldIslands
}
api_enums::Country::HolySee => dir::enums::Country::HolySee,
api_enums::Country::Honduras => dir::enums::Country::Honduras,
api_enums::Country::HongKong => dir::enums::Country::HongKong,
api_enums::Country::Hungary => dir::enums::Country::Hungary,
api_enums::Country::Iceland => dir::enums::Country::Iceland,
api_enums::Country::India => dir::enums::Country::India,
api_enums::Country::Indonesia => dir::enums::Country::Indonesia,
api_enums::Country::IranIslamicRepublic => dir::enums::Country::IranIslamicRepublic,
api_enums::Country::Iraq => dir::enums::Country::Iraq,
api_enums::Country::Ireland => dir::enums::Country::Ireland,
api_enums::Country::IsleOfMan => dir::enums::Country::IsleOfMan,
api_enums::Country::Israel => dir::enums::Country::Israel,
api_enums::Country::Italy => dir::enums::Country::Italy,
api_enums::Country::Jamaica => dir::enums::Country::Jamaica,
api_enums::Country::Japan => dir::enums::Country::Japan,
api_enums::Country::Jersey => dir::enums::Country::Jersey,
api_enums::Country::Jordan => dir::enums::Country::Jordan,
api_enums::Country::Kazakhstan => dir::enums::Country::Kazakhstan,
api_enums::Country::Kenya => dir::enums::Country::Kenya,
api_enums::Country::Kiribati => dir::enums::Country::Kiribati,
api_enums::Country::KoreaDemocraticPeoplesRepublic => {
dir::enums::Country::KoreaDemocraticPeoplesRepublic
}
api_enums::Country::KoreaRepublic => dir::enums::Country::KoreaRepublic,
api_enums::Country::Kuwait => dir::enums::Country::Kuwait,
api_enums::Country::Kyrgyzstan => dir::enums::Country::Kyrgyzstan,
api_enums::Country::LaoPeoplesDemocraticRepublic => {
dir::enums::Country::LaoPeoplesDemocraticRepublic
}
api_enums::Country::Latvia => dir::enums::Country::Latvia,
api_enums::Country::Lebanon => dir::enums::Country::Lebanon,
api_enums::Country::Lesotho => dir::enums::Country::Lesotho,
api_enums::Country::Liberia => dir::enums::Country::Liberia,
api_enums::Country::Libya => dir::enums::Country::Libya,
api_enums::Country::Liechtenstein => dir::enums::Country::Liechtenstein,
api_enums::Country::Lithuania => dir::enums::Country::Lithuania,
api_enums::Country::Luxembourg => dir::enums::Country::Luxembourg,
api_enums::Country::Macao => dir::enums::Country::Macao,
api_enums::Country::MacedoniaTheFormerYugoslavRepublic => {
dir::enums::Country::MacedoniaTheFormerYugoslavRepublic
}
api_enums::Country::Madagascar => dir::enums::Country::Madagascar,
api_enums::Country::Malawi => dir::enums::Country::Malawi,
api_enums::Country::Malaysia => dir::enums::Country::Malaysia,
api_enums::Country::Maldives => dir::enums::Country::Maldives,
api_enums::Country::Mali => dir::enums::Country::Mali,
api_enums::Country::Malta => dir::enums::Country::Malta,
api_enums::Country::MarshallIslands => dir::enums::Country::MarshallIslands,
api_enums::Country::Martinique => dir::enums::Country::Martinique,
api_enums::Country::Mauritania => dir::enums::Country::Mauritania,
api_enums::Country::Mauritius => dir::enums::Country::Mauritius,
api_enums::Country::Mayotte => dir::enums::Country::Mayotte,
api_enums::Country::Mexico => dir::enums::Country::Mexico,
api_enums::Country::MicronesiaFederatedStates => {
dir::enums::Country::MicronesiaFederatedStates
}
api_enums::Country::MoldovaRepublic => dir::enums::Country::MoldovaRepublic,
api_enums::Country::Monaco => dir::enums::Country::Monaco,
api_enums::Country::Mongolia => dir::enums::Country::Mongolia,
api_enums::Country::Montenegro => dir::enums::Country::Montenegro,
api_enums::Country::Montserrat => dir::enums::Country::Montserrat,
api_enums::Country::Morocco => dir::enums::Country::Morocco,
api_enums::Country::Mozambique => dir::enums::Country::Mozambique,
api_enums::Country::Myanmar => dir::enums::Country::Myanmar,
api_enums::Country::Namibia => dir::enums::Country::Namibia,
api_enums::Country::Nauru => dir::enums::Country::Nauru,
api_enums::Country::Nepal => dir::enums::Country::Nepal,
api_enums::Country::Netherlands => dir::enums::Country::Netherlands,
api_enums::Country::NewCaledonia => dir::enums::Country::NewCaledonia,
api_enums::Country::NewZealand => dir::enums::Country::NewZealand,
api_enums::Country::Nicaragua => dir::enums::Country::Nicaragua,
api_enums::Country::Niger => dir::enums::Country::Niger,
api_enums::Country::Nigeria => dir::enums::Country::Nigeria,
api_enums::Country::Niue => dir::enums::Country::Niue,
api_enums::Country::NorfolkIsland => dir::enums::Country::NorfolkIsland,
api_enums::Country::NorthernMarianaIslands => dir::enums::Country::NorthernMarianaIslands,
api_enums::Country::Norway => dir::enums::Country::Norway,
api_enums::Country::Oman => dir::enums::Country::Oman,
api_enums::Country::Pakistan => dir::enums::Country::Pakistan,
api_enums::Country::Palau => dir::enums::Country::Palau,
api_enums::Country::PalestineState => dir::enums::Country::PalestineState,
api_enums::Country::Panama => dir::enums::Country::Panama,
api_enums::Country::PapuaNewGuinea => dir::enums::Country::PapuaNewGuinea,
api_enums::Country::Paraguay => dir::enums::Country::Paraguay,
api_enums::Country::Peru => dir::enums::Country::Peru,
api_enums::Country::Philippines => dir::enums::Country::Philippines,
api_enums::Country::Pitcairn => dir::enums::Country::Pitcairn,
api_enums::Country::Poland => dir::enums::Country::Poland,
api_enums::Country::Portugal => dir::enums::Country::Portugal,
api_enums::Country::PuertoRico => dir::enums::Country::PuertoRico,
api_enums::Country::Qatar => dir::enums::Country::Qatar,
api_enums::Country::Reunion => dir::enums::Country::Reunion,
api_enums::Country::Romania => dir::enums::Country::Romania,
api_enums::Country::RussianFederation => dir::enums::Country::RussianFederation,
api_enums::Country::Rwanda => dir::enums::Country::Rwanda,
api_enums::Country::SaintBarthelemy => dir::enums::Country::SaintBarthelemy,
api_enums::Country::SaintHelenaAscensionAndTristandaCunha => {
dir::enums::Country::SaintHelenaAscensionAndTristandaCunha
}
api_enums::Country::SaintKittsAndNevis => dir::enums::Country::SaintKittsAndNevis,
api_enums::Country::SaintLucia => dir::enums::Country::SaintLucia,
api_enums::Country::SaintMartinFrenchpart => dir::enums::Country::SaintMartinFrenchpart,
api_enums::Country::SaintPierreAndMiquelon => dir::enums::Country::SaintPierreAndMiquelon,
api_enums::Country::SaintVincentAndTheGrenadines => {
dir::enums::Country::SaintVincentAndTheGrenadines
}
api_enums::Country::Samoa => dir::enums::Country::Samoa,
api_enums::Country::SanMarino => dir::enums::Country::SanMarino,
api_enums::Country::SaoTomeAndPrincipe => dir::enums::Country::SaoTomeAndPrincipe,
api_enums::Country::SaudiArabia => dir::enums::Country::SaudiArabia,
api_enums::Country::Senegal => dir::enums::Country::Senegal,
api_enums::Country::Serbia => dir::enums::Country::Serbia,
api_enums::Country::Seychelles => dir::enums::Country::Seychelles,
api_enums::Country::SierraLeone => dir::enums::Country::SierraLeone,
api_enums::Country::Singapore => dir::enums::Country::Singapore,
api_enums::Country::SintMaartenDutchpart => dir::enums::Country::SintMaartenDutchpart,
api_enums::Country::Slovakia => dir::enums::Country::Slovakia,
api_enums::Country::Slovenia => dir::enums::Country::Slovenia,
api_enums::Country::SolomonIslands => dir::enums::Country::SolomonIslands,
api_enums::Country::Somalia => dir::enums::Country::Somalia,
api_enums::Country::SouthAfrica => dir::enums::Country::SouthAfrica,
api_enums::Country::SouthGeorgiaAndTheSouthSandwichIslands => {
dir::enums::Country::SouthGeorgiaAndTheSouthSandwichIslands
}
api_enums::Country::SouthSudan => dir::enums::Country::SouthSudan,
api_enums::Country::Spain => dir::enums::Country::Spain,
api_enums::Country::SriLanka => dir::enums::Country::SriLanka,
api_enums::Country::Sudan => dir::enums::Country::Sudan,
api_enums::Country::Suriname => dir::enums::Country::Suriname,
api_enums::Country::SvalbardAndJanMayen => dir::enums::Country::SvalbardAndJanMayen,
api_enums::Country::Swaziland => dir::enums::Country::Swaziland,
api_enums::Country::Sweden => dir::enums::Country::Sweden,
api_enums::Country::Switzerland => dir::enums::Country::Switzerland,
api_enums::Country::SyrianArabRepublic => dir::enums::Country::SyrianArabRepublic,
api_enums::Country::TaiwanProvinceOfChina => dir::enums::Country::TaiwanProvinceOfChina,
api_enums::Country::Tajikistan => dir::enums::Country::Tajikistan,
api_enums::Country::TanzaniaUnitedRepublic => dir::enums::Country::TanzaniaUnitedRepublic,
api_enums::Country::Thailand => dir::enums::Country::Thailand,
api_enums::Country::TimorLeste => dir::enums::Country::TimorLeste,
api_enums::Country::Togo => dir::enums::Country::Togo,
api_enums::Country::Tokelau => dir::enums::Country::Tokelau,
api_enums::Country::Tonga => dir::enums::Country::Tonga,
api_enums::Country::TrinidadAndTobago => dir::enums::Country::TrinidadAndTobago,
api_enums::Country::Tunisia => dir::enums::Country::Tunisia,
api_enums::Country::Turkey => dir::enums::Country::Turkey,
api_enums::Country::Turkmenistan => dir::enums::Country::Turkmenistan,
api_enums::Country::TurksAndCaicosIslands => dir::enums::Country::TurksAndCaicosIslands,
api_enums::Country::Tuvalu => dir::enums::Country::Tuvalu,
api_enums::Country::Uganda => dir::enums::Country::Uganda,
api_enums::Country::Ukraine => dir::enums::Country::Ukraine,
api_enums::Country::UnitedArabEmirates => dir::enums::Country::UnitedArabEmirates,
api_enums::Country::UnitedKingdomOfGreatBritainAndNorthernIreland => {
dir::enums::Country::UnitedKingdomOfGreatBritainAndNorthernIreland
}
api_enums::Country::UnitedStatesOfAmerica => dir::enums::Country::UnitedStatesOfAmerica,
api_enums::Country::UnitedStatesMinorOutlyingIslands => {
dir::enums::Country::UnitedStatesMinorOutlyingIslands
}
api_enums::Country::Uruguay => dir::enums::Country::Uruguay,
api_enums::Country::Uzbekistan => dir::enums::Country::Uzbekistan,
api_enums::Country::Vanuatu => dir::enums::Country::Vanuatu,
api_enums::Country::VenezuelaBolivarianRepublic => {
dir::enums::Country::VenezuelaBolivarianRepublic
}
api_enums::Country::Vietnam => dir::enums::Country::Vietnam,
api_enums::Country::VirginIslandsBritish => dir::enums::Country::VirginIslandsBritish,
api_enums::Country::VirginIslandsUS => dir::enums::Country::VirginIslandsUS,
api_enums::Country::WallisAndFutuna => dir::enums::Country::WallisAndFutuna,
api_enums::Country::WesternSahara => dir::enums::Country::WesternSahara,
api_enums::Country::Yemen => dir::enums::Country::Yemen,
api_enums::Country::Zambia => dir::enums::Country::Zambia,
api_enums::Country::Zimbabwe => dir::enums::Country::Zimbabwe,
}
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 16,
"total_crates": null
} |
fn_clm_kgraph_utils_business_country_to_dir_value_1515945557120810312 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/transformers
pub fn business_country_to_dir_value(c: api_enums::Country) -> dir::DirValue {
dir::DirValue::BusinessCountry(get_dir_country_dir_value(c))
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14,
"total_crates": null
} |
fn_clm_kgraph_utils_billing_country_to_dir_value_1515945557120810312 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/transformers
pub fn billing_country_to_dir_value(c: api_enums::Country) -> dir::DirValue {
dir::DirValue::BillingCountry(get_dir_country_dir_value(c))
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14,
"total_crates": null
} |
fn_clm_kgraph_utils_compile_request_pm_types_4702994663785621093 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/mca
fn compile_request_pm_types(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
pm_types: RequestPaymentMethodTypes,
pm: api_enums::PaymentMethod,
) -> Result<cgraph::NodeId, KgraphError> {
let mut agg_nodes: Vec<(cgraph::NodeId, cgraph::Relation, cgraph::Strength)> = Vec::new();
let pmt_info = "PaymentMethodType";
let pmt_id = builder.make_value_node(
(pm_types.payment_method_type, pm)
.into_dir_value()
.map(Into::into)?,
Some(pmt_info),
None::<()>,
);
agg_nodes.push((
pmt_id,
cgraph::Relation::Positive,
match pm_types.payment_method_type {
api_enums::PaymentMethodType::Credit | api_enums::PaymentMethodType::Debit => {
cgraph::Strength::Weak
}
_ => cgraph::Strength::Strong,
},
));
if let Some(card_networks) = pm_types.card_networks {
if !card_networks.is_empty() {
let dir_vals: Vec<dir::DirValue> = card_networks
.into_iter()
.map(IntoDirValue::into_dir_value)
.collect::<Result<_, _>>()?;
let card_network_info = "Card Networks";
let card_network_id = builder
.make_in_aggregator(dir_vals, Some(card_network_info), None::<()>)
.map_err(KgraphError::GraphConstructionError)?;
agg_nodes.push((
card_network_id,
cgraph::Relation::Positive,
cgraph::Strength::Weak,
));
}
}
let currencies_data = pm_types
.accepted_currencies
.and_then(|accepted_currencies| match accepted_currencies {
admin_api::AcceptedCurrencies::EnableOnly(curr) if !curr.is_empty() => Some((
curr.into_iter()
.map(IntoDirValue::into_dir_value)
.collect::<Result<_, _>>()
.ok()?,
cgraph::Relation::Positive,
)),
admin_api::AcceptedCurrencies::DisableOnly(curr) if !curr.is_empty() => Some((
curr.into_iter()
.map(IntoDirValue::into_dir_value)
.collect::<Result<_, _>>()
.ok()?,
cgraph::Relation::Negative,
)),
_ => None,
});
if let Some((currencies, relation)) = currencies_data {
let accepted_currencies_info = "Accepted Currencies";
let accepted_currencies_id = builder
.make_in_aggregator(currencies, Some(accepted_currencies_info), None::<()>)
.map_err(KgraphError::GraphConstructionError)?;
agg_nodes.push((accepted_currencies_id, relation, cgraph::Strength::Strong));
}
let mut amount_nodes = Vec::with_capacity(2);
if let Some(min_amt) = pm_types.minimum_amount {
let num_val = NumValue {
number: min_amt,
refinement: Some(NumValueRefinement::GreaterThanEqual),
};
let min_amt_info = "Minimum Amount";
let min_amt_id = builder.make_value_node(
dir::DirValue::PaymentAmount(num_val).into(),
Some(min_amt_info),
None::<()>,
);
amount_nodes.push(min_amt_id);
}
if let Some(max_amt) = pm_types.maximum_amount {
let num_val = NumValue {
number: max_amt,
refinement: Some(NumValueRefinement::LessThanEqual),
};
let max_amt_info = "Maximum Amount";
let max_amt_id = builder.make_value_node(
dir::DirValue::PaymentAmount(num_val).into(),
Some(max_amt_info),
None::<()>,
);
amount_nodes.push(max_amt_id);
}
if !amount_nodes.is_empty() {
let zero_num_val = NumValue {
number: MinorUnit::zero(),
refinement: None,
};
let zero_amt_id = builder.make_value_node(
dir::DirValue::PaymentAmount(zero_num_val).into(),
Some("zero_amount"),
None::<()>,
);
let or_node_neighbor_id = if amount_nodes.len() == 1 {
amount_nodes
.first()
.copied()
.ok_or(KgraphError::IndexingError)?
} else {
let nodes = amount_nodes
.iter()
.copied()
.map(|node_id| {
(
node_id,
cgraph::Relation::Positive,
cgraph::Strength::Strong,
)
})
.collect::<Vec<_>>();
builder
.make_all_aggregator(
&nodes,
Some("amount_constraint_aggregator"),
None::<()>,
None,
)
.map_err(KgraphError::GraphConstructionError)?
};
let any_aggregator = builder
.make_any_aggregator(
&[
(
zero_amt_id,
cgraph::Relation::Positive,
cgraph::Strength::Strong,
),
(
or_node_neighbor_id,
cgraph::Relation::Positive,
cgraph::Strength::Strong,
),
],
Some("zero_plus_limits_amount_aggregator"),
None::<()>,
None,
)
.map_err(KgraphError::GraphConstructionError)?;
agg_nodes.push((
any_aggregator,
cgraph::Relation::Positive,
cgraph::Strength::Strong,
));
}
let pmt_all_aggregator_info = "All Aggregator for PaymentMethodType";
builder
.make_all_aggregator(&agg_nodes, Some(pmt_all_aggregator_info), None::<()>, None)
.map_err(KgraphError::GraphConstructionError)
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 105,
"total_crates": null
} |
fn_clm_kgraph_utils_compile_config_graph_4702994663785621093 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/mca
fn compile_config_graph(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
config: &kgraph_types::CountryCurrencyFilter,
connector: api_enums::RoutableConnectors,
) -> Result<cgraph::NodeId, KgraphError> {
let mut agg_node_id: Vec<(cgraph::NodeId, cgraph::Relation, cgraph::Strength)> = Vec::new();
let mut pmt_enabled: Vec<dir::DirValue> = Vec::new();
if let Some(pmt) = config
.connector_configs
.get(&connector)
.or(config.default_configs.as_ref())
.map(|inner| inner.0.clone())
{
for pm_filter_key in pmt {
match pm_filter_key {
(kgraph_types::PaymentMethodFilterKey::PaymentMethodType(pm), filter) => {
let dir_val_pm = get_dir_value_payment_method(pm)?;
let pm_node = if pm == api_enums::PaymentMethodType::Credit
|| pm == api_enums::PaymentMethodType::Debit
{
pmt_enabled
.push(dir::DirValue::PaymentMethod(api_enums::PaymentMethod::Card));
builder.make_value_node(
cgraph::NodeValue::Value(dir::DirValue::PaymentMethod(
dir::enums::PaymentMethod::Card,
)),
Some("PaymentMethod"),
None::<()>,
)
} else {
pmt_enabled.push(dir_val_pm.clone());
builder.make_value_node(
cgraph::NodeValue::Value(dir_val_pm),
Some("PaymentMethodType"),
None::<()>,
)
};
let node_config =
compile_graph_for_countries_and_currencies(builder, &filter, pm_node)?;
agg_node_id.push((
node_config,
cgraph::Relation::Positive,
cgraph::Strength::Normal,
));
}
(kgraph_types::PaymentMethodFilterKey::CardNetwork(cn), filter) => {
let dir_val_cn = cn.clone().into_dir_value()?;
pmt_enabled.push(dir_val_cn);
let cn_node = builder.make_value_node(
cn.clone().into_dir_value().map(Into::into)?,
Some("CardNetwork"),
None::<()>,
);
let node_config =
compile_graph_for_countries_and_currencies(builder, &filter, cn_node)?;
agg_node_id.push((
node_config,
cgraph::Relation::Positive,
cgraph::Strength::Normal,
));
}
}
}
}
let global_vector_pmt: Vec<cgraph::NodeId> = global_vec_pmt(pmt_enabled, builder);
let any_agg_pmt: Vec<(cgraph::NodeId, cgraph::Relation, cgraph::Strength)> = global_vector_pmt
.into_iter()
.map(|node| (node, cgraph::Relation::Positive, cgraph::Strength::Normal))
.collect::<Vec<_>>();
let any_agg_node = builder
.make_any_aggregator(
&any_agg_pmt,
Some("Any Aggregator For Payment Method Types"),
None::<()>,
None,
)
.map_err(KgraphError::GraphConstructionError)?;
agg_node_id.push((
any_agg_node,
cgraph::Relation::Positive,
cgraph::Strength::Normal,
));
builder
.make_any_aggregator(&agg_node_id, Some("Configs"), None::<()>, None)
.map_err(KgraphError::GraphConstructionError)
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 75,
"total_crates": null
} |
fn_clm_kgraph_utils_build_test_data_4702994663785621093 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/mca
fn build_test_data() -> ConstraintGraph<dir::DirValue> {
use api_models::{admin::*, payment_methods::*};
let profile_id = common_utils::generate_profile_id_of_default_length();
// #[cfg(feature = "v2")]
// let stripe_account = MerchantConnectorResponse {
// connector_type: api_enums::ConnectorType::FizOperations,
// connector_name: "stripe".to_string(),
// id: common_utils::generate_merchant_connector_account_id_of_default_length(),
// connector_label: Some("something".to_string()),
// connector_account_details: masking::Secret::new(serde_json::json!({})),
// disabled: None,
// metadata: None,
// payment_methods_enabled: Some(vec![PaymentMethodsEnabled {
// payment_method: api_enums::PaymentMethod::Card,
// payment_method_types: Some(vec![
// RequestPaymentMethodTypes {
// payment_method_type: api_enums::PaymentMethodType::Credit,
// payment_experience: None,
// card_networks: Some(vec![
// api_enums::CardNetwork::Visa,
// api_enums::CardNetwork::Mastercard,
// ]),
// accepted_currencies: Some(AcceptedCurrencies::EnableOnly(vec![
// api_enums::Currency::INR,
// ])),
// accepted_countries: None,
// minimum_amount: Some(MinorUnit::new(10)),
// maximum_amount: Some(MinorUnit::new(1000)),
// recurring_enabled: true,
// installment_payment_enabled: true,
// },
// RequestPaymentMethodTypes {
// payment_method_type: api_enums::PaymentMethodType::Debit,
// payment_experience: None,
// card_networks: Some(vec![
// api_enums::CardNetwork::Maestro,
// api_enums::CardNetwork::JCB,
// ]),
// accepted_currencies: Some(AcceptedCurrencies::EnableOnly(vec![
// api_enums::Currency::GBP,
// ])),
// accepted_countries: None,
// minimum_amount: Some(MinorUnit::new(10)),
// maximum_amount: Some(MinorUnit::new(1000)),
// recurring_enabled: true,
// installment_payment_enabled: true,
// },
// ]),
// }]),
// frm_configs: None,
// connector_webhook_details: None,
// profile_id,
// applepay_verified_domains: None,
// pm_auth_config: None,
// status: api_enums::ConnectorStatus::Inactive,
// additional_merchant_data: None,
// connector_wallets_details: None,
// };
#[cfg(feature = "v1")]
let stripe_account = MerchantConnectorResponse {
connector_type: api_enums::ConnectorType::FizOperations,
connector_name: "stripe".to_string(),
merchant_connector_id:
common_utils::generate_merchant_connector_account_id_of_default_length(),
business_country: Some(api_enums::CountryAlpha2::US),
connector_label: Some("something".to_string()),
business_label: Some("food".to_string()),
business_sub_label: None,
connector_account_details: masking::Secret::new(serde_json::json!({})),
test_mode: None,
disabled: None,
metadata: None,
payment_methods_enabled: Some(vec![PaymentMethodsEnabled {
payment_method: api_enums::PaymentMethod::Card,
payment_method_types: Some(vec![
RequestPaymentMethodTypes {
payment_method_type: api_enums::PaymentMethodType::Credit,
payment_experience: None,
card_networks: Some(vec![
api_enums::CardNetwork::Visa,
api_enums::CardNetwork::Mastercard,
]),
accepted_currencies: Some(AcceptedCurrencies::EnableOnly(vec![
api_enums::Currency::INR,
])),
accepted_countries: None,
minimum_amount: Some(MinorUnit::new(10)),
maximum_amount: Some(MinorUnit::new(1000)),
recurring_enabled: Some(true),
installment_payment_enabled: Some(true),
},
RequestPaymentMethodTypes {
payment_method_type: api_enums::PaymentMethodType::Debit,
payment_experience: None,
card_networks: Some(vec![
api_enums::CardNetwork::Maestro,
api_enums::CardNetwork::JCB,
]),
accepted_currencies: Some(AcceptedCurrencies::EnableOnly(vec![
api_enums::Currency::GBP,
])),
accepted_countries: None,
minimum_amount: Some(MinorUnit::new(10)),
maximum_amount: Some(MinorUnit::new(1000)),
recurring_enabled: Some(true),
installment_payment_enabled: Some(true),
},
]),
}]),
frm_configs: None,
connector_webhook_details: None,
profile_id,
applepay_verified_domains: None,
pm_auth_config: None,
status: api_enums::ConnectorStatus::Inactive,
additional_merchant_data: None,
connector_wallets_details: None,
};
let config_map = kgraph_types::CountryCurrencyFilter {
connector_configs: HashMap::from([(
api_enums::RoutableConnectors::Stripe,
kgraph_types::PaymentMethodFilters(HashMap::from([
(
kgraph_types::PaymentMethodFilterKey::PaymentMethodType(
api_enums::PaymentMethodType::Credit,
),
kgraph_types::CurrencyCountryFlowFilter {
currency: Some(HashSet::from([
api_enums::Currency::INR,
api_enums::Currency::USD,
])),
country: Some(HashSet::from([api_enums::CountryAlpha2::IN])),
not_available_flows: Some(kgraph_types::NotAvailableFlows {
capture_method: Some(api_enums::CaptureMethod::Manual),
}),
},
),
(
kgraph_types::PaymentMethodFilterKey::PaymentMethodType(
api_enums::PaymentMethodType::Debit,
),
kgraph_types::CurrencyCountryFlowFilter {
currency: Some(HashSet::from([
api_enums::Currency::GBP,
api_enums::Currency::PHP,
])),
country: Some(HashSet::from([api_enums::CountryAlpha2::IN])),
not_available_flows: Some(kgraph_types::NotAvailableFlows {
capture_method: Some(api_enums::CaptureMethod::Manual),
}),
},
),
])),
)]),
default_configs: None,
};
make_mca_graph(vec![stripe_account], &config_map).expect("Failed graph construction")
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 56,
"total_crates": null
} |
fn_clm_kgraph_utils_compile_graph_for_countries_and_currencies_4702994663785621093 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/mca
fn compile_graph_for_countries_and_currencies(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
config: &kgraph_types::CurrencyCountryFlowFilter,
payment_method_type_node: cgraph::NodeId,
) -> Result<cgraph::NodeId, KgraphError> {
let mut agg_nodes: Vec<(cgraph::NodeId, cgraph::Relation, cgraph::Strength)> = Vec::new();
agg_nodes.push((
payment_method_type_node,
cgraph::Relation::Positive,
cgraph::Strength::Normal,
));
if let Some(country) = config.country.clone() {
let node_country = country
.into_iter()
.map(|country| dir::DirValue::BillingCountry(api_enums::Country::from_alpha2(country)))
.collect();
let country_agg = builder
.make_in_aggregator(node_country, Some("Configs for Country"), None::<()>)
.map_err(KgraphError::GraphConstructionError)?;
agg_nodes.push((
country_agg,
cgraph::Relation::Positive,
cgraph::Strength::Weak,
))
}
if let Some(currency) = config.currency.clone() {
let node_currency = currency
.into_iter()
.map(IntoDirValue::into_dir_value)
.collect::<Result<Vec<_>, _>>()?;
let currency_agg = builder
.make_in_aggregator(node_currency, Some("Configs for Currency"), None::<()>)
.map_err(KgraphError::GraphConstructionError)?;
agg_nodes.push((
currency_agg,
cgraph::Relation::Positive,
cgraph::Strength::Normal,
))
}
if let Some(capture_method) = config
.not_available_flows
.and_then(|naf| naf.capture_method)
{
let make_capture_node = builder.make_value_node(
cgraph::NodeValue::Value(dir::DirValue::CaptureMethod(capture_method)),
Some("Configs for CaptureMethod"),
None::<()>,
);
agg_nodes.push((
make_capture_node,
cgraph::Relation::Negative,
cgraph::Strength::Normal,
))
}
builder
.make_all_aggregator(
&agg_nodes,
Some("Country & Currency Configs With Payment Method Type"),
None::<()>,
None,
)
.map_err(KgraphError::GraphConstructionError)
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 54,
"total_crates": null
} |
fn_clm_kgraph_utils_global_vec_pmt_4702994663785621093 | clm | function | // Repository: hyperswitch
// Crate: kgraph_utils
// Module: crates/kgraph_utils/src/mca
fn global_vec_pmt(
enabled_pmt: Vec<dir::DirValue>,
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
) -> Vec<cgraph::NodeId> {
let mut global_vector: Vec<dir::DirValue> = Vec::new();
global_vector.append(collect_global_variants!(PayLaterType));
global_vector.append(collect_global_variants!(WalletType));
global_vector.append(collect_global_variants!(BankRedirectType));
global_vector.append(collect_global_variants!(BankDebitType));
global_vector.append(collect_global_variants!(CryptoType));
global_vector.append(collect_global_variants!(RewardType));
global_vector.append(collect_global_variants!(RealTimePaymentType));
global_vector.append(collect_global_variants!(UpiType));
global_vector.append(collect_global_variants!(VoucherType));
global_vector.append(collect_global_variants!(GiftCardType));
global_vector.append(collect_global_variants!(BankTransferType));
global_vector.append(collect_global_variants!(CardRedirectType));
global_vector.append(collect_global_variants!(OpenBankingType));
global_vector.append(collect_global_variants!(MobilePaymentType));
global_vector.push(dir::DirValue::PaymentMethod(
dir::enums::PaymentMethod::Card,
));
let global_vector = global_vector
.into_iter()
.filter(|global_value| !enabled_pmt.contains(global_value))
.collect::<Vec<_>>();
global_vector
.into_iter()
.map(|dir_v| {
builder.make_value_node(
cgraph::NodeValue::Value(dir_v),
Some("Payment Method Type"),
None::<()>,
)
})
.collect::<Vec<_>>()
}
| {
"crate": "kgraph_utils",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 51,
"total_crates": null
} |
fn_clm_external_services_main_-7571044527138769423 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/build
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Compilation for revenue recovery protos
#[cfg(feature = "revenue_recovery")]
{
let proto_base_path = router_env::workspace_path().join("proto");
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR")?);
let recovery_proto_files = [proto_base_path.join("recovery_decider.proto")];
tonic_build::configure()
.out_dir(&out_dir)
.compile_well_known_types(true)
.extern_path(".google.protobuf.Timestamp", "::prost_types::Timestamp")
.compile_protos(&recovery_proto_files, &[&proto_base_path])
.expect("Failed to compile revenue-recovery proto files");
}
// Compilation for dynamic_routing protos
#[cfg(feature = "dynamic_routing")]
{
// Get the directory of the current crate
let proto_path = router_env::workspace_path().join("proto");
let success_rate_proto_file = proto_path.join("success_rate.proto");
let contract_routing_proto_file = proto_path.join("contract_routing.proto");
let elimination_proto_file = proto_path.join("elimination_rate.proto");
let health_check_proto_file = proto_path.join("health_check.proto");
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR")?);
// Compile the .proto file
tonic_build::configure()
.out_dir(out_dir)
.compile_protos(
&[
success_rate_proto_file,
health_check_proto_file,
elimination_proto_file,
contract_routing_proto_file,
],
&[proto_path],
)
.expect("Failed to compile proto files");
}
Ok(())
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 42,
"total_crates": null
} |
fn_clm_external_services_new_5662202958435539230 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/superposition
// Implementation of None for SuperpositionClient
/// Create a new Superposition client
pub async fn new(config: SuperpositionClientConfig) -> CustomResult<Self, SuperpositionError> {
let provider_options = superposition_provider::SuperpositionProviderOptions {
endpoint: config.endpoint.clone(),
token: config.token.expose(),
org_id: config.org_id.clone(),
workspace_id: config.workspace_id.clone(),
fallback_config: None,
evaluation_cache: None,
refresh_strategy: superposition_provider::RefreshStrategy::Polling(
superposition_provider::PollingStrategy {
interval: config.polling_interval,
timeout: config.request_timeout,
},
),
experimentation_options: None,
};
// Create provider and set up OpenFeature
let provider = superposition_provider::SuperpositionProvider::new(provider_options);
// Initialize OpenFeature API and set provider
let mut api = open_feature::OpenFeature::singleton_mut().await;
api.set_provider(provider).await;
// Create client
let client = api.create_client();
router_env::logger::info!("Superposition client initialized successfully");
Ok(Self { client })
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14481,
"total_crates": null
} |
fn_clm_external_services_build_evaluation_context_5662202958435539230 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/superposition
// Implementation of None for SuperpositionClient
/// Build evaluation context for Superposition requests
fn build_evaluation_context(
&self,
context: Option<&ConfigContext>,
) -> open_feature::EvaluationContext {
open_feature::EvaluationContext {
custom_fields: context.map_or(HashMap::new(), |ctx| {
ctx.values
.iter()
.map(|(k, v)| {
(
k.clone(),
open_feature::EvaluationContextFieldValue::String(v.clone()),
)
})
.collect()
}),
targeting_key: None,
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 39,
"total_crates": null
} |
fn_clm_external_services_get_bool_value_5662202958435539230 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/superposition
// Implementation of None for SuperpositionClient
/// Get a boolean configuration value from Superposition
pub async fn get_bool_value(
&self,
key: &str,
context: Option<&ConfigContext>,
) -> CustomResult<bool, SuperpositionError> {
let evaluation_context = self.build_evaluation_context(context);
self.client
.get_bool_value(key, Some(&evaluation_context), None)
.await
.map_err(|e| {
report!(SuperpositionError::ClientError(format!(
"Failed to get bool value for key '{key}': {e:?}"
)))
})
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 30,
"total_crates": null
} |
fn_clm_external_services_get_string_value_5662202958435539230 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/superposition
// Implementation of None for SuperpositionClient
/// Get a string configuration value from Superposition
pub async fn get_string_value(
&self,
key: &str,
context: Option<&ConfigContext>,
) -> CustomResult<String, SuperpositionError> {
let evaluation_context = self.build_evaluation_context(context);
self.client
.get_string_value(key, Some(&evaluation_context), None)
.await
.map_err(|e| {
report!(SuperpositionError::ClientError(format!(
"Failed to get string value for key '{key}': {e:?}"
)))
})
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 30,
"total_crates": null
} |
fn_clm_external_services_get_int_value_5662202958435539230 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/superposition
// Implementation of None for SuperpositionClient
/// Get an integer configuration value from Superposition
pub async fn get_int_value(
&self,
key: &str,
context: Option<&ConfigContext>,
) -> CustomResult<i64, SuperpositionError> {
let evaluation_context = self.build_evaluation_context(context);
self.client
.get_int_value(key, Some(&evaluation_context), None)
.await
.map_err(|e| {
report!(SuperpositionError::ClientError(format!(
"Failed to get int value for key '{key}': {e:?}"
)))
})
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 30,
"total_crates": null
} |
fn_clm_external_services_validate_-3449243625320966420 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/crm
// Inherent implementation for CrmManagerConfig
/// Verifies that the client configuration is usable
pub fn validate(&self) -> Result<(), InvalidCrmConfig> {
match self {
Self::HubspotProxy { hubspot_proxy } => hubspot_proxy.validate(),
Self::NoCrm => Ok(()),
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 221,
"total_crates": null
} |
fn_clm_external_services_send_request_-3449243625320966420 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/crm
// Implementation of HubspotProxyConfig for CrmInterface
async fn send_request(
&self,
proxy: &Proxy,
request: Request,
) -> CustomResult<reqwest::Response, HttpClientError> {
http_client::send_request(proxy, request, None).await
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 52,
"total_crates": null
} |
fn_clm_external_services_fmt_-3449243625320966420 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/crm
// Implementation of InvalidCrmConfig for std::fmt::Display
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "crm: {}", self.0)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 38,
"total_crates": null
} |
fn_clm_external_services_make_body_-3449243625320966420 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/crm
// Implementation of HubspotProxyConfig for CrmInterface
async fn make_body(&self, details: CrmPayload) -> RequestContent {
RequestContent::FormUrlEncoded(Box::new(HubspotRequest::new(
details.business_country_name.unwrap_or_default(),
self.form_id.clone(),
details.poc_name.unwrap_or_default(),
details.poc_email.clone().unwrap_or_default(),
details.legal_business_name.unwrap_or_default(),
details.business_website.unwrap_or_default(),
)))
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 31,
"total_crates": null
} |
fn_clm_external_services_get_crm_client_-3449243625320966420 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/crm
// Inherent implementation for CrmManagerConfig
/// Retrieves the appropriate Crm client based on the configuration.
pub async fn get_crm_client(&self) -> Arc<dyn CrmInterface> {
match self {
Self::HubspotProxy { hubspot_proxy } => Arc::new(hubspot_proxy.clone()),
Self::NoCrm => Arc::new(NoCrm),
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 27,
"total_crates": null
} |
fn_clm_external_services_new_4342313197335234831 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/grpc_client
// Implementation of None for LineageIds
/// constructor for LineageIds
pub fn new(merchant_id: id_type::MerchantId, profile_id: id_type::ProfileId) -> Self {
Self {
merchant_id,
profile_id,
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14463,
"total_crates": null
} |
fn_clm_external_services_get_grpc_client_interface_4342313197335234831 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/grpc_client
// Inherent implementation for GrpcClientSettings
pub async fn get_grpc_client_interface(&self) -> Arc<GrpcClients> {
#[cfg(any(feature = "dynamic_routing", feature = "revenue_recovery"))]
let client =
hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::new())
.http2_only(true)
.build_http();
#[cfg(feature = "dynamic_routing")]
let dynamic_routing_connection = self
.dynamic_routing_client
.clone()
.map(|config| config.get_dynamic_routing_connection(client.clone()))
.transpose()
.expect("Failed to establish a connection with the Dynamic Routing Server")
.flatten();
#[cfg(feature = "dynamic_routing")]
let health_client = HealthCheckClient::build_connections(self, client.clone())
.await
.expect("Failed to build gRPC connections");
let unified_connector_service_client =
UnifiedConnectorServiceClient::build_connections(self).await;
#[cfg(feature = "revenue_recovery")]
let recovery_decider_client = {
match &self.recovery_decider_client {
Some(config) => {
// Validate the config first
config
.validate()
.expect("Recovery Decider configuration validation failed");
// Create the client
let client = config
.get_recovery_decider_connection(client.clone())
.expect(
"Failed to establish a connection with the Recovery Decider Server",
);
logger::info!("Recovery Decider gRPC client successfully initialized");
let boxed_client: Box<dyn RecoveryDeciderClientInterface> = Box::new(client);
Some(boxed_client)
}
None => {
logger::debug!("Recovery Decider client configuration not provided, client will be disabled");
None
}
}
};
Arc::new(GrpcClients {
#[cfg(feature = "dynamic_routing")]
dynamic_routing: dynamic_routing_connection,
#[cfg(feature = "dynamic_routing")]
health_client,
#[cfg(feature = "revenue_recovery")]
recovery_decider_client,
unified_connector_service_client,
})
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 57,
"total_crates": null
} |
fn_clm_external_services_create_grpc_request_4342313197335234831 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/grpc_client
pub(crate) fn create_grpc_request<T: Debug>(message: T, headers: GrpcHeaders) -> tonic::Request<T> {
let mut request = tonic::Request::new(message);
request.add_headers_to_grpc_request(headers);
logger::info!(?request);
request
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 44,
"total_crates": null
} |
fn_clm_external_services_add_headers_to_grpc_request_4342313197335234831 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/grpc_client
// Implementation of tonic::Request<T> for AddHeaders
fn add_headers_to_grpc_request(&mut self, headers: GrpcHeaders) {
headers.tenant_id
.parse()
.map(|tenant_id| {
self
.metadata_mut()
.append(consts::TENANT_HEADER, tenant_id)
})
.inspect_err(
|err| logger::warn!(header_parse_error=?err,"invalid {} received",consts::TENANT_HEADER),
)
.ok();
headers.request_id.map(|request_id| {
request_id
.parse()
.map(|request_id| {
self
.metadata_mut()
.append(consts::X_REQUEST_ID, request_id)
})
.inspect_err(
|err| logger::warn!(header_parse_error=?err,"invalid {} received",consts::X_REQUEST_ID),
)
.ok();
});
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 37,
"total_crates": null
} |
fn_clm_external_services_get_url_encoded_string_4342313197335234831 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/grpc_client
// Implementation of None for LineageIds
/// get url encoded string representation of LineageIds
pub fn get_url_encoded_string(self) -> Result<String, serde_urlencoded::ser::Error> {
serde_urlencoded::to_string(&self)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 23,
"total_crates": null
} |
fn_clm_external_services_convert_from_prost_timestamp_8869293675424895168 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/lib
/// Converts a `prost_types::Timestamp` to an `time::PrimitiveDateTime`.
pub fn convert_from_prost_timestamp(
ts: &prost_types::Timestamp,
) -> error_stack::Result<time::PrimitiveDateTime, DateTimeConversionError> {
let timestamp_nanos = i128::from(ts.seconds) * 1_000_000_000 + i128::from(ts.nanos);
time::OffsetDateTime::from_unix_timestamp_nanos(timestamp_nanos)
.map(|offset_dt| time::PrimitiveDateTime::new(offset_dt.date(), offset_dt.time()))
.change_context(DateTimeConversionError::TimestampOutOfRange)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 29,
"total_crates": null
} |
fn_clm_external_services_convert_to_prost_timestamp_8869293675424895168 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/lib
/// Converts a `time::PrimitiveDateTime` to a `prost_types::Timestamp`.
pub fn convert_to_prost_timestamp(dt: time::PrimitiveDateTime) -> prost_types::Timestamp {
let odt = dt.assume_utc();
prost_types::Timestamp {
seconds: odt.unix_timestamp(),
// This conversion is safe as nanoseconds (0..999_999_999) always fit within an i32.
#[allow(clippy::as_conversions)]
nanos: odt.nanosecond() as i32,
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 19,
"total_crates": null
} |
fn_clm_external_services_send_request_9200395012896739240 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client
pub async fn send_request(
client_proxy: &Proxy,
request: Request,
option_timeout_secs: Option<u64>,
) -> CustomResult<reqwest::Response, HttpClientError> {
logger::info!(method=?request.method, headers=?request.headers, payload=?request.body, ?request);
let url = url::Url::parse(&request.url).change_context(HttpClientError::UrlParsingFailed)?;
let client = client::create_client(
client_proxy,
request.certificate,
request.certificate_key,
request.ca_certificate,
)?;
let headers = request.headers.construct_header_map()?;
let metrics_tag = router_env::metric_attributes!((
consts::METRICS_HOST_TAG_NAME,
url.host_str().unwrap_or_default().to_owned()
));
let request = {
match request.method {
Method::Get => client.get(url),
Method::Post => {
let client = client.post(url);
match request.body {
Some(RequestContent::Json(payload)) => client.json(&payload),
Some(RequestContent::FormData((form, _))) => client.multipart(form),
Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload),
Some(RequestContent::Xml(payload)) => {
let body = quick_xml::se::to_string(&payload)
.change_context(HttpClientError::BodySerializationFailed)?;
client.body(body).header("Content-Type", "application/xml")
}
Some(RequestContent::RawBytes(payload)) => client.body(payload),
None => client,
}
}
Method::Put => {
let client = client.put(url);
match request.body {
Some(RequestContent::Json(payload)) => client.json(&payload),
Some(RequestContent::FormData((form, _))) => client.multipart(form),
Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload),
Some(RequestContent::Xml(payload)) => {
let body = quick_xml::se::to_string(&payload)
.change_context(HttpClientError::BodySerializationFailed)?;
client.body(body).header("Content-Type", "application/xml")
}
Some(RequestContent::RawBytes(payload)) => client.body(payload),
None => client,
}
}
Method::Patch => {
let client = client.patch(url);
match request.body {
Some(RequestContent::Json(payload)) => client.json(&payload),
Some(RequestContent::FormData((form, _))) => client.multipart(form),
Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload),
Some(RequestContent::Xml(payload)) => {
let body = quick_xml::se::to_string(&payload)
.change_context(HttpClientError::BodySerializationFailed)?;
client.body(body).header("Content-Type", "application/xml")
}
Some(RequestContent::RawBytes(payload)) => client.body(payload),
None => client,
}
}
Method::Delete => client.delete(url),
}
.add_headers(headers)
.timeout(Duration::from_secs(
option_timeout_secs.unwrap_or(consts::REQUEST_TIME_OUT),
))
};
// We cannot clone the request type, because it has Form trait which is not cloneable. So we are cloning the request builder here.
let cloned_send_request = request.try_clone().map(|cloned_request| async {
cloned_request
.send()
.await
.map_err(|error| match error {
error if error.is_timeout() => {
metrics::REQUEST_BUILD_FAILURE.add(1, metrics_tag);
HttpClientError::RequestTimeoutReceived
}
error if is_connection_closed_before_message_could_complete(&error) => {
metrics::REQUEST_BUILD_FAILURE.add(1, metrics_tag);
HttpClientError::ConnectionClosedIncompleteMessage
}
_ => HttpClientError::RequestNotSent(error.to_string()),
})
.attach_printable("Unable to send request to connector")
});
let send_request = async {
request
.send()
.await
.map_err(|error| match error {
error if error.is_timeout() => {
metrics::REQUEST_BUILD_FAILURE.add(1, metrics_tag);
HttpClientError::RequestTimeoutReceived
}
error if is_connection_closed_before_message_could_complete(&error) => {
metrics::REQUEST_BUILD_FAILURE.add(1, metrics_tag);
HttpClientError::ConnectionClosedIncompleteMessage
}
_ => HttpClientError::RequestNotSent(error.to_string()),
})
.attach_printable("Unable to send request to connector")
};
let response = common_utils::metrics::utils::record_operation_time(
send_request,
&metrics::EXTERNAL_REQUEST_TIME,
metrics_tag,
)
.await;
// Retry once if the response is connection closed.
//
// This is just due to the racy nature of networking.
// hyper has a connection pool of idle connections, and it selected one to send your request.
// Most of the time, hyper will receive the server’s FIN and drop the dead connection from its pool.
// But occasionally, a connection will be selected from the pool
// and written to at the same time the server is deciding to close the connection.
// Since hyper already wrote some of the request,
// it can’t really retry it automatically on a new connection, since the server may have acted already
match response {
Ok(response) => Ok(response),
Err(error)
if error.current_context() == &HttpClientError::ConnectionClosedIncompleteMessage =>
{
metrics::AUTO_RETRY_CONNECTION_CLOSED.add(1, metrics_tag);
match cloned_send_request {
Some(cloned_request) => {
logger::info!(
"Retrying request due to connection closed before message could complete"
);
common_utils::metrics::utils::record_operation_time(
cloned_request,
&metrics::EXTERNAL_REQUEST_TIME,
metrics_tag,
)
.await
}
None => {
logger::info!("Retrying request due to connection closed before message could complete failed as request is not cloneable");
Err(error)
}
}
}
err @ Err(_) => err,
}
}
fn
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 178,
"total_crates": null
} |
fn_clm_external_services_onnection_closed_before_message_could_complete(err_9200395012896739240 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client
s_connection_closed_before_message_could_complete(error: &reqwest::Error) -> bool {
let mut source = error.source();
while let Some(err) = source {
if let Some(hyper_err) = err.downcast_ref::<hyper::Error>() {
if hyper_err.is_incomplete_message() {
return true;
}
}
source = err.source();
}
false
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 6,
"total_crates": null
} |
fn_clm_external_services_new_1994120314929746792 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/email
// Inherent implementation for IntermediateString
/// Create a new Instance of IntermediateString using a string
pub fn new(inner: String) -> Self {
Self(inner)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14465,
"total_crates": null
} |
fn_clm_external_services_into_inner_1994120314929746792 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/email
// Inherent implementation for IntermediateString
/// Get the inner String
pub fn into_inner(self) -> String {
self.0
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2061,
"total_crates": null
} |
fn_clm_external_services_validate_1994120314929746792 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/email
// Implementation of None for EmailSettings
/// Validation for the Email client specific configurations
pub fn validate(&self) -> Result<(), &'static str> {
match &self.client_config {
EmailClientConfigs::Ses { ref aws_ses } => aws_ses.validate(),
EmailClientConfigs::Smtp { ref smtp } => smtp.validate(),
EmailClientConfigs::NoEmailClient => Ok(()),
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 223,
"total_crates": null
} |
fn_clm_external_services_compose_and_send_email_1994120314929746792 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/email
// Implementation of T for EmailService
async fn compose_and_send_email(
&self,
base_url: &str,
email_data: Box<dyn EmailData + Send>,
proxy_url: Option<&String>,
) -> EmailResult<()> {
let email_data = email_data.get_email_data(base_url);
let email_data = email_data.await?;
let EmailContents {
subject,
body,
recipient,
} = email_data;
let rich_text_string = self.convert_to_rich_text(body)?;
self.send_email(recipient, subject, rich_text_string, proxy_url)
.await
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 53,
"total_crates": null
} |
fn_clm_external_services_validate_-2886972313220271858 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/file_storage
// Inherent implementation for FileStorageConfig
/// Validates the file storage configuration.
pub fn validate(&self) -> Result<(), InvalidFileStorageConfig> {
match self {
#[cfg(feature = "aws_s3")]
Self::AwsS3 { aws_s3 } => aws_s3.validate(),
Self::FileSystem => Ok(()),
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 221,
"total_crates": null
} |
fn_clm_external_services_fmt_-2886972313220271858 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/file_storage
// Implementation of InvalidFileStorageConfig for Display
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "file_storage: {}", self.0)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 38,
"total_crates": null
} |
fn_clm_external_services_get_file_storage_client_-2886972313220271858 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/file_storage
// Inherent implementation for FileStorageConfig
/// Retrieves the appropriate file storage client based on the file storage configuration.
pub async fn get_file_storage_client(&self) -> Arc<dyn FileStorageInterface> {
match self {
#[cfg(feature = "aws_s3")]
Self::AwsS3 { aws_s3 } => Arc::new(aws_s3::AwsFileStorageClient::new(aws_s3).await),
Self::FileSystem => Arc::new(file_system::FileSystem),
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 30,
"total_crates": null
} |
fn_clm_external_services_new_7735786032461823506 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/hubspot_proxy
// Inherent implementation for HubspotRequest
pub fn new(
country: String,
hubspot_form_id: String,
firstname: Secret<String>,
email: Secret<String>,
company_name: String,
website: String,
) -> Self {
Self {
use_hubspot: true,
country,
hubspot_form_id,
firstname,
email,
company_name,
lead_source: HUBSPOT_LEAD_SOURCE.to_string(),
website,
..Default::default()
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14467,
"total_crates": null
} |
fn_clm_external_services_deserialize_hashset_inner_2141032712598851232 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/utils
/// Parses a comma-separated string into a HashSet of typed values.
///
/// # Arguments
///
/// * `value` - String or string reference containing comma-separated values
///
/// # Returns
///
/// * `Ok(HashSet<T>)` - Successfully parsed HashSet
/// * `Err(String)` - Error message if any value parsing fails
///
/// # Type Parameters
///
/// * `T` - Target type that implements `FromStr`, `Eq`, and `Hash`
///
/// # Examples
///
/// ```
/// use std::collections::HashSet;
///
/// let result: Result<HashSet<i32>, String> =
/// deserialize_hashset_inner("1,2,3");
/// assert!(result.is_ok());
///
/// if let Ok(hashset) = result {
/// assert!(hashset.contains(&1));
/// assert!(hashset.contains(&2));
/// assert!(hashset.contains(&3));
/// }
/// ```
fn deserialize_hashset_inner<T>(value: impl AsRef<str>) -> Result<HashSet<T>, String>
where
T: Eq + std::str::FromStr + std::hash::Hash,
<T as std::str::FromStr>::Err: std::fmt::Display,
{
let (values, errors) = value
.as_ref()
.trim()
.split(',')
.map(|s| {
T::from_str(s.trim()).map_err(|error| {
format!(
"Unable to deserialize `{}` as `{}`: {error}",
s.trim(),
std::any::type_name::<T>()
)
})
})
.fold(
(HashSet::new(), Vec::new()),
|(mut values, mut errors), result| match result {
Ok(t) => {
values.insert(t);
(values, errors)
}
Err(error) => {
errors.push(error);
(values, errors)
}
},
);
if !errors.is_empty() {
Err(format!("Some errors occurred:\n{}", errors.join("\n")))
} else {
Ok(values)
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 59,
"total_crates": null
} |
fn_clm_external_services_deserialize_hashset_2141032712598851232 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/utils
/// Serde deserializer function for converting comma-separated strings into typed HashSets.
///
/// This function is designed to be used with serde's `#[serde(deserialize_with = "deserialize_hashset")]`
/// attribute to customize deserialization of HashSet fields.
///
/// # Arguments
///
/// * `deserializer` - Serde deserializer instance
///
/// # Returns
///
/// * `Ok(HashSet<T>)` - Successfully deserialized HashSet
/// * `Err(D::Error)` - Serde deserialization error
///
/// # Type Parameters
///
/// * `D` - Serde deserializer type
/// * `T` - Target type that implements `FromStr`, `Eq`, and `Hash`
pub(crate) fn deserialize_hashset<'a, D, T>(deserializer: D) -> Result<HashSet<T>, D::Error>
where
D: serde::Deserializer<'a>,
T: Eq + std::str::FromStr + std::hash::Hash,
<T as std::str::FromStr>::Err: std::fmt::Display,
{
use serde::de::Error;
deserialize_hashset_inner(<String>::deserialize(deserializer)?).map_err(D::Error::custom)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 16,
"total_crates": null
} |
fn_clm_external_services_test_deserialize_hashset_inner_success_2141032712598851232 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/utils
fn test_deserialize_hashset_inner_success() {
let result: Result<HashSet<i32>, String> = deserialize_hashset_inner("1,2,3");
assert!(result.is_ok());
if let Ok(hashset) = result {
assert_eq!(hashset.len(), 3);
assert!(hashset.contains(&1));
assert!(hashset.contains(&2));
assert!(hashset.contains(&3));
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2,
"total_crates": null
} |
fn_clm_external_services_test_deserialize_hashset_inner_with_whitespace_2141032712598851232 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/utils
fn test_deserialize_hashset_inner_with_whitespace() {
let result: Result<HashSet<String>, String> = deserialize_hashset_inner(" a , b , c ");
assert!(result.is_ok());
if let Ok(hashset) = result {
assert_eq!(hashset.len(), 3);
assert!(hashset.contains("a"));
assert!(hashset.contains("b"));
assert!(hashset.contains("c"));
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2,
"total_crates": null
} |
fn_clm_external_services_test_deserialize_hashset_inner_empty_string_2141032712598851232 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/utils
fn test_deserialize_hashset_inner_empty_string() {
let result: Result<HashSet<String>, String> = deserialize_hashset_inner("");
assert!(result.is_ok());
if let Ok(hashset) = result {
assert_eq!(hashset.len(), 0);
}
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2,
"total_crates": null
} |
fn_clm_external_services_construct_header_map_-161641526686486311 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client/request
// Implementation of Headers for HeaderExt
fn construct_header_map(self) -> CustomResult<reqwest::header::HeaderMap, HttpClientError> {
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
self.into_iter().try_fold(
HeaderMap::new(),
|mut header_map, (header_name, header_value)| {
let header_name = HeaderName::from_str(&header_name)
.change_context(HttpClientError::HeaderMapConstructionFailed)?;
let header_value = header_value.into_inner();
let header_value = HeaderValue::from_str(&header_value)
.change_context(HttpClientError::HeaderMapConstructionFailed)?;
header_map.append(header_name, header_value);
Ok(header_map)
},
)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 29,
"total_crates": null
} |
fn_clm_external_services_add_headers_-161641526686486311 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client/request
// Implementation of reqwest::RequestBuilder for RequestBuilderExt
fn add_headers(mut self, headers: reqwest::header::HeaderMap) -> Self {
self = self.headers(headers);
self
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 13,
"total_crates": null
} |
fn_clm_external_services_create_client_4818340175508895258 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client/client
pub fn create_client(
proxy_config: &Proxy,
client_certificate: Option<masking::Secret<String>>,
client_certificate_key: Option<masking::Secret<String>>,
ca_certificate: Option<masking::Secret<String>>,
) -> CustomResult<reqwest::Client, HttpClientError> {
// Case 1: Mutual TLS with client certificate and key
if let (Some(encoded_certificate), Some(encoded_certificate_key)) =
(client_certificate.clone(), client_certificate_key.clone())
{
if ca_certificate.is_some() {
logger::warn!("All of client certificate, client key, and CA certificate are provided. CA certificate will be ignored in mutual TLS setup.");
}
logger::debug!("Creating HTTP client with mutual TLS (client cert + key)");
let client_builder =
apply_mitm_certificate(get_client_builder(proxy_config)?, proxy_config);
let identity = create_identity_from_certificate_and_key(
encoded_certificate.clone(),
encoded_certificate_key,
)?;
let certificate_list = create_certificate(encoded_certificate)?;
let client_builder = certificate_list
.into_iter()
.fold(client_builder, |client_builder, certificate| {
client_builder.add_root_certificate(certificate)
});
return client_builder
.identity(identity)
.use_rustls_tls()
.build()
.change_context(HttpClientError::ClientConstructionFailed)
.attach_printable("Failed to construct client with certificate and certificate key");
}
// Case 2: Use provided CA certificate for server authentication only (one-way TLS)
if let Some(ca_pem) = ca_certificate {
logger::debug!("Creating HTTP client with one-way TLS (CA certificate)");
let pem = ca_pem.expose().replace("\\r\\n", "\n"); // Fix escaped newlines
let cert = reqwest::Certificate::from_pem(pem.as_bytes())
.change_context(HttpClientError::ClientConstructionFailed)
.attach_printable("Failed to parse CA certificate PEM block")?;
let client_builder =
apply_mitm_certificate(get_client_builder(proxy_config)?, proxy_config)
.add_root_certificate(cert);
return client_builder
.use_rustls_tls()
.build()
.change_context(HttpClientError::ClientConstructionFailed)
.attach_printable("Failed to construct client with CA certificate");
}
// Case 3: Default client (no certs)
logger::debug!("Creating default HTTP client (no client or CA certificates)");
get_base_client(proxy_config)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 91,
"total_crates": null
} |
fn_clm_external_services_get_client_builder_4818340175508895258 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client/client
pub fn get_client_builder(
proxy_config: &Proxy,
) -> CustomResult<reqwest::ClientBuilder, HttpClientError> {
let mut client_builder = reqwest::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.pool_idle_timeout(Duration::from_secs(
proxy_config
.idle_pool_connection_timeout
.unwrap_or_default(),
));
let proxy_exclusion_config =
reqwest::NoProxy::from_string(&proxy_config.bypass_proxy_hosts.clone().unwrap_or_default());
// Proxy all HTTPS traffic through the configured HTTPS proxy
if let Some(url) = proxy_config.https_url.as_ref() {
client_builder = client_builder.proxy(
reqwest::Proxy::https(url)
.change_context(HttpClientError::InvalidProxyConfiguration)
.attach_printable("HTTPS proxy configuration error")?
.no_proxy(proxy_exclusion_config.clone()),
);
}
// Proxy all HTTP traffic through the configured HTTP proxy
if let Some(url) = proxy_config.http_url.as_ref() {
client_builder = client_builder.proxy(
reqwest::Proxy::http(url)
.change_context(HttpClientError::InvalidProxyConfiguration)
.attach_printable("HTTP proxy configuration error")?
.no_proxy(proxy_exclusion_config),
);
}
Ok(client_builder)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 78,
"total_crates": null
} |
fn_clm_external_services_create_identity_from_certificate_and_key_4818340175508895258 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client/client
pub fn create_identity_from_certificate_and_key(
encoded_certificate: masking::Secret<String>,
encoded_certificate_key: masking::Secret<String>,
) -> Result<reqwest::Identity, error_stack::Report<HttpClientError>> {
let decoded_certificate = BASE64_ENGINE
.decode(encoded_certificate.expose())
.change_context(HttpClientError::CertificateDecodeFailed)?;
let decoded_certificate_key = BASE64_ENGINE
.decode(encoded_certificate_key.expose())
.change_context(HttpClientError::CertificateDecodeFailed)?;
let certificate = String::from_utf8(decoded_certificate)
.change_context(HttpClientError::CertificateDecodeFailed)?;
let certificate_key = String::from_utf8(decoded_certificate_key)
.change_context(HttpClientError::CertificateDecodeFailed)?;
let key_chain = format!("{certificate_key}{certificate}");
reqwest::Identity::from_pem(key_chain.as_bytes())
.change_context(HttpClientError::CertificateDecodeFailed)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 51,
"total_crates": null
} |
fn_clm_external_services_create_certificate_4818340175508895258 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client/client
pub fn create_certificate(
encoded_certificate: masking::Secret<String>,
) -> Result<Vec<reqwest::Certificate>, error_stack::Report<HttpClientError>> {
let decoded_certificate = BASE64_ENGINE
.decode(encoded_certificate.expose())
.change_context(HttpClientError::CertificateDecodeFailed)?;
let certificate = String::from_utf8(decoded_certificate)
.change_context(HttpClientError::CertificateDecodeFailed)?;
reqwest::Certificate::from_pem_bundle(certificate.as_bytes())
.change_context(HttpClientError::CertificateDecodeFailed)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_external_services_apply_mitm_certificate_4818340175508895258 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/http_client/client
fn apply_mitm_certificate(
mut client_builder: reqwest::ClientBuilder,
proxy_config: &Proxy,
) -> reqwest::ClientBuilder {
if let Some(mitm_ca_cert) = &proxy_config.mitm_ca_certificate {
let pem = mitm_ca_cert.clone().expose().replace("\\r\\n", "\n");
match reqwest::Certificate::from_pem(pem.as_bytes()) {
Ok(cert) => {
logger::debug!("Successfully added MITM CA certificate");
client_builder = client_builder.add_root_certificate(cert);
}
Err(err) => {
logger::error!(
"Failed to parse MITM CA certificate: {}, continuing without MITM support",
err
);
}
}
}
client_builder
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_external_services_new_-483753875943095846 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/hashicorp_vault/core
// Inherent implementation for HashiCorpVault
/// Creates a new instance of HashiCorpVault based on the provided configuration.
///
/// # Parameters
///
/// - `config`: A reference to a `HashiCorpVaultConfig` containing the configuration details.
pub fn new(config: &HashiCorpVaultConfig) -> error_stack::Result<Self, HashiCorpError> {
VaultClient::new(
VaultClientSettingsBuilder::default()
.address(&config.url)
.token(config.token.peek())
.build()
.map_err(Into::<Report<_>>::into)
.change_context(HashiCorpError::ClientCreationFailed)
.attach_printable("Failed while building vault settings")?,
)
.map_err(Into::<Report<_>>::into)
.change_context(HashiCorpError::ClientCreationFailed)
.map(|client| Self { client })
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14487,
"total_crates": null
} |
fn_clm_external_services_validate_-483753875943095846 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/hashicorp_vault/core
// Inherent implementation for HashiCorpVaultConfig
/// Verifies that the [`HashiCorpVault`] configuration is usable.
pub fn validate(&self) -> Result<(), &'static str> {
when(self.url.is_default_or_empty(), || {
Err("HashiCorp vault url must not be empty")
})?;
when(self.token.is_default_or_empty(), || {
Err("HashiCorp vault token must not be empty")
})
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 227,
"total_crates": null
} |
fn_clm_external_services_read_-483753875943095846 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/hashicorp_vault/core
// Implementation of Kv2 for Engine
fn read(client: &HashiCorpVault, location: String) -> Self::ReturnType<'_, String> {
Box::pin(async move {
let mut split = location.split(':');
let mount = split.next().ok_or(HashiCorpError::IncompleteData)?;
let path = split.next().ok_or(HashiCorpError::IncompleteData)?;
let key = split.next().unwrap_or("value");
let mut output =
vaultrs::kv2::read::<HashMap<String, String>>(&client.client, mount, path)
.await
.map_err(Into::<Report<_>>::into)
.change_context(HashiCorpError::FetchFailed)?;
Ok(output.remove(key).ok_or(HashiCorpError::ParseError)?)
})
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 47,
"total_crates": null
} |
fn_clm_external_services_fetch_-483753875943095846 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/hashicorp_vault/core
// Inherent implementation for HashiCorpVault
/// Asynchronously fetches data from HashiCorp Vault using the specified engine.
///
/// # Parameters
///
/// - `data`: A String representing the location or identifier of the data in HashiCorp Vault.
///
/// # Type Parameters
///
/// - `En`: The engine type that implements the `Engine` trait.
/// - `I`: The type that can be constructed from the retrieved encoded data.
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))
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 24,
"total_crates": null
} |
fn_clm_external_services_from_encoded_-483753875943095846 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/hashicorp_vault/core
// Implementation of Vec<u8> for FromEncoded
fn from_encoded(input: String) -> Option<Self> {
hex::decode(input).ok()
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 15,
"total_crates": null
} |
fn_clm_external_services_get_secret_1465100044782645857 | clm | function | // Repository: hyperswitch
// Crate: external_services
// Module: crates/external_services/src/hashicorp_vault/implementers
// Implementation of HashiCorpVault for SecretManagementInterface
async fn get_secret(
&self,
input: Secret<String>,
) -> CustomResult<Secret<String>, SecretsManagementError> {
self.fetch::<Kv2, Secret<String>>(input.expose())
.await
.map(|val| val.expose().to_owned())
.change_context(SecretsManagementError::FetchSecretFailed)
.map(Into::into)
}
| {
"crate": "external_services",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 104,
"total_crates": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.