id stringlengths 11 116 | type stringclasses 1
value | granularity stringclasses 4
values | content stringlengths 16 477k | metadata dict |
|---|---|---|---|---|
fn_clm_api_models_from_-5206725892084843784 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payment_methods
// Implementation of MigrateCardDetail for From<&Card>
fn from(card: &Card) -> Self {
Self {
card_number: masking::Secret::new(card.card_number.get_card_no()),
card_exp_month: card.card_exp_month.clone(),
card_exp_year: card.card_exp_year.clone(),
card_holder_name: card.name_on_card.clone(),
nick_name: card
.nick_name
.as_ref()
.map(|name| masking::Secret::new(name.clone())),
card_issuing_country: None,
card_network: None,
card_issuer: None,
card_type: None,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2618,
"total_crates": null
} |
fn_clm_api_models_deserialize_-5206725892084843784 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payment_methods
// Implementation of ListMethodsForPaymentMethodsRequest for serde::Deserialize<'de>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
struct FieldVisitor;
impl<'de> de::Visitor<'de> for FieldVisitor {
type Value = ListMethodsForPaymentMethodsRequest;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("Failed while deserializing as map")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
where
A: de::MapAccess<'de>,
{
let mut output = ListMethodsForPaymentMethodsRequest::default();
while let Some(key) = map.next_key()? {
match key {
"client_secret" => {
set_or_reject_duplicate(
&mut output.client_secret,
"client_secret",
map.next_value()?,
)?;
}
"accepted_countries" => match output.accepted_countries.as_mut() {
Some(inner) => inner.push(map.next_value()?),
None => {
output.accepted_countries = Some(vec![map.next_value()?]);
}
},
"amount" => {
set_or_reject_duplicate(
&mut output.amount,
"amount",
map.next_value()?,
)?;
}
"accepted_currencies" => match output.accepted_currencies.as_mut() {
Some(inner) => inner.push(map.next_value()?),
None => {
output.accepted_currencies = Some(vec![map.next_value()?]);
}
},
"recurring_enabled" => {
set_or_reject_duplicate(
&mut output.recurring_enabled,
"recurring_enabled",
map.next_value()?,
)?;
}
"card_network" => match output.card_networks.as_mut() {
Some(inner) => inner.push(map.next_value()?),
None => output.card_networks = Some(vec![map.next_value()?]),
},
"limit" => {
set_or_reject_duplicate(&mut output.limit, "limit", map.next_value()?)?;
}
_ => {}
}
}
Ok(output)
}
}
deserializer.deserialize_identifier(FieldVisitor)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 176,
"total_crates": null
} |
fn_clm_api_models_get_payment_method_type_-5206725892084843784 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payment_methods
// Inherent implementation for RequestPaymentMethodTypes
pub fn get_payment_method_type(&self) -> Option<api_enums::PaymentMethodType> {
Some(self.payment_method_type)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 129,
"total_crates": null
} |
fn_clm_api_models_from_header_map_-7529224292561833183 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/proxy
// Inherent implementation for Headers
pub fn from_header_map(headers: Option<&HeaderMap>) -> Self {
headers
.map(|h| {
let map = h
.iter()
.map(|(k, v)| (k.to_string(), v.to_str().unwrap_or("").to_string()))
.collect();
Self(map)
})
.unwrap_or_else(|| Self(HashMap::new()))
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 45,
"total_crates": null
} |
fn_clm_api_models_as_map_-7529224292561833183 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/proxy
// Inherent implementation for Headers
pub fn as_map(&self) -> &HashMap<String, String> {
&self.0
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_-2300207809800408672 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events
// Implementation of PaymentMethodSessionResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::PaymentMethodSession {
payment_method_session_id: self.id.clone(),
})
}
| {
"crate": "api_models",
"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_api_models_try_from_7147108024175136003 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/open_router
// Implementation of DebitRoutingRequestData for TryFrom<(payment_methods::CoBadgedCardData, String)>
fn try_from(
(output, card_type): (payment_methods::CoBadgedCardData, String),
) -> Result<Self, Self::Error> {
let parsed_card_type = card_type.parse::<common_enums::CardType>().map_err(|_| {
error_stack::Report::new(errors::ParsingError::EnumParseFailure("CardType"))
})?;
Ok(Self {
co_badged_card_networks_info: output.co_badged_card_networks_info.get_card_networks(),
issuer_country: output.issuer_country_code,
is_regulated: output.is_regulated,
regulated_name: output.regulated_name,
card_type: parsed_card_type,
})
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2665,
"total_crates": null
} |
fn_clm_api_models_from_7147108024175136003 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/open_router
// Implementation of payment_methods::CoBadgedCardData for From<&DebitRoutingOutput>
fn from(output: &DebitRoutingOutput) -> Self {
Self {
co_badged_card_networks_info: output.co_badged_card_networks_info.clone(),
issuer_country_code: output.issuer_country,
is_regulated: output.is_regulated,
regulated_name: output.regulated_name.clone(),
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2604,
"total_crates": null
} |
fn_clm_api_models_update_7147108024175136003 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/open_router
// Inherent implementation for DecisionEngineEliminationData
pub fn update(&mut self, new_config: Self) {
self.threshold = new_config.threshold;
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 87,
"total_crates": null
} |
fn_clm_api_models_get_card_networks_7147108024175136003 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/open_router
// Inherent implementation for CoBadgedCardNetworks
pub fn get_card_networks(&self) -> Vec<common_enums::CardNetwork> {
self.0.iter().map(|info| info.network.clone()).collect()
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 35,
"total_crates": null
} |
fn_clm_api_models_get_signature_network_7147108024175136003 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/open_router
// Inherent implementation for CoBadgedCardNetworks
pub fn get_signature_network(&self) -> Option<common_enums::CardNetwork> {
self.0
.iter()
.find(|info| info.network.is_signature_network())
.map(|info| info.network.clone())
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 31,
"total_crates": null
} |
fn_clm_api_models_from_-4710265271675324014 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/refunds
// Implementation of enums::RefundStatus for From<RefundStatus>
fn from(status: RefundStatus) -> Self {
match status {
RefundStatus::Failed => Self::Failure,
RefundStatus::Review => Self::ManualReview,
RefundStatus::Pending => Self::Pending,
RefundStatus::Succeeded => Self::Success,
}
}
| {
"crate": "api_models",
"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_api_models_get_refund_id_as_string_-4710265271675324014 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/refunds
// Inherent implementation for RefundResponse
pub fn get_refund_id_as_string(&self) -> String {
self.id.get_string_repr().to_owned()
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 22,
"total_crates": null
} |
fn_clm_api_models_new_-4329110896698221663 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/organization
// Inherent implementation for OrganizationNew
pub fn new(org_type: OrganizationType, org_name: Option<String>) -> Self {
Self {
org_id: id_type::OrganizationId::default(),
org_type,
org_name,
}
}
| {
"crate": "api_models",
"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_api_models_default_6733962254890640749 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payouts
// Implementation of PayoutMethodData for Default
fn default() -> Self {
Self::Card(CardPayout::default())
}
| {
"crate": "api_models",
"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_api_models_from_6733962254890640749 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payouts
// Implementation of PayoutMethodDataResponse for From<payout_method_utils::AdditionalPayoutMethodData>
fn from(additional_data: payout_method_utils::AdditionalPayoutMethodData) -> Self {
match additional_data {
payout_method_utils::AdditionalPayoutMethodData::Card(card_data) => {
Self::Card(card_data)
}
payout_method_utils::AdditionalPayoutMethodData::Bank(bank_data) => {
Self::Bank(bank_data)
}
payout_method_utils::AdditionalPayoutMethodData::Wallet(wallet_data) => {
Self::Wallet(wallet_data)
}
payout_method_utils::AdditionalPayoutMethodData::BankRedirect(bank_redirect) => {
Self::BankRedirect(bank_redirect)
}
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2608,
"total_crates": null
} |
fn_clm_api_models_get_customer_id_6733962254890640749 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payouts
// Inherent implementation for PayoutCreateRequest
pub fn get_customer_id(&self) -> Option<&id_type::CustomerId> {
self.customer_id
.as_ref()
.or(self.customer.as_ref().map(|customer| &customer.id))
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 68,
"total_crates": null
} |
fn_clm_api_models_from_8874925974170754185 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/cards_info
// Implementation of CardInfoMigrationResponse for From<CardInfoMigrationResponseType>
fn from((response, record): CardInfoMigrationResponseType) -> Self {
match response {
Ok(res) => Self {
card_iin: record.card_iin,
line_number: record.line_number,
card_issuer: res.card_issuer,
card_network: res.card_network,
card_type: res.card_type,
card_sub_type: res.card_sub_type,
card_issuing_country: res.card_issuing_country,
migration_status: CardInfoMigrationStatus::Success,
migration_error: None,
},
Err(e) => Self {
card_iin: record.card_iin,
migration_status: CardInfoMigrationStatus::Failed,
migration_error: Some(e),
line_number: record.line_number,
..Self::default()
},
}
}
| {
"crate": "api_models",
"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_api_models_deserialize_7068997592184470589 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/revenue_recovery_data_backfill
// Implementation of ScheduledAtUpdate for Deserialize<'de>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value {
serde_json::Value::String(s) => {
if s.to_lowercase() == "null" {
Ok(Self::SetToNull)
} else {
// Parse as datetime using iso8601 deserializer
common_utils::custom_serde::iso8601::deserialize(
&mut serde_json::Deserializer::from_str(&format!("\"{}\"", s)),
)
.map(Self::SetToDateTime)
.map_err(serde::de::Error::custom)
}
}
_ => Err(serde::de::Error::custom(
"Expected null variable or datetime iso8601 ",
)),
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 148,
"total_crates": null
} |
fn_clm_api_models_validate_and_get_records_with_errors_7068997592184470589 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/revenue_recovery_data_backfill
// Implementation of None for RevenueRecoveryDataBackfillForm
pub fn validate_and_get_records_with_errors(&self) -> Result<CsvParsingResult, BackfillError> {
// Step 1: Open the file
let file = File::open(self.file.file.path())
.map_err(|error| BackfillError::FileProcessingError(error.to_string()))?;
let mut csv_reader = Reader::from_reader(BufReader::new(file));
// Step 2: Parse CSV into typed records
let mut records = Vec::new();
let mut failed_records = Vec::new();
for (row_index, record_result) in csv_reader
.deserialize::<RevenueRecoveryBackfillRequest>()
.enumerate()
{
match record_result {
Ok(record) => {
records.push(record);
}
Err(err) => {
failed_records.push(CsvParsingError {
row_number: row_index + 2, // +2 because enumerate starts at 0 and CSV has header row
error: err.to_string(),
});
}
}
}
Ok(CsvParsingResult {
records,
failed_records,
})
}
| {
"crate": "api_models",
"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_api_models_fmt_7068997592184470589 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/revenue_recovery_data_backfill
// Implementation of BackfillError for std::fmt::Display
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::InvalidCardType(msg) => write!(f, "Invalid card type: {}", msg),
Self::DatabaseError(msg) => write!(f, "Database error: {}", msg),
Self::RedisError(msg) => write!(f, "Redis error: {}", msg),
Self::CsvParsingError(msg) => write!(f, "CSV parsing error: {}", msg),
Self::FileProcessingError(msg) => write!(f, "File processing error: {}", msg),
}
}
| {
"crate": "api_models",
"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_api_models_get_api_event_type_7068997592184470589 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/revenue_recovery_data_backfill
// Implementation of UpdateTokenStatusResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
Some(common_utils::events::ApiEventsType::Miscellaneous)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_error_response_7068997592184470589 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/revenue_recovery_data_backfill
// Implementation of BackfillError for ResponseError
fn error_response(&self) -> HttpResponse {
HttpResponse::BadRequest().json(serde_json::json!({
"error": self.to_string()
}))
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 24,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_7519940221799831716 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/surcharge_decision_configs
// Implementation of SurchargeDecisionConfigReq for events::ApiEventMetric
fn get_api_event_type(&self) -> Option<events::ApiEventsType> {
Some(events::ApiEventsType::Routing)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_onal_-3871336949266383998 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payments
// Implementation of fn from(payment_method_da for PaymentMethodDataResponse {
itionalPaymentData) -> Self {
match payment_method_data {
AdditionalPaymentData::Card(card) => Self::Card(Box::new(CardResponse::from(*card))),
AdditionalPaymentData::PayLater { klarna_sdk } => match klarna_sdk {
Some(sdk) => Self::PayLater(Box::new(PaylaterResponse::from(sdk))),
None => Self::PayLater(Box::new(PaylaterResponse { klarna_sdk: None })),
},
AdditionalPaymentData::Wallet {
apple_pay,
google_pay,
samsung_pay,
} => match (apple_pay, google_pay, samsung_pay) {
(Some(apple_pay_pm), _, _) => Self::Wallet(Box::new(WalletResponse {
details: Some(WalletResponseData::ApplePay(Box::new(
additional_info::WalletAdditionalDataForCard {
last4: apple_pay_pm
.display_name
.clone()
.chars()
.rev()
.take(4)
.collect::<String>()
.chars()
.rev()
.collect::<String>(),
card_network: apple_pay_pm.network.clone(),
card_type: Some(apple_pay_pm.pm_type.clone()),
},
))),
})),
(_, Some(google_pay_pm), _) => Self::Wallet(Box::new(WalletResponse {
details: Some(WalletResponseData::GooglePay(Box::new(google_pay_pm))),
})),
(_, _, Some(samsung_pay_pm)) => Self::Wallet(Box::new(WalletResponse {
details: Some(WalletResponseData::SamsungPay(Box::new(samsung_pay_pm))),
})),
_ => Self::Wallet(Box::new(WalletResponse { details: None })),
},
AdditionalPaymentData::BankRedirect { bank_name, details } => {
Self::BankRedirect(Box::new(BankRedirectResponse { bank_name, details }))
}
AdditionalPaymentData::Crypto { details } => {
Self::Crypto(Box::new(CryptoResponse { details }))
}
AdditionalPaymentData::BankDebit { details } => {
Self::BankDebit(Box::new(BankDebitResponse { details }))
}
AdditionalPaymentData::MandatePayment {} => Self::MandatePayment {},
AdditionalPaymentData::Reward {} => Self::Reward {},
AdditionalPaymentData::RealTimePayment { details } => {
Self::RealTimePayment(Box::new(RealTimePaymentDataResponse { details }))
}
AdditionalPaymentData::Upi { details } => Self::Upi(Box::new(UpiResponse { details })),
AdditionalPaymentData::BankTransfer { details } => {
Self::BankTransfer(Box::new(BankTransferResponse { details }))
}
AdditionalPaymentData::Voucher { details } => {
Self::Voucher(Box::new(VoucherResponse { details }))
}
AdditionalPaymentData::GiftCard { details } => {
Self::GiftCard(Box::new(GiftCardResponse { details }))
}
AdditionalPaymentData::CardRedirect { details } => {
Self::CardRedirect(Box::new(CardRedirectResponse { details }))
}
AdditionalPaymentData::CardToken { details } => {
Self::CardToken(Box::new(CardTokenResponse { details }))
}
AdditionalPaymentData::OpenBanking { details } => {
Self::OpenBanking(Box::new(OpenBankingResponse { details }))
}
AdditionalPaymentData::MobilePayment { details } => {
Self::MobilePayment(Box::new(MobilePaymentResponse { details }))
}
}
}
}
#[derive(Debug, Clone, serde
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 124,
"total_crates": null
} |
fn_clm_api_models_details_in_request(&self) -> Option<_-3871336949266383998 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payments
// Implementation of None for /// Get the
stomer_details_in_request(&self) -> Option<Vec<&str>> {
if let Some(CustomerDetails {
id,
name,
email,
phone,
phone_country_code,
..
}) = self.customer.as_ref()
{
let invalid_fields = [
are_optional_values_invalid(self.customer_id.as_ref(), Some(id))
.then_some("customer_id and customer.id"),
are_optional_values_invalid(self.email.as_ref(), email.as_ref())
.then_some("email and customer.email"),
are_optional_values_invalid(self.name.as_ref(), name.as_ref())
.then_some("name and customer.name"),
are_optional_values_invalid(self.phone.as_ref(), phone.as_ref())
.then_some("phone and customer.phone"),
are_optional_values_invalid(
self.phone_country_code.as_ref(),
phone_country_code.as_ref(),
)
.then_some("phone_country_code and customer.phone_country_code"),
]
.into_iter()
.flatten()
.collect::<Vec<_>>();
if invalid_fields.is_empty() {
None
} else {
Some(invalid_fields)
}
} else {
None
}
}
pub fn get_f
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 58,
"total_crates": null
} |
fn_clm_api_models_>(
_-3871336949266383998 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payments
<'de, D>(
deserializer: D,
) -> Result<Option<PaymentMethodDataRequest>, D::Error>
where
D: Deserializer<'de>,
{
#[derive(serde::Deserialize, Debug)]
#[serde(untagged)]
enum __Inner {
RewardString(String),
OptionalPaymentMethod(serde_json::Value),
}
// This struct is an intermediate representation
// This is required in order to catch deserialization errors when deserializing `payment_method_data`
// The #[serde(flatten)] attribute applied on `payment_method_data` discards
// any of the error when deserializing and deserializes to an option instead
#[derive(serde::Deserialize, Debug)]
struct __InnerPaymentMethodData {
billing: Option<Address>,
#[serde(flatten)]
payment_method_data: Option<serde_json::Value>,
}
let deserialize_to_inner = __Inner::deserialize(deserializer)?;
match deserialize_to_inner {
__Inner::OptionalPaymentMethod(value) => {
let parsed_value = serde_json::from_value::<__InnerPaymentMethodData>(value)
.map_err(|serde_json_error| de::Error::custom(serde_json_error.to_string()))?;
let payment_method_data = if let Some(payment_method_data_value) =
parsed_value.payment_method_data
{
// Even though no data is passed, the flatten serde_json::Value is deserialized as Some(Object {})
if let serde_json::Value::Object(ref inner_map) = payment_method_data_value {
if inner_map.is_empty() {
None
} else {
let payment_method_data = serde_json::from_value::<PaymentMethodData>(
payment_method_data_value,
)
.map_err(|serde_json_error| {
de::Error::custom(serde_json_error.to_string())
})?;
let address_details = parsed_value
.billing
.as_ref()
.and_then(|billing| billing.address.clone());
match (payment_method_data.clone(), address_details.as_ref()) {
(
PaymentMethodData::Card(ref mut card),
Some(billing_address_details),
) => {
if card.card_holder_name.is_none() {
card.card_holder_name =
billing_address_details.get_optional_full_name();
}
Some(PaymentMethodData::Card(card.clone()))
}
_ => Some(payment_method_data),
}
}
} else {
Err(de::Error::custom("Expected a map for payment_method_data"))?
}
} else {
None
};
Ok(Some(PaymentMethodDataRequest {
payment_method_data,
billing: parsed_value.billing,
}))
}
__Inner::RewardString(inner_string) => {
let payment_method_data = match inner_string.as_str() {
"reward" => PaymentMethodData::Reward,
_ => Err(de::Error::custom("Invalid Variant"))?,
};
Ok(Some(PaymentMethodDataRequest {
payment_method_data: Some(payment_method_data),
billing: None,
}))
}
}
}
pub fn seria
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 58,
"total_crates": null
} |
fn_clm_api_models_s(&self) -> Option<_-3871336949266383998 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payments
// Implementation of fn get_bill for entMethodData for VoucherData {
ress(&self) -> Option<Address> {
match self {
Self::Alfamart(voucher_data) => Some(Address {
address: Some(AddressDetails {
first_name: voucher_data.first_name.clone(),
last_name: voucher_data.last_name.clone(),
..AddressDetails::default()
}),
phone: None,
email: voucher_data.email.clone(),
}),
Self::Indomaret(voucher_data) => Some(Address {
address: Some(AddressDetails {
first_name: voucher_data.first_name.clone(),
last_name: voucher_data.last_name.clone(),
..AddressDetails::default()
}),
phone: None,
email: voucher_data.email.clone(),
}),
Self::Lawson(voucher_data)
| Self::MiniStop(voucher_data)
| Self::FamilyMart(voucher_data)
| Self::Seicomart(voucher_data)
| Self::PayEasy(voucher_data)
| Self::SevenEleven(voucher_data) => Some(Address {
address: Some(AddressDetails {
first_name: voucher_data.first_name.clone(),
last_name: voucher_data.last_name.clone(),
..AddressDetails::default()
}),
phone: Some(PhoneDetails {
number: voucher_data.phone_number.clone().map(Secret::new),
country_code: None,
}),
email: voucher_data.email.clone(),
}),
Self::Boleto(_)
| Self::Efecty
| Self::PagoEfectivo
| Self::RedCompra
| Self::RedPagos
| Self::Oxxo => None,
}
}
}
/// Use custom
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 50,
"total_crates": null
} |
fn_clm_api_models_s(self, other: Option_-3871336949266383998 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payments
// Inherent implementation for pub fn get_op
_details(self, other: Option<&Self>) -> Self {
if let Some(other) = other {
let (first_name, last_name) = if self
.first_name
.as_ref()
.is_some_and(|first_name| !first_name.is_empty_after_trim())
{
(self.first_name, self.last_name)
} else {
(other.first_name.clone(), other.last_name.clone())
};
Self {
first_name,
last_name,
city: self.city.or(other.city.clone()),
country: self.country.or(other.country),
line1: self.line1.or(other.line1.clone()),
line2: self.line2.or(other.line2.clone()),
line3: self.line3.or(other.line3.clone()),
zip: self.zip.or(other.zip.clone()),
state: self.state.or(other.state.clone()),
origin_zip: self.origin_zip.or(other.origin_zip.clone()),
}
} else {
self
}
}
}
pub struct Addre
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 48,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_3130588392109770897 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/conditional_configs
// Implementation of DecisionManagerRequest for events::ApiEventMetric
fn get_api_event_type(&self) -> Option<events::ApiEventsType> {
Some(events::ApiEventsType::Routing)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_parse_comma_separated_8960038812343838943 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/disputes
fn parse_comma_separated<'de, D, T>(v: D) -> Result<Option<Vec<T>>, D::Error>
where
D: serde::Deserializer<'de>,
T: std::str::FromStr,
<T as std::str::FromStr>::Err: std::fmt::Debug + std::fmt::Display + std::error::Error,
{
let output = Option::<&str>::deserialize(v)?;
output
.map(|s| {
s.split(",")
.map(|x| x.parse::<T>().map_err(D::Error::custom))
.collect::<Result<_, _>>()
})
.transpose()
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 12,
"total_crates": null
} |
fn_clm_api_models_new_-5988986703809198155 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/subscription
// Inherent implementation for ClientSecret
pub fn new(secret: String) -> Self {
Self(secret)
}
| {
"crate": "api_models",
"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_api_models_as_str_-5988986703809198155 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/subscription
// Inherent implementation for ClientSecret
pub fn as_str(&self) -> &str {
&self.0
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 1242,
"total_crates": null
} |
fn_clm_api_models_get_billing_address_-5988986703809198155 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/subscription
// Inherent implementation for CreateAndConfirmSubscriptionRequest
pub fn get_billing_address(&self) -> Option<Address> {
self.payment_details
.payment_method_data
.as_ref()
.and_then(|data| data.billing.clone())
.or(self.billing.clone())
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 67,
"total_crates": null
} |
fn_clm_api_models_as_string_-5988986703809198155 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/subscription
// Inherent implementation for ClientSecret
pub fn as_string(&self) -> &String {
&self.0
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_api_models_try_from_-8059452633077308952 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/enums
// Implementation of PayoutConnectors for TryFrom<Connector>
fn try_from(value: Connector) -> Result<Self, Self::Error> {
match value {
Connector::Adyen => Ok(Self::Adyen),
Connector::Adyenplatform => Ok(Self::Adyenplatform),
Connector::Cybersource => Ok(Self::Cybersource),
Connector::Ebanx => Ok(Self::Ebanx),
Connector::Gigadat => Ok(Self::Gigadat),
Connector::Loonio => Ok(Self::Loonio),
Connector::Nuvei => Ok(Self::Nuvei),
Connector::Nomupay => Ok(Self::Nomupay),
Connector::Payone => Ok(Self::Payone),
Connector::Paypal => Ok(Self::Paypal),
Connector::Stripe => Ok(Self::Stripe),
Connector::Wise => Ok(Self::Wise),
Connector::Worldpay => Ok(Self::Worldpay),
_ => Err(format!("Invalid payout connector {value}")),
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2657,
"total_crates": null
} |
fn_clm_api_models_from_-8059452633077308952 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/enums
// Implementation of ReconPermissionScope for From<PermissionScope>
fn from(scope: PermissionScope) -> Self {
match scope {
PermissionScope::Read => Self::Read,
PermissionScope::Write => Self::Write,
}
}
| {
"crate": "api_models",
"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_api_models_eq_-8059452633077308952 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/enums
// Implementation of FieldType for PartialEq
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::UserCardNumber, Self::UserCardNumber) => true,
(Self::UserCardExpiryMonth, Self::UserCardExpiryMonth) => true,
(Self::UserCardExpiryYear, Self::UserCardExpiryYear) => true,
(Self::UserCardCvc, Self::UserCardCvc) => true,
(Self::UserFullName, Self::UserFullName) => true,
(Self::UserEmailAddress, Self::UserEmailAddress) => true,
(Self::UserPhoneNumber, Self::UserPhoneNumber) => true,
(Self::UserPhoneNumberCountryCode, Self::UserPhoneNumberCountryCode) => true,
(
Self::UserCountry {
options: options_self,
},
Self::UserCountry {
options: options_other,
},
) => options_self.eq(options_other),
(
Self::UserCurrency {
options: options_self,
},
Self::UserCurrency {
options: options_other,
},
) => options_self.eq(options_other),
(Self::UserCryptoCurrencyNetwork, Self::UserCryptoCurrencyNetwork) => true,
(Self::UserBillingName, Self::UserBillingName) => true,
(Self::UserAddressLine1, Self::UserAddressLine1) => true,
(Self::UserAddressLine2, Self::UserAddressLine2) => true,
(Self::UserAddressCity, Self::UserAddressCity) => true,
(Self::UserAddressPincode, Self::UserAddressPincode) => true,
(Self::UserAddressState, Self::UserAddressState) => true,
(Self::UserAddressCountry { .. }, Self::UserAddressCountry { .. }) => true,
(Self::UserShippingName, Self::UserShippingName) => true,
(Self::UserShippingAddressLine1, Self::UserShippingAddressLine1) => true,
(Self::UserShippingAddressLine2, Self::UserShippingAddressLine2) => true,
(Self::UserShippingAddressCity, Self::UserShippingAddressCity) => true,
(Self::UserShippingAddressPincode, Self::UserShippingAddressPincode) => true,
(Self::UserShippingAddressState, Self::UserShippingAddressState) => true,
(Self::UserShippingAddressCountry { .. }, Self::UserShippingAddressCountry { .. }) => {
true
}
(Self::UserBlikCode, Self::UserBlikCode) => true,
(Self::UserBank, Self::UserBank) => true,
(Self::Text, Self::Text) => true,
(
Self::DropDown {
options: options_self,
},
Self::DropDown {
options: options_other,
},
) => options_self.eq(options_other),
(Self::UserDateOfBirth, Self::UserDateOfBirth) => true,
(Self::UserVpaId, Self::UserVpaId) => true,
(Self::UserPixKey, Self::UserPixKey) => true,
(Self::UserCpf, Self::UserCpf) => true,
(Self::UserCnpj, Self::UserCnpj) => true,
(Self::LanguagePreference { .. }, Self::LanguagePreference { .. }) => true,
(Self::UserMsisdn, Self::UserMsisdn) => true,
(Self::UserClientIdentifier, Self::UserClientIdentifier) => true,
(Self::OrderDetailsProductName, Self::OrderDetailsProductName) => true,
_unused => false,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 1664,
"total_crates": null
} |
fn_clm_api_models_convert_authentication_connector_-8059452633077308952 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/enums
pub fn convert_authentication_connector(connector_name: &str) -> Option<AuthenticationConnectors> {
AuthenticationConnectors::from_str(connector_name).ok()
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_billing_variants_-8059452633077308952 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/enums
// Inherent implementation for FieldType
pub fn get_billing_variants() -> Vec<Self> {
vec![
Self::UserBillingName,
Self::UserAddressLine1,
Self::UserAddressLine2,
Self::UserAddressCity,
Self::UserAddressPincode,
Self::UserAddressState,
Self::UserAddressCountry { options: vec![] },
]
}
| {
"crate": "api_models",
"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_api_models_default_list_limit_7078955511354128231 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/blocklist
fn default_list_limit() -> u16 {
10
}
| {
"crate": "api_models",
"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_api_models_get_user_id_-5014943549664492220 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/external_service_auth
// Inherent implementation for ExternalVerifyTokenResponse
pub fn get_user_id(&self) -> &str {
match self {
Self::Hypersense { user_id, .. } => user_id,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 171,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_3446517446963304696 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/poll
// Implementation of PollResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Poll {
poll_id: self.poll_id.clone(),
})
}
| {
"crate": "api_models",
"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_api_models_from_6829001868269539189 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/webhooks
// Implementation of WebhookFlow for From<IncomingWebhookEvent>
fn from(evt: IncomingWebhookEvent) -> Self {
match evt {
IncomingWebhookEvent::PaymentIntentFailure
| IncomingWebhookEvent::PaymentIntentSuccess
| IncomingWebhookEvent::PaymentIntentProcessing
| IncomingWebhookEvent::PaymentActionRequired
| IncomingWebhookEvent::PaymentIntentPartiallyFunded
| IncomingWebhookEvent::PaymentIntentCancelled
| IncomingWebhookEvent::PaymentIntentCancelFailure
| IncomingWebhookEvent::PaymentIntentAuthorizationSuccess
| IncomingWebhookEvent::PaymentIntentAuthorizationFailure
| IncomingWebhookEvent::PaymentIntentCaptureSuccess
| IncomingWebhookEvent::PaymentIntentCaptureFailure
| IncomingWebhookEvent::PaymentIntentExpired
| IncomingWebhookEvent::PaymentIntentExtendAuthorizationSuccess
| IncomingWebhookEvent::PaymentIntentExtendAuthorizationFailure => Self::Payment,
IncomingWebhookEvent::EventNotSupported => Self::ReturnResponse,
IncomingWebhookEvent::RefundSuccess | IncomingWebhookEvent::RefundFailure => {
Self::Refund
}
IncomingWebhookEvent::MandateActive | IncomingWebhookEvent::MandateRevoked => {
Self::Mandate
}
IncomingWebhookEvent::DisputeOpened
| IncomingWebhookEvent::DisputeAccepted
| IncomingWebhookEvent::DisputeExpired
| IncomingWebhookEvent::DisputeCancelled
| IncomingWebhookEvent::DisputeChallenged
| IncomingWebhookEvent::DisputeWon
| IncomingWebhookEvent::DisputeLost => Self::Dispute,
IncomingWebhookEvent::EndpointVerification => Self::ReturnResponse,
IncomingWebhookEvent::SourceChargeable
| IncomingWebhookEvent::SourceTransactionCreated => Self::BankTransfer,
IncomingWebhookEvent::ExternalAuthenticationARes => Self::ExternalAuthentication,
IncomingWebhookEvent::FrmApproved | IncomingWebhookEvent::FrmRejected => {
Self::FraudCheck
}
#[cfg(feature = "payouts")]
IncomingWebhookEvent::PayoutSuccess
| IncomingWebhookEvent::PayoutFailure
| IncomingWebhookEvent::PayoutProcessing
| IncomingWebhookEvent::PayoutCancelled
| IncomingWebhookEvent::PayoutCreated
| IncomingWebhookEvent::PayoutExpired
| IncomingWebhookEvent::PayoutReversed => Self::Payout,
#[cfg(all(feature = "revenue_recovery", feature = "v2"))]
IncomingWebhookEvent::RecoveryInvoiceCancel
| IncomingWebhookEvent::RecoveryPaymentFailure
| IncomingWebhookEvent::RecoveryPaymentPending
| IncomingWebhookEvent::RecoveryPaymentSuccess => Self::Recovery,
IncomingWebhookEvent::SetupWebhook => Self::Setup,
IncomingWebhookEvent::InvoiceGenerated => Self::Subscription,
}
}
| {
"crate": "api_models",
"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_api_models_get_payment_id_6829001868269539189 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/webhooks
// Inherent implementation for WebhookResponseTracker
pub fn get_payment_id(&self) -> Option<common_utils::id_type::GlobalPaymentId> {
match self {
Self::Payment { payment_id, .. }
| Self::Refund { payment_id, .. }
| Self::Dispute { payment_id, .. } => Some(payment_id.to_owned()),
Self::NoEffect | Self::Mandate { .. } => None,
#[cfg(feature = "payouts")]
Self::Payout { .. } => None,
Self::Relay { .. } => None,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 35,
"total_crates": null
} |
fn_clm_api_models_get_payment_method_id_6829001868269539189 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/webhooks
// Inherent implementation for WebhookResponseTracker
pub fn get_payment_method_id(&self) -> Option<String> {
match self {
Self::PaymentMethod {
payment_method_id, ..
} => Some(payment_method_id.to_owned()),
Self::Payment { .. }
| Self::Refund { .. }
| Self::Dispute { .. }
| Self::NoEffect
| Self::Mandate { .. }
| Self::Relay { .. } => None,
#[cfg(feature = "payouts")]
Self::Payout { .. } => None,
}
}
| {
"crate": "api_models",
"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_api_models_from_ucs_event_type_6829001868269539189 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/webhooks
// Inherent implementation for IncomingWebhookEvent
/// Convert UCS event type integer to IncomingWebhookEvent
/// Maps from proto WebhookEventType enum values to IncomingWebhookEvent variants
pub fn from_ucs_event_type(event_type: i32) -> Self {
match event_type {
0 => Self::EventNotSupported,
// Payment intent events
1 => Self::PaymentIntentFailure,
2 => Self::PaymentIntentSuccess,
3 => Self::PaymentIntentProcessing,
4 => Self::PaymentIntentPartiallyFunded,
5 => Self::PaymentIntentCancelled,
6 => Self::PaymentIntentCancelFailure,
7 => Self::PaymentIntentAuthorizationSuccess,
8 => Self::PaymentIntentAuthorizationFailure,
9 => Self::PaymentIntentCaptureSuccess,
10 => Self::PaymentIntentCaptureFailure,
11 => Self::PaymentIntentExpired,
12 => Self::PaymentActionRequired,
// Source events
13 => Self::SourceChargeable,
14 => Self::SourceTransactionCreated,
// Refund events
15 => Self::RefundFailure,
16 => Self::RefundSuccess,
// Dispute events
17 => Self::DisputeOpened,
18 => Self::DisputeExpired,
19 => Self::DisputeAccepted,
20 => Self::DisputeCancelled,
21 => Self::DisputeChallenged,
22 => Self::DisputeWon,
23 => Self::DisputeLost,
// Mandate events
24 => Self::MandateActive,
25 => Self::MandateRevoked,
// Miscellaneous events
26 => Self::EndpointVerification,
27 => Self::ExternalAuthenticationARes,
28 => Self::FrmApproved,
29 => Self::FrmRejected,
// Payout events
#[cfg(feature = "payouts")]
30 => Self::PayoutSuccess,
#[cfg(feature = "payouts")]
31 => Self::PayoutFailure,
#[cfg(feature = "payouts")]
32 => Self::PayoutProcessing,
#[cfg(feature = "payouts")]
33 => Self::PayoutCancelled,
#[cfg(feature = "payouts")]
34 => Self::PayoutCreated,
#[cfg(feature = "payouts")]
35 => Self::PayoutExpired,
#[cfg(feature = "payouts")]
36 => Self::PayoutReversed,
_ => Self::EventNotSupported,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_api_models_get_connector_transaction_id_as_string_6829001868269539189 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/webhooks
// Inherent implementation for ObjectReferenceId
pub fn get_connector_transaction_id_as_string(
self,
) -> Result<String, common_utils::errors::ValidationError> {
match self {
Self::PaymentId(
payments::PaymentIdType::ConnectorTransactionId(id)
) => Ok(id),
Self::PaymentId(_)=>Err(
common_utils::errors::ValidationError::IncorrectValueProvided {
field_name: "ConnectorTransactionId variant of PaymentId is required but received otherr variant",
},
),
Self::RefundId(_) => Err(
common_utils::errors::ValidationError::IncorrectValueProvided {
field_name: "PaymentId is required but received RefundId",
},
),
Self::MandateId(_) => Err(
common_utils::errors::ValidationError::IncorrectValueProvided {
field_name: "PaymentId is required but received MandateId",
},
),
Self::ExternalAuthenticationID(_) => Err(
common_utils::errors::ValidationError::IncorrectValueProvided {
field_name: "PaymentId is required but received ExternalAuthenticationID",
},
),
#[cfg(feature = "payouts")]
Self::PayoutId(_) => Err(
common_utils::errors::ValidationError::IncorrectValueProvided {
field_name: "PaymentId is required but received PayoutId",
},
),
Self::InvoiceId(_) => Err(
common_utils::errors::ValidationError::IncorrectValueProvided {
field_name: "PaymentId is required but received InvoiceId",
},
),
Self::SubscriptionId(_) => Err(
common_utils::errors::ValidationError::IncorrectValueProvided {
field_name: "PaymentId is required but received SubscriptionId",
},
),
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_api_models_from_223265635973037133 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/api_keys
// Implementation of ApiKeyExpiration for From<Option<PrimitiveDateTime>>
fn from(date_time: Option<PrimitiveDateTime>) -> Self {
date_time.map_or(Self::Never, Self::DateTime)
}
| {
"crate": "api_models",
"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_api_models_deserialize_223265635973037133 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/api_keys
pub fn deserialize<'de, D>(deserializer: D) -> Result<(), D::Error>
where
D: serde::Deserializer<'de>,
{
struct NeverVisitor;
impl serde::de::Visitor<'_> for NeverVisitor {
type Value = ();
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, r#""{NEVER}""#)
}
fn visit_str<E: serde::de::Error>(self, value: &str) -> Result<Self::Value, E> {
if value == NEVER {
Ok(())
} else {
Err(E::invalid_value(serde::de::Unexpected::Str(value), &self))
}
}
}
deserializer.deserialize_str(NeverVisitor)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 142,
"total_crates": null
} |
fn_clm_api_models_serialize_223265635973037133 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/api_keys
pub fn serialize<S>(serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(NEVER)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 87,
"total_crates": null
} |
fn_clm_api_models_schema_223265635973037133 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/api_keys
// Implementation of ApiKeyExpiration for ToSchema<'a>
fn schema() -> (
&'a str,
utoipa::openapi::RefOr<utoipa::openapi::schema::Schema>,
) {
use utoipa::openapi::{KnownFormat, ObjectBuilder, OneOfBuilder, SchemaFormat, SchemaType};
(
"ApiKeyExpiration",
OneOfBuilder::new()
.item(
ObjectBuilder::new()
.schema_type(SchemaType::String)
.enum_values(Some(["never"])),
)
.item(
ObjectBuilder::new()
.schema_type(SchemaType::String)
.format(Some(SchemaFormat::KnownFormat(KnownFormat::DateTime))),
)
.into(),
)
}
| {
"crate": "api_models",
"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_api_models_visit_str_223265635973037133 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/api_keys
// Implementation of NeverVisitor for serde::de::Visitor<'_>
fn visit_str<E: serde::de::Error>(self, value: &str) -> Result<Self::Value, E> {
if value == NEVER {
Ok(())
} else {
Err(E::invalid_value(serde::de::Unexpected::Str(value), &self))
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 12,
"total_crates": null
} |
fn_clm_api_models_into_298206735259128649 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/analytics
// Implementation of QueryLimit for Into<u64>
fn into(self) -> u64 {
match self {
Self::Top5 => 5,
Self::Top10 => 10,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 6545,
"total_crates": null
} |
fn_clm_api_models_requires_forex_functionality_298206735259128649 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/analytics
// Inherent implementation for AnalyticsRequest
pub fn requires_forex_functionality(&self) -> bool {
self.payment_attempt
.as_ref()
.map(|req| req.metrics.iter().any(|metric| metric.is_forex_metric()))
.unwrap_or_default()
|| self
.payment_intent
.as_ref()
.map(|req| req.metrics.iter().any(|metric| metric.is_forex_metric()))
.unwrap_or_default()
|| self
.refund
.as_ref()
.map(|req| req.metrics.iter().any(|metric| metric.is_forex_metric()))
.unwrap_or_default()
|| self
.dispute
.as_ref()
.map(|req| req.metrics.iter().any(|metric| metric.is_forex_metric()))
.unwrap_or_default()
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 69,
"total_crates": null
} |
fn_clm_api_models_get_address_6589176179595977485 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/customers
// Inherent implementation for CustomerUpdateRequest
pub fn get_address(&self) -> Option<payments::AddressDetails> {
self.address.clone()
}
| {
"crate": "api_models",
"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_api_models_get_merchant_reference_id_6589176179595977485 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/customers
// Inherent implementation for CustomerResponse
pub fn get_merchant_reference_id(&self) -> Option<id_type::CustomerId> {
self.merchant_reference_id.clone()
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_default_customer_billing_address_6589176179595977485 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/customers
// Inherent implementation for CustomerUpdateRequest
pub fn get_default_customer_billing_address(&self) -> Option<payments::AddressDetails> {
self.default_billing_address.clone()
}
| {
"crate": "api_models",
"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_api_models_get_default_customer_shipping_address_6589176179595977485 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/customers
// Inherent implementation for CustomerUpdateRequest
pub fn get_default_customer_shipping_address(&self) -> Option<payments::AddressDetails> {
self.default_shipping_address.clone()
}
| {
"crate": "api_models",
"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_api_models_get_optional_email_6589176179595977485 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/customers
// Inherent implementation for CustomerRequest
pub fn get_optional_email(&self) -> Option<pii::Email> {
Some(self.email.clone())
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 20,
"total_crates": null
} |
fn_clm_api_models_from_-8809082633815412222 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/profile_acquirer
// Implementation of ProfileAcquirerResponse for From<(
common_utils::id_type::ProfileAcquirerId,
&common_utils::id_type::ProfileId,
&common_types::domain::AcquirerConfig,
)>
fn from(
(profile_acquirer_id, profile_id, acquirer_config): (
common_utils::id_type::ProfileAcquirerId,
&common_utils::id_type::ProfileId,
&common_types::domain::AcquirerConfig,
),
) -> Self {
Self {
profile_acquirer_id,
profile_id: profile_id.clone(),
acquirer_assigned_merchant_id: acquirer_config.acquirer_assigned_merchant_id.clone(),
merchant_name: acquirer_config.merchant_name.clone(),
network: acquirer_config.network.clone(),
acquirer_bin: acquirer_config.acquirer_bin.clone(),
acquirer_ica: acquirer_config.acquirer_ica.clone(),
acquirer_fraud_rate: acquirer_config.acquirer_fraud_rate,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2612,
"total_crates": null
} |
fn_clm_api_models_get_billing_address_-827691694973891486 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/authentication
// Inherent implementation for AuthenticationEligibilityRequest
pub fn get_billing_address(&self) -> Option<Address> {
self.billing.clone()
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 59,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_-827691694973891486 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/authentication
// Implementation of AuthenticationSyncPostUpdateRequest for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Authentication {
authentication_id: self.authentication_id.clone(),
})
}
| {
"crate": "api_models",
"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_api_models_get_next_action_api_-827691694973891486 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/authentication
// Inherent implementation for AuthenticationEligibilityRequest
pub fn get_next_action_api(
&self,
base_url: String,
authentication_id: String,
) -> CustomResult<NextAction, errors::ParsingError> {
let url = format!("{base_url}/authentication/{authentication_id}/authenticate");
Ok(NextAction {
url: url::Url::parse(&url).change_context(errors::ParsingError::UrlParsingError)?,
http_method: common_utils::request::Method::Post,
})
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 25,
"total_crates": null
} |
fn_clm_api_models_get_shipping_address_-827691694973891486 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/authentication
// Inherent implementation for AuthenticationEligibilityRequest
pub fn get_shipping_address(&self) -> Option<Address> {
self.shipping.clone()
}
| {
"crate": "api_models",
"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_api_models_get_browser_information_-827691694973891486 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/authentication
// Inherent implementation for AuthenticationEligibilityRequest
pub fn get_browser_information(&self) -> Option<BrowserInformation> {
self.browser_information.clone()
}
| {
"crate": "api_models",
"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_api_models_new_2435838503430416793 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/routing
// Inherent implementation for RuleMigrationResponse
pub fn new(
profile_id: common_utils::id_type::ProfileId,
euclid_algorithm_id: common_utils::id_type::RoutingId,
decision_engine_algorithm_id: String,
is_active_rule: bool,
) -> Self {
Self {
profile_id,
euclid_algorithm_id,
decision_engine_algorithm_id,
is_active_rule,
}
}
| {
"crate": "api_models",
"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_api_models_default_2435838503430416793 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/routing
// Implementation of ContractBasedRoutingConfig for Default
fn default() -> Self {
Self {
config: Some(ContractBasedRoutingConfigBody {
constants: Some(vec![0.7, 0.35]),
time_scale: Some(ContractBasedTimeScale::Day),
}),
label_info: None,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7703,
"total_crates": null
} |
fn_clm_api_models_try_from_2435838503430416793 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/routing
// Implementation of StraightThroughAlgorithm for TryFrom<StraightThroughAlgorithmSerde>
fn try_from(value: StraightThroughAlgorithmSerde) -> Result<Self, Self::Error> {
let inner = match value {
StraightThroughAlgorithmSerde::Direct(algorithm) => algorithm,
StraightThroughAlgorithmSerde::Nested { algorithm } => algorithm,
};
match &inner {
StraightThroughAlgorithmInner::Priority(i) if i.is_empty() => {
Err(ParsingError::StructParseFailure(
"Connectors list can't be empty for Priority Algorithm",
))?
}
StraightThroughAlgorithmInner::VolumeSplit(i) if i.is_empty() => {
Err(ParsingError::StructParseFailure(
"Connectors list can't be empty for Volume split Algorithm",
))?
}
_ => {}
};
Ok(match inner {
StraightThroughAlgorithmInner::Single(single) => Self::Single(single),
StraightThroughAlgorithmInner::Priority(plist) => Self::Priority(plist),
StraightThroughAlgorithmInner::VolumeSplit(vsplit) => Self::VolumeSplit(vsplit),
})
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2671,
"total_crates": null
} |
fn_clm_api_models_from_2435838503430416793 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/routing
// Implementation of RoutableConnectorChoice for From<DeRoutableConnectorChoice>
fn from(choice: DeRoutableConnectorChoice) -> Self {
Self {
choice_kind: RoutableChoiceKind::FullStruct,
connector: choice.gateway_name,
merchant_connector_id: choice.gateway_id,
}
}
| {
"crate": "api_models",
"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_api_models_eq_2435838503430416793 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/routing
// Implementation of RoutableConnectorChoice for PartialEq
fn eq(&self, other: &Self) -> bool {
self.connector.eq(&other.connector)
&& self.merchant_connector_id.eq(&other.merchant_connector_id)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 1662,
"total_crates": null
} |
fn_clm_api_models_from_-5453112875249631948 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/health_check
// Implementation of Option<bool> for From<HealthState>
fn from(value: HealthState) -> Self {
match value {
HealthState::Running => Some(true),
HealthState::Error => Some(false),
HealthState::NotApplicable => None,
}
}
| {
"crate": "api_models",
"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_api_models_get_api_event_type_540003125855632861 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/ephemeral_key
// Implementation of ClientSecretResponse for common_utils::events::ApiEventMetric
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
Some(common_utils::events::ApiEventsType::Miscellaneous)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models__network_transaction_id_and_card_details_flow(s_-9214414268479607772 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/mandates
// Inherent implementation for curringDetails {
b fn is_network_transaction_id_and_card_details_flow(self) -> bool {
matches!(self, Self::NetworkTransactionIdAndCardDetails(_))
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 8,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_-2666573885222363361 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/three_ds_decision_rule
// Implementation of ThreeDsDecisionRuleExecuteResponse for common_utils::events::ApiEventMetric
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
Some(common_utils::events::ApiEventsType::ThreeDsDecisionRule)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_new_8914312575702603349 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/webhook_events
// Inherent implementation for TotalEventsResponse
pub fn new(total_count: i64, events: Vec<EventListItemResponse>) -> Self {
Self {
events,
total_count,
}
}
| {
"crate": "api_models",
"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_api_models_get_api_event_type_8914312575702603349 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/webhook_events
// Implementation of WebhookDeliveryRetryRequestInternal for common_utils::events::ApiEventMetric
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
Some(common_utils::events::ApiEventsType::Events {
merchant_id: self.merchant_id.clone(),
})
}
| {
"crate": "api_models",
"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_api_models_new_-7069525346315822665 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/admin
// Inherent implementation for MerchantConnectorInfo
pub fn new(
connector_label: String,
merchant_connector_id: id_type::MerchantConnectorAccountId,
) -> Self {
Self {
connector_label,
merchant_connector_id,
}
}
| {
"crate": "api_models",
"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_api_models_default_-7069525346315822665 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/admin
// Implementation of TtlForExtendedCardInfo for Default
fn default() -> Self {
Self(consts::DEFAULT_TTL_FOR_EXTENDED_CARD_INFO)
}
| {
"crate": "api_models",
"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_api_models_validate_-7069525346315822665 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/admin
// Inherent implementation for BusinessPaymentLinkConfig
pub fn validate(&self) -> Result<(), &str> {
let host_domain_valid = self
.domain_name
.clone()
.map(|host_domain| link_utils::validate_strict_domain(&host_domain))
.unwrap_or(true);
if !host_domain_valid {
return Err("Invalid host domain name received in payment_link_config");
}
let are_allowed_domains_valid = self
.allowed_domains
.clone()
.map(|allowed_domains| {
allowed_domains
.iter()
.all(|allowed_domain| link_utils::validate_wildcard_domain(allowed_domain))
})
.unwrap_or(true);
if !are_allowed_domains_valid {
return Err("Invalid allowed domain names received in payment_link_config");
}
Ok(())
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 239,
"total_crates": null
} |
fn_clm_api_models_deserialize_-7069525346315822665 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/admin
// Implementation of TtlForExtendedCardInfo for Deserialize<'de>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = u16::deserialize(deserializer)?;
// Check if value exceeds the maximum allowed
if value > consts::MAX_TTL_FOR_EXTENDED_CARD_INFO {
Err(serde::de::Error::custom(
"ttl_in_secs must be less than or equal to 7200 (2hrs)",
))
} else {
Ok(Self(value))
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 140,
"total_crates": null
} |
fn_clm_api_models_get_payment_method_type_-7069525346315822665 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/admin
// Inherent implementation for PaymentMethodsEnabled
pub fn get_payment_method_type(
&self,
) -> Option<&Vec<payment_methods::RequestPaymentMethodTypes>> {
self.payment_method_types.as_ref()
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 131,
"total_crates": null
} |
fn_clm_api_models_validate_field_and_get_-4539846180506973705 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/payments/trait_impls
// Implementation of common_types::primitive_wrappers::RequestExtendedAuthorizationBool for crate::ValidateFieldAndGet<payments::PaymentsRequest>
fn validate_field_and_get(
&self,
request: &payments::PaymentsRequest,
) -> errors::CustomResult<Self, errors::ValidationError>
where
Self: Sized,
{
match request.capture_method{
Some(enums::CaptureMethod::Automatic)
| Some(enums::CaptureMethod::Scheduled)
| Some(enums::CaptureMethod::SequentialAutomatic)
| None => Err(error_stack::report!(errors::ValidationError::InvalidValue { message: "request_extended_authorization must be sent only if capture method is manual or manual_multiple".to_string() })),
Some(enums::CaptureMethod::Manual)
| Some(enums::CaptureMethod::ManualMultiple) => Ok(*self)
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 8,
"total_crates": null
} |
fn_clm_api_models_new_-8459004448201607555 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/errors/types
// Inherent implementation for ApiError
pub fn new(
sub_code: &'static str,
error_identifier: u16,
error_message: impl ToString,
extra: Option<Extra>,
) -> Self {
Self {
sub_code,
error_identifier,
error_message: error_message.to_string(),
extra,
#[cfg(feature = "detailed_errors")]
stacktrace: None,
}
}
| {
"crate": "api_models",
"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_api_models_from_-8459004448201607555 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/errors/types
// Implementation of ErrorResponse for From<&ApiErrorResponse>
fn from(value: &ApiErrorResponse) -> Self {
let error_info = value.get_internal_error();
let error_type = value.error_type();
Self {
code: format!("{}_{:02}", error_info.sub_code, error_info.error_identifier),
message: error_info.error_message.clone(),
error_type,
extra: error_info.extra.clone(),
#[cfg(feature = "detailed_errors")]
stacktrace: error_info.stacktrace.clone(),
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2610,
"total_crates": null
} |
fn_clm_api_models_fmt_-8459004448201607555 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/errors/types
// Implementation of ApiErrorResponse for ::core::fmt::Display
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let error_response: ErrorResponse = self.into();
write!(
f,
r#"{{"error":{}}}"#,
serde_json::to_string(&error_response)
.unwrap_or_else(|_| "API error response".to_string())
)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 40,
"total_crates": null
} |
fn_clm_api_models_get_internal_error_-8459004448201607555 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/errors/types
// Inherent implementation for ApiErrorResponse
pub(crate) fn get_internal_error(&self) -> &ApiError {
match self {
Self::Unauthorized(i)
| Self::ForbiddenCommonResource(i)
| Self::ForbiddenPrivateResource(i)
| Self::Conflict(i)
| Self::Gone(i)
| Self::Unprocessable(i)
| Self::InternalServerError(i)
| Self::NotImplemented(i)
| Self::NotFound(i)
| Self::MethodNotAllowed(i)
| Self::BadRequest(i)
| Self::DomainError(i)
| Self::ConnectorError(i, _) => i,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_api_models_get_internal_error_mut_-8459004448201607555 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/errors/types
// Inherent implementation for ApiErrorResponse
pub fn get_internal_error_mut(&mut self) -> &mut ApiError {
match self {
Self::Unauthorized(i)
| Self::ForbiddenCommonResource(i)
| Self::ForbiddenPrivateResource(i)
| Self::Conflict(i)
| Self::Gone(i)
| Self::Unprocessable(i)
| Self::InternalServerError(i)
| Self::NotImplemented(i)
| Self::NotFound(i)
| Self::MethodNotAllowed(i)
| Self::BadRequest(i)
| Self::DomainError(i)
| Self::ConnectorError(i, _) => i,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_api_models_error_response_564651257933940686 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/errors/actix
// Implementation of ApiErrorResponse for actix_web::ResponseError
fn error_response(&self) -> actix_web::HttpResponse {
use actix_web::http::header;
actix_web::HttpResponseBuilder::new(self.status_code())
.insert_header((header::CONTENT_TYPE, mime::APPLICATION_JSON))
.body(self.to_string())
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 30,
"total_crates": null
} |
fn_clm_api_models_status_code_564651257933940686 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/errors/actix
// Implementation of ApiErrorResponse for actix_web::ResponseError
fn status_code(&self) -> reqwest::StatusCode {
use reqwest::StatusCode;
match self {
Self::Unauthorized(_) => StatusCode::UNAUTHORIZED,
Self::ForbiddenCommonResource(_) => StatusCode::FORBIDDEN,
Self::ForbiddenPrivateResource(_) => StatusCode::NOT_FOUND,
Self::Conflict(_) => StatusCode::CONFLICT,
Self::Gone(_) => StatusCode::GONE,
Self::Unprocessable(_) => StatusCode::UNPROCESSABLE_ENTITY,
Self::InternalServerError(_) => StatusCode::INTERNAL_SERVER_ERROR,
Self::NotImplemented(_) => StatusCode::NOT_IMPLEMENTED,
Self::ConnectorError(_, code) => *code,
Self::MethodNotAllowed(_) => StatusCode::METHOD_NOT_ALLOWED,
Self::NotFound(_) => StatusCode::NOT_FOUND,
Self::BadRequest(_) => StatusCode::BAD_REQUEST,
Self::DomainError(_) => StatusCode::OK,
}
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_-3954689250158598587 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/locker_migration
// Implementation of MigrateCardResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
Some(common_utils::events::ApiEventsType::RustLocker)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_8350895787667286611 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/dispute
// Implementation of DisputesAggregateResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::ResourceListAPI)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_8881428012375381123 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/payouts
// Implementation of PayoutLinkInitiateRequest for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payout {
payout_id: self.payout_id.to_owned(),
})
}
| {
"crate": "api_models",
"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_api_models_get_api_event_type_-302017817635946511 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/refund
// Implementation of RefundListFilters for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::ResourceListAPI)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_8398341637152126259 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/external_service_auth
// Implementation of ExternalSignoutTokenRequest for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::ExternalServiceAuth)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_-2190667616093404911 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/payment
// Implementation of payments::PaymentsCaptureResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
payment_id: self.id.clone(),
})
}
| {
"crate": "api_models",
"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_api_models_get_api_event_type_7276555110552447802 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/recon
// Implementation of VerifyTokenResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::User {
user_id: self.user_email.peek().to_string(),
})
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 30,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_-6742731289014925684 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/customer
// Implementation of CustomerListResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::ResourceListAPI)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_3668477515344801069 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/gsm
// Implementation of gsm::GsmResponse for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Gsm)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_api_models_get_api_event_type_1473563448441917735 | clm | function | // Repository: hyperswitch
// Crate: api_models
// Purpose: External API request/response types (what clients see)
// Module: crates/api_models/src/events/revenue_recovery
// Implementation of RevenueRecoveryRetriggerRequest for ApiEventMetric
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::ProcessTracker)
}
| {
"crate": "api_models",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.