Passed
Push — master ( 4451a5...337712 )
by Adam
02:38
created

Organizations::changeOwner()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 2
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Response\ApplicationsResponse;
6
use AcquiaCloudApi\Response\InvitationsResponse;
7
use AcquiaCloudApi\Response\MembersResponse;
8
use AcquiaCloudApi\Response\MemberResponse;
9
use AcquiaCloudApi\Response\OrganizationsResponse;
10
use AcquiaCloudApi\Response\TeamsResponse;
11
use AcquiaCloudApi\Response\OperationResponse;
12
13
/**
14
 * Class Organizations
15
 *
16
 * @package AcquiaCloudApi\CloudApi
17
 */
18
class Organizations extends CloudApiBase implements CloudApiInterface
19
{
20
21
    /**
22
     * Show all organizations.
23
     *
24
     * @return OrganizationsResponse
25
     */
26
    public function getAll()
27
    {
28
        return new OrganizationsResponse($this->client->request('get', '/organizations'));
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('get', '/organizations') can also be of type AcquiaCloudApi\Connector\StreamInterface; however, parameter $organizations of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

28
        return new OrganizationsResponse(/** @scrutinizer ignore-type */ $this->client->request('get', '/organizations'));
Loading history...
29
    }
30
31
    /**
32
     * Show all applications in an organization.
33
     *
34
     * @param string $organizationUuid
35
     * @return ApplicationsResponse
36
     */
37
    public function getApplications($organizationUuid)
38
    {
39
        return new ApplicationsResponse(
40
            $this->client->request('get', "/organizations/${organizationUuid}/applications")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...onUuid.'/applications') can also be of type AcquiaCloudApi\Connector\StreamInterface; however, parameter $applications of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

40
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/applications")
Loading history...
41
        );
42
    }
43
44
    /**
45
     * Show all members of an organization.
46
     *
47
     * @param  string $organizationUuid
48
     * @return MembersResponse
49
     */
50
    public function getMembers($organizationUuid)
51
    {
52
        return new MembersResponse(
53
            $this->client->request('get', "/organizations/${organizationUuid}/members")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...izationUuid.'/members') can also be of type AcquiaCloudApi\Connector\StreamInterface; however, parameter $members of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

53
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/members")
Loading history...
54
        );
55
    }
56
57
    /**
58
     * Returns the user profile of this organization member.
59
     *
60
     * @param  string $organizationUuid
61
     * @param  string $memberUuid
62
     * @return MemberResponse
63
     */
64
    public function getMember($organizationUuid, $memberUuid)
65
    {
66
        return new MemberResponse(
67
            $this->client->request('get', "/organizations/${organizationUuid}/members/${memberUuid}")
68
        );
69
    }
70
71
    /**
72
     * Show all admins of an organization.
73
     *
74
     * @param  string $organizationUuid
75
     * @return MembersResponse
76
     */
77
    public function getAdmins($organizationUuid)
78
    {
79
        return new MembersResponse(
80
            $this->client->request('get', "/organizations/${organizationUuid}/admins")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...nizationUuid.'/admins') can also be of type AcquiaCloudApi\Connector\StreamInterface; however, parameter $members of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

80
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/admins")
Loading history...
81
        );
82
    }
83
84
    /**
85
     * Returns the user profile of this organization administrator.
86
     *
87
     * @param  string $organizationUuid
88
     * @param  string $memberUuid
89
     * @return MemberResponse
90
     */
91
    public function getAdmin($organizationUuid, $memberUuid)
92
    {
93
        return new MemberResponse(
94
            $this->client->request('get', "/organizations/${organizationUuid}/admins/${memberUuid}")
95
        );
96
    }
97
98
    /**
99
     * Show all members invited to an organization.
100
     *
101
     * @param  string $organizationUuid
102
     * @return InvitationsResponse
103
     */
104
    public function getMemberInvitations($organizationUuid)
105
    {
106
        return new InvitationsResponse(
107
            $this->client->request('get', "/organizations/${organizationUuid}/team-invites")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...onUuid.'/team-invites') can also be of type AcquiaCloudApi\Connector\StreamInterface; however, parameter $invitations of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

107
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/team-invites")
Loading history...
108
        );
109
    }
110
111
    /**
112
     * Delete a member from an organization.
113
     *
114
     * @param  string $organizationUuid
115
     * @param  string $memberUuid
116
     * @return OperationResponse
117
     */
118
    public function deleteMember($organizationUuid, $memberUuid)
119
    {
120
        return new OperationResponse(
121
            $this->client->request(
122
                'delete',
123
                "/organizations/${organizationUuid}/members/${memberUuid}"
124
            )
125
        );
126
    }
127
128
    /**
129
     * Leave an organization.
130
     *
131
     * @param string $organizationUuid
132
     * @return OperationResponse
133
     */
134
    public function leaveOrganization($organizationUuid)
135
    {
136
        return new OperationResponse(
137
            $this->client->request(
138
                'post',
139
                "/organizations/${organizationUuid}/actions/leave"
140
            )
141
        );
142
    }
143
144
    /**
145
     * Change the owner of an organization.
146
     *
147
     * @param string $organizationUuid
148
     * @param string $newOwnerUuid
149
     * @return OperationResponse
150
     */
151
    public function changeOwner($organizationUuid, $newOwnerUuid)
152
    {
153
        $options = [
154
            'json' => [
155
                'user_uuid' => $newOwnerUuid,
156
            ],
157
        ];
158
        return new OperationResponse(
159
            $this->client->request(
160
                'post',
161
                "/organizations/${organizationUuid}/actions/change-owner",
162
                $options
163
            )
164
        );
165
    }
166
167
    /**
168
     * Show all teams in an organization.
169
     *
170
     * @param  string $organizationUuid
171
     * @return TeamsResponse
172
     */
173
    public function getTeams($organizationUuid)
174
    {
175
        return new TeamsResponse(
176
            $this->client->request('get', "/organizations/${organizationUuid}/teams")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...anizationUuid.'/teams') can also be of type AcquiaCloudApi\Connector\StreamInterface; however, parameter $teams of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

176
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/teams")
Loading history...
177
        );
178
    }
179
180
    /**
181
     * Invites a user to become admin of an organization.
182
     *
183
     * @param  string $organizationUuid
184
     * @param  string $email
185
     * @return OperationResponse
186
     */
187
    public function inviteAdmin($organizationUuid, $email)
188
    {
189
        $options = [
190
            'json' => [
191
                'email' => $email,
192
            ],
193
        ];
194
195
        return new OperationResponse(
196
            $this->client->request('post', "/organizations/${organizationUuid}/admin-invites", $options)
197
        );
198
    }
199
}
200