Passed
Push — v2.0 ( 36b776...013406 )
by Raza
02:14
created

WebHooksEvents::listEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
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';
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
19
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20
21
        $this->verb = 'get';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
23
        return $this->doPayPalRequest();
1 ignored issue
show
Bug introduced by
It seems like doPayPalRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        return $this->/** @scrutinizer ignore-call */ doPayPalRequest();
Loading history...
24
    }
25
26
    /**
27
     * List all events notifications for web hooks.
28
     *
29
     * @throws \Throwable
30
     *
31
     * @return array|\Psr\Http\Message\StreamInterface|string
32
     *
33
     * @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_list
34
     */
35
    public function listEvents()
36
    {
37
        $this->apiEndPoint = 'v1/notifications/webhooks-events';
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
38
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
40
        $this->verb = 'get';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
42
        return $this->doPayPalRequest();
43
    }
44
45
    /**
46
     * List all events notifications for web hooks.
47
     *
48
     * @param string $event_id
49
     *
50
     * @throws \Throwable
51
     *
52
     * @return array|\Psr\Http\Message\StreamInterface|string
53
     *
54
     * @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_get
55
     */
56
    public function showEventDetails($event_id)
57
    {
58
        $this->apiEndPoint = "v1/notifications/webhooks-events/{$event_id}";
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
59
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
60
61
        $this->verb = 'get';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
62
63
        return $this->doPayPalRequest();
64
    }
65
66
    /**
67
     * Resend notification for the event.
68
     *
69
     * @param string $event_id
70
     * @param array  $items
71
     *
72
     * @throws \Throwable
73
     *
74
     * @return array|\Psr\Http\Message\StreamInterface|string
75
     *
76
     * @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_resend
77
     */
78
    public function resendEventNotification($event_id, array $items)
79
    {
80
        $this->apiEndPoint = "v1/notifications/webhooks-events/{$event_id}/resend";
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
81
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
82
83
        $this->options['json'] = [
1 ignored issue
show
Bug Best Practice introduced by
The property options does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
84
            'webhook_ids' => $items
85
        ];
86
        $this->verb = 'post';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
87
88
        return $this->doPayPalRequest();
89
    }
90
}
91