Passed
Pull Request — master (#2)
by
unknown
01:49
created

AccountsApi::delete()   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 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Incapsula\Api;
4
5
class AccountsApi extends AbstractApi
6
{
7
    private $apiUri = 'https://my.incapsula.com/api/prov/v1';
8
9
    /**
10
     *   sub_account_id
11
     *	Numeric identifier of the sub account to operate on.
12
     *
13
     * @param mixed $subAccountId
14
     */
15
    public function delete($subAccountId)
16
    {
17
        return $this->client->send(sprintf('%s/subaccounts/delete', $this->apiUri), [
18
            'sub_account_id' => $subAccountId,
19
        ]);  
20
    }
21
22
    /**
23
     * Parameters:
24
     *api_id
25
     *   API authentication identifier.
26
     *api_key
27
     *	API authentication identifier.
28
     *sub_account_name
29
     *	The name of the sub account.
30
     *
31
     *parent_id
32
     *	The newly created account's parent id. If not specified, the invoking account will be assigned as the parent account. 	Optional:Yes
33
     *ref_id
34
     *   Customer specific identifier for this operation. 	Optional:Yes
35
     */
36
    public function add($subAccountName)
37
    {
38
        return $this->client->send(sprintf('%s/subaccounts/add', $this->apiUri), [
39
            'sub_account_name' => $$subAccountName,
40
        ]);   
41
    }
42
43
    /**
44
     * @param int $pageSize
45
     * @param int $pageNum
46
     *
47
     * @return array
48
     */
49
    public function list($pageSize = 50, $pageNum = 0)
50
    {
51
        return $this->client->send(sprintf('%s/accounts/listSubAccounts', $this->apiUri), [
52
            'page_size' => $pageSize,
53
            'page_num' => $pageNum,
54
        ]);
55
    }
56
57
    /**
58
     * Get account login token.
59
     *
60
     *Tokens are used instead of user/password based authentication to log in to the Incapsula management console.
61
     *
62
     *Use this operation to generate a token for an account. The token is valid for 15 minutes.
63
     *
64
     * /api/prov/v1/accounts/gettoken
65
     *
66
     *In order to use the token, the user must use the following link:
67
     *
68
     *https://my.incapsula.com/?token={generated_token}
69
     */
70
    public function getLoginToken($accountId)
71
    {
72
        return $this->client->send(sprintf('%s/accounts/gettoken', $this->apiUri), [
73
            'account_id' => $accountId,
74
        ]);
75
    }
76
}
77