Passed
Push — v3.0 ( ebb9a5...15a205 )
by Raza
01:53
created

Identity::deleteUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Srmklive\PayPal\Traits\PayPalAPI;
4
5
trait Identity
6
{
7
    /**
8
     * Get user profile information.
9
     *
10
     * @throws \Throwable
11
     *
12
     * @return array|\Psr\Http\Message\StreamInterface|string
13
     *
14
     * @see https://developer.paypal.com/docs/api/identity/v1/#userinfo_get
15
     */
16
    public function showProfileInfo()
17
    {
18
        $this->apiEndPoint = 'v1/identity/openidconnect/userinfo?schema=openid';
19
20
        $this->setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
0 ignored issues
show
Bug introduced by
It seems like setRequestHeader() 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

20
        $this->/** @scrutinizer ignore-call */ 
21
               setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
Loading history...
21
22
        $this->verb = 'get';
23
24
        return $this->doPayPalRequest();
25
    }
26
27
    /**
28
     * List Users.
29
     *
30
     * @param string $field
31
     *
32
     * @throws \Throwable
33
     *
34
     * @return array|\Psr\Http\Message\StreamInterface|string
35
     *
36
     * @see https://developer.paypal.com/docs/api/identity/v2/#users_list
37
     */
38
    public function listUsers(string $field = 'userName')
39
    {
40
        $this->apiEndPoint = "v2/scim/Users?filter={$field}";
41
42
        $this->setRequestHeader('Content-Type', 'application/scim+json');
43
44
        $this->verb = 'get';
45
46
        return $this->doPayPalRequest();
47
    }
48
49
    /**
50
     * Show details for a user by ID.
51
     *
52
     * @param string $user_id
53
     *
54
     * @throws \Throwable
55
     *
56
     * @return array|\Psr\Http\Message\StreamInterface|string
57
     *
58
     * @see https://developer.paypal.com/docs/api/identity/v2/#users_get
59
     */
60
    public function showUserDetails(string $user_id)
61
    {
62
        $this->apiEndPoint = "v2/scim/Users/{$user_id}";
63
64
        $this->setRequestHeader('Content-Type', 'application/scim+json');
65
66
        $this->verb = 'get';
67
68
        return $this->doPayPalRequest();
69
    }
70
71
    /**
72
     * Delete a user by ID.
73
     *
74
     * @param string $user_id
75
     *
76
     * @throws \Throwable
77
     *
78
     * @return array|\Psr\Http\Message\StreamInterface|string
79
     *
80
     * @see https://developer.paypal.com/docs/api/identity/v2/#users_get
81
     */
82
    public function deleteUser(string $user_id)
83
    {
84
        $this->apiEndPoint = "v2/scim/Users/{$user_id}";
85
86
        $this->setRequestHeader('Content-Type', 'application/scim+json');
87
88
        $this->verb = 'delete';
89
90
        return $this->doPayPalRequest(false);
91
    }
92
}
93