mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 05:17:02 +08:00
feat(router): add mandates list api (#1143)
This commit is contained in:
committed by
GitHub
parent
bd8868efd0
commit
75ba3ff09f
@ -1,5 +1,6 @@
|
||||
use common_utils::{ext_traits::Encode, pii};
|
||||
use error_stack::{report, ResultExt};
|
||||
use futures::future;
|
||||
use router_env::{instrument, logger, tracing};
|
||||
use storage_models::enums as storage_enums;
|
||||
|
||||
@ -259,6 +260,25 @@ where
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
#[instrument(skip(state))]
|
||||
pub async fn retrieve_mandates_list(
|
||||
state: &AppState,
|
||||
merchant_account: storage::MerchantAccount,
|
||||
constraints: api_models::mandates::MandateListConstraints,
|
||||
) -> RouterResponse<Vec<api_models::mandates::MandateResponse>> {
|
||||
let mandates = state
|
||||
.store
|
||||
.find_mandates_by_merchant_id(&merchant_account.merchant_id, constraints)
|
||||
.await
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Unable to retrieve mandates")?;
|
||||
let mandates_list = future::try_join_all(mandates.into_iter().map(|mandate| {
|
||||
mandates::MandateResponse::from_db_mandate(state, mandate, &merchant_account)
|
||||
}))
|
||||
.await?;
|
||||
Ok(services::ApplicationResponse::Json(mandates_list))
|
||||
}
|
||||
|
||||
impl ForeignTryFrom<Result<types::PaymentsResponseData, types::ErrorResponse>>
|
||||
for Option<pii::SecretSerdeValue>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user