Show webhooks

This commit is contained in:
Alex P 2021-09-16 13:48:20 +03:00
parent 0b029a9392
commit e2a7f6d8d9
12 changed files with 5132 additions and 7 deletions

View file

@ -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.
*