本文整理汇总了PHP中WC_Webhook::get_delivery_url方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Webhook::get_delivery_url方法的具体用法?PHP WC_Webhook::get_delivery_url怎么用?PHP WC_Webhook::get_delivery_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Webhook
的用法示例。
在下文中一共展示了WC_Webhook::get_delivery_url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_webhook
/**
* Get the webhook for the given ID
*
* @since 2.2
* @param int $id webhook ID
* @param array $fields
* @return array
*/
public function get_webhook($id, $fields = null)
{
// ensure webhook ID is valid & user has permission to read
$id = $this->validate_request($id, 'shop_webhook', 'read');
if (is_wp_error($id)) {
return $id;
}
$webhook = new WC_Webhook($id);
$webhook_data = array('id' => $webhook->id, 'name' => $webhook->get_name(), 'status' => $webhook->get_status(), 'topic' => $webhook->get_topic(), 'resource' => $webhook->get_resource(), 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), 'created_at' => $this->server->format_datetime($webhook->get_post_data()->post_date_gmt), 'updated_at' => $this->server->format_datetime($webhook->get_post_data()->post_modified_gmt));
return array('webhook' => apply_filters('woocommerce_api_webhook_response', $webhook_data, $webhook, $fields, $this));
}
示例2: check_get_webhook_response
/**
* Ensure valid webhook data response.
*
* @since 2.2
* @param array $response
* @param WC_Webhook $webhook
*/
protected function check_get_webhook_response($response, $webhook)
{
$this->assertEquals($webhook->id, $response['id']);
$this->assertEquals($webhook->get_name(), $response['name']);
$this->assertEquals($webhook->get_status(), $response['status']);
$this->assertEquals($webhook->get_topic(), $response['topic']);
$this->assertEquals($webhook->get_resource(), $response['resource']);
$this->assertEquals($webhook->get_event(), $response['event']);
$this->assertEquals($webhook->get_hooks(), $response['hooks']);
$this->assertEquals($webhook->get_delivery_url(), $response['delivery_url']);
$this->assertArrayHasKey('created_at', $response);
$this->assertArrayHasKey('updated_at', $response);
}
示例3: prepare_item_for_response
/**
* Prepare a single webhook output for response.
*
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response Response data.
*/
public function prepare_item_for_response($post, $request)
{
$id = (int) $post->ID;
$webhook = new WC_Webhook($id);
$data = array('id' => $webhook->id, 'name' => $webhook->get_name(), 'status' => $webhook->get_status(), 'topic' => $webhook->get_topic(), 'resource' => $webhook->get_resource(), 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), 'date_created' => wc_rest_prepare_date_response($webhook->get_post_data()->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($webhook->get_post_data()->post_modified_gmt));
$context = !empty($request['context']) ? $request['context'] : 'view';
$data = $this->add_additional_fields_to_object($data, $request);
$data = $this->filter_response_by_context($data, $context);
// Wrap the data in a response object.
$response = rest_ensure_response($data);
$response->add_links($this->prepare_links($post));
/**
* Filter webhook object returned from the REST API.
*
* @param WP_REST_Response $response The response object.
* @param WC_Webhook $webhook Webhook object used to create response.
* @param WP_REST_Request $request Request object.
*/
return apply_filters("woocommerce_rest_prepare_{$this->post_type}", $response, $webhook, $request);
}