GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — 2.0 ( 4b0ab2...40b088 )
by Nico
06:03
created

Bucket::UpdateBulk()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
namespace Datatrics\API\Modules;
3
4
class Bucket extends Base
5
{
6
    /**
7
     * Private constructor so only the client can create this
8
     * @param string $apikey
9
     * @param string $projectid
10
     */
11
    public function __construct($apikey, $projectid)
12
    {
13
        parent::__construct($apikey, "/project/" . $projectid . "/bucket");
14
    }
15
16
    /**
17
     * Get one or multiple buckets
18
     * @param string bucket id, leave null for list of buckets
19
     * @param object Containing query arguments
20
     * @return object Result of the request
21
     */
22
    public function Get($bucketId = null, $args = array("limit" => 50))
23
    {
24
        return $bucketId == null ? $this->request(self::HTTP_GET, "?".http_build_query($args)) : $this->request(self::HTTP_GET, "/".$bucketId."?".http_build_query($args));
25
    }
26
27
    /**
28
     * Get one or multiple buckets
29
     * @param string bucket id
30
     * @param string object id, leave null for list of objects
31
     * @param object Containing query arguments
32
     * @return object Result of the request
33
     */
34
    public function GetObject($bucketId, $objectId, $args = array("limit" => 50))
35
    {
36
        return $objectId == null ? $this->request(self::HTTP_GET, "/".$bucketId."/object?".http_build_query($args)) : $this->request(self::HTTP_GET, "/".$bucketId."/object/".$objectId."?".http_build_query($args));
37
    }
38
39
    /**
40
     * Create new bucket
41
     * @param object Containing all the information of a bucket
42
     * @return object Result of the request
43
     */
44
    public function Create($bucket)
45
    {
46
        return $this->request(self::HTTP_POST, "", $bucket);
47
    }
48
49
    /**
50
     * Create new bucket
51
     * @param string bucket id
52
     * @param object Containing all the information of a bucket
53
     * @return object Result of the request
54
     */
55
    public function CreateObject($bucketId, $object)
56
    {
57
        return $this->request(self::HTTP_POST, "/".$bucketId."/object", $object);
58
    }
59
60
    /**
61
     * Delete a bucket object by bucket id
62
     * @param string Id of the bucket
63
     * @return object Result of the request
64
     */
65
    public function Delete($bucketId)
66
    {
67
        return $this->request(self::HTTP_DELETE, "/".$bucketId);
68
    }
69
70
    /**
71
     * List fields of a bucket
72
     * @param string Id of the bucket
73
     * @return object Result of the request
74
     */
75
    public function Fields($bucketId)
76
    {
77
        return $this->request(self::HTTP_GET, "/".$bucketId."/fields");
78
    }
79
80
    /**
81
     * Updates a maximum of 50 object at a time
82
     * @param array Containing objects with a maximum of 50
83
     * @throws \Exception When more that 50 objects are provided
84
     * @return object Result of the request
85
     */
86
    public function UpdateBulk($bucketId, $items)
87
    {
88
        if (count($items) > 50) {
89
            throw new \Exception("Maximum of 50 content items allowed at a time");
90
        }
91
92
        return $this->request(self::HTTP_POST, "/".$bucketId."/object/bulk", ['items' => $items]);
93
    }
94
}
95