Notification Setup Error

We have detected an error in your notification set-up (Event-ID dab39dc24f564ec7bd4628d1305fd03c). Currently, we cannot inform you about inspection progress. Please check that the user 557058:bca11929-8c2d-43f2-8a82-c5416880d395 still has access to your repository or update the API account.

Invitations::deleteByGroup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
/**
4
 * This file is part of the bitbucket-api package.
5
 *
6
 * (c) Alexandru G. <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bitbucket\API\Users;
13
14
use Bitbucket\API\Api;
15
use Psr\Http\Message\ResponseInterface;
16
17
/**
18
 * An invitation is a request sent to an external email address to participate
19
 * one or more of an account's groups.
20
 *
21
 * @author  Alexandru G.    <[email protected]>
22
 * @see https://confluence.atlassian.com/bitbucket/invitations-resource-296911749.html
23
 */
24
class Invitations extends Api
25
{
26
    /**
27
     * Get a list of pending invitations
28
     *
29
     * @access public
30
     * @param  string           $account The name of an individual or team account.
31
     * @return ResponseInterface
32 1
     */
33
    public function all($account)
34 1
    {
35 1
        return $this->getClient()->setApiVersion('1.0')->get(
36
            sprintf('/users/%s/invitations', $account)
37
        );
38
    }
39
40
    /**
41
     * Issues an invitation to the specified account group.
42
     *
43
     * An invitation is a request sent to an external email address to participate one or more of an account's groups.
44
     *
45
     * @access public
46
     * @param  string           $account    The name of an individual or team account.
47
     * @param  string           $groupSlug  An identifier for the group.
48
     * @param  string           $email      Name of the email address
49 1
     * @return ResponseInterface
50
     */
51 1
    public function create($account, $groupSlug, $email)
52 1
    {
53
        return $this->getClient()->setApiVersion('1.0')->put(
54
            sprintf('/users/%s/invitations', $account),
55
            ['email' => $email, 'group_slug' => $groupSlug]
56
        );
57
    }
58
59
    /**
60
     * Delete pending invitations by email address
61
     *
62
     * Deletes any pending invitations on a team or individual account for a particular email address.
63
     *
64
     * @access public
65
     * @param  string           $account The name of an individual or team account.
66 1
     * @param  string           $email   Name of the email address to delete.
67
     * @return ResponseInterface
68 1
     */
69 1
    public function deleteByEmail($account, $email)
70
    {
71
        return $this->getClient()->setApiVersion('1.0')->delete(
72
            sprintf('/users/%s/invitations', $account),
73
            ['email' => $email]
74
        );
75
    }
76
77
    /**
78
     * Delete pending invitations by group
79
     *
80
     * Deletes a pending invitation for a particular email on account's group.
81
     *
82
     * @access public
83
     * @param  string           $account    The name of an individual or team account.
84
     * @param  string           $groupSlug  An identifier for the group.
85 1
     * @param  string           $email      Name of the email address to delete.
86
     * @return ResponseInterface
87 1
     */
88 1
    public function deleteByGroup($account, $groupSlug, $email)
89
    {
90
        return $this->getClient()->setApiVersion('1.0')->delete(
91
            sprintf('/users/%s/invitations', $account),
92
            ['email' => $email, 'group_slug' => $groupSlug]
93
        );
94
    }
95
}
96