mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
feat(customers): add time range filtering and count functionality to customer list endpoints (#9767)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
e7dee751b5
commit
587588f870
21
crates/router/src/core/utils/customer_validation.rs
Normal file
21
crates/router/src/core/utils/customer_validation.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use crate::core::errors::{self, CustomResult};
|
||||
|
||||
pub const CUSTOMER_LIST_LOWER_LIMIT: u16 = 1;
|
||||
pub const CUSTOMER_LIST_UPPER_LIMIT: u16 = 100;
|
||||
pub const CUSTOMER_LIST_DEFAULT_LIMIT: u16 = 10;
|
||||
|
||||
pub fn validate_customer_list_limit(
|
||||
limit: Option<u16>,
|
||||
) -> CustomResult<u16, errors::ApiErrorResponse> {
|
||||
match limit {
|
||||
Some(l) if (CUSTOMER_LIST_LOWER_LIMIT..=CUSTOMER_LIST_UPPER_LIMIT).contains(&l) => Ok(l),
|
||||
Some(_) => Err(errors::ApiErrorResponse::InvalidRequestData {
|
||||
message: format!(
|
||||
"limit should be between {} and {}",
|
||||
CUSTOMER_LIST_LOWER_LIMIT, CUSTOMER_LIST_UPPER_LIMIT
|
||||
),
|
||||
}
|
||||
.into()),
|
||||
None => Ok(CUSTOMER_LIST_DEFAULT_LIMIT),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user