mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
move module.local to module
This commit is contained in:
parent
c443e4053c
commit
f8e82bdfaf
217 changed files with 8 additions and 2 deletions
97
modules/ppcp-api-client/src/Entity/class-webhook.php
Normal file
97
modules/ppcp-api-client/src/Entity/class-webhook.php
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/**
|
||||
* The Webhook object.
|
||||
*
|
||||
* @package Inpsyde\PayPalCommerce\ApiClient\Entity
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
/**
|
||||
* Class Webhook
|
||||
*/
|
||||
class Webhook {
|
||||
|
||||
/**
|
||||
* The ID of the webhook.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* The URL of the webhook.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* The event types.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $event_types;
|
||||
|
||||
/**
|
||||
* Webhook constructor.
|
||||
*
|
||||
* @param string $url The URL of the webhook.
|
||||
* @param string[] $event_types The associated event types.
|
||||
* @param string $id The id of the webhook.
|
||||
*/
|
||||
public function __construct( string $url, array $event_types, string $id = '' ) {
|
||||
$this->url = $url;
|
||||
$this->event_types = $event_types;
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the webhook.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function id(): string {
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL listening to the hook.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url(): string {
|
||||
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event types.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function event_types(): array {
|
||||
|
||||
return $this->event_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object as array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array(): array {
|
||||
|
||||
$data = array(
|
||||
'url' => $this->url(),
|
||||
'event_types' => $this->event_types(),
|
||||
);
|
||||
if ( $this->id() ) {
|
||||
$data['id'] = $this->id();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue