Skip to content

Commit

Permalink
fix(refund_list): updated refund list response status code when no re…
Browse files Browse the repository at this point in the history
…funds found. (#974)

Co-authored-by: hrithikesh vm <[email protected]>
  • Loading branch information
hrithikesh026 and hrithikesh vm authored May 2, 2023
1 parent 22a5372 commit 4e0489c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion crates/api_models/src/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ pub struct RefundListRequest {

#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)]
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>,
}

Expand Down
8 changes: 4 additions & 4 deletions crates/router/src/core/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,11 @@ pub async fn refund_list(
.into_iter()
.map(ForeignInto::foreign_into)
.collect();
utils::when(data.is_empty(), || {
Err(errors::ApiErrorResponse::RefundNotFound)
})?;
Ok(services::ApplicationResponse::Json(
api_models::refunds::RefundListResponse { data },
api_models::refunds::RefundListResponse {
size: data.len(),
data,
},
))
}

Expand Down
1 change: 0 additions & 1 deletion crates/router/src/routes/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ pub async fn refunds_update(
),
responses(
(status = 200, description = "List of refunds", body = RefundListResponse),
(status = 404, description = "Refund does not exist in our records")
),
tag = "Refunds",
operation_id = "List all Refunds",
Expand Down

0 comments on commit 4e0489c

Please sign in to comment.