fix(refund_list): updated refund list response status code when no refunds found. (#974)

Co-authored-by: hrithikesh vm <hrithikesh.vm@hrithikesh.vm-MacBookPro>
This commit is contained in:
Hrithikesh
2023-05-03 01:55:46 +05:30
committed by GitHub
parent 22a5372481
commit 4e0489cf1c
3 changed files with 7 additions and 6 deletions

View File

@ -146,7 +146,9 @@ pub struct RefundListRequest {
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)] #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
pub struct RefundListResponse { pub struct RefundListResponse {
/// The list of refund response /// The number of refunds included in the list
pub size: usize,
/// The List of refund response object
pub data: Vec<RefundResponse>, pub data: Vec<RefundResponse>,
} }

View File

@ -626,11 +626,11 @@ pub async fn refund_list(
.into_iter() .into_iter()
.map(ForeignInto::foreign_into) .map(ForeignInto::foreign_into)
.collect(); .collect();
utils::when(data.is_empty(), || {
Err(errors::ApiErrorResponse::RefundNotFound)
})?;
Ok(services::ApplicationResponse::Json( Ok(services::ApplicationResponse::Json(
api_models::refunds::RefundListResponse { data }, api_models::refunds::RefundListResponse {
size: data.len(),
data,
},
)) ))
} }

View File

@ -183,7 +183,6 @@ pub async fn refunds_update(
), ),
responses( responses(
(status = 200, description = "List of refunds", body = RefundListResponse), (status = 200, description = "List of refunds", body = RefundListResponse),
(status = 404, description = "Refund does not exist in our records")
), ),
tag = "Refunds", tag = "Refunds",
operation_id = "List all Refunds", operation_id = "List all Refunds",