text stringlengths 70 351k | source stringclasses 4
values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/types/api.rs | crate: pm_auth
use common_utils::{
errors::CustomResult,
request::{Request, RequestContent},
};
use crate::{
core::errors::ConnectorError,
types::{
self as auth_types,
api::auth_service::{AuthService, PaymentInitiation},
},
};
fn get_5xx_error_response(
&self,
res: auth_types::Response,
) -> CustomResult<auth_types::ErrorResponse, ConnectorError> {
{
500 => "internal_server_error",
501 => "not_implemented",
502 => "bad_gateway",<|fim_suffix|>
<|fim_middle|>
510 => "not_extended",
511 => "network_authentication_required",
_ => "unknown_error",
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/types/api.rs | crate: pm_auth
use common_utils::{
errors::CustomResult,
request::{Request, RequestContent},
};
use crate::{
core::errors::ConnectorError,
types::{
self as auth_types,
api::auth_service::{AuthService, PaymentInitiation},
},
};
fn get_error_response(
&self,
_res: auth_types::Response,
) -> CustomResult<auth_types::ErrorResponse, ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/types/api.rs | crate: pm_auth
use common_utils::{
errors::CustomResult,
request::{Request, RequestContent},
};
use crate::{
core::errors::ConnectorError,
types::{
self as auth_types,
api::auth_service::{AuthService, PaymentInitiation},
},
};
pub type BoxedConnectorIntegration<'a, T, Req, Resp> =
Box<&'a (dyn ConnectorIntegration<T, Req, Resp> + Send + Sync)>;
fn handle_response(
&self,
data: &super::PaymentAuthRouterData<T, Req, Resp>,
_res: auth_types::Response,
) -> CustomResult<super::PaymentAuthRouterData<T, Req, Resp>, ConnectorError>
where
T: Clone,
Req: Clone,
Resp: Clone,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/types/api.rs | crate: pm_auth
use common_utils::{
errors::CustomResult,
request::{Request, RequestContent},
};
use crate::{
core::errors::ConnectorError,
types::{
self as auth_types,
api::auth_service::{AuthService, PaymentInitiation},
},
};
pub type BoxedConnectorIntegration<'a, T, Req, Resp> =
Box<&'a (dyn ConnectorIntegration<T, Req, Resp> + Send + Sync)>;
fn build_request(
&self,
_req: &super::PaymentAuthRouterData<T, Req, Resp>,
_connectors: &auth_types::PaymentMethodAuthConnectors,
) -> CustomResult<Option<Request>, ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/types/api.rs | crate: pm_auth
use common_utils::{
errors::CustomResult,
request::{Request, RequestContent},
};
use crate::{
core::errors::ConnectorError,
types::{
self as auth_types,
api::auth_service::{AuthService, PaymentInitiation},
},
};
pub type BoxedConnectorIntegration<'a, T, Req, Resp> =
Box<&'a (dyn ConnectorIntegration<T, Req, Resp> + Send + Sync)>;
pub type BoxedPaymentAuthConnector = Box<&'static (dyn AuthServiceConnector + Sync)>;
fn get_request_body(
&self,
_req: &super::PaymentAuthRouterData<T, Req, Resp>,
) -> CustomResult<RequestContent, ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/types/api.rs | crate: pm_auth
use common_utils::{
errors::CustomResult,
request::{Request, RequestContent},
};
use crate::{
core::errors::ConnectorError,
types::{
self as auth_types,
api::auth_service::{AuthService, PaymentInitiation},
},
};
pub type BoxedConnectorIntegration<'a, T, Req, Resp> =
Box<&'a (dyn ConnectorIntegration<T, Req, Resp> + Send + Sync)>;
fn get_url(
&self,
_req: &super::PaymentAuthRouterData<T, Req, Resp>,
_connectors: &auth_types::PaymentMethodAuthConnectors,
) -> CustomResult<String, ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/types/api.rs | crate: pm_auth
use common_utils::{
errors::CustomResult,
request::{Request, RequestContent},
};
use masking::Maskable;
use crate::{
core::errors::ConnectorError,
types::{
self as auth_types,
api::auth_service::{AuthService, PaymentInitiation},
},
};
pub type BoxedConnectorIntegration<'a, T, Req, Resp> =
Box<&'a (dyn ConnectorIntegration<T, Req, Resp> + Send + Sync)>;
fn get_headers(
&self,
_req: &super::PaymentAuthRouterData<T, Req, Resp>,
_connectors: &auth_types::PaymentMethodAuthConnectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_request_body(
&self,
req: &auth_types::RecipientCreateRouterData,
) -> errors::CustomResult<RequestContent, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn build_error_response(
&self,
res: auth_types::Response,
) -> errors::CustomResult<auth_types::ErrorResponse, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn handle_response(
&self,
data: &auth_types::RecipientCreateRouterData,
res: auth_types::Response,
) -> errors::CustomResult<auth_types::RecipientCreateRouterData, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn build_request(
&self,
req: &auth_types::RecipientCreateRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Option<Request>, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_request_body(
&self,
req: &auth_types::RecipientCreateRouterData,
) -> errors::CustomResult<RequestContent, errors::ConnectorError> {
let req_obj = plaid::PlaidRecipientCreateRequest::from(req);
Ok(RequestContent::Json(Box::new(req_obj)))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_url(
&self,
_req: &auth_types::RecipientCreateRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<String, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use masking::{Mask, Maskable};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_headers(
&self,
req: &auth_types::RecipientCreateRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_error_response(
&self,
res: auth_types::Response,
) -> errors::CustomResult<auth_types::ErrorResponse, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn handle_response(
&self,
data: &auth_types::BankDetailsRouterData,
res: auth_types::Response,
) -> errors::CustomResult<auth_types::BankDetailsRouterData, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn build_request(
&self,
req: &auth_types::BankDetailsRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Option<Request>, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_request_body(
&self,
req: &auth_types::BankDetailsRouterData,
) -> errors::CustomResult<RequestContent, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_url(
&self,
_req: &auth_types::BankDetailsRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<String, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use masking::{Mask, Maskable};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_headers(
&self,
req: &auth_types::BankDetailsRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn handle_response(
&self,
data: &auth_types::ExchangeTokenRouterData,
res: auth_types::Response,
) -> errors::CustomResult<auth_types::ExchangeTokenRouterData, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn build_request(
&self,
req: &auth_types::ExchangeTokenRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Option<Request>, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_request_body(
&self,
req: &auth_types::ExchangeTokenRouterData,
) -> errors::CustomResult<RequestContent, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_url(
&self,
_req: &auth_types::ExchangeTokenRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<String, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use masking::{Mask, Maskable};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_headers(
&self,
req: &auth_types::ExchangeTokenRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn handle_response(
&self,
data: &auth_types::LinkTokenRouterData,
res: auth_types::Response,
) -> errors::CustomResult<auth_types::LinkTokenRouterData, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn build_request(
&self,
req: &auth_types::LinkTokenRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Option<Request>, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_request_body(
&self,
req: &auth_types::LinkTokenRouterData,
) -> errors::CustomResult<RequestContent, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_url(
&self,
_req: &auth_types::LinkTokenRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<String, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use masking::{Mask, Maskable};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_headers(
&self,
req: &auth_types::LinkTokenRouterData,
connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn build_error_response(
&self,
res: auth_types::Response,
) -> errors::CustomResult<auth_types::ErrorResponse, errors::ConnectorError> {
let response: plaid::PlaidErrorResponse =
res.response
.parse_struct("PlaidErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
Ok(auth_types::ErrorResponse {
status_code: res.status_code,
code: crate::consts::NO_ERROR_CODE.to_string(),
message: response.error_message,
reason: response.display_message,
})
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use masking::{Mask, Maskable};
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn get_auth_header(
&self,
auth_type: &auth_types::ConnectorAuthType,
) -> errors::CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use transformers as plaid;
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn base_url<'a>(&self, _connectors: &'a auth_types::PaymentMethodAuthConnectors) -> &'a str {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/pm_auth/src/connector/plaid.rs | crate: pm_auth
use common_utils::{
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
};
use masking::{Mask, Maskable};
use crate::{
core::errors,
types::{
self as auth_types,
api::{
auth_service::{
self, BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate,
},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,
},
},
};
fn build_headers(
&self,
req: &auth_types::PaymentAuthRouterData<Flow, Request, Response>,
_connectors: &auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
use crate::error::KgraphError;
fn into_context(self) -> Result<Vec<dir::DirValue>, KgraphError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use api_models::enums as api_enums;
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
use crate::error::KgraphError;
fn into_dir_value(self) -> Result<dir::DirValue, KgraphError> {
{
api_enums::PaymentMethodType::AmazonPay => Ok(dirval!(WalletType = AmazonPay)),<|fim_suffix|>
<|fim_middle|>
api_enums::PaymentMethodType::DirectCarrierBilling => {
Ok(dirval!(MobilePaymentType = DirectCarrierBilling))
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
use crate::error::KgraphError;
fn into_dir_value(self) -> Result<dir::DirValue, KgraphError> {
{
Self::ThreeDs => Ok(dirval!(AuthenticationType = ThreeDs)),<|fim_suffix|>
<|fim_middle|>
Self::NoThreeDs => Ok(dirval!(AuthenticationType = NoThreeDs)),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use api_models::enums as api_enums;
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
pub fn billing_country_to_dir_value(c: api_enums::Country) -> dir::DirValue {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use api_models::enums as api_enums;
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
pub fn business_country_to_dir_value(c: api_enums::Country) -> dir::DirValue {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
use crate::error::KgraphError;
fn into_dir_value(self) -> Result<dir::DirValue, KgraphError> {
{
Self::Visa => Ok(dirval!(CardNetwork = Visa)),
Self::Mastercard => Ok(dirval!(CardNetwork = Mastercard)),
Self::AmericanExpress => Ok(dirval!(CardNetwork = AmericanExpress)),<|fim_suffix|>
<|fim_middle|>
Self::Interac => Ok(dirval!(CardNetwork = Interac)),
Self::RuPay => Ok(dirval!(CardNetwork = RuPay)),
Self::Maestro => Ok(dirval!(CardNetwork = Maestro)),
}
} | ast_fragments |
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
use crate::error::KgraphError;
fn into_dir_value(self) -> Result<dir::DirValue, KgraphError> {
match self {
Self::Card => Ok(dirval!(PaymentMethod = Card)),
Self::Wallet => Ok(dirval!(PaymentMethod = Wallet)),
Self::PayLater => Ok(dirval!(PaymentMethod = PayLater)),
Self::BankRedirect => Ok(dirval!(PaymentMethod = BankRedirect)),
Self::Crypto => Ok(dirval!(PaymentMethod = Crypto)),
Self::BankDebit => Ok(dirval!(PaymentMethod = BankDebit)),
Self::BankTransfer => Ok(dirval!(PaymentMethod = BankTransfer)),
Self::Reward => Ok(dirval!(PaymentMethod = Reward)),
Self::RealTimePayment => Ok(dirval!(PaymentMethod = RealTimePayment)),
Self::Upi => Ok(dirval!(PaymentMethod = Upi)),
Self::Voucher => Ok(dirval!(PaymentMethod = Voucher)),
Self::GiftCard => Ok(dirval!(PaymentMethod = GiftCard)),
Self::CardRedirect => Ok(dirval!(PaymentMethod = CardRedirect)),
Self::OpenBanking => Ok(dirval!(PaymentMethod = OpenBanking)),
Self::MobilePayment => Ok(dirval!(PaymentMethod = MobilePayment)),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use api_models::enums as api_enums;
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
pub fn get_dir_country_dir_value(c: api_enums::Country) -> dir::enums::Country {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/transformers.rs | crate: kgraph_utils
use api_models::enums as api_enums;
use euclid::{
backend::BackendInput,
dirval,
dssa::types::AnalysisErrorType,
frontend::{ast, dir},
types::{NumValue, StrValue},
};
use crate::error::KgraphError;
fn into_dir_value(self) -> Result<dir::DirValue, KgraphError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn compile_merchant_connector_graph(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
mca: admin_api::MerchantConnectorResponse,
config: &kgraph_types::CountryCurrencyFilter,
) -> Result<(), KgraphError> {
let connector = common_enums::RoutableConnectors::from_str(&mca.connector_name)
.map_err(|_| KgraphError::InvalidConnectorName(mca.connector_name.clone()))?;
let mut agg_nodes: Vec<(cgraph::NodeId, cgraph::Relation, cgraph::Strength)> = Vec::new();
if let Some(pms_enabled) = mca.payment_methods_enabled.clone() {
for pm_enabled in pms_enabled {
let maybe_pm_enabled_id = compile_payment_method_enabled(builder, pm_enabled)?;
if let Some(pm_enabled_id) = maybe_pm_enabled_id {
agg_nodes.push((
pm_enabled_id,
cgraph::Relation::Positive,
cgraph::Strength::Strong,
));
}
}
}
let aggregator_info = "Available Payment methods for connector";
let pms_enabled_agg_id = builder
.make_any_aggregator(&agg_nodes, Some(aggregator_info), None::<()>, None)
.map_err(KgraphError::GraphConstructionError)?;
let config_info = "Config for respective PaymentMethodType for the connector";
let config_enabled_agg_id = compile_config_graph(builder, config, connector)?;
let domain_level_node_id = builder
.make_all_aggregator(
&[
(
config_enabled_agg_id,
cgraph::Relation::Positive,
cgraph::Strength::Normal,
),
(
pms_enabled_agg_id,
cgraph::Relation::Positive,
cgraph::Strength::Normal,
),
],
Some(config_info),
None::<()>,
None,
)
.map_err(KgraphError::GraphConstructionError)?;
let connector_dir_val = dir::DirValue::Connector(Box::new(ast::ConnectorChoice { connector }));
let connector_info = "Connector";
let connector_node_id =
builder.make_value_node(connector_dir_val.into(), Some(connector_info), None::<()>);
builder
.make_edge(
domain_level_node_id,
connector_node_id,
cgraph::Strength::Normal,
cgraph::Relation::Positive,
None::<cgraph::DomainId>,
)
.map_err(KgraphError::GraphConstructionError)?;
Ok(())
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn compile_merchant_connector_graph(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
mca: admin_api::MerchantConnectorResponse,
config: &kgraph_types::CountryCurrencyFilter,
) -> Result<(), KgraphError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn compile_graph_for_countries_and_currencies(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
config: &kgraph_types::CurrencyCountryFlowFilter,
payment_method_type_node: cgraph::NodeId,
) -> Result<cgraph::NodeId, KgraphError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
fn global_vec_pmt(
enabled_pmt: Vec<dir::DirValue>,
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
) -> Vec<cgraph::NodeId> {
{let mut global_vector: Vec<dir::DirValue> = Vec::new();<|fim_suffix|>
<|fim_middle|>
global_vector
.into_iter()
.map(|dir_v| {
builder.make_value_node(
cgraph::NodeValue::Value(dir_v),
Some("Payment Method Type"),
None::<()>,
)
})
.collect::<Vec<_>>()}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn compile_payment_method_enabled(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
enabled: admin_api::PaymentMethodsEnabled,
) -> Result<Option<cgraph::NodeId>, KgraphError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn compile_payment_method_enabled(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
enabled: common_types::payment_methods::PaymentMethodsEnabled,
) -> Result<Option<cgraph::NodeId>, KgraphError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn get_dir_value_payment_method(
from: api_enums::PaymentMethodType,
) -> Result<dir::DirValue, KgraphError> {
{
api_enums::PaymentMethodType::AmazonPay => Ok(dirval!(WalletType = AmazonPay)),<|fim_suffix|>
<|fim_middle|>
api_enums::PaymentMethodType::DirectCarrierBilling => {
Ok(dirval!(MobilePaymentType = DirectCarrierBilling))
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
fn test_incomplete_data_failure_case2() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
fn test_incomplete_data_failure_case() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
fn test_amount_mismatch_failure_case() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
fn test_single_mismatch_failure_case() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
fn test_debit_card_success_case() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
fn test_credit_card_success_case() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
pub fn make_mca_graph(
accts: Vec<admin_api::MerchantConnectorResponse>,
config: &kgraph_types::CountryCurrencyFilter,
) -> Result<cgraph::ConstraintGraph<dir::DirValue>, KgraphError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn compile_config_graph(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
config: &kgraph_types::CountryCurrencyFilter,
connector: api_enums::RoutableConnectors,
) -> Result<cgraph::NodeId, KgraphError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn get_dir_value_payment_method(
from: api_enums::PaymentMethodType,
) -> Result<dir::DirValue, KgraphError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn test_sandbox_applepay_bug_usecase() {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use std::str::FromStr;
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use strum::IntoEnumIterator;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn build_test_data() -> ConstraintGraph<dir::DirValue> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn compile_request_pm_types(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
pm_types: RequestPaymentMethodTypes,
pm: api_enums::PaymentMethod,
) -> Result<cgraph::NodeId, KgraphError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/kgraph_utils/src/mca.rs | crate: kgraph_utils
use api_models::{
admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes,
refunds::MinorUnit,
};
use euclid::{
dirval,
frontend::{ast, dir},
types::{NumValue, NumValueRefinement},
};
use hyperswitch_constraint_graph as cgraph;
use crate::{error::KgraphError, transformers::IntoDirValue, types as kgraph_types};
fn compile_request_pm_types(
builder: &mut cgraph::ConstraintGraphBuilder<dir::DirValue>,
pm_types: common_types::payment_methods::RequestPaymentMethodTypes,
pm: api_enums::PaymentMethod,
) -> Result<cgraph::NodeId, KgraphError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email.rs | crate: external_services
pub type EmailResult<T> = CustomResult<T, EmailError>;
/// Validation for the Email client specific configurations
pub fn validate(&self) -> Result<(), &'static str> {
{
EmailClientConfigs::Ses { ref aws_ses } => aws_ses.validate(),<|fim_suffix|>
<|fim_middle|>
EmailClientConfigs::NoEmailClient => Ok(()),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email.rs | crate: external_services
pub type EmailResult<T> = CustomResult<T, EmailError>;
/// Validation for the Email client specific configurations
pub fn validate(&self) -> Result<(), &'static str> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email.rs | crate: external_services
pub type EmailResult<T> = CustomResult<T, EmailError>;
/// Get the inner String
pub fn into_inner(self) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email.rs | crate: external_services
pub type EmailResult<T> = CustomResult<T, EmailError>;
/// Create a new Instance of IntermediateString using a string
pub fn new(inner: String) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email.rs | crate: external_services
pub type EmailResult<T> = CustomResult<T, EmailError>;
async fn compose_and_send_email(
&self,
base_url: &str,
email_data: Box<dyn EmailData + Send>,
proxy_url: Option<&String>,
) -> EmailResult<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/file_storage.rs | crate: external_services
/// Validates the file storage configuration.
pub fn validate(&self) -> Result<(), InvalidFileStorageConfig> {
{
#[cfg(feature = "aws_s3")]
Self::AwsS3 { aws_s3 } => aws_s3.validate(),<|fim_suffix|>
<|fim_middle|>
Self::FileSystem => Ok(()),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/file_storage.rs | crate: external_services
use std::{
fmt::{Display, Formatter},
sync::Arc,
};
/// Retrieves the appropriate file storage client based on the file storage configuration.
pub async fn get_file_storage_client(&self) -> Arc<dyn FileStorageInterface> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/file_storage.rs | crate: external_services
/// Validates the file storage configuration.
pub fn validate(&self) -> Result<(), InvalidFileStorageConfig> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/managers/secrets_management.rs | crate: external_services
use common_utils::errors::CustomResult;
use hyperswitch_interfaces::secrets_interface::{
SecretManagementInterface, SecretsManagementError,
};
use crate::aws_kms;
use crate::hashicorp_vault;
use crate::no_encryption::core::NoEncryption;
/// Retrieves the appropriate secret management client based on the configuration.
pub async fn get_secret_management_client(
&self,
) -> CustomResult<Box<dyn SecretManagementInterface>, SecretsManagementError> {
{
#[cfg(feature = "aws_kms")]
Self::AwsKms { aws_kms } => {
Ok(Box::new(aws_kms::core::AwsKmsClient::new(aws_kms).await))
}<|fim_suffix|>
<|fim_middle|>
Self::NoEncryption => Ok(Box::new(NoEncryption)),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/managers/secrets_management.rs | crate: external_services
use common_utils::errors::CustomResult;
use hyperswitch_interfaces::secrets_interface::{
SecretManagementInterface, SecretsManagementError,
};
use crate::aws_kms;
use crate::hashicorp_vault;
use crate::no_encryption::core::NoEncryption;
/// Retrieves the appropriate secret management client based on the configuration.
pub async fn get_secret_management_client(
&self,
) -> CustomResult<Box<dyn SecretManagementInterface>, SecretsManagementError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/managers/secrets_management.rs | crate: external_services
use crate::aws_kms;
use crate::no_encryption::core::NoEncryption;
/// Verifies that the client configuration is usable
pub fn validate(&self) -> Result<(), &'static str> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/managers/encryption_management.rs | crate: external_services
use std::sync::Arc;
use common_utils::errors::CustomResult;
use hyperswitch_interfaces::encryption_interface::{
EncryptionError, EncryptionManagementInterface,
};
use crate::aws_kms;
use crate::no_encryption::core::NoEncryption;
/// Retrieves the appropriate encryption client based on the configuration.
pub async fn get_encryption_management_client(
&self,
) -> CustomResult<Arc<dyn EncryptionManagementInterface>, EncryptionError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/managers/encryption_management.rs | crate: external_services
use crate::aws_kms;
use crate::no_encryption::core::NoEncryption;
/// Verifies that the client configuration is usable
pub fn validate(&self) -> Result<(), &'static str> {
{
#[cfg(feature = "aws_kms")]
Self::AwsKms { aws_kms } => aws_kms.validate(),<|fim_suffix|>
<|fim_middle|>
Self::NoEncryption => Ok(()),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/managers/encryption_management.rs | crate: external_services
use std::sync::Arc;
use common_utils::errors::CustomResult;
use hyperswitch_interfaces::encryption_interface::{
EncryptionError, EncryptionManagementInterface,
};
use crate::aws_kms;
use crate::no_encryption::core::NoEncryption;
/// Retrieves the appropriate encryption client based on the configuration.
pub async fn get_encryption_management_client(
&self,
) -> CustomResult<Arc<dyn EncryptionManagementInterface>, EncryptionError> {
{
#[cfg(feature = "aws_kms")]
Self::AwsKms { aws_kms } => Arc::new(aws_kms::core::AwsKmsClient::new(aws_kms).await),<|fim_suffix|>
<|fim_middle|>
Self::NoEncryption => Arc::new(NoEncryption),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/health_check_client.rs | crate: external_services
use api_models::health_check::{HealthCheckMap, HealthCheckServices};
pub use health_check::{
health_check_response::ServingStatus, health_client::HealthClient, HealthCheckRequest,
HealthCheckResponse,
};
use router_env::logger;
use super::{Client, DynamicRoutingClientConfig, GrpcClientSettings};
pub type HealthCheckResult<T> = CustomResult<T, HealthCheckError>;
/// Perform health check for all services involved
pub async fn perform_health_check(
&self,
config: &GrpcClientSettings,
) -> HealthCheckResult<HealthCheckMap> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/health_check_client.rs | crate: external_services
use std::{collections::HashMap, fmt::Debug};
use api_models::health_check::{HealthCheckMap, HealthCheckServices};
pub use health_check::{
health_check_response::ServingStatus, health_client::HealthClient, HealthCheckRequest,
HealthCheckResponse,
};
use super::{Client, DynamicRoutingClientConfig, GrpcClientSettings};
pub type HealthCheckResult<T> = CustomResult<T, HealthCheckError>;
/// Build connections to all gRPC services
pub async fn build_connections(
config: &GrpcClientSettings,
client: Client,
) -> Result<Self, Box<dyn std::error::Error>> {
{
DynamicRoutingClientConfig::Enabled {
host,
port,
service,
} => Some((host.clone(), *port, service.clone())),<|fim_suffix|>
<|fim_middle|>
_ => None,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/health_check_client.rs | crate: external_services
use api_models::health_check::{HealthCheckMap, HealthCheckServices};
pub use health_check::{
health_check_response::ServingStatus, health_client::HealthClient, HealthCheckRequest,
HealthCheckResponse,
};
use router_env::logger;
use super::{Client, DynamicRoutingClientConfig, GrpcClientSettings};
pub type HealthCheckResult<T> = CustomResult<T, HealthCheckError>;
/// Perform health check for all services involved
pub async fn perform_health_check(
&self,
config: &GrpcClientSettings,
) -> HealthCheckResult<HealthCheckMap> {
{
DynamicRoutingClientConfig::Enabled {
host,
port,
service,
} => Some((host.clone(), *port, service.clone())),<|fim_suffix|>
<|fim_middle|>
_ => None,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/health_check_client.rs | crate: external_services
pub use health_check::{
health_check_response::ServingStatus, health_client::HealthClient, HealthCheckRequest,
HealthCheckResponse,
};
use super::{Client, DynamicRoutingClientConfig, GrpcClientSettings};
pub type HealthCheckResult<T> = CustomResult<T, HealthCheckError>;
async fn get_response_from_grpc_service(
&self,
service: String,
client: Option<&HealthClient<Client>>,
) -> HealthCheckResult<HealthCheckResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/contract_routing_client.rs | crate: external_services
use api_models::routing::{
ContractBasedRoutingConfig, ContractBasedRoutingConfigBody, ContractBasedTimeScale,
LabelInformation, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus,
};
pub use contract_routing::{
contract_score_calculator_client::ContractScoreCalculatorClient, CalContractScoreConfig,
CalContractScoreRequest, CalContractScoreResponse, InvalidateContractRequest,
InvalidateContractResponse, LabelInformation as ProtoLabelInfo, TimeScale,
UpdateContractRequest, UpdateContractResponse,
};
use router_env::logger;
use crate::grpc_client::{self, GrpcHeaders};
use super::{Client, DynamicRoutingError, DynamicRoutingResult};
async fn update_contracts(
&self,
id: String,
label_info: Vec<LabelInformation>,
params: String,
_response: Vec<RoutableConnectorChoiceWithStatus>,
incr_count: u64,
headers: GrpcHeaders,
) -> DynamicRoutingResult<UpdateContractResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/contract_routing_client.rs | crate: external_services
use api_models::routing::{
ContractBasedRoutingConfig, ContractBasedRoutingConfigBody, ContractBasedTimeScale,
LabelInformation, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus,
};
use common_utils::{
ext_traits::OptionExt,
transformers::{ForeignFrom, ForeignTryFrom},
};
pub use contract_routing::{
contract_score_calculator_client::ContractScoreCalculatorClient, CalContractScoreConfig,
CalContractScoreRequest, CalContractScoreResponse, InvalidateContractRequest,
InvalidateContractResponse, LabelInformation as ProtoLabelInfo, TimeScale,
UpdateContractRequest, UpdateContractResponse,
};
use router_env::logger;
use crate::grpc_client::{self, GrpcHeaders};
pub use tonic::Code;
use super::{Client, DynamicRoutingError, DynamicRoutingResult};
async fn calculate_contract_score(
&self,
id: String,
config: ContractBasedRoutingConfig,
params: String,
label_input: Vec<RoutableConnectorChoice>,
headers: GrpcHeaders,
) -> DynamicRoutingResult<CalContractScoreResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/contract_routing_client.rs | crate: external_services
use api_models::routing::{
ContractBasedRoutingConfig, ContractBasedRoutingConfigBody, ContractBasedTimeScale,
LabelInformation, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus,
};
fn foreign_from(scale: ContractBasedTimeScale) -> Self {
{
ContractBasedTimeScale::Day => 0,<|fim_suffix|>
<|fim_middle|>
_ => 1,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/contract_routing_client.rs | crate: external_services
use api_models::routing::{
ContractBasedRoutingConfig, ContractBasedRoutingConfigBody, ContractBasedTimeScale,
LabelInformation, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus,
};
pub use contract_routing::{
contract_score_calculator_client::ContractScoreCalculatorClient, CalContractScoreConfig,
CalContractScoreRequest, CalContractScoreResponse, InvalidateContractRequest,
InvalidateContractResponse, LabelInformation as ProtoLabelInfo, TimeScale,
UpdateContractRequest, UpdateContractResponse,
};
fn foreign_from(config: LabelInformation) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/contract_routing_client.rs | crate: external_services
use api_models::routing::{
ContractBasedRoutingConfig, ContractBasedRoutingConfigBody, ContractBasedTimeScale,
LabelInformation, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus,
};
pub use contract_routing::{
contract_score_calculator_client::ContractScoreCalculatorClient, CalContractScoreConfig,
CalContractScoreRequest, CalContractScoreResponse, InvalidateContractRequest,
InvalidateContractResponse, LabelInformation as ProtoLabelInfo, TimeScale,
UpdateContractRequest, UpdateContractResponse,
};
use super::{Client, DynamicRoutingError, DynamicRoutingResult};
fn foreign_try_from(config: ContractBasedRoutingConfigBody) -> Result<Self, Self::Error> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/contract_routing_client.rs | crate: external_services
use api_models::routing::{
ContractBasedRoutingConfig, ContractBasedRoutingConfigBody, ContractBasedTimeScale,
LabelInformation, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus,
};
fn foreign_from(scale: ContractBasedTimeScale) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing/contract_routing_client.rs | crate: external_services
pub use contract_routing::{
contract_score_calculator_client::ContractScoreCalculatorClient, CalContractScoreConfig,
CalContractScoreRequest, CalContractScoreResponse, InvalidateContractRequest,
InvalidateContractResponse, LabelInformation as ProtoLabelInfo, TimeScale,
UpdateContractRequest, UpdateContractResponse,
};
use crate::grpc_client::{self, GrpcHeaders};
use super::{Client, DynamicRoutingError, DynamicRoutingResult};
async fn invalidate_contracts(
&self,
id: String,
headers: GrpcHeaders,
) -> DynamicRoutingResult<InvalidateContractResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email/smtp.rs | crate: external_services
use std::time::Duration;
use common_utils::{errors::CustomResult, pii};
use lettre::{
address::AddressError,
error,
message::{header::ContentType, Mailbox},
transport::smtp::{self, authentication::Credentials},
Message, SmtpTransport, Transport,
};
use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString};
async fn send_email(
&self,
recipient: pii::Email,
subject: String,
body: Self::RichText,
_proxy_url: Option<&String>,
) -> EmailResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email/smtp.rs | crate: external_services
use std::time::Duration;
use lettre::{
address::AddressError,
error,
message::{header::ContentType, Mailbox},
transport::smtp::{self, authentication::Credentials},
Message, SmtpTransport, Transport,
};
/// A helper function to create SMTP server client
pub fn create_client(&self) -> Result<SmtpTransport, SmtpError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email/smtp.rs | crate: external_services
use std::time::Duration;
use lettre::{
address::AddressError,
error,
message::{header::ContentType, Mailbox},
transport::smtp::{self, authentication::Credentials},
Message, SmtpTransport, Transport,
};
/// A helper function to create SMTP server client
pub fn create_client(&self) -> Result<SmtpTransport, SmtpError> {
{
Some(credentials) => Ok(SmtpTransport::starttls_relay(&host)
.map_err(SmtpError::ConnectionFailure)?
.port(port)
.timeout(timeout)
.credentials(credentials)
.build()),<|fim_suffix|>
<|fim_middle|>
None => Ok(SmtpTransport::starttls_relay(&host)
.map_err(SmtpError::ConnectionFailure)?
.port(port)
.timeout(timeout)
.build()),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email/smtp.rs | crate: external_services
use std::time::Duration;
use common_utils::{errors::CustomResult, pii};
use error_stack::ResultExt;
use lettre::{
address::AddressError,
error,
message::{header::ContentType, Mailbox},
transport::smtp::{self, authentication::Credentials},
Message, SmtpTransport, Transport,
};
use masking::{PeekInterface, Secret};
use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString};
/// Validation for the SMTP server client specific configs
pub fn validate(&self) -> Result<(), &'static str> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email/smtp.rs | crate: external_services
use lettre::{
address::AddressError,
error,
message::{header::ContentType, Mailbox},
transport::smtp::{self, authentication::Credentials},
Message, SmtpTransport, Transport,
};
use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString};
/// helper function to convert email id into Mailbox
fn to_mail_box(email: String) -> EmailResult<Mailbox> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/external_services/src/email/smtp.rs | crate: external_services
use crate::email::{EmailClient, EmailError, EmailResult, EmailSettings, IntermediateString};
/// Constructs a new SMTP client
pub async fn create(conf: &EmailSettings, smtp_config: SmtpServerConfig) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid_macros/src/inner/enum_nums.rs | crate: euclid_macros
use proc_macro::TokenStream;
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::quote;
pub(crate) fn enum_nums_inner(ts: TokenStream) -> TokenStream {
{
syn::Fields::Unit => {}<|fim_suffix|>
<|fim_middle|>
_ => return error().into(),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid_macros/src/inner/enum_nums.rs | crate: euclid_macros
use proc_macro::TokenStream;
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::quote;
pub(crate) fn enum_nums_inner(ts: TokenStream) -> TokenStream {
{
syn::Data::Enum(e) => e,<|fim_suffix|>
<|fim_middle|>
_ => return error().into(),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid_macros/src/inner/enum_nums.rs | crate: euclid_macros
use proc_macro2::{Span, TokenStream as TokenStream2};
fn error() -> TokenStream2 {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/euclid_macros/src/inner/enum_nums.rs | crate: euclid_macros
use proc_macro2::{Span, TokenStream as TokenStream2};
fn error() -> TokenStream2 {
syn::Error::new(
Span::call_site(),
"'EnumNums' can only be derived on enums with unit variants".to_string(),
)
.to_compile_error()
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid_macros/src/inner/knowledge.rs | crate: euclid_macros
use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote};
fn compile_rule(&mut self, rule: &Rule, tokens: &mut TokenStream) -> Result<(), String> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid_macros/src/inner/knowledge.rs | crate: euclid_macros
use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote};
fn compile_atom_type(
&mut self,
atom_type: &AtomType,
tokens: &mut TokenStream,
) -> Result<(proc_macro2::Ident, Relation), String> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.