Skip to content

Commit dea67da

Browse files
committed
Add additional DTOs, SDKs and tests per the requirements
1 parent b9993c1 commit dea67da

File tree

11 files changed

+188
-3
lines changed

11 files changed

+188
-3
lines changed

src/Dto/Issue.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ public function __construct(
88
readonly ?string $id,
99
readonly string $title,
1010
readonly string $description,
11+
readonly int $priority,
12+
readonly string $priorityLabel,
13+
readonly ?State $state,
1114
readonly ?Project $project,
1215
) {}
1316

src/Dto/Priorities.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Linear\Dto;
4+
5+
final class Priorities
6+
{
7+
public function __construct(
8+
/** @var array<Priority> */
9+
readonly array $issuePriorityValues
10+
) {}
11+
12+
}

src/Dto/Priority.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Linear\Dto;
4+
5+
class Priority
6+
{
7+
public function __construct(
8+
readonly int $priority,
9+
readonly string $label,
10+
) {}
11+
12+
}

src/Dto/State.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Linear\Dto;
4+
5+
class State
6+
{
7+
public function __construct(
8+
readonly string $id,
9+
readonly string $name,
10+
readonly string $type
11+
) {}
12+
13+
}

src/Dto/States.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Linear\Dto;
4+
5+
final class States
6+
{
7+
public function __construct(
8+
/** @var array<State> */
9+
readonly array $nodes
10+
) {}
11+
12+
}

src/Dto/Team.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ final class Team
77
public function __construct(
88
readonly ?string $id,
99
readonly string $name,
10-
readonly Issues $issues,
10+
readonly ?States $states,
11+
readonly ?Issues $issues,
1112
) {}
1213

1314
}

src/Sdk/Issues.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ public function getAll(): Dto\Issues
2020
id
2121
title
2222
description
23+
priority
24+
priorityLabel
25+
state {
26+
id
27+
name
28+
type
29+
}
2330
project {
2431
id
2532
name
@@ -48,6 +55,13 @@ public function getOne(string $id): Dto\Issue
4855
id
4956
title
5057
description
58+
priority
59+
priorityLabel
60+
state {
61+
id
62+
name
63+
type
64+
}
5165
project {
5266
id
5367
name
@@ -102,6 +116,13 @@ public function create(string $title, string $description, Dto\Team $team, ?Dto\
102116
id
103117
title
104118
description
119+
priority
120+
priorityLabel
121+
state {
122+
id
123+
name
124+
type
125+
}
105126
project {
106127
id
107128
name
@@ -142,6 +163,13 @@ public function update(Dto\Issue $issue): Dto\Issue
142163
id
143164
title
144165
description
166+
priority
167+
priorityLabel
168+
state {
169+
id
170+
name
171+
type
172+
}
145173
project {
146174
id
147175
name

src/Sdk/Priorities.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Linear\Sdk;
4+
5+
use CuyZ\Valinor\Mapper\MappingError;
6+
use CuyZ\Valinor\Mapper\Source\Source;
7+
use Exception;
8+
use Linear\Dto;
9+
use Linear\Utils\Mapper;
10+
11+
12+
class Priorities extends Client
13+
{
14+
public function get(): Dto\Priorities
15+
{
16+
$query = "
17+
query Priorities {
18+
issuePriorityValues {
19+
priority
20+
label
21+
}
22+
}
23+
";
24+
$response = $this->http->post('/', ['query' => $query]);
25+
26+
$prioritiesArr = $this->process($response);
27+
28+
try {
29+
return Mapper::get()->map(Dto\Priorities::class, Source::array($prioritiesArr));
30+
} catch (MappingError $error) {
31+
throw new Exception('Priorities DTO Mapping error:' . $error->getMessage());
32+
}
33+
}
34+
35+
}

src/Sdk/Projects.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ public function getAll(): Dto\Projects
2525
id
2626
title
2727
description
28-
28+
priority
29+
priorityLabel
30+
state {
31+
id
32+
name
33+
type
34+
}
2935
}
3036
}
3137
}
@@ -56,7 +62,13 @@ public function getOne(string $id): Dto\Project
5662
id
5763
title
5864
description
59-
65+
priority
66+
priorityLabel
67+
state {
68+
id
69+
name
70+
type
71+
}
6072
}
6173
}
6274
}

src/Sdk/Teams.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,25 @@ public function getAll(): Dto\Teams
1919
nodes {
2020
id
2121
name
22+
states {
23+
nodes {
24+
id
25+
name
26+
type
27+
}
28+
}
2229
issues {
2330
nodes {
2431
id
2532
title
2633
description
34+
priority
35+
priorityLabel
36+
state {
37+
id
38+
name
39+
type
40+
}
2741
project {
2842
id
2943
name
@@ -53,11 +67,25 @@ public function getOne(string $id): Dto\Team
5367
team(id: \"$id\" ) {
5468
id
5569
name
70+
states {
71+
nodes {
72+
id
73+
name
74+
type
75+
}
76+
}
5677
issues {
5778
nodes {
5879
id
5980
title
6081
description
82+
priority
83+
priorityLabel
84+
state {
85+
id
86+
name
87+
type
88+
}
6189
project {
6290
id
6391
name

0 commit comments

Comments
 (0)