text
stringlengths
70
351k
source
stringclasses
4 values
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/user_role.rs | crate: router use std::collections::{HashMap, HashSet}; use api_models::{ user as user_api, user_role::{self as user_role_api, role as role_api}, }; use once_cell::sync::Lazy; use crate::{ core::errors::{StorageErrorExt, UserErrors, UserResponse}, db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload}, routes::{app::ReqState, SessionState}, services::{ authentication as auth, authorization::{ info, permission_groups::{ParentGroupExt, PermissionGroupExt}, roles, }, ApplicationResponse, }, types::domain, utils, }; use common_enums::{EntityType, ParentGroup, PermissionGroup}; pub async fn get_authorization_info_with_group_tag( ) -> UserResponse<user_role_api::AuthorizationInfoResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/user_role.rs | crate: router domain::CurrentFlow::new(user_token, domain::SPTFlow::MerchantSelect.into())?; let next_flow = current_flow.next(user_from_db.clone(), &state).await?; let token = next_flow.get_token(&state).await?; let response = user_api::TokenResponse { token: token.clone(), token_type: next_flow.get_flow().into(), }; auth::cookies::set_cookie_response(response, token) } pub async fn delete_user_role( state: SessionState, user_from_token: auth::UserFromToken, request: user_role_api::DeleteUserRoleRequest, _req_state: ReqState, ) -> UserResponse<()> { let user_from_db: domain::UserFromStorage = state .global_store .find_user_by_email(&domain::UserEmail::from_pii_email(request.email)?) .await .map_err(|e| { if e.current_context().is_db_not_found() { e.change_context(UserErrors::InvalidRoleOperation) pub async fn delete_user_role( state: SessionState, user_from_token: auth::UserFromToken, request: user_role_api::DeleteUserRoleRequest, _req_state: ReqState, ) -> UserResponse<()> { { Ok(user_role) => Some(user_role),<|fim_suffix|> <|fim_middle|> Err(e) => { if e.current_context().is_db_not_found() { None } else { return Err(UserErrors::InternalServerError.into()); } } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/user_role.rs | crate: router .filter_map(|group| (group.parent() == parent_group).then_some(group.scope())) // TODO: Remove this hashset conversion when merhant access // and organization access groups are removed .collect::<HashSet<_>>() .into_iter() .collect(), }) .collect::<Vec<_>>(); Ok(ApplicationResponse::Json(parent_groups)) } pub async fn update_user_role( state: SessionState, user_from_token: auth::UserFromToken, req: user_role_api::UpdateUserRoleRequest, _req_state: ReqState, ) -> UserResponse<()> { let role_info = roles::RoleInfo::from_role_id_in_lineage( &state, &req.role_id, &user_from_token.merchant_id, &user_from_token.org_id, &user_from_token.profile_id, user_from_token pub async fn update_user_role( state: SessionState, user_from_token: auth::UserFromToken, req: user_role_api::UpdateUserRoleRequest, _req_state: ReqState, ) -> UserResponse<()> { { Ok(user_role) => Some(user_role),<|fim_suffix|> <|fim_middle|> Err(e) => { if e.current_context().is_db_not_found() { None } else { return Err(UserErrors::InternalServerError.into()); } } } }
ast_fragments
// file: hyperswitch/crates/router/src/core/user_role.rs | crate: router use api_models::{ user as user_api, user_role::{self as user_role_api, role as role_api}, }; use crate::{ core::errors::{StorageErrorExt, UserErrors, UserResponse}, db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload}, routes::{app::ReqState, SessionState}, services::{ authentication as auth, authorization::{ info, permission_groups::{ParentGroupExt, PermissionGroupExt}, roles, }, ApplicationResponse, }, types::domain, utils, }; pub async fn get_authorization_info_with_groups( _state: SessionState, ) -> UserResponse<user_role_api::AuthorizationInfoResponse> { Ok(ApplicationResponse::Json( user_role_api::AuthorizationInfoResponse( info::get_group_authorization_info() .into_iter() .map(user_role_api::AuthorizationInfo::Group) .collect(), ), )) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/user_role.rs | crate: router use std::collections::{HashMap, HashSet}; use api_models::{ user as user_api, user_role::{self as user_role_api, role as role_api}, }; use diesel_models::{ enums::{UserRoleVersion, UserStatus}, organization::OrganizationBridge, user_role::UserRoleUpdate, }; use error_stack::{report, ResultExt}; use masking::Secret; use crate::{ core::errors::{StorageErrorExt, UserErrors, UserResponse}, db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload}, routes::{app::ReqState, SessionState}, services::{ authentication as auth, authorization::{ info, permission_groups::{ParentGroupExt, PermissionGroupExt}, roles, }, ApplicationResponse, }, types::domain, utils, }; use common_enums::{EntityType, ParentGroup, PermissionGroup}; pub async fn list_invitations_for_user( state: SessionState, user_from_token: auth::UserIdFromAuth, ) -> UserResponse<Vec<user_role_api::ListInvitationForUserResponse>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/user_role.rs | crate: router use std::collections::{HashMap, HashSet}; use api_models::{ user as user_api, user_role::{self as user_role_api, role as role_api}, }; use diesel_models::{ enums::{UserRoleVersion, UserStatus}, organization::OrganizationBridge, user_role::UserRoleUpdate, }; use error_stack::{report, ResultExt}; use crate::{ core::errors::{StorageErrorExt, UserErrors, UserResponse}, db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload}, routes::{app::ReqState, SessionState}, services::{ authentication as auth, authorization::{ info, permission_groups::{ParentGroupExt, PermissionGroupExt}, roles, }, ApplicationResponse, }, types::domain, utils, }; use common_enums::{EntityType, ParentGroup, PermissionGroup}; pub async fn list_users_in_lineage( state: SessionState, user_from_token: auth::UserFromToken, request: user_role_api::ListUsersInEntityRequest, ) -> UserResponse<Vec<user_role_api::ListUsersInEntityResponse>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/user_role.rs | crate: router use api_models::{ user as user_api, user_role::{self as user_role_api, role as role_api}, }; use diesel_models::{ enums::{UserRoleVersion, UserStatus}, organization::OrganizationBridge, user_role::UserRoleUpdate, }; use error_stack::{report, ResultExt}; use crate::{ core::errors::{StorageErrorExt, UserErrors, UserResponse}, db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload}, routes::{app::ReqState, SessionState}, services::{ authentication as auth, authorization::{ info, permission_groups::{ParentGroupExt, PermissionGroupExt}, roles, }, ApplicationResponse, }, types::domain, utils, }; pub async fn delete_user_role( state: SessionState, user_from_token: auth::UserFromToken, request: user_role_api::DeleteUserRoleRequest, _req_state: ReqState, ) -> UserResponse<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/user_role.rs | crate: router use api_models::{ user as user_api, user_role::{self as user_role_api, role as role_api}, }; use diesel_models::{ enums::{UserRoleVersion, UserStatus}, organization::OrganizationBridge, user_role::UserRoleUpdate, }; use error_stack::{report, ResultExt}; use crate::{ core::errors::{StorageErrorExt, UserErrors, UserResponse}, db::user_role::{ListUserRolesByOrgIdPayload, ListUserRolesByUserIdPayload}, routes::{app::ReqState, SessionState}, services::{ authentication as auth, authorization::{ info, permission_groups::{ParentGroupExt, PermissionGroupExt}, roles, }, ApplicationResponse, }, types::domain, utils, }; pub async fn update_user_role( state: SessionState, user_from_token: auth::UserFromToken, req: user_role_api::UpdateUserRoleRequest, _req_state: ReqState, ) -> UserResponse<()> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/external_service_auth.rs | crate: router use api_models::external_service_auth as external_service_auth_api; use common_utils::fp_utils; use crate::{ core::errors::{self, RouterResponse}, services::{ api as service_api, authentication::{self, ExternalServiceType, ExternalToken}, }, SessionState, }; pub async fn verify_external_token( state: SessionState, json_payload: external_service_auth_api::ExternalVerifyTokenRequest, external_service_type: ExternalServiceType, ) -> RouterResponse<external_service_auth_api::ExternalVerifyTokenResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/external_service_auth.rs | crate: router use api_models::external_service_auth as external_service_auth_api; use crate::{ core::errors::{self, RouterResponse}, services::{ api as service_api, authentication::{self, ExternalServiceType, ExternalToken}, }, SessionState, }; pub async fn generate_external_token( state: SessionState, user: authentication::UserFromToken, external_service_type: ExternalServiceType, ) -> RouterResponse<external_service_auth_api::ExternalTokenResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/external_service_auth.rs | crate: router use api_models::external_service_auth as external_service_auth_api; use crate::{ core::errors::{self, RouterResponse}, services::{ api as service_api, authentication::{self, ExternalServiceType, ExternalToken}, }, SessionState, }; pub async fn signout_external_token( state: SessionState, json_payload: external_service_auth_api::ExternalSignoutTokenRequest, ) -> RouterResponse<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/external_service_auth.rs | crate: router use api_models::external_service_auth as external_service_auth_api; use crate::{ core::errors::{self, RouterResponse}, services::{ api as service_api, authentication::{self, ExternalServiceType, ExternalToken}, }, SessionState, }; pub async fn signout_external_token( state: SessionState, json_payload: external_service_auth_api::ExternalSignoutTokenRequest, ) -> RouterResponse<()> { let token = authentication::decode_jwt::<ExternalToken>(&json_payload.token.expose(), &state) .await .change_context(errors::ApiErrorResponse::Unauthorized)?; authentication::blacklist::insert_user_in_blacklist(&state, &token.user_id) .await .change_context(errors::ApiErrorResponse::InvalidJwtToken)?; Ok(service_api::ApplicationResponse::StatusOk) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use error_stack::{report, ResultExt}; use masking::{PeekInterface, Secret}; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; fn validate_order_details( order_details: Option<Vec<Secret<serde_json::Value>>>, currency: api_models::enums::Currency, ) -> Result< Option<Vec<api_models::payments::OrderDetailsWithStringAmount>>, error_stack::Report<errors::ApiErrorResponse>, > { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use hyperswitch_domain_models::api::{GenericLinks, GenericLinksData}; use router_env::logger; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub async fn initiate_payment_link_flow( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: common_utils::id_type::PaymentId, ) -> RouterResponse<services::PaymentLinkFormData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router #[cfg(feature = "v2")] pub async fn get_payment_link_status( _state: SessionState, _merchant_account: domain::MerchantAccount, _key_store: domain::MerchantKeyStore, _merchant_id: common_utils::id_type::MerchantId, _payment_id: common_utils::id_type::PaymentId, ) -> RouterResponse<services::PaymentLinkFormData> { todo!() } #[cfg(feature = "v1")] pub async fn get_payment_link_status( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: common_utils::id_type::PaymentId, ) -> RouterResponse<services::PaymentLinkFormData> { let db = &*state.store; let key_manager_state = &(&state).into(); let payment_intent = db .find_payment_intent_by_payment_id_merchant_id( key_manager_state, pub async fn get_payment_link_status( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: common_utils::id_type::PaymentId, ) -> RouterResponse<services::PaymentLinkFormData> { {let db = &*state.store;<|fim_suffix|> <|fim_middle|> Ok(services::ApplicationResponse::PaymentLinkForm(Box::new( services::api::PaymentLinkAction::PaymentLinkStatus(payment_link_status_data), )))}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub async fn get_payment_link_status( _state: SessionState, _merchant_account: domain::MerchantAccount, _key_store: domain::MerchantKeyStore, _merchant_id: common_utils::id_type::MerchantId, _payment_id: common_utils::id_type::PaymentId, ) -> RouterResponse<services::PaymentLinkFormData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; fn check_payment_link_invalid_conditions( intent_status: storage_enums::IntentStatus, not_allowed_statuses: &[storage_enums::IntentStatus], ) -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router fn capitalize_first_char(s: &str) -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use error_stack::{report, ResultExt}; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub fn extract_payment_link_config( pl_config: serde_json::Value, ) -> Result<PaymentLinkConfig, error_stack::Report<errors::ApiErrorResponse>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use time::PrimitiveDateTime; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; pub fn check_payment_link_status( payment_link_expiry: PrimitiveDateTime, ) -> api_models::payments::PaymentLinkStatus { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use futures::future; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub async fn list_payment_link( state: SessionState, merchant: domain::MerchantAccount, constraints: api_models::payments::PaymentLinkListConstraints, ) -> RouterResponse<Vec<api_models::payments::RetrievePaymentLinkResponse>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; fn validate_sdk_requirements( currency: Option<api_models::enums::Currency>, client_secret: Option<String>, ) -> Result<(api_models::enums::Currency, String), errors::ApiErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; fn get_meta_tags_html(payment_details: &api_models::payments::PaymentLinkDetails) -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; fn get_color_scheme_css(payment_link_config: &PaymentLinkConfig) -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; fn get_js_script(payment_details: &PaymentLinkData) -> RouterResult<String> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub async fn form_payment_link_data( state: &SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: common_utils::id_type::PaymentId, ) -> RouterResult<(PaymentLink, PaymentLinkData, PaymentLinkConfig)> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use time::PrimitiveDateTime; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub async fn retrieve_payment_link( state: SessionState, payment_link_id: String, ) -> RouterResponse<api_models::payments::RetrievePaymentLinkResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use error_stack::{report, ResultExt}; use router_env::logger; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub fn get_payment_link_config_based_on_priority( payment_create_link_config: Option<api_models::payments::PaymentCreatePaymentLinkConfig>, business_link_config: Option<diesel_models::business_profile::BusinessPaymentLinkConfig>, merchant_name: String, default_domain_name: String, payment_link_config_id: Option<String>, ) -> Result<(PaymentLinkConfig, String), error_stack::Report<errors::ApiErrorResponse>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use actix_web::http::header; use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::api::{GenericLinks, GenericLinksData}; use router_env::logger; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub async fn initiate_secure_payment_link_flow( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: common_utils::id_type::PaymentId, request_headers: &header::HeaderMap, ) -> RouterResponse<services::PaymentLinkFormData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use hyperswitch_domain_models::api::{GenericLinks, GenericLinksData}; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub async fn get_payment_link_status( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: common_utils::id_type::PaymentId, ) -> RouterResponse<services::PaymentLinkFormData> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/payment_link.rs | crate: router use api_models::{ admin::PaymentLinkConfig, payments::{PaymentLinkData, PaymentLinkStatusWrap}, }; use common_utils::{ consts::{DEFAULT_LOCALE, DEFAULT_SESSION_EXPIRY}, ext_traits::{OptionExt, ValueExt}, types::{AmountConvertor, StringMajorUnitForCore}, }; use router_env::logger; use time::PrimitiveDateTime; use super::{ errors::{self, RouterResult, StorageErrorExt}, payments::helpers, }; use crate::{ consts::{ self, DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY, DEFAULT_ENABLE_BUTTON_ONLY_ON_FORM_READY, DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_MERCHANT_LOGO, DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SHOW_CARD_FORM, }, errors::RouterResponse, get_payment_link_config_value, get_payment_link_config_value_based_on_priority, routes::SessionState, services, types::{ api::payment_link::PaymentLinkResponseExt, domain, storage::{enums as storage_enums, payment_link::PaymentLink}, transformers::{ForeignFrom, ForeignInto}, }, }; pub async fn form_payment_link_data( state: &SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, merchant_id: common_utils::id_type::MerchantId, payment_id: common_utils::id_type::PaymentId, ) -> RouterResult<(PaymentLink, PaymentLinkData, PaymentLinkConfig)> { {let db = &*state.store;<|fim_suffix|> <|fim_middle|> Ok(( payment_link, PaymentLinkData::PaymentLinkDetails(Box::new(payment_link_details)), payment_link_config, ))}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn revoke_api_key( state: SessionState, merchant_id: &common_utils::id_type::MerchantId, key_id: &common_utils::id_type::ApiKeyId, ) -> RouterResponse<api::RevokeApiKeyResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use diesel_models::{api_keys::ApiKey, enums as storage_enums}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn update_api_key_expiry_task( store: &dyn crate::db::StorageInterface, api_key: &ApiKey, expiry_reminder_days: Vec<u8>, ) -> Result<(), errors::ProcessTrackerError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use diesel_models::{api_keys::ApiKey, enums as storage_enums}; use router_env::{instrument, tracing}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn add_api_key_expiry_task( store: &dyn crate::db::StorageInterface, api_key: &ApiKey, expiry_reminder_days: Vec<u8>, ) -> Result<(), errors::ProcessTrackerError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use diesel_models::{api_keys::ApiKey, enums as storage_enums}; use router_env::{instrument, tracing}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn create_api_key( state: SessionState, api_key: api::CreateApiKeyRequest, key_store: domain::MerchantKeyStore, ) -> RouterResponse<api::CreateApiKeyResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; fn from(hashed_api_key: storage::HashedApiKey) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use diesel_models::{api_keys::ApiKey, enums as storage_enums}; use router_env::{instrument, tracing}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn create_api_key( state: SessionState, api_key: api::CreateApiKeyRequest, key_store: domain::MerchantKeyStore, ) -> RouterResponse<api::CreateApiKeyResponse> { {let api_key_config = state.conf.api_keys.get_inner();<|fim_suffix|> <|fim_middle|> Ok(ApplicationResponse::Json( (api_key, plaintext_api_key).foreign_into(), ))}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use diesel_models::{api_keys::ApiKey, enums as storage_enums}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; async fn test_hashing_and_verification() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; fn from(hashed_api_key: storage::HashedApiKey) -> Self { Self(hashed_api_key.into_inner()) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router fn from(hashed_api_key: HashedApiKey) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router fn from(s: String) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router fn from(s: &str) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; fn generate_task_id_for_api_key_expiry_workflow( key_id: &common_utils::id_type::ApiKeyId, ) -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use diesel_models::{api_keys::ApiKey, enums as storage_enums}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn list_api_keys( state: SessionState, merchant_id: common_utils::id_type::MerchantId, limit: Option<i64>, offset: Option<i64>, ) -> RouterResponse<Vec<api::RetrieveApiKeyResponse>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use diesel_models::{api_keys::ApiKey, enums as storage_enums}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn revoke_api_key_expiry_task( store: &dyn crate::db::StorageInterface, key_id: &common_utils::id_type::ApiKeyId, ) -> Result<(), errors::ProcessTrackerError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use error_stack::{report, ResultExt}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn retrieve_api_key( state: SessionState, merchant_id: common_utils::id_type::MerchantId, key_id: common_utils::id_type::ApiKeyId, ) -> RouterResponse<api::RetrieveApiKeyResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub fn peek(&self) -> &str { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub fn prefix(&self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use router_env::{instrument, tracing}; pub fn new_key_id() -> common_utils::id_type::ApiKeyId { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use common_utils::date_time; use router_env::{instrument, tracing}; pub fn new(length: usize) -> Self { let env = router_env::env::prefix_for_env(); let key = common_utils::crypto::generate_cryptographically_secure_random_string(length); Self(format!("{env}_{key}").into()) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use masking::{PeekInterface, StrongSecret}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub fn get_hash_key( &self, ) -> errors::RouterResult<&'static StrongSecret<[u8; PlaintextApiKey::HASH_KEY_LEN]>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/api_keys.rs | crate: router use diesel_models::{api_keys::ApiKey, enums as storage_enums}; use crate::{ configs::settings, consts, core::errors::{self, RouterResponse, StorageErrorExt}, db::domain, routes::{metrics, SessionState}, services::{authentication, ApplicationResponse}, types::{api, storage, transformers::ForeignInto}, }; pub async fn update_api_key( state: SessionState, api_key: api::UpdateApiKeyRequest, ) -> RouterResponse<api::RetrieveApiKeyResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/errors.rs | crate: router DisputeWebhookValidationFailed, #[error("Outgoing webhook body encoding failed")] OutgoingWebhookEncodingFailed, #[error("Failed to update outgoing webhook process tracker task")] OutgoingWebhookProcessTrackerTaskUpdateFailed, #[error("Failed to schedule retry attempt for outgoing webhook")] OutgoingWebhookRetrySchedulingFailed, #[error("Outgoing webhook response encoding failed")] OutgoingWebhookResponseEncodingFailed, } impl WebhooksFlowError { pub(crate) fn is_webhook_delivery_retryable_error(&self) -> bool { match self { Self::MerchantConfigNotFound | Self::MerchantWebhookDetailsNotFound | Self::MerchantWebhookUrlNotConfigured | Self::OutgoingWebhookResponseEncodingFailed => false, Self::WebhookEventUpdationFailed | Self::OutgoingWebhookSigningFailed | Self::CallToMerchantFailed | Self::NotReceivedByMerchant | Self::DisputeWebhookValidationFailed | Self::OutgoingWebhookEncodingFailed pub(crate) fn is_webhook_delivery_retryable_error(&self) -> bool { { Self::MerchantConfigNotFound | Self::MerchantWebhookDetailsNotFound | Self::MerchantWebhookUrlNotConfigured | Self::OutgoingWebhookResponseEncodingFailed => false,<|fim_suffix|> <|fim_middle|> Self::WebhookEventUpdationFailed | Self::OutgoingWebhookSigningFailed | Self::CallToMerchantFailed | Self::NotReceivedByMerchant | Self::DisputeWebhookValidationFailed | Self::OutgoingWebhookEncodingFailed | Self::OutgoingWebhookProcessTrackerTaskUpdateFailed | Self::OutgoingWebhookRetrySchedulingFailed => true, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/errors.rs | crate: router fn from(value: Vec<NestedErrorStack<'a>>) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/errors.rs | crate: router pub use common_utils::errors::{CustomResult, ParsingError, ValidationError}; pub use hyperswitch_domain_models::errors::api_error_response::{ ApiErrorResponse, ErrorType, NotImplementedMessage, }; pub use hyperswitch_interfaces::errors::ConnectorError; pub use redis_interface::errors::RedisError; pub use user::*; pub use self::{ customers_error_response::CustomersErrorResponse, sch_errors::*, storage_errors::*, storage_impl_errors::*, utils::{ConnectorErrorExt, StorageErrorExt}, }; use crate::services; pub type RouterResult<T> = CustomResult<T, ApiErrorResponse>; pub type RouterResponse<T> = CustomResult<services::ApplicationResponse<T>, ApiErrorResponse>; pub type ApplicationResult<T> = error_stack::Result<T, ApplicationError>; pub type ApplicationResponse<T> = ApplicationResult<services::ApplicationResponse<T>>; pub type CustomerResponse<T> = CustomResult<services::ApplicationResponse<T>, CustomersErrorResponse>; pub use error_stack_parsing::*; pub(crate) fn is_webhook_delivery_retryable_error(&self) -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/errors.rs | crate: router use actix_web::{body::BoxBody, ResponseError}; pub use common_utils::errors::{CustomResult, ParsingError, ValidationError}; pub use hyperswitch_domain_models::errors::api_error_response::{ ApiErrorResponse, ErrorType, NotImplementedMessage, }; pub use hyperswitch_interfaces::errors::ConnectorError; pub use redis_interface::errors::RedisError; pub use user::*; pub use self::{ customers_error_response::CustomersErrorResponse, sch_errors::*, storage_errors::*, storage_impl_errors::*, utils::{ConnectorErrorExt, StorageErrorExt}, }; pub type RouterResult<T> = CustomResult<T, ApiErrorResponse>; pub type RouterResponse<T> = CustomResult<services::ApplicationResponse<T>, ApiErrorResponse>; pub type ApplicationResult<T> = error_stack::Result<T, ApplicationError>; pub type ApplicationResponse<T> = ApplicationResult<services::ApplicationResponse<T>>; pub type CustomerResponse<T> = CustomResult<services::ApplicationResponse<T>, CustomersErrorResponse>; pub use error_stack_parsing::*; pub fn http_not_implemented() -> actix_web::HttpResponse<BoxBody> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/errors.rs | crate: router fn from(_: ring::error::Unspecified) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn update_address_if_sent( &self, db: &dyn StorageInterface, ) -> errors::CustomResult<Option<domain::Address>, errors::CustomersErrorResponse> { let address = if let Some(addr) = &self.update_customer.address { match self.domain_customer.address_id.clone() { Some(address_id) => { let customer_address: api_models::payments::AddressDetails = addr.clone(); let update_address = self .update_customer .get_address_update( self.state, customer_address, self.key_store.key.get_inner().peek(), self.merchant_account.storage_scheme, self.merchant_account.get_id().clone(), ) .await .switch() .attach_printable("Failed while encrypting Address while Update")?; Some( db.update_address( self.key_manager_state, address_id, update_address, self.key_store, ) .await .switch() .attach_printable(format!( "Failed while updating address: merchant_id: {:?}, customer_id: {:?}", self.merchant_account.get_id(), self.domain_customer.customer_id ))?, ) } None => { let customer_address: api_models::payments::AddressDetails = addr.clone(); let address = self .update_customer .get_domain_address( self.state, customer_address, self.merchant_account.get_id(), &self.domain_customer.customer_id, self.key_store.key.get_inner().peek(), self.merchant_account.storage_scheme, ) .await .switch() .attach_printable("Failed while encrypting address")?; Some( db.insert_address_for_customers( self.key_manager_state, address, self.key_store, ) .await .switch() .attach_printable("Failed while inserting new address")?, ) } } } else { match &self.domain_customer.address_id { Some(address_id) => Some( db.find_address_by_address_id( self.key_manager_state, address_id, self.key_store, ) .await .switch()?, ), None => None, } }; Ok(address) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; pub async fn update_customer( state: SessionState, merchant_account: domain::MerchantAccount, update_customer: customers::CustomerUpdateRequestInternal, key_store: domain::MerchantKeyStore, ) -> errors::CustomerResponse<customers::CustomerResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::core::payment_methods::cards::create_encrypted_data; use crate::utils::CustomerAddress; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; pub async fn list_customers( state: SessionState, merchant_id: id_type::MerchantId, _profile_id_list: Option<Vec<id_type::ProfileId>>, key_store: domain::MerchantKeyStore, request: customers::CustomerListRequest, ) -> errors::CustomerResponse<Vec<customers::CustomerResponse>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; pub async fn retrieve_customer( state: SessionState, merchant_account: domain::MerchantAccount, _profile_id: Option<id_type::ProfileId>, key_store: domain::MerchantKeyStore, customer_id: id_type::CustomerId, ) -> errors::CustomerResponse<customers::CustomerResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use error_stack::{report, ResultExt}; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn verify_if_merchant_reference_not_present_by_merchant_reference( &self, merchant_ref: &'a id_type::CustomerId, db: &dyn StorageInterface, ) -> Result<(), error_stack::Report<errors::CustomersErrorResponse>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use error_stack::{report, ResultExt}; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn verify_if_merchant_reference_not_present_by_merchant_reference_id( &self, cus: &'a id_type::CustomerId, db: &dyn StorageInterface, ) -> Result<(), error_stack::Report<errors::CustomersErrorResponse>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn encrypt_customer_address_and_set_to_db( &self, db: &dyn StorageInterface, ) -> errors::CustomResult<Option<domain::Address>, errors::CustomersErrorResponse> { let encrypted_customer_address = self .address .async_map(|addr| async { self.customer_data .get_domain_address( self.state, addr.clone(), self.merchant_id, self.customer_id .ok_or(errors::CustomersErrorResponse::InternalServerError)?, // should we raise error since in v1 appilcation is supposed to have this id or generate it at this point. self.key_store.key.get_inner().peek(), self.storage_scheme, ) .await .switch() .attach_printable("Failed while encrypting address") }) .await .transpose()?; encrypted_customer_address .async_map(|encrypt_add| async { db.insert_address_for_customers(self.key_manager_state, encrypt_add, self.key_store) .await .switch() .attach_printable("Failed while inserting new address") }) .await .transpose() }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use masking::{ExposeInterface, Secret, SwitchStrategy}; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn create_domain_model_from_request<'a>( &'a self, db: &'a dyn StorageInterface, key_store: &'a domain::MerchantKeyStore, merchant_reference_id: &'a Option<id_type::CustomerId>, merchant_account: &'a domain::MerchantAccount, key_manager_state: &'a KeyManagerState, state: &'a SessionState, ) -> errors::CustomResult<domain::Customer, errors::CustomersErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; pub async fn create_customer( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, customer_data: customers::CustomerRequest, ) -> errors::CustomerResponse<customers::CustomerResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router } fn generate_response<'a>( &'a self, customer: &'a domain::Customer, ) -> errors::CustomerResponse<customers::CustomerResponse> { Ok(services::ApplicationResponse::Json( customers::CustomerResponse::foreign_from(customer.clone()), )) } } pub async fn migrate_customers( state: SessionState, customers: Vec<customers::CustomerRequest>, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, ) -> errors::CustomerResponse<()> { for customer in customers { match create_customer( state.clone(), merchant_account.clone(), key_store.clone(), customer, ) pub async fn migrate_customers( state: SessionState, customers: Vec<customers::CustomerRequest>, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, ) -> errors::CustomerResponse<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] struct AddressStructForDbUpdate<'a> { update_customer: &'a customers::CustomerUpdateRequest, merchant_account: &'a domain::MerchantAccount, key_store: &'a domain::MerchantKeyStore, key_manager_state: &'a KeyManagerState, state: &'a SessionState, domain_customer: &'a domain::Customer, } #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] impl AddressStructForDbUpdate<'_> { async fn update_address_if_sent( &self, db: &dyn StorageInterface, ) -> errors::CustomResult<Option<domain::Address>, errors::CustomersErrorResponse> { let address = if let Some(addr) = &self.update_customer.address { match self.domain_customer.address_id.clone() { Some(address_id) => { let customer_address: api_models::payments::AddressDetails = addr.clone(); let update_address = self .update_customer .get_address_update( self.state, customer_address, async fn update_address_if_sent( &self, db: &dyn StorageInterface, ) -> errors::CustomResult<Option<domain::Address>, errors::CustomersErrorResponse> { { Some(address_id) => Some( db.find_address_by_address_id( self.key_manager_state, address_id, self.key_store, ) .await .switch()?, ),<|fim_suffix|> <|fim_middle|> None => None, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; pub async fn migrate_customers( state: SessionState, customers: Vec<customers::CustomerRequest>, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, ) -> errors::CustomerResponse<()> { { errors::CustomersErrorResponse::CustomerAlreadyExists => (),<|fim_suffix|> <|fim_middle|> _ => return Err(e), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; fn generate_response<'a>( &'a self, customer: &'a domain::Customer, ) -> errors::CustomerResponse<customers::CustomerResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use error_stack::{report, ResultExt}; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn verify_id_and_get_customer_object( &self, db: &dyn StorageInterface, ) -> Result<domain::Customer, error_stack::Report<errors::CustomersErrorResponse>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; pub async fn delete_customer( state: SessionState, merchant_account: domain::MerchantAccount, customer_id: id_type::CustomerId, key_store: domain::MerchantKeyStore, ) -> errors::CustomerResponse<customers::CustomerDeleteResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; pub async fn delete_customer( state: SessionState, merchant_account: domain::MerchantAccount, id: id_type::GlobalCustomerId, key_store: domain::MerchantKeyStore, ) -> errors::CustomerResponse<customers::CustomerDeleteResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; pub async fn retrieve_customer( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, id: id_type::GlobalCustomerId, ) -> errors::CustomerResponse<customers::CustomerResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use error_stack::{report, ResultExt}; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn verify_if_merchant_reference_not_present_by_optional_merchant_reference_id( &self, db: &dyn StorageInterface, ) -> Result<Option<()>, error_stack::Report<errors::CustomersErrorResponse>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use masking::{ExposeInterface, Secret, SwitchStrategy}; use crate::core::payment_methods::cards::create_encrypted_data; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn create_domain_model_from_request<'a>( &'a self, db: &'a dyn StorageInterface, key_store: &'a domain::MerchantKeyStore, merchant_account: &'a domain::MerchantAccount, key_manager_state: &'a KeyManagerState, state: &'a SessionState, domain_customer: &'a domain::Customer, ) -> errors::CustomResult<domain::Customer, errors::CustomersErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use masking::{ExposeInterface, Secret, SwitchStrategy}; use crate::core::payment_methods::cards::create_encrypted_data; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn create_domain_model_from_request<'a>( &'a self, _db: &'a dyn StorageInterface, key_store: &'a domain::MerchantKeyStore, merchant_reference_id: &'a Option<id_type::CustomerId>, merchant_account: &'a domain::MerchantAccount, key_state: &'a KeyManagerState, state: &'a SessionState, ) -> errors::CustomResult<domain::Customer, errors::CustomersErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/customers.rs | crate: router use common_utils::{ crypto::Encryptable, errors::ReportSwitchExt, ext_traits::AsyncExt, id_type, pii, type_name, types::{ keymanager::{Identifier, KeyManagerState, ToEncryptable}, Description, }, }; use masking::{ExposeInterface, Secret, SwitchStrategy}; use crate::core::payment_methods::cards::create_encrypted_data; use crate::{ core::{ errors::{self, StorageErrorExt}, payment_methods::{cards, network_tokenization}, }, db::StorageInterface, pii::PeekInterface, routes::{metrics, SessionState}, services, types::{ api::customers, domain::{self, types}, storage::{self, enums}, transformers::ForeignFrom, }, }; async fn redact_customer_details_and_generate_response<'a>( &'a self, db: &'a dyn StorageInterface, key_store: &'a domain::MerchantKeyStore, merchant_account: &'a domain::MerchantAccount, key_manager_state: &'a KeyManagerState, state: &'a SessionState, ) -> errors::CustomerResponse<customers::CustomerDeleteResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/gsm.rs | crate: router use api_models::gsm as gsm_api_types; use diesel_models::gsm as storage; use crate::{ core::{ errors, errors::{RouterResponse, StorageErrorExt}, }, db::gsm::GsmInterface, services, types::transformers::ForeignInto, SessionState, }; pub async fn delete_gsm_rule( state: SessionState, gsm_request: gsm_api_types::GsmDeleteRequest, ) -> RouterResponse<gsm_api_types::GsmDeleteResponse> { { Ok(is_deleted) => { if is_deleted { Ok(services::ApplicationResponse::Json( gsm_api_types::GsmDeleteResponse { gsm_rule_delete: true, connector, flow, sub_flow, code, }, )) } else { Err(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while Deleting Gsm rule, got response as false") } }<|fim_suffix|> <|fim_middle|> Err(err) => Err(err), } }
ast_fragments
// file: hyperswitch/crates/router/src/core/gsm.rs | crate: router use api_models::gsm as gsm_api_types; use diesel_models::gsm as storage; use crate::{ core::{ errors, errors::{RouterResponse, StorageErrorExt}, }, db::gsm::GsmInterface, services, types::transformers::ForeignInto, SessionState, }; pub async fn update_gsm_rule( state: SessionState, gsm_request: gsm_api_types::GsmUpdateRequest, ) -> RouterResponse<gsm_api_types::GsmResponse> { let db = state.store.as_ref(); let gsm_api_types::GsmUpdateRequest { connector, flow, sub_flow, code, message, decision, status, router_error, step_up_possible, unified_code, unified_message, error_category, clear_pan_possible, } = gsm_request; GsmInterface::update_gsm_rule( db, connector.to_string(), flow, sub_flow, code, message, storage::GatewayStatusMappingUpdate { decision: decision.map(|d| d.to_string()), status, router_error: Some(router_error), step_up_possible, unified_code, unified_message, error_category, clear_pan_possible, }, ) .await .to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError { message: "GSM with given key does not exist in our records".to_string(), }) .attach_printable("Failed while updating Gsm rule") .map(|gsm| services::ApplicationResponse::Json(gsm.foreign_into())) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/gsm.rs | crate: router use api_models::gsm as gsm_api_types; use diesel_models::gsm as storage; use crate::{ core::{ errors, errors::{RouterResponse, StorageErrorExt}, }, db::gsm::GsmInterface, services, types::transformers::ForeignInto, SessionState, }; pub async fn delete_gsm_rule( state: SessionState, gsm_request: gsm_api_types::GsmDeleteRequest, ) -> RouterResponse<gsm_api_types::GsmDeleteResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/gsm.rs | crate: router use api_models::gsm as gsm_api_types; use diesel_models::gsm as storage; use crate::{ core::{ errors, errors::{RouterResponse, StorageErrorExt}, }, db::gsm::GsmInterface, services, types::transformers::ForeignInto, SessionState, }; pub async fn update_gsm_rule( state: SessionState, gsm_request: gsm_api_types::GsmUpdateRequest, ) -> RouterResponse<gsm_api_types::GsmResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/gsm.rs | crate: router use api_models::gsm as gsm_api_types; use diesel_models::gsm as storage; use crate::{ core::{ errors, errors::{RouterResponse, StorageErrorExt}, }, db::gsm::GsmInterface, services, types::transformers::ForeignInto, SessionState, }; pub async fn retrieve_gsm_rule( state: SessionState, gsm_request: gsm_api_types::GsmRetrieveRequest, ) -> RouterResponse<gsm_api_types::GsmResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/gsm.rs | crate: router use api_models::gsm as gsm_api_types; use diesel_models::gsm as storage; use crate::{ core::{ errors, errors::{RouterResponse, StorageErrorExt}, }, db::gsm::GsmInterface, services, types::transformers::ForeignInto, SessionState, }; pub async fn create_gsm_rule( state: SessionState, gsm_rule: gsm_api_types::GsmCreateRequest, ) -> RouterResponse<gsm_api_types::GsmResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/revenue_recovery.rs | crate: router use api_models::{ payments::{PaymentRevenueRecoveryMetadata, PaymentsRetrieveRequest}, process_tracker::revenue_recovery, }; use common_utils::{ self, errors::CustomResult, ext_traits::{OptionExt, ValueExt}, id_type, types::keymanager::KeyManagerState, }; use diesel_models::process_tracker::business_status; use hyperswitch_domain_models::{ api::ApplicationResponse, behaviour::ReverseConversion, errors::api_error_response, merchant_connector_account, payments::{PaymentIntent, PaymentStatusData}, ApiModelToDieselModelConvertor, }; use scheduler::errors as sch_errors; use crate::{ core::{ errors::{self, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, operations::Operation}, revenue_recovery::types as pcr_types, }, db::StorageInterface, logger, routes::{metrics, SessionState}, types::{ api, storage::{self, revenue_recovery as pcr}, transformers::ForeignInto, }, }; pub async fn retrieve_revenue_recovery_process_tracker( state: SessionState, id: id_type::GlobalPaymentId, ) -> RouterResponse<revenue_recovery::RevenueRecoveryResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/revenue_recovery.rs | crate: router use api_models::{ payments::{PaymentRevenueRecoveryMetadata, PaymentsRetrieveRequest}, process_tracker::revenue_recovery, }; use common_utils::{ self, errors::CustomResult, ext_traits::{OptionExt, ValueExt}, id_type, types::keymanager::KeyManagerState, }; use hyperswitch_domain_models::{ api::ApplicationResponse, behaviour::ReverseConversion, errors::api_error_response, merchant_connector_account, payments::{PaymentIntent, PaymentStatusData}, ApiModelToDieselModelConvertor, }; use crate::{ core::{ errors::{self, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, operations::Operation}, revenue_recovery::types as pcr_types, }, db::StorageInterface, logger, routes::{metrics, SessionState}, types::{ api, storage::{self, revenue_recovery as pcr}, transformers::ForeignInto, }, }; pub async fn call_psync_api( state: &SessionState, global_payment_id: &id_type::GlobalPaymentId, pcr_data: &pcr::PcrPaymentData, ) -> RouterResult<PaymentStatusData<api::PSync>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/revenue_recovery.rs | crate: router use common_utils::{ self, errors::CustomResult, ext_traits::{OptionExt, ValueExt}, id_type, types::keymanager::KeyManagerState, }; use hyperswitch_domain_models::{ api::ApplicationResponse, behaviour::ReverseConversion, errors::api_error_response, merchant_connector_account, payments::{PaymentIntent, PaymentStatusData}, ApiModelToDieselModelConvertor, }; use scheduler::errors as sch_errors; use crate::{ core::{ errors::{self, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, operations::Operation}, revenue_recovery::types as pcr_types, }, db::StorageInterface, logger, routes::{metrics, SessionState}, types::{ api, storage::{self, revenue_recovery as pcr}, transformers::ForeignInto, }, }; async fn insert_psync_pcr_task( db: &dyn StorageInterface, merchant_id: id_type::MerchantId, payment_id: id_type::GlobalPaymentId, profile_id: id_type::ProfileId, payment_attempt_id: id_type::GlobalAttemptId, runner: storage::ProcessTrackerRunner, ) -> RouterResult<storage::ProcessTracker> { let task = PSYNC_WORKFLOW; let process_tracker_id = payment_attempt_id.get_psync_revenue_recovery_id(task, runner); let schedule_time = common_utils::date_time::now(); let psync_workflow_tracking_data = pcr::PcrWorkflowTrackingData { global_payment_id: payment_id, merchant_id, profile_id, payment_attempt_id, }; let tag = ["PCR"]; let process_tracker_entry = storage::ProcessTrackerNew::new( process_tracker_id, task, runner, tag, psync_workflow_tracking_data, None, schedule_time, common_types::consts::API_VERSION, ) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to construct delete tokenized data process tracker task")?; let response = db .insert_process(process_tracker_entry) .await .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to construct delete tokenized data process tracker task")?; metrics::TASKS_ADDED_COUNT.add(1, router_env::metric_attributes!(("flow", "PsyncPcr"))); Ok(response) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/revenue_recovery.rs | crate: router db.finish_process_with_business_status( execute_task_process.clone(), business_status::EXECUTE_WORKFLOW_COMPLETE, ) .await?; logger::warn!("Abnormal State Identified") } } Ok(()) } async fn insert_psync_pcr_task( db: &dyn StorageInterface, merchant_id: id_type::MerchantId, payment_id: id_type::GlobalPaymentId, profile_id: id_type::ProfileId, payment_attempt_id: id_type::GlobalAttemptId, runner: storage::ProcessTrackerRunner, ) -> RouterResult<storage::ProcessTracker> { let task = PSYNC_WORKFLOW; let process_tracker_id = payment_attempt_id.get_psync_revenue_recovery_id(task, runner); let schedule_time = common_utils::date_time::now(); let psync_workflow_tracking_data = pcr::PcrWorkflowTrackingData { global_payment_id: payment_id, async fn insert_psync_pcr_task( db: &dyn StorageInterface, merchant_id: id_type::MerchantId, payment_id: id_type::GlobalPaymentId, profile_id: id_type::ProfileId, payment_attempt_id: id_type::GlobalAttemptId, runner: storage::ProcessTrackerRunner, ) -> RouterResult<storage::ProcessTracker> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/revenue_recovery.rs | crate: router use common_utils::{ self, errors::CustomResult, ext_traits::{OptionExt, ValueExt}, id_type, types::keymanager::KeyManagerState, }; use diesel_models::process_tracker::business_status; use hyperswitch_domain_models::{ api::ApplicationResponse, behaviour::ReverseConversion, errors::api_error_response, merchant_connector_account, payments::{PaymentIntent, PaymentStatusData}, ApiModelToDieselModelConvertor, }; use scheduler::errors as sch_errors; use crate::{ core::{ errors::{self, RouterResponse, RouterResult, StorageErrorExt}, payments::{self, operations::Operation}, revenue_recovery::types as pcr_types, }, db::StorageInterface, logger, routes::{metrics, SessionState}, types::{ api, storage::{self, revenue_recovery as pcr}, transformers::ForeignInto, }, }; pub async fn perform_execute_payment( state: &SessionState, execute_task_process: &storage::ProcessTracker, tracking_data: &pcr::PcrWorkflowTrackingData, pcr_data: &pcr::PcrPaymentData, _key_manager_state: &KeyManagerState, payment_intent: &PaymentIntent, billing_mca: &merchant_connector_account::MerchantConnectorAccount, ) -> Result<(), sch_errors::ProcessTrackerError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use common_utils::ext_traits::AsyncExt; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn construct_dsl_and_perform_eligibility_analysis<F, D>( self, state: &SessionState, key_store: &domain::MerchantKeyStore, payment_data: &D, profile_id: &common_utils::id_type::ProfileId, ) -> RouterResult<Vec<api::ConnectorData>> where F: Send + Clone, D: OperationSessionGetters<F>, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::routing::DynamicRoutingAlgoAccessor; use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use diesel_models::routing_algorithm::RoutingAlgorithm; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; async fn get_routable_connectors( &self, _db: &dyn StorageInterface, _business_profile: &domain::Profile, ) -> RouterResult<RoutableConnectors> { let straight_through_routing_algorithm = self .0 .clone() .parse_value::<api::routing::StraightThroughAlgorithm>("RoutingAlgorithm") .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to parse the straight through routing algorithm")?; let routable_connector = match straight_through_routing_algorithm { api::routing::StraightThroughAlgorithm::Single(connector) => { vec![*connector] } api::routing::StraightThroughAlgorithm::Priority(_) | api::routing::StraightThroughAlgorithm::VolumeSplit(_) => { Err(errors::RoutingError::DslIncorrectSelectionAlgorithm) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable( "Unsupported algorithm received as a result of static routing", )? } }; Ok(RoutableConnectors(routable_connector)) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::routing::DynamicRoutingAlgoAccessor; use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use common_utils::ext_traits::AsyncExt; use router_env::logger; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::utils::ValueExt; use crate::{core::admin, utils::ValueExt}; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn configure_dynamic_routing_volume_split( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, profile_id: common_utils::id_type::ProfileId, routing_info: routing::RoutingVolumeSplit, ) -> RouterResponse<()> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::routing::DynamicRoutingAlgoAccessor; use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use common_utils::ext_traits::AsyncExt; use router_env::logger; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn toggle_specific_dynamic_routing( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, feature_to_enable: routing::DynamicRoutingFeatures, profile_id: common_utils::id_type::ProfileId, dynamic_routing_type: routing::DynamicRoutingType, ) -> RouterResponse<routing_types::RoutingDictionaryRecord> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn retrieve_default_routing_config_for_profiles( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, transaction_type: &enums::TransactionType, ) -> RouterResponse<Vec<routing_types::ProfileDefaultRoutingConfig>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::routing::DynamicRoutingAlgoAccessor; use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use common_utils::ext_traits::AsyncExt; use diesel_models::routing_algorithm::RoutingAlgorithm; use super::payouts; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn retrieve_linked_routing_config( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, authentication_profile_id: Option<common_utils::id_type::ProfileId>, query_params: routing_types::RoutingRetrieveLinkQuery, transaction_type: &enums::TransactionType, ) -> RouterResponse<routing_types::LinkedRoutingConfigRetrieveResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use common_utils::ext_traits::AsyncExt; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn retrieve_routing_config_under_profile( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, query_params: RoutingRetrieveQuery, profile_id: common_utils::id_type::ProfileId, transaction_type: &enums::TransactionType, ) -> RouterResponse<routing_types::LinkedRoutingConfigRetrieveResponse> { metrics::ROUTING_RETRIEVE_LINK_CONFIG.add(1, &[]); let db = state.store.as_ref(); let key_manager_state = &(&state).into(); let business_profile = core_utils::validate_and_get_business_profile( db, key_manager_state, &key_store, Some(&profile_id), merchant_account.get_id(), ) .await? .get_required_value("Profile")?; let record = db .list_routing_algorithm_metadata_by_profile_id( business_profile.get_id(), i64::from(query_params.limit.unwrap_or_default()), i64::from(query_params.offset.unwrap_or_default()), ) .await .to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound)?; let active_algorithms = record .into_iter() .filter(|routing_rec| &routing_rec.algorithm_for == transaction_type) .map(|routing_algo| routing_algo.foreign_into()) .collect::<Vec<_>>(); metrics::ROUTING_RETRIEVE_LINK_CONFIG_SUCCESS_RESPONSE.add(1, &[]); Ok(service_api::ApplicationResponse::Json( routing_types::LinkedRoutingConfigRetrieveResponse::ProfileBased(active_algorithms), )) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use rustc_hash::FxHashSet; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::utils::ValueExt; use crate::{core::admin, utils::ValueExt}; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn update_default_routing_config( state: SessionState, merchant_account: domain::MerchantAccount, updated_config: Vec<routing_types::RoutableConnectorChoice>, transaction_type: &enums::TransactionType, ) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use common_utils::ext_traits::AsyncExt; use rustc_hash::FxHashSet; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::utils::ValueExt; use crate::{core::admin, utils::ValueExt}; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn update_default_fallback_routing( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, profile_id: common_utils::id_type::ProfileId, updated_list_of_connectors: Vec<routing_types::RoutableConnectorChoice>, ) -> RouterResponse<Vec<routing_types::RoutableConnectorChoice>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use common_utils::ext_traits::AsyncExt; use super::payouts; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::{core::admin, utils::ValueExt}; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn unlink_routing_config_under_profile( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, profile_id: common_utils::id_type::ProfileId, transaction_type: &enums::TransactionType, ) -> RouterResponse<routing_types::RoutingDictionaryRecord> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router/src/core/routing.rs | crate: router use api_models::routing::DynamicRoutingAlgoAccessor; use api_models::{ enums, mandates as mandates_api, routing, routing::{self as routing_types, RoutingRetrieveQuery}, }; use common_utils::ext_traits::AsyncExt; use diesel_models::routing_algorithm::RoutingAlgorithm; use super::{ errors::RouterResult, payments::{ routing::{self as payments_routing}, OperationSessionGetters, }, }; use crate::{ core::{ errors::{self, CustomResult, RouterResponse, StorageErrorExt}, metrics, utils as core_utils, }, db::StorageInterface, routes::SessionState, services::api as service_api, types::{ api, domain, storage::{self, enums as storage_enums}, transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self, OptionExt}, }; pub async fn retrieve_routing_algorithm_from_algorithm_id( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, authentication_profile_id: Option<common_utils::id_type::ProfileId>, algorithm_id: common_utils::id_type::RoutingId, ) -> RouterResponse<routing_types::MerchantRoutingAlgorithm> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments