-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathIteration.php
31 lines (27 loc) · 959 Bytes
/
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
<?php
namespace App\Coding;
use Carbon\Carbon;
class Iteration extends Base
{
public function create($token, $projectName, $data)
{
$response = $this->client->request('POST', 'https://e.coding.net/open-api', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => "token ${token}",
'Content-Type' => 'application/json'
],
'json' => array_merge([
'Action' => 'CreateIteration',
'ProjectName' => $projectName,
], $data),
]);
$result = json_decode($response->getBody(), true);
return $result['Response']['Iteration'];
}
public static function generateName(Carbon $startAt, Carbon $endAt): string
{
$endFormat = $startAt->year == $endAt->year ? 'm/d' : 'Y/m/d';
return $startAt->format('Y/m/d') . '-' . $endAt->format($endFormat) . ' 迭代';
}
}