Passed
Pull Request — v3.0 (#504)
by
unknown
11:09
created

Identity::disableAccountProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 11
rs 10
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/oauth2/userinfo?schema=paypalv1.1';
19
20
        $this->verb = 'get';
21
22
        return $this->doPayPalRequest();
23
    }
24
25
    /**
26
     * Create a merchant application.
27
     *
28
     * @param string $client_name
29
     * @param array  $redirect_uris
30
     * @param array  $contacts
31
     * @param string $payer_id
32
     * @param string $migrated_app
33
     * @param string $application_type
34
     * @param string $logo_url
35
     *
36
     * @throws \Throwable
37
     *
38
     * @return array|\Psr\Http\Message\StreamInterface|string
39
     *
40
     * @see https://developer.paypal.com/docs/api/identity/v1/#applications_post
41
     */
42
    public function createMerchantApplication(string $client_name, array $redirect_uris, array $contacts, string $payer_id, string $migrated_app, string $application_type = 'web', string $logo_url = '')
43
    {
44
        $this->apiEndPoint = 'v1/identity/applications';
45
46
        $this->options['json'] = array_filter([
47
            'application_type'  => $application_type,
48
            'redirect_uris'     => $redirect_uris,
49
            'client_name'       => $client_name,
50
            'contacts'          => $contacts,
51
            'payer_id'          => $payer_id,
52
            'migrated_app'      => $migrated_app,
53
            'logo_uri'          => $logo_url,
54
        ]);
55
56
        $this->verb = 'post';
57
58
        return $this->doPayPalRequest();
59
    }
60
61
    /**
62
     * Create a merchant application.
63
     *
64
     * @param array  $features
65
     * @param string $account_property
66
     *
67
     * @throws \Throwable
68
     *
69
     * @return array|\Psr\Http\Message\StreamInterface|string
70
     *
71
     * @see https://developer.paypal.com/docs/api/identity/v1/#account-settings_post
72
     */
73
    public function setAccountProperties(array $features, string $account_property = 'BRAINTREE_MERCHANT')
74
    {
75
        $this->apiEndPoint = 'v1/identity/account-settings';
76
77
        $this->options['json'] = [
78
            'account_property'  => $account_property,
79
            'features'          => $features,
80
        ];
81
82
        $this->verb = 'post';
83
84
        return $this->doPayPalRequest();
85
    }
86
87
    /**
88
     * Create a merchant application.
89
     *
90
     * @param string $account_property
91
     *
92
     * @throws \Throwable
93
     *
94
     * @return array|\Psr\Http\Message\StreamInterface|string
95
     *
96
     * @see https://developer.paypal.com/docs/api/identity/v1/#account-settings_deactivate
97
     */
98
    public function disableAccountProperties(string $account_property = 'BRAINTREE_MERCHANT')
99
    {
100
        $this->apiEndPoint = 'v1/identity/account-settings/deactivate';
101
102
        $this->options['json'] = [
103
            'account_property'  => $account_property,
104
        ];
105
106
        $this->verb = 'post';
107
108
        return $this->doPayPalRequest();
109
    }
110
    
111
    public function getClientToken()
112
    {
113
        $this->apiEndPoint = 'v1/identity/generate-token?schema=paypalv1.1';
114
115
        $this->verb = 'post';
116
117
        return $this->doPayPalRequest();
118
    }
119
}
120