+ duration
+ summary
+ request method/url
+ request headers/body
+ response code/message/headers/body
/** * Get the delivery log for the given webhook ID and delivery ID * * @since 2.2 * @param string $webhook_id webhook ID * @param string $id delivery log ID * @param string|null $fields fields to limit response to * @return array */ public function get_webhook_delivery($webhook_id, $id, $fields = null) { try { // Validate webhook ID $webhook_id = $this->validate_request($webhook_id, 'shop_webhook', 'read'); if (is_wp_error($webhook_id)) { return $webhook_id; } $id = absint($id); if (empty($id)) { throw new WC_API_Exception('woocommerce_api_invalid_webhook_delivery_id', __('Invalid webhook delivery ID', 'woocommerce'), 404); } $webhook = new WC_Webhook($webhook_id); $log = $webhook->get_delivery_log($id); if (!$log) { throw new WC_API_Exception('woocommerce_api_invalid_webhook_delivery_id', __('Invalid webhook delivery', 'woocommerce'), 400); } $delivery_log = $log; // Add timestamp $delivery_log['created_at'] = $this->server->format_datetime($log['comment']->comment_date_gmt); // Remove comment object unset($delivery_log['comment']); return array('webhook_delivery' => apply_filters('woocommerce_api_webhook_delivery_response', $delivery_log, $id, $fields, $log, $webhook_id, $this)); } catch (WC_API_Exception $e) { return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode())); } }
/** * Get a single webhook delivery. * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|WP_REST_Response */ public function get_item($request) { $id = (int) $request['id']; $webhook = new WC_Webhook((int) $request['webhook_id']); if (empty($webhook->post_data->post_type) || 'shop_webhook' !== $webhook->post_data->post_type) { return new WP_Error('woocommerce_rest_webhook_invalid_id', __('Invalid webhook id.', 'woocommerce'), array('status' => 404)); } $log = $webhook->get_delivery_log($id); if (empty($id) || empty($log)) { return new WP_Error('woocommerce_rest_invalid_id', __('Invalid resource id.', 'woocommerce'), array('status' => 404)); } $delivery = $this->prepare_item_for_response((object) $log, $request); $response = rest_ensure_response($delivery); return $response; }