LabelApiController::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2018 Ryan Fletcher <[email protected]>
4
 *
5
 * @author Ryan Fletcher <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Deck\Controller;
25
26
use OCP\AppFramework\ApiController;
27
use OCP\AppFramework\Http;
28
use OCP\AppFramework\Http\DataResponse;
29
use OCP\IRequest;
30
use OCA\Deck\Service\LabelService;
31
use OCA\Deck\Controller\Helper\ApiHelper;
32
33
 /**
34
 * Class BoardApiController
35
 *
36
 * @package OCA\Deck\Controller
37
 */
38
class LabelApiController extends ApiController {
39
40
	private $labelService;
41
	private $userId;
42
43
	/**
44
	 * @param string $appName
45
	 * @param IRequest $request
46
	 * @param LabelService $labelService
47
	 * @param $userId
48
	 */
49
	public function __construct($appName, IRequest $request, LabelService $labelService, $userId) {
50
		parent::__construct($appName, $request);
51
		$this->labelService = $labelService;		
52
		$this->userId = $userId;		
53
	}
54
	
55
	/**
56
	 * @NoAdminRequired
57
	 * @CORS
58
	 * @NoCSRFRequired
59
	 *
60
	 * Get a specific label.
61
	 */
62
	public function get() {
63
		$label = $this->labelService->find($this->request->getParam('labelId'));		
64
		return new DataResponse($label, HTTP::STATUS_OK);
65
	}
66
67
	/**
68
	 * @NoAdminRequired
69
	 * @CORS
70
	 * @NoCSRFRequired
71
	 *
72
	 * @params $title
73
	 * @params $color
74
	 * Create a new label
75
	 */
76
	public function create($title, $color) {
77
		$label = $this->labelService->create($title, $color, $this->request->getParam('boardId'));
78
		return new DataResponse($label, HTTP::STATUS_OK);
79
	}
80
81
	/**
82
	 * @NoAdminRequired
83
	 * @CORS
84
	 * @NoCSRFRequired
85
	 *
86
	 * @params $title
87
	 * @params $color
88
	 * Update a specific label
89
	 */
90
	public function update($title, $color) {				
91
		$label = $this->labelService->update($this->request->getParam('labelId'), $title, $color);
92
		return new DataResponse($label, HTTP::STATUS_OK);
93
	}
94
95
	/**
96
	 * @NoAdminRequired
97
	 * @CORS
98
	 * @NoCSRFRequired
99
	 *	 
100
	 * Delete a specific label
101
	 */
102
	public function delete() {
103
		$label = $this->labelService->delete($this->request->getParam('labelId'));
104
		return new DataResponse($label, HTTP::STATUS_OK);
105
	}
106
	
107
}