Skip to content

Commit

Permalink
Apply Deposits API changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
shendy-a8c committed Dec 23, 2023
1 parent 4e2918f commit dcf4de7
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions includes/admin/class-wc-rest-payments-deposits-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ public function register_routes() {
public function get_deposits( $request ) {
$wcpay_request = List_Deposits::from_rest_request( $request );

return $wcpay_request->handle_rest_request();
$response = $wcpay_request->handle_rest_request();
$no_estimated_deposits = array_filter(
$response['data'],
function( $deposit ) {
return 'estimated' !== $deposit['status'];
}
);
$no_estimated_deposits = array_values( $no_estimated_deposits );
$response['data'] = $no_estimated_deposits;
return $response;
}

/**
Expand All @@ -120,7 +129,11 @@ public function get_deposits_summary( $request ) {
public function get_deposits_overview() {
$request = Request::get( WC_Payments_API_Client::DEPOSITS_API . '/overview' );
$request->assign_hook( 'wcpay_get_deposits_overview' );
return $request->handle_rest_request();
$response = $request->handle_rest_request();
unset( $response['next_deposit'] );
unset( $response['balance']['pending']['deposits_count'] );
unset( $response['balance']['instant_balance']['transaction_ids'] );
return $response;
}

/**
Expand All @@ -129,7 +142,17 @@ public function get_deposits_overview() {
public function get_all_deposits_overviews() {
$request = Request::get( WC_Payments_API_Client::DEPOSITS_API . '/overview-all' );
$request->assign_hook( 'wcpay_get_all_deposits_overviews' );
return $request->handle_rest_request();
$response = $request->handle_rest_request();
unset( $response['deposit']['next_scheduled'] );
$count = count( $response['balance']['instant'] );
for ( $i = 0; $i < $count; $i++ ) {
unset( $response['balance']['instant'][ $i ]['transaction_ids'] );
}
$count = count( $response['balance']['pending'] );
for ( $i = 0; $i < $count; $i++ ) {
unset( $response['balance']['pending'][ $i ]['deposits_count'] );
}
return $response;
}

/**
Expand Down

0 comments on commit dcf4de7

Please sign in to comment.