• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tylernathanreed / jira-client-php / 14480277072

15 Apr 2025 10:05PM UTC coverage: 82.095% (-1.4%) from 83.476%
14480277072

push

github

tylernathanreed
~ Fixed polymorphic dtos

5736 of 6987 relevant lines covered (82.1%)

10.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.24
/src/Operations/IssueTypes.php
1
<?php
2

3
namespace Jira\Client\Operations;
4

5
use Jira\Client\Client;
6
use Jira\Client\Schema;
7

8
/** @phpstan-require-extends Client */
9
trait IssueTypes
10
{
11
    /**
12
     * Returns all issue types
13
     * 
14
     * This operation can be accessed anonymously
15
     * 
16
     * **"Permissions" required:** Issue types are only returned as follows:
17
     * 
18
     *  - if the user has the *Administer Jira* "global permission", all issue types are returned
19
     *  - if the user has the *Browse projects* "project permission" for one or more projects, the issue types associated with the projects the user has permission to browse are returned
20
     *  - if the user is anonymous then they will be able to access projects with the *Browse projects* for anonymous users
21
     *  - if the user authentication is incorrect they will fall back to anonymous
22
     * 
23
     * @link https://confluence.atlassian.com/x/x4dKLg
24
     * @link https://confluence.atlassian.com/x/yodKLg
25
     * 
26
     * @return list<Schema\IssueTypeDetails>
27
     */
28
    public function getIssueAllTypes(): array
1✔
29
    {
30
        return $this->call(
1✔
31
            uri: '/rest/api/3/issuetype',
1✔
32
            method: 'get',
1✔
33
            success: 200,
1✔
34
            schema: [Schema\IssueTypeDetails::class],
1✔
35
        );
1✔
36
    }
37

38
    /**
39
     * Creates an issue type and adds it to the default issue type scheme
40
     * 
41
     * **"Permissions" required:** *Administer Jira* "global permission".
42
     * 
43
     * @link https://confluence.atlassian.com/x/x4dKLg
44
     */
45
    public function createIssueType(
×
46
        Schema\IssueTypeCreateBean $request,
47
    ): Schema\IssueTypeDetails {
48
        return $this->call(
×
49
            uri: '/rest/api/3/issuetype',
×
50
            method: 'post',
×
51
            body: $request,
×
52
            success: 201,
×
53
            schema: Schema\IssueTypeDetails::class,
×
54
        );
×
55
    }
56

57
    /**
58
     * Returns issue types for a project
59
     * 
60
     * This operation can be accessed anonymously
61
     * 
62
     * **"Permissions" required:** *Browse projects* "project permission" in the relevant project or *Administer Jira* "global permission".
63
     * 
64
     * @link https://confluence.atlassian.com/x/yodKLg
65
     * @link https://confluence.atlassian.com/x/x4dKLg
66
     * 
67
     * @param int $projectId The ID of the project.
68
     * @param ?int $level The level of the issue type to filter by.
69
     *                    Use:
70
     *                     - `-1` for Subtask
71
     *                     - `0` for Base
72
     *                     - `1` for Epic.
73
     * 
74
     * @return list<Schema\IssueTypeDetails>
75
     */
76
    public function getIssueTypesForProject(
1✔
77
        int $projectId,
78
        ?int $level = null,
79
    ): array {
80
        return $this->call(
1✔
81
            uri: '/rest/api/3/issuetype/project',
1✔
82
            method: 'get',
1✔
83
            query: compact('projectId', 'level'),
1✔
84
            success: 200,
1✔
85
            schema: [Schema\IssueTypeDetails::class],
1✔
86
        );
1✔
87
    }
88

89
    /**
90
     * Returns an issue type
91
     * 
92
     * This operation can be accessed anonymously
93
     * 
94
     * **"Permissions" required:** *Browse projects* "project permission" in a project the issue type is associated with or *Administer Jira* "global permission".
95
     * 
96
     * @link https://confluence.atlassian.com/x/yodKLg
97
     * @link https://confluence.atlassian.com/x/x4dKLg
98
     * 
99
     * @param string $id The ID of the issue type.
100
     */
101
    public function getIssueType(
1✔
102
        string $id,
103
    ): Schema\IssueTypeDetails {
104
        return $this->call(
1✔
105
            uri: '/rest/api/3/issuetype/{id}',
1✔
106
            method: 'get',
1✔
107
            path: compact('id'),
1✔
108
            success: 200,
1✔
109
            schema: Schema\IssueTypeDetails::class,
1✔
110
        );
1✔
111
    }
112

113
    /**
114
     * Updates the issue type
115
     * 
116
     * **"Permissions" required:** *Administer Jira* "global permission".
117
     * 
118
     * @link https://confluence.atlassian.com/x/x4dKLg
119
     * 
120
     * @param string $id The ID of the issue type.
121
     */
122
    public function updateIssueType(
×
123
        Schema\IssueTypeUpdateBean $request,
124
        string $id,
125
    ): Schema\IssueTypeDetails {
126
        return $this->call(
×
127
            uri: '/rest/api/3/issuetype/{id}',
×
128
            method: 'put',
×
129
            body: $request,
×
130
            path: compact('id'),
×
131
            success: 200,
×
132
            schema: Schema\IssueTypeDetails::class,
×
133
        );
×
134
    }
135

136
    /**
137
     * Deletes the issue type.
138
     * If the issue type is in use, all uses are updated with the alternative issue type (`alternativeIssueTypeId`).
139
     * A list of alternative issue types are obtained from the "Get alternative issue types" resource
140
     * 
141
     * **"Permissions" required:** *Administer Jira* "global permission".
142
     * 
143
     * @link https://confluence.atlassian.com/x/x4dKLg
144
     * 
145
     * @param string $id The ID of the issue type.
146
     * @param ?string $alternativeIssueTypeId The ID of the replacement issue type.
147
     */
148
    public function deleteIssueType(
1✔
149
        string $id,
150
        ?string $alternativeIssueTypeId = null,
151
    ): true {
152
        return $this->call(
1✔
153
            uri: '/rest/api/3/issuetype/{id}',
1✔
154
            method: 'delete',
1✔
155
            query: compact('alternativeIssueTypeId'),
1✔
156
            path: compact('id'),
1✔
157
            success: 204,
1✔
158
            schema: true,
1✔
159
        );
1✔
160
    }
161

162
    /**
163
     * Returns a list of issue types that can be used to replace the issue type.
164
     * The alternative issue types are those assigned to the same workflow scheme, field configuration scheme, and screen scheme
165
     * 
166
     * This operation can be accessed anonymously
167
     * 
168
     * **"Permissions" required:** None.
169
     * 
170
     * @param string $id The ID of the issue type.
171
     * 
172
     * @return list<Schema\IssueTypeDetails>
173
     */
174
    public function getAlternativeIssueTypes(
1✔
175
        string $id,
176
    ): array {
177
        return $this->call(
1✔
178
            uri: '/rest/api/3/issuetype/{id}/alternatives',
1✔
179
            method: 'get',
1✔
180
            path: compact('id'),
1✔
181
            success: 200,
1✔
182
            schema: [Schema\IssueTypeDetails::class],
1✔
183
        );
1✔
184
    }
185

186
    /**
187
     * Loads an avatar for the issue type
188
     * 
189
     * Specify the avatar's local file location in the body of the request.
190
     * Also, include the following headers:
191
     * 
192
     *  - `X-Atlassian-Token: no-check` To prevent XSRF protection blocking the request, for more information see "Special Headers"
193
     *  - `Content-Type: image/image type` Valid image types are JPEG, GIF, or PNG
194
     * 
195
     * For example:  
196
     * `curl --request POST \ --user email@example.com:<api_token> \ --header 'X-Atlassian-Token: no-check' \ --header 'Content-Type: image/< image_type>' \ --data-binary "<@/path/to/file/with/your/avatar>" \ --url 'https://your-domain.atlassian.net/rest/api/3/issuetype/{issueTypeId}'This`
197
     * 
198
     * The avatar is cropped to a square.
199
     * If no crop parameters are specified, the square originates at the top left of the image.
200
     * The length of the square's sides is set to the smaller of the height or width of the image
201
     * 
202
     * The cropped image is then used to create avatars of 16x16, 24x24, 32x32, and 48x48 in size
203
     * 
204
     * After creating the avatar, use " Update issue type" to set it as the issue type's displayed avatar
205
     * 
206
     * **"Permissions" required:** *Administer Jira* "global permission".
207
     * 
208
     * @link https://confluence.atlassian.com/x/x4dKLg
209
     * 
210
     * @param string $id The ID of the issue type.
211
     * @param int $size The length of each side of the crop region.
212
     * @param ?int $x The X coordinate of the top-left corner of the crop region.
213
     * @param ?int $y The Y coordinate of the top-left corner of the crop region.
214
     */
215
    public function createIssueTypeAvatar(
1✔
216
        string $id,
217
        int $size,
218
        ?int $x = 0,
219
        ?int $y = 0,
220
    ): Schema\Avatar {
221
        return $this->call(
1✔
222
            uri: '/rest/api/3/issuetype/{id}/avatar2',
1✔
223
            method: 'post',
1✔
224
            query: compact('size', 'x', 'y'),
1✔
225
            path: compact('id'),
1✔
226
            success: 201,
1✔
227
            schema: Schema\Avatar::class,
1✔
228
        );
1✔
229
    }
230
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc