guard( 'manage_pointics', 'manage_options' ); if ( null !== $guard ) { return $guard; } $ready = $this->pointics_tables_ready(); if ( null !== $ready ) { return $this->steer( $ready ); } try { $request = new \WP_REST_Request( 'GET', '/pointics/v1/rewards/' . $reward_id ); $request->set_url_params( [ 'id' => $reward_id ] ); $controller = pointics_container()->make( \Pointics\Api\Controllers\Rewards_Controller::class ); $data = $this->extract_response( $controller->get_reward( $request ), __( 'Failed to retrieve the Pointics reward.', 'aisentic' ), 'pointics-get-reward' ); if ( $this->is_error( $data ) ) { return $data; } return $this->shape_reward( $data ); } catch ( \Throwable $e ) { Log::error( 'Pointics_Get_Reward_Tool error', [ 'error' => $e->getMessage() ] ); return $this->steer( [ 'error' => __( 'Failed to retrieve the Pointics reward.', 'aisentic' ), 'code' => 'internal', 'status' => null, ] ); } } }