-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIteration.php
39 lines (33 loc) · 1.02 KB
/
Iteration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Coding;
use Coding\Exceptions\ValidationException;
use Coding\Handlers\Validator;
class Iteration
{
private Core $core;
public function __construct(string $token = '', Core $core = null)
{
$this->core = $core ?? new Core($token);
}
public function create(array $data)
{
$validator = Validator::getInstance()->make($data, [
'ProjectName' => 'string|required',
'Name' => 'string|required',
'Goal' => 'string',
'Assignee' => 'integer',
'StartAt' => 'date_format:Y-m-d',
'EndAt' => 'date_format:Y-m-d|after:StartAt',
]);
if ($validator->fails()) {
// TODO Laravel ValidationException no message
throw new ValidationException($validator->errors()->all()[0]);
}
$response = $this->core->request('CreateIteration', $data);
return $response['Iteration'];
}
public function setToken(string $token)
{
$this->core->setToken($token);
}
}