id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
connector-service_body_ucs_cards_-8250640920232975802 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: get_last4
{
self.0
.peek()
.chars()
.rev()
.take(4)
.collect::<String>()
.chars()
.rev()
.collect::<String>()
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_last4",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_7140463363829715490 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: is_cobadged_card
{
/// Regex to identify card networks
static CARD_NETWORK_REGEX: LazyLock<HashMap<&str, Result<Regex, regex::Error>>> =
LazyLock::new(|| {
let mut map = HashMap::new();
map.insert(
"Mastercard",
Regex::new(r"^(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[0-1][0-9]|2720|5[1-5])"),
);
map.insert("American Express", Regex::new(r"^3[47]"));
map.insert("Visa", Regex::new(r"^4"));
map.insert(
"Discover",
Regex::new(
r"^(6011|64[4-9]|65|622126|622[1-9][0-9][0-9]|6229[0-1][0-9]|622925)",
),
);
map.insert(
"Maestro",
Regex::new(r"^(5018|5081|5044|504681|504993|5020|502260|5038|5893|603845|603123|6304|6759|676[1-3]|6220|504834|504817|504645|504775|600206|627741)"),
);
map.insert(
"RuPay",
Regex::new(r"^(508227|508[5-9]|603741|60698[5-9]|60699|607[0-8]|6079[0-7]|60798[0-4]|60800[1-9]|6080[1-9]|608[1-4]|608500|6521[5-9]|652[2-9]|6530|6531[0-4]|817290|817368|817378|353800|82)"),
);
map.insert("Diners Club", Regex::new(r"^(36|38|39|30[0-5])"));
map.insert("JCB", Regex::new(r"^35(2[89]|[3-8][0-9])"));
map.insert("CarteBlanche", Regex::new(r"^389[0-9]{11}$"));
map.insert("Sodex", Regex::new(r"^(637513)"));
map.insert("BAJAJ", Regex::new(r"^(203040)"));
map.insert("CartesBancaires", Regex::new(r"^(401(005|006|581)|4021(01|02)|403550|405936|406572|41(3849|4819|50(56|59|62|71|74)|6286|65(37|79)|71[7])|420110|423460|43(47(21|22)|50(48|49|50|51|52)|7875|95(09|11|15|39|98)|96(03|18|19|20|22|72))|4424(48|49|50|51|52|57)|448412|4505(19|60)|45(33|56[6-8]|61|62[^3]|6955|7452|7717|93[02379])|46(099|54(76|77)|6258|6575|98[023])|47(4107|71(73|74|86)|72(65|93)|9619)|48(1091|3622|6519)|49(7|83[5-9]|90(0[1-6]|1[0-6]|2[0-3]|3[0-3]|4[0-3]|5[0-2]|68|9[256789]))|5075(89|90|93|94|97)|51(0726|3([0-7]|8[56]|9(00|38))|5214|62(07|36)|72(22|43)|73(65|66)|7502|7647|8101|9920)|52(0993|1662|3718|7429|9227|93(13|14|31)|94(14|21|30|40|47|55|56|[6-9])|9542)|53(0901|10(28|30)|1195|23(4[4-7])|2459|25(09|34|54|56)|3801|41(02|05|11)|50(29|66)|5324|61(07|15)|71(06|12)|8011)|54(2848|5157|9538|98(5[89]))|55(39(79|93)|42(05|60)|4965|7008|88(67|82)|89(29|4[23])|9618|98(09|10))|56(0408|12(0[2-6]|4[134]|5[04678]))|58(17(0[0-7]|15|2[14]|3[16789]|4[0-9]|5[016]|6[269]|7[3789]|8[0-7]|9[017])|55(0[2-5]|7[7-9]|8[0-2])))"));
map
});
let mut no_of_supported_card_networks = 0;
let card_number_str = self.get_card_no();
for (_, regex) in CARD_NETWORK_REGEX.iter() {
let card_regex = match regex.as_ref() {
Ok(regex) => Ok(regex),
Err(_) => Err(report!(ValidationError::InvalidValue {
message: "Invalid regex expression".into(),
})),
}?;
if card_regex.is_match(&card_number_str) {
no_of_supported_card_networks += 1;
if no_of_supported_card_networks > 1 {
break;
}
}
}
Ok(no_of_supported_card_networks > 1)
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_cobadged_card",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_-4529903721819221078 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: from_str
{
// Valid test cards for threedsecureio
let valid_test_network_tokens = [
"4000100511112003",
"6000100611111203",
"3000100811111072",
"9000100111111111",
];
let network_token = network_token.split_whitespace().collect::<String>();
let is_network_token_valid = sanitize_card_number(&network_token)?;
if valid_test_network_tokens.contains(&network_token.as_str()) || is_network_token_valid {
Ok(Self(StrongSecret::new(network_token)))
} else {
Err(CardNumberValidationErr("network token invalid"))
}
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from_str",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_4090719509907874803 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: sanitize_card_number
{
let is_card_number_valid = Ok(card_number)
.and_then(validate_card_number_chars)
.and_then(validate_card_number_length)
.map(|number| luhn(&number))?;
Ok(is_card_number_valid)
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "sanitize_card_number",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_5770649892114254562 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: validate_card_number_chars
{
let data = number.chars().try_fold(
Vec::with_capacity(MAX_CARD_NUMBER_LENGTH),
|mut data, character| {
data.push(
#[allow(clippy::expect_used)]
character
.to_digit(10)
.ok_or(CardNumberValidationErr(
"invalid character found in card number",
))?
.try_into()
.expect("error while converting a single character to u8"), // safety, a single character will never be greater `u8`
);
Ok::<Vec<u8>, CardNumberValidationErr>(data)
},
)?;
Ok(data)
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "validate_card_number_chars",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_-4684749551525406764 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: validate_card_number_length
{
if number.len() >= MIN_CARD_NUMBER_LENGTH && number.len() <= MAX_CARD_NUMBER_LENGTH {
Ok(number)
} else {
Err(CardNumberValidationErr("invalid card number length"))
}
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "validate_card_number_length",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_1392407872263454969 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: luhn
{
number
.iter()
.rev()
.enumerate()
.map(|(idx, element)| {
((*element * 2) / 10 + (*element * 2) % 10) * ((idx as u8) % 2)
+ (*element) * (((idx + 1) as u8) % 2)
})
.sum::<u8>()
% 10
== 0
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "luhn",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_-8969722543016351626 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: try_from
{
let curr_year = u16::try_from(date_time::now().year()).map_err(|_| {
report!(ValidationError::InvalidValue {
message: "invalid year".to_string()
})
})?;
if year >= curr_year {
Ok(Self(StrongSecret::<u16>::new(year)))
} else {
Err(report!(ValidationError::InvalidValue {
message: "invalid card expiration year".to_string()
}))
}
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_-6403422563303116448 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: deserialize
{
let year = u16::deserialize(deserializer)?;
year.try_into().map_err(de::Error::custom)
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "deserialize",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_-4070326131862386617 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: fmt
{
let val_str: &str = val.as_ref();
if val_str.len() < 15 || val_str.len() > 19 {
return WithType::fmt(val, f);
}
if let Some(value) = val_str.get(..6) {
write!(f, "{}{}", value, "*".repeat(val_str.len() - 6))
} else {
WithType::fmt(val, f)
}
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "fmt",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_2724232053419439141 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: encode_raw
{
if !self.0.peek().is_empty() {
prost::encoding::string::encode(1, self.0.peek(), buf);
}
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "encode_raw",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_3787932175087580209 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: merge_field
{
if tag == 1 {
let mut temp_string = String::new();
prost::encoding::string::merge(wire_type, &mut temp_string, buf, ctx)?;
*self = CardNumber(StrongSecret::new(temp_string));
Ok(())
} else {
prost::encoding::skip_field(wire_type, tag, buf, ctx)
}
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "merge_field",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_-3390198332579866782 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: encoded_len
{
if !self.0.peek().is_empty() {
prost::encoding::string::encoded_len(1, self.0.peek())
} else {
0
}
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "encoded_len",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_6710905094482211648 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: valid_card_number
{
let s = "371449635398431";
assert_eq!(
CardNumber::from_str(s).unwrap(),
CardNumber(StrongSecret::from_str(s).unwrap())
);
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "valid_card_number",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_6534007621610457218 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: invalid_card_number_length
{
let s = "371446";
assert_eq!(
CardNumber::from_str(s).unwrap_err().to_string(),
"invalid card number length".to_string()
);
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "invalid_card_number_length",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_4482378709883041225 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: card_number_with_non_digit_character
{
let s = "371446431 A";
assert_eq!(
CardNumber::from_str(s).unwrap_err().to_string(),
"invalid character found in card number".to_string()
);
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "card_number_with_non_digit_character",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_5522451283480828457 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: invalid_card_number
{
let s = "371446431";
assert_eq!(
CardNumber::from_str(s).unwrap_err().to_string(),
"card number invalid".to_string()
);
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "invalid_card_number",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_7523401176785001644 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: card_number_no_whitespace
{
let s = "3714 4963 5398 431";
assert_eq!(
CardNumber::from_str(s).unwrap().to_string(),
"371449*********"
);
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "card_number_no_whitespace",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_-2635707241033700750 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: test_valid_card_number_masking
{
let secret: Secret<String, CardNumberStrategy> =
Secret::new("1234567890987654".to_string());
assert_eq!("123456**********", format!("{secret:?}"));
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_valid_card_number_masking",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_6345511159147623403 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: test_invalid_card_number_masking
{
let secret: Secret<String, CardNumberStrategy> = Secret::new("9123456789".to_string());
assert_eq!("*** alloc::string::String ***", format!("{secret:?}"));
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_invalid_card_number_masking",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_2247840550772808069 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: test_valid_card_number_strong_secret_masking
{
let card_number = CardNumber::from_str("3714 4963 5398 431").unwrap();
let secret = &(*card_number);
assert_eq!("371449*********", format!("{secret:?}"));
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_valid_card_number_strong_secret_masking",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_223984684510692136 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: test_valid_card_number_deserialization
{
let card_number = serde_json::from_str::<CardNumber>(r#""3714 4963 5398 431""#).unwrap();
let secret = card_number.to_string();
assert_eq!(r#""371449*********""#, format!("{secret:?}"));
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_valid_card_number_deserialization",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_ucs_cards_4400803078422626555 | clm | function_body | // connector-service/backend/cards/src/validate.rs
// Function: test_invalid_card_number_deserialization
{
let card_number = serde_json::from_str::<CardNumber>(r#""1234 5678""#);
let error_msg = card_number.unwrap_err().to_string();
assert_eq!(error_msg, "card number invalid".to_string());
}
| {
"chunk": null,
"crate": "ucs_cards",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_invalid_card_number_deserialization",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-6602466564389153354 | clm | function_body | // connector-service/backend/external-services/src/shared_metrics.rs
// Function: call
{
let clone = self.inner.clone();
let mut inner = std::mem::replace(&mut self.inner, clone);
let start_time = Instant::now();
// Extract method name from gRPC path
let method_name = extract_grpc_method_name(&req);
let service_name = extract_grpc_service_name(&req);
// Extract connector from request headers/metadata
let connector = extract_connector_from_request(&req);
// Increment total requests counter
GRPC_SERVER_REQUESTS_TOTAL
.with_label_values(&[&method_name, &service_name, &connector])
.inc();
req.extensions_mut().insert(service_name.clone());
Box::pin(async move {
let result = inner.call(req).await;
// Record metrics based on response
match &result {
Ok(response) => {
// Check gRPC status from response
if is_grpc_success(response) {
GRPC_SERVER_REQUESTS_SUCCESSFUL
.with_label_values(&[&method_name, &service_name, &connector])
.inc();
}
}
Err(_) => {
// Network/transport level error
}
}
// Record latency
let duration = start_time.elapsed().as_secs_f64();
GRPC_SERVER_REQUEST_LATENCY
.with_label_values(&[&method_name, &service_name, &connector])
.observe(duration);
result
})
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "call",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_503263431121531102 | clm | function_body | // connector-service/backend/external-services/src/shared_metrics.rs
// Function: extract_grpc_method_name
{
let path = req.uri().path();
if let Some(method) = path.rfind('/') {
let method_name = &path[method + 1..];
if !method_name.is_empty() {
return method_name.to_string();
}
}
"unknown_method".to_string()
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_grpc_method_name",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_8088297729169909433 | clm | function_body | // connector-service/backend/external-services/src/shared_metrics.rs
// Function: extract_grpc_service_name
{
let path = req.uri().path();
if let Some(pos) = path.rfind('/') {
let full_service = &path[1..pos];
if let Some(service_name) = full_service.rsplit('.').next() {
return service_name.to_string();
}
}
"unknown_service".to_string()
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_grpc_service_name",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_1980720506448655783 | clm | function_body | // connector-service/backend/external-services/src/shared_metrics.rs
// Function: extract_connector_from_request
{
if let Some(connector) = req.headers().get("x-connector") {
if let Ok(connector_str) = connector.to_str() {
return connector_str.to_string();
}
}
"unknown".to_string()
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_connector_from_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-5623872648773061171 | clm | function_body | // connector-service/backend/external-services/src/shared_metrics.rs
// Function: is_grpc_success
{
// gRPC success is based on grpc-status header, not HTTP status
if let Some(grpc_status) = response.headers().get("grpc-status") {
if let Ok(status_str) = grpc_status.to_str() {
if let Ok(status_code) = status_str.parse::<i32>() {
if status_code == 0 {
return true; // gRPC OK
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
true
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_grpc_success",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_7238490995989900839 | clm | function_body | // connector-service/backend/external-services/src/shared_metrics.rs
// Function: metrics_handler
{
let mut buffer = Vec::new();
let encoder = TextEncoder::new();
let metric_families = prometheus::gather();
encoder
.encode(&metric_families, &mut buffer)
.change_context(MetricsError::EncodingError)?;
String::from_utf8(buffer).change_context(MetricsError::Utf8Error)
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "metrics_handler",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_4172114858272677039 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: to_http_method
{
match self {
Self::Get => HttpMethod::GET,
Self::Post => HttpMethod::POST,
Self::Put => HttpMethod::PUT,
Self::Patch => HttpMethod::PATCH,
Self::Delete => HttpMethod::DELETE,
}
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "to_http_method",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-5961039244651565098 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: execute_connector_processing_step
{
let start = tokio::time::Instant::now();
let result = match call_connector_action {
common_enums::CallConnectorAction::HandleResponse(res) => {
let body = Response {
headers: None,
response: res.into(),
status_code: 200,
};
let status_code = body.status_code;
tracing::Span::current().record("status_code", tracing::field::display(status_code));
if let Ok(response) = parse_json_with_bom_handling(&body.response) {
tracing::Span::current().record(
"response.body",
tracing::field::display(response.masked_serialize().unwrap_or(
json!({ "error": "failed to mask serialize connector response"}),
)),
);
}
// Set raw_connector_response BEFORE calling the transformer
let mut updated_router_data = router_data.clone();
if all_keys_required.unwrap_or(true) {
let raw_response_string = strip_bom_and_convert_to_string(&body.response);
updated_router_data
.resource_common_data
.set_raw_connector_response(raw_response_string.map(Into::into));
}
let handle_response_result =
connector.handle_response_v2(&updated_router_data, None, body.clone());
let response = match handle_response_result {
Ok(data) => {
tracing::info!("Transformer completed successfully");
Ok(data)
}
Err(err) => Err(err),
}?;
Ok(response)
}
common_enums::CallConnectorAction::Trigger => {
let mut connector_request = connector.build_request_v2(&router_data.clone())?;
let mut updated_router_data = router_data.clone();
updated_router_data = match &connector_request {
Some(request) => {
updated_router_data
.resource_common_data
.set_raw_connector_request(Some(
extract_raw_connector_request(request).into(),
));
updated_router_data
}
None => updated_router_data,
};
connector_request = connector_request.map(|mut req| {
if event_params.shadow_mode {
req.add_header(
consts::X_REQUEST_ID,
Maskable::Masked(Secret::new(event_params.request_id.to_string())),
);
req.add_header(
consts::X_SOURCE_NAME,
Maskable::Masked(Secret::new(consts::X_CONNECTOR_SERVICE.to_string())),
);
req.add_header(
consts::X_FLOW_NAME,
Maskable::Masked(Secret::new(event_params.flow_name.to_string())),
);
req.add_header(
consts::X_CONNECTOR_NAME,
Maskable::Masked(Secret::new(event_params.connector_name.to_string())),
);
}
req
});
let headers = connector_request
.as_ref()
.map(|connector_request| connector_request.headers.clone())
.unwrap_or_default();
tracing::info!(?headers, "headers of connector request");
let event_headers: HashMap<String, String> = headers
.iter()
.map(|(k, v)| (k.clone(), format!("{v:?}")))
.collect();
let masked_headers = headers
.iter()
.fold(serde_json::Map::new(), |mut acc, (k, v)| {
let value = match v {
Maskable::Masked(_) => {
serde_json::Value::String("*** alloc::string::String ***".to_string())
}
Maskable::Normal(iv) => serde_json::Value::String(iv.to_owned()),
};
acc.insert(k.clone(), value);
acc
});
let headers = serde_json::Value::Object(masked_headers);
tracing::Span::current().record("request.headers", tracing::field::display(&headers));
let req = connector_request.as_ref().map(|connector_request| {
let masked_request = match connector_request.body.as_ref() {
Some(request) => match request {
RequestContent::Json(i)
| RequestContent::FormUrlEncoded(i)
| RequestContent::Xml(i) => (**i).masked_serialize().unwrap_or(
json!({ "error": "failed to mask serialize connector request"}),
),
RequestContent::FormData(_) => json!({"request_type": "FORM_DATA"}),
RequestContent::RawBytes(_) => json!({"request_type": "RAW_BYTES"}),
},
None => serde_json::Value::Null,
};
tracing::info!(request=?masked_request, "request of connector");
tracing::Span::current()
.record("request.body", tracing::field::display(&masked_request));
masked_request
});
match connector_request {
Some(request) => {
let url = request.url.clone();
let method = request.method;
metrics::EXTERNAL_SERVICE_TOTAL_API_CALLS
.with_label_values(&[
&method.to_string(),
event_params.service_name,
event_params.connector_name,
])
.inc();
let external_service_start_latency = tokio::time::Instant::now();
tracing::Span::current().record("request.url", tracing::field::display(&url));
tracing::Span::current()
.record("request.method", tracing::field::display(method));
let request_id = event_params.request_id.to_string();
let response = if let Some(token_data) = token_data {
tracing::debug!(
"Creating injector request with token data using unified API"
);
// Extract template and combine headers
let template = request
.body
.as_ref()
.ok_or(ConnectorError::RequestEncodingFailed)?
.get_inner_value()
.expose()
.to_string();
let headers = request
.headers
.iter()
.map(|(key, value)| {
(
key.clone(),
Secret::new(match value {
Maskable::Normal(val) => val.clone(),
Maskable::Masked(val) => val.clone().expose().to_string(),
}),
)
})
.chain(
updated_router_data
.resource_common_data
.get_vault_headers()
.map(|headers| {
headers.iter().map(|(k, v)| (k.clone(), v.clone()))
})
.into_iter()
.flatten(),
)
.collect();
// Create injector request
let injector_request = injector::InjectorRequest::new(
request.url.clone(),
request.method.to_http_method(),
template,
token_data,
Some(headers),
proxy
.https_url
.as_ref()
.or(proxy.http_url.as_ref())
.map(|url| Secret::new(url.clone())),
None,
None,
None,
);
// New injector handles HTTP request internally and returns enhanced response
let injector_response = injector_core(injector_request)
.await
.change_context(ConnectorError::RequestEncodingFailed)?;
// Convert injector response to connector service Response format
let response_bytes = serde_json::to_vec(&injector_response.response)
.map_err(|_| ConnectorError::ResponseHandlingFailed)?;
// Convert headers from HashMap<String, String> to reqwest::HeaderMap if present
let headers = injector_response.headers.map(|h| {
let mut header_map = reqwest::header::HeaderMap::new();
for (key, value) in h {
if let (Ok(header_name), Ok(header_value)) = (
reqwest::header::HeaderName::from_bytes(key.as_bytes()),
reqwest::header::HeaderValue::from_str(&value),
) {
header_map.insert(header_name, header_value);
}
}
header_map
});
Ok(Ok(Response {
headers,
response: response_bytes.into(),
status_code: injector_response.status_code, // Use actual status code from connector
}))
} else {
call_connector_api(proxy, request, "execute_connector_processing_step")
.await
.change_context(ConnectorError::RequestEncodingFailed)
.inspect_err(|err| {
info_log(
"NETWORK_ERROR",
&json!(format!(
"Failed getting response from connector. Error: {:?}",
err
)),
);
})
};
let external_service_elapsed = external_service_start_latency.elapsed();
metrics::EXTERNAL_SERVICE_API_CALLS_LATENCY
.with_label_values(&[
&method.to_string(),
event_params.service_name,
event_params.connector_name,
])
.observe(external_service_elapsed.as_secs_f64());
tracing::info!(?response, "response from connector");
// Extract status code BEFORE creating event - one liner
let status_code = response.as_ref().ok().map(|result| match result {
Ok(body) | Err(body) => i32::from(body.status_code),
});
// Construct masked request for event
let masked_request_data = req.as_ref().and_then(|r| {
MaskedSerdeValue::from_masked_optional(r, "connector_request")
});
let latency =
u64::try_from(external_service_elapsed.as_millis()).unwrap_or(u64::MAX);
// Create single event (response_data will be set by connector)
let mut event = Event {
request_id: request_id.to_string(),
timestamp: chrono::Utc::now().timestamp().into(),
flow_type: event_params.flow_name,
connector: event_params.connector_name.to_string(),
url: Some(url.clone()),
stage: EventStage::ConnectorCall,
latency_ms: Some(latency),
status_code,
request_data: masked_request_data,
response_data: None, // Will be set by connector via set_response_body
headers: event_headers,
additional_fields: HashMap::new(),
lineage_ids: event_params.lineage_ids.to_owned(),
};
event.add_reference_id(event_params.reference_id.as_deref());
let result = match response {
Ok(body) => {
let response = match body {
Ok(body) => {
let status_code = body.status_code;
tracing::Span::current().record(
"status_code",
tracing::field::display(status_code),
);
let is_source_verified = connector.verify(&updated_router_data, interfaces::verification::ConnectorSourceVerificationSecrets::AuthHeaders(updated_router_data.connector_auth_type.clone()), &body.response)?;
if !is_source_verified {
return Err(error_stack::report!(
ConnectorError::SourceVerificationFailed
));
}
if all_keys_required.unwrap_or(true) {
let raw_response_string =
strip_bom_and_convert_to_string(&body.response);
updated_router_data
.resource_common_data
.set_raw_connector_response(
raw_response_string.map(Into::into),
);
// Set response headers if available
updated_router_data
.resource_common_data
.set_connector_response_headers(body.headers.clone());
}
let handle_response_result = connector.handle_response_v2(
&updated_router_data,
Some(&mut event),
body.clone(),
);
// Log response body and headers using properly masked data from connector
if let Some(response_data) = &event.response_data {
tracing::Span::current().record(
"response.body",
tracing::field::display(response_data.inner()),
);
}
// Log response headers from event (already masked)
tracing::Span::current().record(
"response.headers",
tracing::field::debug(&event.headers),
);
match handle_response_result {
Ok(data) => {
tracing::info!("Transformer completed successfully");
Ok(data)
}
Err(err) => Err(err),
}?
}
Err(body) => {
metrics::EXTERNAL_SERVICE_API_CALLS_ERRORS
.with_label_values(&[
&method.to_string(),
event_params.service_name,
event_params.connector_name,
body.status_code.to_string().as_str(),
])
.inc();
if all_keys_required.unwrap_or(true) {
let raw_response_string =
strip_bom_and_convert_to_string(&body.response);
updated_router_data
.resource_common_data
.set_raw_connector_response(
raw_response_string.map(Into::into),
);
updated_router_data
.resource_common_data
.set_connector_response_headers(body.headers.clone());
}
let error = match body.status_code {
500..=511 => connector.get_5xx_error_response(
body.clone(),
Some(&mut event),
)?,
_ => connector.get_error_response_v2(
body.clone(),
Some(&mut event),
)?,
};
tracing::Span::current().record(
"response.error_message",
tracing::field::display(&error.message),
);
tracing::Span::current().record(
"response.status_code",
tracing::field::display(error.status_code),
);
updated_router_data.response = Err(error);
updated_router_data
}
};
Ok(response)
}
Err(err) => {
tracing::Span::current().record("url", tracing::field::display(url));
Err(err.change_context(ConnectorError::ProcessingStepFailed(None)))
}
};
emit_event_with_config(event, event_params.event_config);
result
}
None => Ok(router_data),
}
}
};
let result_with_integrity_check = match result {
Ok(data) => {
data.request
.check_integrity(&data.request.clone(), None)
.map_err(|err| ConnectorError::IntegrityCheckFailed {
field_names: err.field_names,
connector_transaction_id: err.connector_transaction_id,
})?;
Ok(data)
}
Err(err) => Err(err),
};
let elapsed = start.elapsed().as_millis();
tracing::Span::current().record("latency", elapsed);
tracing::info!(tag = ?Tag::OutgoingApi, log_type = "api", "Outgoing Request completed");
result_with_integrity_check
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "execute_connector_processing_step",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-2260444341298051893 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: call_connector_api
{
let url =
reqwest::Url::parse(&request.url).change_context(ApiClientError::UrlEncodingFailed)?;
let should_bypass_proxy = proxy.bypass_proxy_urls.contains(&url.to_string());
let client = create_client(
proxy,
should_bypass_proxy,
request.certificate,
request.certificate_key,
)?;
let headers = request.headers.construct_header_map()?;
// Process and log the request body based on content type
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::FormUrlEncoded(payload)) => client.form(&payload),
Some(RequestContent::Xml(payload)) => {
// For XML content, we need to extract the XML string properly
// The payload implements a custom Serialize that generates XML content
let body = serde_json::to_string(&payload)
.change_context(ApiClientError::UrlEncodingFailed)?;
// Properly deserialize the JSON string to extract clean XML
let xml_body = if body.starts_with('"') && body.ends_with('"') {
// This is a JSON-encoded string, deserialize it properly
serde_json::from_str::<String>(&body)
.change_context(ApiClientError::UrlEncodingFailed)?
} else {
// This is already the raw body content
body
};
client.body(xml_body).header("Content-Type", "text/xml")
}
Some(RequestContent::FormData(form)) => client.multipart(form),
_ => client,
}
}
Method::Put => {
let client = client.put(url);
match request.body {
Some(RequestContent::Json(payload)) => client.json(&payload),
Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload),
Some(RequestContent::Xml(payload)) => {
let body = serde_json::to_string(&payload)
.change_context(ApiClientError::UrlEncodingFailed)?;
let xml_body = if body.starts_with('"') && body.ends_with('"') {
serde_json::from_str::<String>(&body)
.change_context(ApiClientError::UrlEncodingFailed)?
} else {
body
};
client.body(xml_body).header("Content-Type", "text/xml")
}
Some(RequestContent::FormData(form)) => client.multipart(form),
_ => client,
}
}
Method::Patch => {
let client = client.patch(url);
match request.body {
Some(RequestContent::Json(payload)) => client.json(&payload),
Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload),
Some(RequestContent::Xml(payload)) => {
let body = serde_json::to_string(&payload)
.change_context(ApiClientError::UrlEncodingFailed)?;
let xml_body = if body.starts_with('"') && body.ends_with('"') {
serde_json::from_str::<String>(&body)
.change_context(ApiClientError::UrlEncodingFailed)?
} else {
body
};
client.body(xml_body).header("Content-Type", "text/xml")
}
Some(RequestContent::FormData(form)) => client.multipart(form),
_ => client,
}
}
Method::Delete => {
let client = client.delete(url);
match request.body {
Some(RequestContent::Json(payload)) => client.json(&payload),
Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload),
Some(RequestContent::Xml(payload)) => {
let body = serde_json::to_string(&payload)
.change_context(ApiClientError::UrlEncodingFailed)?;
let xml_body = if body.starts_with('"') && body.ends_with('"') {
serde_json::from_str::<String>(&body)
.change_context(ApiClientError::UrlEncodingFailed)?
} else {
body
};
client.body(xml_body).header("Content-Type", "text/xml")
}
Some(RequestContent::FormData(form)) => client.multipart(form),
_ => client,
}
}
}
.add_headers(headers)
};
let send_request = async {
request.send().await.map_err(|error| {
let api_error = match error {
error if error.is_timeout() => ApiClientError::RequestTimeoutReceived,
_ => ApiClientError::RequestNotSent(error.to_string()),
};
info_log(
"REQUEST_FAILURE",
&json!(format!("Unable to send request to connector.",)),
);
report!(api_error)
})
};
let response = send_request.await;
handle_response(response).await
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "call_connector_api",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-7005820752609541274 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: create_client
{
get_base_client(proxy_config, should_bypass_proxy)
// match (client_certificate, client_certificate_key) {
// (Some(encoded_certificate), Some(encoded_certificate_key)) => {
// let client_builder = get_client_builder(proxy_config, should_bypass_proxy)?;
// 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)
// });
// client_builder
// .identity(identity)
// .use_rustls_tls()
// .build()
// .change_context(ApiClientError::ClientConstructionFailed)
// .inspect_err(|err| {
// info_log(
// "ERROR",
// &json!(format!(
// "Failed to construct client with certificate and certificate key. Error: {:?}",
// err
// )),
// );
// })
// }
// _ => ,
// }
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_client",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-8424277478848662049 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: get_base_client
{
Ok(if should_bypass_proxy
|| (proxy_config.http_url.is_none() && proxy_config.https_url.is_none())
{
&NON_PROXIED_CLIENT
} else {
&PROXIED_CLIENT
}
.get_or_try_init(|| {
get_client_builder(proxy_config, should_bypass_proxy)?
.build()
.change_context(ApiClientError::ClientConstructionFailed)
.inspect_err(|err| {
info_log(
"ERROR",
&json!(format!("Failed to construct base client. Error: {:?}", err)),
);
})
})?
.clone())
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_base_client",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-4767538265721295944 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: load_custom_ca_certificate_from_content
{
let certificate = reqwest::Certificate::from_pem(cert_content.as_bytes())
.change_context(ApiClientError::InvalidProxyConfiguration)
.attach_printable("Failed to parse certificate PEM from provided content")?;
client_builder = client_builder.add_root_certificate(certificate);
Ok(client_builder)
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "load_custom_ca_certificate_from_content",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-7191740770390109649 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: get_client_builder
{
let mut client_builder = Client::builder()
.redirect(reqwest::redirect::Policy::none())
.pool_idle_timeout(Duration::from_secs(
proxy_config
.idle_pool_connection_timeout
.unwrap_or_default(),
));
if should_bypass_proxy {
return Ok(client_builder);
}
// Attach MITM certificate if enabled
if proxy_config.mitm_proxy_enabled {
if let Some(cert_content) = &proxy_config.mitm_ca_cert {
if !cert_content.trim().is_empty() {
client_builder =
load_custom_ca_certificate_from_content(client_builder, cert_content.trim())?;
}
}
}
// 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(ApiClientError::InvalidProxyConfiguration)
.inspect_err(|err| {
info_log(
"PROXY_ERROR",
&json!(format!("HTTPS proxy configuration error. Error: {:?}", err)),
);
})?,
);
}
// 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(ApiClientError::InvalidProxyConfiguration)
.inspect_err(|err| {
info_log(
"PROXY_ERROR",
&json!(format!("HTTP proxy configuration error. Error: {:?}", err)),
);
})?,
);
}
Ok(client_builder)
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_client_builder",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-7860840419646094093 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: handle_response
{
response
.async_map(|resp| async {
let status_code = resp.status().as_u16();
let headers = Some(resp.headers().to_owned());
match status_code {
200..=202 | 302 | 204 => {
let response = resp
.bytes()
.await
.change_context(ApiClientError::ResponseDecodingFailed)?;
Ok(Ok(Response {
headers,
response,
status_code,
}))
}
500..=599 => {
let bytes = resp.bytes().await.map_err(|error| {
report!(error).change_context(ApiClientError::ResponseDecodingFailed)
})?;
Ok(Err(Response {
headers,
response: bytes,
status_code,
}))
}
400..=499 => {
let bytes = resp.bytes().await.map_err(|error| {
report!(error).change_context(ApiClientError::ResponseDecodingFailed)
})?;
Ok(Err(Response {
headers,
response: bytes,
status_code,
}))
}
_ => {
info_log(
"UNEXPECTED_RESPONSE",
&json!("Unexpected response from server."),
);
Err(report!(ApiClientError::UnexpectedServerResponse))
}
}
})
.await?
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_-1959449871651696467 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: strip_bom_and_convert_to_string
{
String::from_utf8(response_bytes.to_vec()).ok().map(|s| {
// Remove BOM if present (UTF-8 BOM is 0xEF, 0xBB, 0xBF)
if s.starts_with('\u{FEFF}') {
s.trim_start_matches('\u{FEFF}').to_string()
} else {
s
}
})
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "strip_bom_and_convert_to_string",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_7848620400928568688 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: extract_raw_connector_request
{
// Extract actual body content
let body_content = match connector_request.body.as_ref() {
Some(request) => {
let inner_value = request.get_inner_value();
serde_json::from_str(&inner_value.expose()).unwrap_or_else(|_| {
tracing::warn!("failed to parse JSON body in extract_raw_connector_request");
json!({ "error": "failed to parse JSON body" })
})
}
None => serde_json::Value::Null,
};
// Extract unmasked headers
let headers_content = connector_request
.headers
.iter()
.map(|(k, v)| {
let value = match v {
Maskable::Normal(val) => val.clone(),
Maskable::Masked(val) => val.clone().expose().to_string(),
};
(k.clone(), value)
})
.collect::<HashMap<_, _>>();
// Create complete request with actual content
json!({
"url": connector_request.url,
"method": connector_request.method.to_string(),
"headers": headers_content,
"body": body_content
})
.to_string()
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_raw_connector_request",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_3523581762954642757 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: parse_json_with_bom_handling
{
// Try direct parsing first (most common case)
match serde_json::from_slice::<serde_json::Value>(response_bytes) {
Ok(value) => Ok(value),
Err(_) => {
// If direct parsing fails, try after removing BOM
let cleaned_response = if response_bytes.starts_with(&[0xEF, 0xBB, 0xBF]) {
// UTF-8 BOM detected, remove it
#[allow(clippy::indexing_slicing)]
&response_bytes[3..]
} else {
response_bytes
};
serde_json::from_slice::<serde_json::Value>(cleaned_response)
}
}
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_json_with_bom_handling",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_external-services_6696056494800711017 | clm | function_body | // connector-service/backend/external-services/src/service.rs
// Function: construct_header_map
{
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(ApiClientError::HeaderMapConstructionFailed)?;
let header_value = header_value.into_inner();
let header_value = HeaderValue::from_str(&header_value)
.change_context(ApiClientError::HeaderMapConstructionFailed)?;
header_map.append(header_name, header_value);
Ok(header_map)
},
)
}
| {
"chunk": null,
"crate": "external-services",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "construct_header_map",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-7209444786323127603 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_ip_address
{
let ip_address = self
.ip_address
.ok_or_else(utils::missing_field_err("browser_info.ip_address"))?;
Ok(Secret::new(ip_address.to_string()))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_ip_address",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_7945571125934558495 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_accept_header
{
self.accept_header
.clone()
.ok_or_else(utils::missing_field_err("browser_info.accept_header"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_accept_header",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-7429259318831095021 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_language
{
self.language
.clone()
.ok_or_else(utils::missing_field_err("browser_info.language"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_language",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-806592399312115496 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_screen_height
{
self.screen_height
.ok_or_else(utils::missing_field_err("browser_info.screen_height"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_screen_height",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-6423875530982077210 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_screen_width
{
self.screen_width
.ok_or_else(utils::missing_field_err("browser_info.screen_width"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_screen_width",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_8416886961401014088 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_color_depth
{
self.color_depth
.ok_or_else(utils::missing_field_err("browser_info.color_depth"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_color_depth",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_4917793438521297491 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_user_agent
{
self.user_agent
.clone()
.ok_or_else(utils::missing_field_err("browser_info.user_agent"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_user_agent",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_7327789699829497671 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_time_zone
{
self.time_zone
.ok_or_else(utils::missing_field_err("browser_info.time_zone"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_time_zone",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_6855290060646537424 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_java_enabled
{
self.java_enabled
.ok_or_else(utils::missing_field_err("browser_info.java_enabled"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_java_enabled",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_3428299074299688718 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_java_script_enabled
{
self.java_script_enabled
.ok_or_else(utils::missing_field_err("browser_info.java_script_enabled"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_java_script_enabled",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-6577527412679990216 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_referer
{
self.referer
.clone()
.ok_or_else(utils::missing_field_err("browser_info.referer"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_referer",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-2535516207904136444 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: try_from
{
let payments::AuthenticationData {
eci,
cavv,
threeds_server_transaction_id,
message_version,
ds_transaction_id,
trans_status,
acs_transaction_id,
transaction_id,
ucaf_collection_indicator,
} = value;
let threeds_server_transaction_id =
utils::extract_optional_connector_request_reference_id(&threeds_server_transaction_id);
let message_version = message_version.map(|message_version|{
SemanticVersion::from_str(&message_version).change_context(errors::ApplicationErrorResponse::BadRequest(errors::ApiError{
sub_code: "INVALID_SEMANTIC_VERSION_DATA".to_owned(),
error_identifier: 400,
error_message: "Invalid semantic version format. Expected format: 'major.minor.patch' (e.g., '2.1.0')".to_string(),
error_object: Some(serde_json::json!({
"field": "message_version",
"provided_value": message_version,
"expected_format": "major.minor.patch",
"examples": ["1.0.0", "2.1.0", "2.2.0"],
"validation_rule": "Must be in format X.Y.Z where X, Y, Z are non-negative integers"
})),
}))
}).transpose()?;
let trans_status = trans_status.map(|trans_status|{
grpc_api_types::payments::TransactionStatus::try_from(trans_status).change_context(errors::ApplicationErrorResponse::BadRequest(errors::ApiError{
sub_code: "INVALID_TRANSACTION_STATUS".to_owned(),
error_identifier: 400,
error_message: "Invalid transaction status format. Expected one of the valid 3DS transaction status values".to_string(),
error_object: Some(serde_json::json!({
"field": "transaction_status",
"provided_value": trans_status,
"expected_values": [
"Y (Success)",
"N (Failure)",
"U (Verification Not Performed)",
"A (Not Verified)",
"R (Rejected)",
"C (Challenge Required)",
"D (Challenge Required - Decoupled Authentication)",
"I (Information Only)"
],
"validation_rule": "Must be one of the valid 3DS transaction status codes (Y, N, U, A, R, C, D, I)",
"description": "Transaction status represents the result of 3D Secure authentication/verification process"
})),
}))}).transpose()?.map(common_enums::TransactionStatus::foreign_from);
Ok(Self {
ucaf_collection_indicator,
trans_status,
eci,
cavv: cavv.map(Secret::new),
threeds_server_transaction_id,
message_version,
ds_trans_id: ds_transaction_id,
acs_transaction_id,
transaction_id,
})
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_1896942585621761364 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: foreign_from
{
use hyperswitch_masking::ExposeInterface;
Self {
ucaf_collection_indicator: value.ucaf_collection_indicator,
eci: value.eci,
cavv: value.cavv.map(|cavv| cavv.expose()),
threeds_server_transaction_id: value.threeds_server_transaction_id.map(|id| {
payments::Identifier {
id_type: Some(payments::identifier::IdType::Id(id)),
}
}),
message_version: value.message_version.map(|v| v.to_string()),
ds_transaction_id: value.ds_trans_id,
trans_status: value
.trans_status
.map(payments::TransactionStatus::foreign_from)
.map(i32::from),
acs_transaction_id: value.acs_transaction_id,
transaction_id: value.transaction_id,
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "foreign_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-5362745961345584718 | clm | function_body | // connector-service/backend/domain_types/src/router_request_types.rs
// Function: get_email
{
self.email
.clone()
.ok_or_else(utils::missing_field_err("email"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_email",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_5936836728972859051 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: extract_headers_from_metadata
{
let mut vault_headers = HashMap::new();
if let Some(vault_creds) = metadata.get(X_EXTERNAL_VAULT_METADATA) {
vault_headers.insert(X_EXTERNAL_VAULT_METADATA.to_string(), vault_creds);
}
if vault_headers.is_empty() {
None
} else {
Some(vault_headers)
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_headers_from_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-5648428159486731419 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: new
{
Self {
base_url,
dispute_base_url,
secondary_base_url: None,
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_1345813950335438908 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: foreign_try_from
{
let address = match &value.address {
Some(address_value) => {
payment_address::PaymentAddress::foreign_try_from((*address_value).clone())?
}
None => {
return Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_ADDRESS".to_owned(),
error_identifier: 400,
error_message: "Address is required".to_owned(),
error_object: None,
}))?
}
};
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
let vault_headers = extract_headers_from_metadata(metadata);
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::foreign_try_from(
value.payment_method.unwrap_or_default(),
)?,
address,
auth_type: common_enums::AuthenticationType::ThreeDs, // Post-auth uses 3DS
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: value.metadata.get("description").cloned(),
return_url: value.return_url.clone(),
connector_meta_data: {
(!value.merchant_account_metadata.is_empty())
.then(|| {
serde_json::to_value(&value.merchant_account_metadata)
.map(common_utils::pii::SecretSerdeValue::new)
.map_err(|_| {
error_stack::Report::new(
ApplicationErrorResponse::InternalServerError(
crate::errors::ApiError {
sub_code: "SERDE_JSON_ERROR".to_owned(),
error_identifier: 500,
error_message:
"Failed to serialize merchant_account_metadata"
.to_owned(),
error_object: None,
},
),
)
})
})
.transpose()?
},
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
connector_response_headers: None,
vault_headers,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "foreign_try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_5406251786367767754 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: convert_card_details
{
Ok(payment_method_data::Card {
card_number: RawCardNumber(
card.card_number
.ok_or(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "MISSING_CARD_NUMBER".to_owned(),
error_identifier: 400,
error_message: "Missing card number".to_owned(),
error_object: None,
}))
.map(|cn| cn.get_card_no())?,
),
card_exp_month: card
.card_exp_month
.ok_or(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "MISSING_EXP_MONTH".to_owned(),
error_identifier: 400,
error_message: "Missing Card Expiry Month".to_owned(),
error_object: None,
}))?,
card_exp_year: card
.card_exp_year
.ok_or(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "MISSING_EXP_YEAR".to_owned(),
error_identifier: 400,
error_message: "Missing Card Expiry Year".to_owned(),
error_object: None,
}))?,
card_cvc: card
.card_cvc
.ok_or(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "MISSING_CVC".to_owned(),
error_identifier: 400,
error_message: "Missing CVC".to_owned(),
error_object: None,
}))?,
card_issuer: card.card_issuer,
card_network: None,
card_type: card.card_type,
card_issuing_country: card.card_issuing_country_alpha2,
bank_code: card.bank_code,
nick_name: card.nick_name.map(|name| name.into()),
card_holder_name: card.card_holder_name,
co_badged_card_data: None,
})
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert_card_details",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-3204081330955907656 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: foreign_from
{
match method {
common_utils::Method::Post => Self::Post,
common_utils::Method::Get => Self::Get,
common_utils::Method::Put => Self::Put,
common_utils::Method::Delete => Self::Delete,
common_utils::Method::Patch => Self::Post, // Patch is not defined in gRPC, using Post
// as a fallback
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "foreign_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-8607865889522121409 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_create_order_response
{
let transaction_response = router_data_v2.response;
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
let response = match transaction_response {
Ok(response) => {
// For successful order creation, return basic success response
PaymentServiceAuthorizeResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(
response.order_id,
)),
}),
redirection_data: None,
network_txn_id: None,
response_ref_id: None,
incremental_authorization_allowed: None,
status: grpc_status as i32,
error_message: None,
error_code: None,
status_code: 200,
raw_connector_response,
raw_connector_request,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
connector_metadata: std::collections::HashMap::new(),
state: None,
captured_amount: None,
minor_captured_amount: None,
minor_amount_capturable: None,
mandate_reference: None,
connector_response: None,
}
}
Err(err) => {
let status = err
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
PaymentServiceAuthorizeResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
redirection_data: None,
network_txn_id: None,
response_ref_id: err.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
incremental_authorization_allowed: None,
status: status as i32,
error_message: Some(err.message),
error_code: Some(err.code),
status_code: err.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
connector_metadata: std::collections::HashMap::new(),
raw_connector_response,
raw_connector_request,
state: None,
captured_amount: None,
minor_captured_amount: None,
minor_amount_capturable: None,
mandate_reference: None,
connector_response: None,
}
}
};
Ok(response)
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_create_order_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_5307564993304475998 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_payment_authorize_response
{
let transaction_response = router_data_v2.response;
let status = router_data_v2.resource_common_data.status;
info!("Payment authorize response status: {:?}", status);
let order_id = router_data_v2.resource_common_data.reference_id.clone();
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let connector_response = router_data_v2
.resource_common_data
.connector_response
.as_ref()
.map(|connector_response_data| {
grpc_api_types::payments::ConnectorResponseData::foreign_try_from(
connector_response_data.clone(),
)
})
.transpose()?;
let response = match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data,
connector_metadata,
network_txn_id,
connector_response_reference_id,
incremental_authorization_allowed,
mandate_reference,
status_code,
} => {
let mandate_reference_grpc =
mandate_reference.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
});
PaymentServiceAuthorizeResponse {
transaction_id: Some(grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?),
redirection_data: redirection_data.map(
|form| {
match *form {
crate::router_response_types::RedirectForm::Form { endpoint, method, form_fields } => {
Ok::<grpc_api_types::payments::RedirectForm, ApplicationErrorResponse>(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Form(
grpc_api_types::payments::FormData {
endpoint,
method: grpc_api_types::payments::HttpMethod::foreign_from(method) as i32,
form_fields, //TODO
}
))
})
},
router_response_types::RedirectForm::Html { html_data } => {
Ok(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Html(
grpc_api_types::payments::HtmlData {
html_data,
}
))
})
},
router_response_types::RedirectForm::Uri { uri } => {
Ok(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Uri(
grpc_api_types::payments::UriData {
uri,
}
))
})
},
crate::router_response_types::RedirectForm::Mifinity { initialization_token } => {
Ok(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Uri(
grpc_api_types::payments::UriData {
uri: initialization_token,
}
))
})
},
_ => Err(
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
}
}
).transpose()?,
connector_metadata: connector_metadata
.and_then(|value| value.as_object().cloned())
.map(|map| {map.into_iter().filter_map(|(k, v)| v.as_str()
.map(|s| (k, s.to_string())))
.collect::<HashMap<_, _>>()}).unwrap_or_default(),
network_txn_id,
response_ref_id: connector_response_reference_id.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}),
mandate_reference: mandate_reference_grpc,
incremental_authorization_allowed,
status: grpc_status as i32,
error_message: None,
error_code: None,
raw_connector_response,
raw_connector_request,
status_code: status_code as u32,
response_headers,
state,
captured_amount: router_data_v2.resource_common_data.amount_captured,
minor_captured_amount: router_data_v2
.resource_common_data
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
minor_amount_capturable: router_data_v2
.resource_common_data
.minor_amount_capturable
.map(|amount_capturable| amount_capturable.get_amount_as_i64()),
connector_response,
}
}
_ => Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
},
Err(err) => {
let status = err
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
PaymentServiceAuthorizeResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
redirection_data: None,
network_txn_id: None,
response_ref_id: order_id.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}),
mandate_reference: None,
incremental_authorization_allowed: None,
status: status as i32,
error_message: Some(err.message),
error_code: Some(err.code),
status_code: err.status_code as u32,
response_headers,
raw_connector_response,
raw_connector_request,
connector_metadata: std::collections::HashMap::new(),
state,
captured_amount: None,
minor_captured_amount: None,
minor_amount_capturable: None,
connector_response: None,
}
}
};
Ok(response)
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_payment_authorize_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_7637267764714927020 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_payment_void_response
{
let transaction_response = router_data_v2.response;
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: _,
connector_metadata: _,
network_txn_id: _,
connector_response_reference_id,
incremental_authorization_allowed,
mandate_reference,
status_code,
} => {
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let grpc_resource_id =
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?;
let mandate_reference_grpc =
mandate_reference.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
});
Ok(PaymentServiceVoidResponse {
transaction_id: Some(grpc_resource_id),
status: grpc_status.into(),
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: None,
error_message: None,
status_code: u32::from(status_code),
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
raw_connector_request,
state,
mandate_reference: mandate_reference_grpc,
incremental_authorization_allowed,
})
}
_ => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "INVALID_RESPONSE_TYPE".to_owned(),
error_identifier: 500,
error_message: "Invalid response type received from connector".to_owned(),
error_object: None,
}
))),
},
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(PaymentServiceVoidResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
response_ref_id: e.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
status: status as i32,
error_message: Some(e.message),
error_code: Some(e.code),
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state: None,
raw_connector_request,
mandate_reference: None,
incremental_authorization_allowed: None,
})
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_payment_void_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-4370289689367593198 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_payment_void_post_capture_response
{
let transaction_response = router_data_v2.response;
// If there's an access token in PaymentFlowData, it must be newly generated (needs caching)
let _state = router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| ConnectorState {
access_token: Some(grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
});
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: _,
connector_metadata: _,
network_txn_id: _,
connector_response_reference_id,
incremental_authorization_allowed: _,
mandate_reference: _,
status_code,
} => {
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let grpc_resource_id =
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?;
Ok(PaymentServiceVoidPostCaptureResponse {
transaction_id: Some(grpc_resource_id),
status: grpc_status.into(),
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: None,
error_message: None,
status_code: u32::from(status_code),
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
})
}
_ => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "INVALID_RESPONSE_TYPE".to_owned(),
error_identifier: 500,
error_message: "Invalid response type received from connector".to_owned(),
error_object: None,
}
))),
},
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(PaymentServiceVoidPostCaptureResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
status: status.into(),
response_ref_id: e.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: Some(e.code),
error_message: Some(e.message),
status_code: u32::from(e.status_code),
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
})
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_payment_void_post_capture_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_7097838368851244234 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_payment_sync_response
{
let transaction_response = router_data_v2.response;
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
let connector_response = router_data_v2
.resource_common_data
.connector_response
.as_ref()
.map(|connector_response_data| {
grpc_api_types::payments::ConnectorResponseData::foreign_try_from(
connector_response_data.clone(),
)
})
.transpose()?;
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: _,
connector_metadata: _,
network_txn_id,
connector_response_reference_id,
incremental_authorization_allowed: _,
mandate_reference,
status_code,
} => {
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let grpc_resource_id =
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?;
let mandate_reference_grpc =
mandate_reference.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
});
Ok(PaymentServiceGetResponse {
transaction_id: Some(grpc_resource_id),
status: grpc_status as i32,
mandate_reference: mandate_reference_grpc,
error_code: None,
error_message: None,
network_txn_id,
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
amount: None,
minor_amount: None,
currency: None,
captured_amount: router_data_v2.resource_common_data.amount_captured,
minor_captured_amount: router_data_v2
.resource_common_data
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
payment_method_type: None,
capture_method: None,
auth_type: None,
created_at: None,
updated_at: None,
authorized_at: None,
captured_at: None,
customer_name: None,
email: None,
connector_customer_id: None,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
status_code: status_code as u32,
raw_connector_response,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response,
})
}
_ => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "INVALID_RESPONSE_TYPE".to_owned(),
error_identifier: 500,
error_message: "Invalid response type received from connector".to_owned(),
error_object: None,
}
))),
},
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(PaymentServiceGetResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(if let Some(txn_id) = e.connector_transaction_id {
grpc_api_types::payments::identifier::IdType::Id(txn_id)
} else {
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(())
}),
}),
mandate_reference: None,
status: status as i32,
error_message: Some(e.message),
error_code: Some(e.code),
network_txn_id: None,
response_ref_id: None,
amount: None,
minor_amount: None,
currency: None,
captured_amount: None,
minor_captured_amount: None,
payment_method_type: None,
capture_method: None,
auth_type: None,
created_at: None,
updated_at: None,
authorized_at: None,
captured_at: None,
customer_name: None,
email: None,
connector_customer_id: None,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
raw_connector_response,
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response: None,
})
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_payment_sync_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_4327484497991821407 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_accept_dispute_response
{
let dispute_response = router_data_v2.response;
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match dispute_response {
Ok(response) => {
let grpc_status =
grpc_api_types::payments::DisputeStatus::foreign_from(response.dispute_status);
Ok(AcceptDisputeResponse {
dispute_status: grpc_status.into(),
dispute_id: response.connector_dispute_id,
connector_status_code: None,
error_message: None,
error_code: None,
response_ref_id: None,
status_code: response.status_code as u32,
response_headers,
raw_connector_request,
})
}
Err(e) => {
let grpc_dispute_status = grpc_api_types::payments::DisputeStatus::default();
Ok(AcceptDisputeResponse {
dispute_status: grpc_dispute_status as i32,
dispute_id: e.connector_transaction_id.unwrap_or_default(),
connector_status_code: None,
error_message: Some(e.message),
error_code: Some(e.code),
response_ref_id: None,
status_code: e.status_code as u32,
response_headers,
raw_connector_request,
})
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_accept_dispute_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_3597507176957991578 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_submit_evidence_response
{
let dispute_response = router_data_v2.response;
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match dispute_response {
Ok(response) => {
let grpc_status =
grpc_api_types::payments::DisputeStatus::foreign_from(response.dispute_status);
Ok(DisputeServiceSubmitEvidenceResponse {
dispute_status: grpc_status.into(),
dispute_id: Some(response.connector_dispute_id),
submitted_evidence_ids: vec![],
connector_status_code: None,
error_message: None,
error_code: None,
response_ref_id: None,
status_code: response.status_code as u32,
response_headers,
raw_connector_request,
})
}
Err(e) => {
let grpc_attempt_status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(DisputeServiceSubmitEvidenceResponse {
dispute_status: grpc_attempt_status.into(),
dispute_id: e.connector_transaction_id,
submitted_evidence_ids: vec![],
connector_status_code: None,
error_message: Some(e.message),
error_code: Some(e.code),
response_ref_id: None,
status_code: e.status_code as u32,
response_headers,
raw_connector_request,
})
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_submit_evidence_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_92883177999497284 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_refund_sync_response
{
let refunds_response = router_data_v2.response;
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match refunds_response {
Ok(response) => {
let status = response.refund_status;
let grpc_status = grpc_api_types::payments::RefundStatus::foreign_from(status);
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
Ok(RefundResponse {
transaction_id: Some(grpc_api_types::payments::Identifier::default()),
refund_id: response.connector_refund_id.clone(),
status: grpc_status as i32,
response_ref_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(
response.connector_refund_id.clone(),
)),
}),
error_code: None,
error_message: None,
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
raw_connector_response,
status_code: response.status_code as u32,
response_headers,
state: None,
raw_connector_request,
})
}
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
Ok(RefundResponse {
transaction_id: Some(
e.connector_transaction_id
.as_ref()
.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(
id.clone(),
)),
})
.unwrap_or_default(),
),
refund_id: String::new(),
status: status as i32,
response_ref_id: e.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: Some(e.code),
error_message: Some(e.message),
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
raw_connector_response,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
status_code: e.status_code as u32,
response_headers,
state: None,
raw_connector_request,
})
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_refund_sync_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-5473603701916895073 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_refund_response
{
let refund_response = router_data_v2.response;
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
// RefundFlowData doesn't have access_token field, so no state to return
let state = None;
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match refund_response {
Ok(response) => {
let status = response.refund_status;
let grpc_status = grpc_api_types::payments::RefundStatus::foreign_from(status);
Ok(RefundResponse {
transaction_id: Some(grpc_api_types::payments::Identifier::default()),
refund_id: response.connector_refund_id,
status: grpc_status as i32,
response_ref_id: None,
error_code: None,
error_message: None,
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
merchant_order_reference_id: None,
raw_connector_response,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
status_code: response.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
})
}
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(RefundResponse {
transaction_id: Some(
e.connector_transaction_id
.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
})
.unwrap_or_default(),
),
refund_id: String::new(),
status: status as i32,
response_ref_id: None,
error_code: Some(e.code),
error_message: Some(e.message),
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
raw_connector_response,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
})
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_refund_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_5063655948150355455 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_payment_capture_response
{
let transaction_response = router_data_v2.response;
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: _,
connector_metadata: _,
network_txn_id: _,
connector_response_reference_id,
incremental_authorization_allowed,
mandate_reference,
status_code,
} => {
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let grpc_resource_id =
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?;
let mandate_reference_grpc =
mandate_reference.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
});
Ok(PaymentServiceCaptureResponse {
transaction_id: Some(grpc_resource_id),
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: None,
error_message: None,
status: grpc_status.into(),
status_code: status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
incremental_authorization_allowed,
mandate_reference: mandate_reference_grpc,
captured_amount: router_data_v2.resource_common_data.amount_captured,
minor_captured_amount: router_data_v2
.resource_common_data
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
})
}
_ => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "INVALID_RESPONSE_TYPE".to_owned(),
error_identifier: 500,
error_message: "Invalid response type received from connector".to_owned(),
error_object: None,
}
))),
},
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(PaymentServiceCaptureResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
response_ref_id: e.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
status: status.into(),
error_message: Some(e.message),
error_code: Some(e.code),
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
incremental_authorization_allowed: None,
mandate_reference: None,
captured_amount: None,
minor_captured_amount: None,
})
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_payment_capture_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-6035007039868011658 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_setup_mandate_response
{
let transaction_response = router_data_v2.response;
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
let connector_response = router_data_v2
.resource_common_data
.connector_response
.as_ref()
.map(|connector_response_data| {
grpc_api_types::payments::ConnectorResponseData::foreign_try_from(
connector_response_data.clone(),
)
})
.transpose()?;
let response = match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data,
connector_metadata: _,
network_txn_id,
connector_response_reference_id,
incremental_authorization_allowed,
mandate_reference,
status_code,
} => {
PaymentServiceRegisterResponse {
registration_id: Some(grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?),
redirection_data: redirection_data.map(
|form| {
match *form {
router_response_types::RedirectForm::Form { endpoint, method, form_fields: _ } => {
Ok::<grpc_api_types::payments::RedirectForm, ApplicationErrorResponse>(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Form(
grpc_api_types::payments::FormData {
endpoint,
method: match method {
Method::Get => 1,
Method::Post => 2,
Method::Put => 3,
Method::Delete => 4,
_ => 0,
},
form_fields: HashMap::default(), //TODO
}
))
})
},
router_response_types::RedirectForm::Html { html_data } => {
Ok(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Html(
grpc_api_types::payments::HtmlData {
html_data,
}
))
})
},
_ => Err(
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
}
}
).transpose()?,
network_txn_id,
response_ref_id: connector_response_reference_id.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}),
status: grpc_status as i32,
mandate_reference: Some(grpc_api_types::payments::MandateReference {
mandate_id: mandate_reference.clone().and_then(|m| m.connector_mandate_id),
payment_method_id: mandate_reference.and_then(|m| m.payment_method_id),
}),
incremental_authorization_allowed,
error_message: None,
error_code: None,
status_code: status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response,
}
}
_ => Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
},
Err(err) => PaymentServiceRegisterResponse {
registration_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(())),
}),
redirection_data: None,
network_txn_id: None,
response_ref_id: err.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
status: grpc_status as i32,
mandate_reference: None,
incremental_authorization_allowed: None,
error_message: Some(err.message),
error_code: Some(err.code),
status_code: err.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response: None,
},
};
Ok(response)
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_setup_mandate_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_8387549574810344720 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_defend_dispute_response
{
let defend_dispute_response = router_data_v2.response;
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match defend_dispute_response {
Ok(response) => Ok(DisputeDefendResponse {
dispute_id: response.connector_dispute_id,
dispute_status: response.dispute_status as i32,
connector_status_code: None,
error_message: None,
error_code: None,
response_ref_id: None,
status_code: response.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
raw_connector_request,
}),
Err(e) => Ok(DisputeDefendResponse {
dispute_id: e
.connector_transaction_id
.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
dispute_status: common_enums::DisputeStatus::DisputeLost as i32,
connector_status_code: None,
error_message: Some(e.message),
error_code: Some(e.code),
response_ref_id: None,
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
raw_connector_request,
}),
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_defend_dispute_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-1003705216086411148 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_session_token_response
{
let session_token_response = router_data_v2.response;
match session_token_response {
Ok(response) => Ok(response.session_token),
Err(e) => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "SESSION_TOKEN_ERROR".to_string(),
error_identifier: 500,
error_message: format!("Session token creation failed: {}", e.message),
error_object: None,
}
))),
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_session_token_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_8307721890582249058 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_payment_method_token_response
{
let payment_method_token_response = router_data_v2.response;
match payment_method_token_response {
Ok(response) => Ok(response.token),
Err(e) => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "PAYMENT_METHOD_TOKEN_ERROR".to_string(),
error_identifier: 500,
error_message: format!("Payment method token creation failed: {}", e.message),
error_object: None,
}
))),
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_payment_method_token_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_2484801577035817352 | clm | function_body | // connector-service/backend/domain_types/src/types.rs
// Function: generate_repeat_payment_response
{
let transaction_response = router_data_v2.response;
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
network_txn_id,
connector_response_reference_id,
connector_metadata,
mandate_reference,
status_code,
..
} => Ok(
grpc_api_types::payments::PaymentServiceRepeatEverythingResponse {
transaction_id: Some(grpc_api_types::payments::Identifier::foreign_try_from(
resource_id,
)?),
status: grpc_status as i32,
error_code: None,
error_message: None,
network_txn_id,
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
connector_metadata: connector_metadata
.and_then(|value| value.as_object().cloned())
.map(|map| {
map.into_iter()
.filter_map(|(k, v)| v.as_str().map(|s| (k, s.to_string())))
.collect::<HashMap<_, _>>()
})
.unwrap_or_default(),
mandate_reference: mandate_reference.map(|m| {
grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
}
}),
status_code: status_code as u32,
raw_connector_response,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response: router_data_v2
.resource_common_data
.connector_response
.and_then(|data| {
grpc_api_types::payments::ConnectorResponseData::foreign_try_from(data)
.ok()
}),
captured_amount: router_data_v2.resource_common_data.amount_captured,
minor_captured_amount: router_data_v2
.resource_common_data
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
},
),
_ => Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
},
Err(err) => {
let status = err
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(
grpc_api_types::payments::PaymentServiceRepeatEverythingResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
status: status as i32,
error_code: Some(err.code),
error_message: Some(err.message),
network_txn_id: None,
response_ref_id: err.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
connector_metadata: HashMap::new(),
raw_connector_response: None,
status_code: err.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
mandate_reference: None,
raw_connector_request,
connector_response: None,
captured_amount: None,
minor_captured_amount: None,
},
)
}
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_repeat_payment_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-3235651235271002766 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: new
{
// billing -> .billing, this is the billing details passed in the root of payments request
// payment_method_billing -> .payment_method_data.billing
let unified_payment_method_billing = if should_unify_address.unwrap_or(true) {
// Merge the billing details field from both `payment.billing` and `payment.payment_method_data.billing`
// The unified payment_method_billing will be used as billing address and passed to the connector module
// This unification is required in order to provide backwards compatibility
// so that if `payment.billing` is passed it should be sent to the connector module
// Unify the billing details with `payment_method_data.billing`
payment_method_billing
.as_ref()
.map(|payment_method_billing| {
payment_method_billing
.clone()
.unify_address(billing.as_ref())
})
.or(billing.clone())
} else {
payment_method_billing.clone()
};
Self {
shipping,
billing,
unified_payment_method_billing,
payment_method_billing,
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_2955161330460120233 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: unify_with_payment_method_data_billing
{
// Unify the billing details with `payment_method_data.billing_details`
let unified_payment_method_billing = payment_method_data_billing
.map(|payment_method_data_billing| {
payment_method_data_billing.unify_address(self.get_payment_method_billing())
})
.or(self.get_payment_method_billing().cloned());
Self {
shipping: self.shipping,
billing: self.billing,
unified_payment_method_billing,
payment_method_billing: self.payment_method_billing,
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "unify_with_payment_method_data_billing",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-3323115700721975692 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: unify_address
{
let other_address_details = other.and_then(|address| address.address.as_ref());
Self {
address: self
.address
.map(|address| address.unify_address_details(other_address_details))
.or(other_address_details.cloned()),
email: self.email.or(other.and_then(|other| other.email.clone())),
phone: self.phone.or(other.and_then(|other| other.phone.clone())),
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "unify_address",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-6475035949860880325 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_phone_with_country_code
{
self.phone
.clone()
.map(|phone_details| phone_details.get_number_with_country_code())
.transpose()?
.ok_or_else(missing_field_err("phone"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_phone_with_country_code",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-7792149512651628040 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_optional_full_name
{
match (self.first_name.as_ref(), self.last_name.as_ref()) {
(Some(first_name), Some(last_name)) => Some(Secret::new(format!(
"{} {}",
first_name.peek(),
last_name.peek()
))),
(Some(name), None) | (None, Some(name)) => Some(name.to_owned()),
_ => None,
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_optional_full_name",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-5766534633677495448 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: unify_address_details
{
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()),
}
} else {
self
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "unify_address_details",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_3436067376799441037 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_first_name
{
self.first_name
.as_ref()
.ok_or_else(missing_field_err("address.first_name"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_first_name",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-6935447366986556910 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_last_name
{
self.last_name
.as_ref()
.ok_or_else(missing_field_err("address.last_name"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_last_name",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_4183921000471658802 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_full_name
{
let first_name = self.get_first_name()?.peek().to_owned();
let last_name = self
.get_last_name()
.ok()
.cloned()
.unwrap_or(Secret::new("".to_string()));
let last_name = last_name.peek();
let full_name = format!("{first_name} {last_name}").trim().to_string();
Ok(Secret::new(full_name))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_full_name",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-3786522604797827136 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_line1
{
self.line1
.as_ref()
.ok_or_else(missing_field_err("address.line1"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_line1",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_7165983519105187303 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_city
{
self.city
.as_ref()
.ok_or_else(missing_field_err("address.city"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_city",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-8732517709561973306 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_state
{
self.state
.as_ref()
.ok_or_else(missing_field_err("address.state"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_state",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-6411560175852186816 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_line2
{
self.line2
.as_ref()
.ok_or_else(missing_field_err("address.line2"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_line2",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_3039805038005019255 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_zip
{
self.zip
.as_ref()
.ok_or_else(missing_field_err("address.zip"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_zip",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-49677851189454821 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_country
{
self.country
.as_ref()
.ok_or_else(missing_field_err("address.country"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_country",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-6032862379470059663 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_combined_address_line
{
Ok(Secret::new(format!(
"{},{}",
self.get_line1()?.peek(),
self.get_line2()?.peek()
)))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_combined_address_line",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_892611390386466067 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: to_state_code
{
let country = self.get_country()?;
let state = self.get_state()?;
match country {
common_enums::CountryAlpha2::US => Ok(Secret::new(
convert_us_state_to_code(&state.peek().to_string()).to_string(),
)),
_ => Ok(state.clone()),
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "to_state_code",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_1880273672394021769 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: to_state_code_as_optional
{
self.state
.as_ref()
.map(|state| {
if state.peek().len() == 2 {
Ok(state.to_owned())
} else {
self.to_state_code()
}
})
.transpose()
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "to_state_code_as_optional",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-4496827198293862672 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_country_code
{
self.country_code
.clone()
.ok_or_else(missing_field_err("billing.phone.country_code"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_country_code",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-2838860010243520851 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: extract_country_code
{
self.get_country_code()
.map(|cc| cc.trim_start_matches('+').to_string())
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_country_code",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_6140352177073431464 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_number
{
self.number
.clone()
.ok_or_else(missing_field_err("billing.phone.number"))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_number",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-6937353415402565242 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_number_with_country_code
{
let number = self.get_number()?;
let country_code = self.get_country_code()?;
Ok(Secret::new(format!("{}{}", country_code, number.peek())))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_number_with_country_code",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_-4810755106811170471 | clm | function_body | // connector-service/backend/domain_types/src/payment_address.rs
// Function: get_number_with_hash_country_code
{
let number = self.get_number()?;
let country_code = self.get_country_code()?;
let number_without_plus = country_code.trim_start_matches('+');
Ok(Secret::new(format!(
"{}#{}",
number_without_plus,
number.peek()
)))
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_number_with_hash_country_code",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_776626725897399639 | clm | function_body | // connector-service/backend/domain_types/src/connector_types.rs
// Function: foreign_try_from
{
Ok(Self {
secret: value.secret.into(),
additional_secret: value.additional_secret.map(Secret::new),
})
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "foreign_try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_domain_types_4139114646262505786 | clm | function_body | // connector-service/backend/domain_types/src/connector_types.rs
// Function: new
{
Self {
mandate_id: Some(mandate_id),
mandate_reference_id: None,
}
}
| {
"chunk": null,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.