PHP 클래스 WC_Webhook

This class handles storing and retrieving webhook data from the associated. shop_webhook custom post type, as well as delivery logs from the webhook_delivery. comment type. Webhooks are enqueued to their associated actions, delivered, and logged.
부터: 2.2
저자: WooThemes
파일 보기 프로젝트 열기: woocommerce/woocommerce 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$id webhook ID (post ID)

공개 메소드들

메소드 설명
__construct ( string | integer $id ) Setup webhook & load post data.
__get ( string $key ) : mixed Magic get, wraps get_post_meta() for all keys except $status.
__isset ( string $key ) : boolean Magic isset as a wrapper around metadata_exists().
deliver ( mixed $arg ) Deliver the webhook payload using wp_safe_remote_request().
deliver_ping ( ) : boolean | WP_Error Send a test ping to the delivery URL, sent when the webhook is first created.
enqueue ( ) Enqueue the hooks associated with the webhook.
generate_signature ( string $payload ) : string Generate a base64-encoded HMAC-SHA256 signature of the payload body so the.
get_api_version ( ) : string API version.
get_delivery_log ( integer $delivery_id ) : boolean | array Get the delivery log specified by the ID. The delivery log includes:
get_delivery_logs ( ) : array Get the delivery logs for this webhook.
get_delivery_url ( ) : string Get the delivery URL.
get_event ( ) : string Get the event for the webhook, e.g. created.
get_failure_count ( ) : integer Get the failure count.
get_hooks ( ) : array Get the hook names for the webhook.
get_i18n_status ( ) : string Get the webhook i18n status.
get_name ( ) : string Get the friendly name for the webhook.
get_new_delivery_id ( ) : integer Create a new comment for log the delivery request/response and.
get_post_data ( ) : null | WP_Post Get the post data for the webhook.
get_resource ( ) : string Get the resource for the webhook, e.g. order.
get_secret ( ) : string Get the secret used for generating the HMAC-SHA256 signature.
get_status ( ) : string Get the webhook status:
get_topic ( ) : string Get the webhook topic, e.g. order.created.
get_user_id ( ) : integer | string Get the user ID for this webhook.
log_delivery ( integer $delivery_id, array $request, array | WP_Error $response, float $duration ) Log the delivery request/response.
process ( mixed $arg ) Process the webhook for delivery by verifying that it should be delivered.
set_api_version ( string $version ) Set API version.
set_delivery_url ( string $url ) Set the delivery URL.
set_secret ( string $secret ) Set the secret used for generating the HMAC-SHA256 signature.
set_topic ( string $topic ) Set the webhook topic and associated hooks. The topic resource & event.
update_status ( $status ) Update the webhook status, see get_status() for valid statuses.

비공개 메소드들

메소드 설명
build_payload ( mixed $resource_id ) : mixed Build the payload data for the webhook.
failed_delivery ( ) Track consecutive delivery failures and automatically disable the webhook.
get_legacy_api_payload ( string $resource, integer $resource_id, string $event ) : array Get Legacy API payload.
get_topic_hooks ( string $topic ) : array Get the associated hook names for a topic.
get_wp_api_payload ( string $resource, integer $resource_id, string $event ) : array Get WP API integration payload.
should_deliver ( mixed $arg ) : boolean Helper to check if the webhook should be delivered, as some hooks.

메소드 상세

__construct() 공개 메소드

Setup webhook & load post data.
부터: 2.2
public __construct ( string | integer $id )
$id string | integer

__get() 공개 메소드

Magic get, wraps get_post_meta() for all keys except $status.
부터: 2.2
public __get ( string $key ) : mixed
$key string
리턴 mixed value

__isset() 공개 메소드

Magic isset as a wrapper around metadata_exists().
부터: 2.2
public __isset ( string $key ) : boolean
$key string
리턴 boolean true if $key isset, false otherwise

deliver() 공개 메소드

Deliver the webhook payload using wp_safe_remote_request().
부터: 2.2
public deliver ( mixed $arg )
$arg mixed First hook argument.

deliver_ping() 공개 메소드

Send a test ping to the delivery URL, sent when the webhook is first created.
부터: 2.2
public deliver_ping ( ) : boolean | WP_Error
리턴 boolean | WP_Error

enqueue() 공개 메소드

Enqueue the hooks associated with the webhook.
부터: 2.2
public enqueue ( )

generate_signature() 공개 메소드

recipient can verify the authenticity of the webhook. Note that the signature. is calculated after the body has already been encoded (JSON by default).
부터: 2.2
public generate_signature ( string $payload ) : string
$payload string payload data to hash
리턴 string hash

get_api_version() 공개 메소드

API version.
부터: 2.7.0
public get_api_version ( ) : string
리턴 string

get_delivery_log() 공개 메소드

+ duration + summary + request method/url + request headers/body + response code/message/headers/body
부터: 2.2
public get_delivery_log ( integer $delivery_id ) : boolean | array
$delivery_id integer
리턴 boolean | array false if invalid delivery ID, array of log data otherwise

get_delivery_logs() 공개 메소드

Get the delivery logs for this webhook.
부터: 2.2
public get_delivery_logs ( ) : array
리턴 array

get_delivery_url() 공개 메소드

Get the delivery URL.
부터: 2.2
public get_delivery_url ( ) : string
리턴 string

get_event() 공개 메소드

Get the event for the webhook, e.g. created.
부터: 2.2
public get_event ( ) : string
리턴 string

get_failure_count() 공개 메소드

Get the failure count.
부터: 2.2
public get_failure_count ( ) : integer
리턴 integer

get_hooks() 공개 메소드

Get the hook names for the webhook.
부터: 2.2
public get_hooks ( ) : array
리턴 array hook names

get_i18n_status() 공개 메소드

Get the webhook i18n status.
public get_i18n_status ( ) : string
리턴 string

get_name() 공개 메소드

Get the friendly name for the webhook.
부터: 2.2
public get_name ( ) : string
리턴 string

get_new_delivery_id() 공개 메소드

return the ID for inclusion in the webhook request.
부터: 2.2
public get_new_delivery_id ( ) : integer
리턴 integer delivery (comment) ID

get_post_data() 공개 메소드

Get the post data for the webhook.
부터: 2.2
public get_post_data ( ) : null | WP_Post
리턴 null | WP_Post

get_resource() 공개 메소드

Get the resource for the webhook, e.g. order.
부터: 2.2
public get_resource ( ) : string
리턴 string

get_secret() 공개 메소드

Get the secret used for generating the HMAC-SHA256 signature.
부터: 2.2
public get_secret ( ) : string
리턴 string

get_status() 공개 메소드

+ active - delivers payload. + paused - does not deliver payload, paused by admin. + disabled - does not delivery payload, paused automatically due to. consecutive failures.
부터: 2.2
public get_status ( ) : string
리턴 string status

get_topic() 공개 메소드

Get the webhook topic, e.g. order.created.
부터: 2.2
public get_topic ( ) : string
리턴 string

get_user_id() 공개 메소드

Get the user ID for this webhook.
부터: 2.2
public get_user_id ( ) : integer | string
리턴 integer | string user ID

log_delivery() 공개 메소드

Log the delivery request/response.
부터: 2.2
public log_delivery ( integer $delivery_id, array $request, array | WP_Error $response, float $duration )
$delivery_id integer previously created comment ID
$request array request data
$response array | WP_Error response data
$duration float request duration

process() 공개 메소드

and scheduling the delivery (in the background by default, or immediately).
부터: 2.2
public process ( mixed $arg )
$arg mixed the first argument provided from the associated hooks

set_api_version() 공개 메소드

Set API version.
부터: 2.7.0
public set_api_version ( string $version )
$version string REST API version.

set_delivery_url() 공개 메소드

Set the delivery URL.
부터: 2.2
public set_delivery_url ( string $url )
$url string

set_secret() 공개 메소드

Set the secret used for generating the HMAC-SHA256 signature.
부터: 2.2
public set_secret ( string $secret )
$secret string

set_topic() 공개 메소드

are also saved separately.
부터: 2.2
public set_topic ( string $topic )
$topic string

update_status() 공개 메소드

Update the webhook status, see get_status() for valid statuses.
부터: 2.2
public update_status ( $status )
$status

프로퍼티 상세

$id 공개적으로 프로퍼티

webhook ID (post ID)
public $id