WebhooksEndpoint   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A test() 0 3 1
A attempts() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DigitalCz\DigiSign\Endpoint;
6
7
use DigitalCz\DigiSign\DigiSign;
8
use DigitalCz\DigiSign\Endpoint\Traits\CRUDEndpointTrait;
9
use DigitalCz\DigiSign\Resource\ResourceInterface;
10
use DigitalCz\DigiSign\Resource\Webhook;
11
12
/**
13
 * @extends ResourceEndpoint<Webhook>
14
 * @method Webhook get(string $id)
15
 * @method Webhook create(array $body)
16
 * @method Webhook update(string $id, array $body)
17
 */
18
final class WebhooksEndpoint extends ResourceEndpoint
19
{
20
    /** @use CRUDEndpointTrait<Webhook> */
21
    use CRUDEndpointTrait;
22
23
    public function __construct(DigiSign $parent)
24
    {
25
        parent::__construct($parent, '/api/webhooks', Webhook::class);
26
    }
27
28
    /**
29
     * @param Webhook|string $webhook
30
     */
31
    public function attempts($webhook): WebhookAttemptsEndpoint
32
    {
33
        return new WebhookAttemptsEndpoint($this, $webhook);
34
    }
35
36
    public function test(string $id): ResourceInterface
37
    {
38
        return $this->createResource($this->postRequest('/{id}/test', ['id' => $id]));
39
    }
40
}
41