mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Show webhooks
This commit is contained in:
parent
0b029a9392
commit
e2a7f6d8d9
12 changed files with 5132 additions and 7 deletions
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class Webhook
|
||||
*/
|
||||
|
@ -71,13 +73,38 @@ class Webhook {
|
|||
/**
|
||||
* Returns the event types.
|
||||
*
|
||||
* @return array
|
||||
* @return stdClass[]
|
||||
*/
|
||||
public function event_types(): array {
|
||||
|
||||
return $this->event_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the human-friendly names of the event types.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function humanfriendly_event_names(): array {
|
||||
|
||||
return array_map(
|
||||
function ( $event ): string {
|
||||
return Webhook::get_humanfriendly_event_name( $event->name );
|
||||
},
|
||||
$this->event_types
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts event names to more human-friendly form.
|
||||
*
|
||||
* @param string $name The event name like 'CHECKOUT.ORDER.APPROVED'.
|
||||
* @return string
|
||||
*/
|
||||
public static function get_humanfriendly_event_name( string $name ): string {
|
||||
return strtolower( str_replace( '.', ' ', $name ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object as array.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue