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.
Completed
Push — 2.0 ( 14ab12...ed0ed3 )
by Nico
05:48
created

Campaign::Delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
namespace Datatrics\API\Modules;
3
4
use Datatrics\API\Client;
5
6
class Campaign extends Base
7
{
8
    /**
9
     * Private constructor so only the client can create this
10
     * @param Client $client
11
     */
12 20
    public function __construct(Client $client)
13
    {
14 20
        parent::__construct($client);
15 20
        $this->SetUrl("/project/" . $this->GetClient()->GetProjectId() . "/campaign");
16 20
    }
17
18
    /**
19
     * Get one or multiple campaigns
20
     * @param string campaign id, leave null for list of campaigns
21
     * @param object Containing query arguments
22
     * @return object Result of the request
23
     */
24
    public function Get($campaignId = null, $args = array("limit" => 50))
25
    {
26
        if (is_null($campaignId)) {
27
            return $this->GetClient()->Get($this->GetUrl(), $args);
28
        }
29
        return $this->GetClient()->Get($this->GetUrl()."/".$campaignId, $args);
30
    }
31
32
    /**
33
     * Get one or multiple lanes
34
     * @param string campaign id
35
     * @param string lane id, leave null for list of lanes
36
     * @param object Containing query arguments
37
     * @return object Result of the request
38
     */
39
    public function GetLane($campaignId, $laneId = null, $args = array("limit" => 50))
40
    {
41
        if (is_null($laneId)) {
42
            return $this->GetClient()->Get($this->GetUrl()."/".$campaignId."/lane", $args);
43
        }
44
        return $this->GetClient()->Get($this->GetUrl()."/".$campaignId."/lane/".$laneId, $args);
45
    }
46
47
    /**
48
     * Create new campaign
49
     * @param object Containing all the information of a lane
50
     * @return object Result of the request
51
     */
52
    public function Create($campaign)
53
    {
54
        return $this->GetClient()->Post($this->GetUrl(), $campaign);
55
    }
56
57
    /**
58
     * Create new lane
59
     * @param string campaign id
60
     * @param object Containing all the information of a lane
61
     * @return object Result of the request
62
     */
63
    public function CreateLane($campaignId, $lane)
64
    {
65
        return $this->GetClient()->Post($this->GetUrl()."/".$campaignId."/lane", $lane);
66
    }
67
68
    /**
69
     * Update a campaign
70
     * @param object campaign containing the campaign id and fields that need to be updated
71
     * @throws \Exception When boxid is not present
72
     * @return object Result of the request
73
     */
74
    public function Update($campaign)
75
    {
76
        if (!isset($campaign['campaignid'])) {
77
            throw new \Exception("campaign must contain a campaignid");
78
        }
79
        return $this->GetClient()->Put($this->GetUrl()."/".$campaign['campaignid'], $campaign);
80
    }
81
82
    /**
83
     * Update a lane
84
     * @param string Id of the campaign
85
     * @param object lane containing the laneid and fields that need to be updated
86
     * @throws \Exception When boxid is not present
87
     * @return object Result of the request
88
     */
89
    public function UpdateLane($campaignId, $lane)
90
    {
91
        if (!isset($lane['laneid'])) {
92
            throw new \Exception("lane must contain a laneid");
93
        }
94
        return $this->GetClient()->Put($this->GetUrl()."/".$campaignId."/lane/".$lane['laneid'], $lane);
95
    }
96
97
    /**
98
     * Delete a campaign object by campaign id
99
     * @param string Id of the campaign
100
     * @return object Result of the request
101
     */
102
    public function Delete($campaignId)
103
    {
104
        return $this->GetClient()->Delete($this->GetUrl()."/".$campaignId);
105
    }
106
107
    /**
108
     * Delete a campaign object by campaign id
109
     * @param string Id of the campaign
110
     * @return object Result of the request
111
     */
112
    public function DeleteLane($campaignId, $laneId)
113
    {
114
        return $this->GetClient()->Delete($this->GetUrl()."/".$campaignId."/lane/".$laneId);
115
    }
116
117
    /**
118
     * Retrieve stats of a lane by campaign
119
     * @param string Id of the campaign
120
     * @return object Result of the request
121
     */
122
    public function Stats($campaignId)
123
    {
124
        return $this->GetClient()->Get($this->GetUrl()."/".$campaignId."/stats");
125
    }
126
127
    /**
128
     * Retrieve stats of a lane by campaign and lane id
129
     * @param string Id of the campaign
130
     * @param string Id of the lane to be deleted
131
     * @return object Result of the request
132
     */
133
    public function StatsLane($campaignId, $laneId)
134
    {
135
        return $this->GetClient()->Get($this->GetUrl()."/".$campaignId."/lane/".$laneId."/stats");
136
    }
137
}
138