WebHooksEvents::listEvents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Srmklive\PayPal\Traits\PayPalAPI;
4
5
trait WebHooksEvents
6
{
7
    /**
8
     * List all events types for web hooks.
9
     *
10
     * @throws \Throwable
11
     *
12
     * @return array|\Psr\Http\Message\StreamInterface|string
13
     *
14
     * @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-event-types_list
15
     */
16
    public function listEventTypes()
17
    {
18
        $this->apiEndPoint = 'v1/notifications/webhooks-event-types';
19
20
        $this->verb = 'get';
21
22
        return $this->doPayPalRequest();
23
    }
24
25
    /**
26
     * List all events notifications for web hooks.
27
     *
28
     * @throws \Throwable
29
     *
30
     * @return array|\Psr\Http\Message\StreamInterface|string
31
     *
32
     * @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_list
33
     */
34
    public function listEvents()
35
    {
36
        $this->apiEndPoint = 'v1/notifications/webhooks-events';
37
38
        $this->verb = 'get';
39
40
        return $this->doPayPalRequest();
41
    }
42
43
    /**
44
     * List all events notifications for web hooks.
45
     *
46
     * @param string $event_id
47
     *
48
     * @throws \Throwable
49
     *
50
     * @return array|\Psr\Http\Message\StreamInterface|string
51
     *
52
     * @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_get
53
     */
54
    public function showEventDetails(string $event_id)
55
    {
56
        $this->apiEndPoint = "v1/notifications/webhooks-events/{$event_id}";
57
58
        $this->verb = 'get';
59
60
        return $this->doPayPalRequest();
61
    }
62
63
    /**
64
     * Resend notification for the event.
65
     *
66
     * @param string $event_id
67
     * @param array  $items
68
     *
69
     * @throws \Throwable
70
     *
71
     * @return array|\Psr\Http\Message\StreamInterface|string
72
     *
73
     * @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_resend
74
     */
75
    public function resendEventNotification(string $event_id, array $items)
76
    {
77
        $this->apiEndPoint = "v1/notifications/webhooks-events/{$event_id}/resend";
78
79
        $this->options['json'] = [
80
            'webhook_ids' => $items,
81
        ];
82
        $this->verb = 'post';
83
84
        return $this->doPayPalRequest();
85
    }
86
}
87