feat(merchant_account): add merchant account list endpoint (#2560)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Narayan Bhat
2023-10-18 12:53:18 +05:30
committed by GitHub
parent 373a10beff
commit a1472c6b78
13 changed files with 244 additions and 3 deletions

View File

@ -252,6 +252,31 @@ pub async fn create_merchant_account(
))
}
#[cfg(feature = "olap")]
pub async fn list_merchant_account(
state: AppState,
req: api_models::admin::MerchantAccountListRequest,
) -> RouterResponse<Vec<api::MerchantAccountResponse>> {
let merchant_accounts = state
.store
.list_merchant_accounts_by_organization_id(&req.organization_id)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let merchant_accounts = merchant_accounts
.into_iter()
.map(|merchant_account| {
merchant_account
.try_into()
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "merchant_account",
})
})
.collect::<Result<Vec<_>, _>>()?;
Ok(services::ApplicationResponse::Json(merchant_accounts))
}
pub async fn get_merchant_account(
state: AppState,
req: api::MerchantId,