Passed
Pull Request — master (#43)
by Adam
03:08
created

Organizations::getAdmin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\ApplicationsResponse;
7
use AcquiaCloudApi\Response\InvitationsResponse;
8
use AcquiaCloudApi\Response\MembersResponse;
9
use AcquiaCloudApi\Response\MemberResponse;
10
use AcquiaCloudApi\Response\OrganizationsResponse;
11
use AcquiaCloudApi\Response\TeamsResponse;
12
use AcquiaCloudApi\Response\OperationResponse;
13
14
/**
15
 * Class Organizations
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 Psr\Http\Message\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 organisation.
33
     *
34
     * @param string $organizationUuid
35
     *
36
     * @return ApplicationsResponse
37
     */
38
    public function getApplications($organizationUuid)
39
    {
40
        return new ApplicationsResponse(
41
            $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 Psr\Http\Message\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

41
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/applications")
Loading history...
42
        );
43
    }
44
45
    /**
46
     * Show all members of an organisation.
47
     *
48
     * @param string $organizationUuid
49
     * @return MembersResponse
50
     */
51
    public function getMembers($organizationUuid)
52
    {
53
        return new MembersResponse(
54
            $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 Psr\Http\Message\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

54
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/members")
Loading history...
55
        );
56
    }
57
58
    /**
59
     * Returns the user profile of this organization member.
60
     *
61
     * @param string $organizationUuid
62
     * @param string $memberUuid
63
     * @return MemberResponse
64
     */
65
    public function getMember($organizationUuid, $memberUuid)
66
    {
67
        return new MemberResponse(
68
            $this->client->request('get', "/organizations/${organizationUuid}/members/${memberUuid}")
69
        );
70
    }
71
72
    /**
73
     * Show all admins of an organisation.
74
     *
75
     * @param string $organizationUuid
76
     * @return MembersResponse
77
     */
78
    public function getAdmins($organizationUuid)
79
    {
80
        return new MembersResponse(
81
            $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 Psr\Http\Message\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

81
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/admins")
Loading history...
82
        );
83
    }
84
85
    /**
86
     * Returns the user profile of this organization administrator.
87
     *
88
     * @param string $organizationUuid
89
     * @param string $memberUuid
90
     * @return MemberResponse
91
     */
92
    public function getAdmin($organizationUuid, $memberUuid)
93
    {
94
        return new MemberResponse(
95
            $this->client->request('get', "/organizations/${organizationUuid}/admins/${memberUuid}")
96
        );
97
    }
98
99
    /**
100
     * Show all members invited to an organisation.
101
     *
102
     * @param string $organizationUuid
103
     * @return InvitationsResponse
104
     */
105
    public function getMemberInvitations($organizationUuid)
106
    {
107
        return new InvitationsResponse(
108
            $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 Psr\Http\Message\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

108
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/team-invites")
Loading history...
109
        );
110
    }
111
112
    /**
113
     * Delete a member from an organisation.
114
     *
115
     * @param string $organizationUuid
116
     * @param string $memberUuid
117
     * @return OperationResponse
118
     */
119
    public function deleteMember($organizationUuid, $memberUuid)
120
    {
121
        return new OperationResponse(
122
            $this->client->request(
123
                'delete',
124
                "/organizations/${organizationUuid}/members/${memberUuid}"
125
            )
126
        );
127
    }
128
129
    /**
130
     * Show all teams in an organization.
131
     *
132
     * @param string $organizationUuid
133
     * @return TeamsResponse
134
     */
135
    public function getTeams($organizationUuid)
136
    {
137
        return new TeamsResponse(
138
            $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 Psr\Http\Message\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

138
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/teams")
Loading history...
139
        );
140
    }
141
142
    /**
143
     * Invites a user to become admin of an organization.
144
     *
145
     * @param string $organizationUuid
146
     * @param string $email
147
     * @return OperationResponse
148
     */
149
    public function inviteAdmin($organizationUuid, $email)
150
    {
151
        $options = [
152
            'form_params' => [
153
                'email' => $email,
154
            ],
155
        ];
156
157
        return new OperationResponse(
158
            $this->client->request('post', "/organizations/${organizationUuid}/admin-invites", $options)
159
        );
160
    }
161
}
162