@@ -27,7 +27,7 @@ Usability, consistency, and performance are key focuses of jira.js, and it also
27
27
- [ OAuth 2.0] ( #oauth-20 )
28
28
- [ JWT] ( #jwt )
29
29
- [ Personal access token] ( #personal-access-token )
30
- - [ Your first request and using algorithm] ( #your-first-request -and-using-algorithm )
30
+ - [ Example and using algorithm] ( #example -and-using-algorithm )
31
31
- [ Decreasing Webpack bundle size] ( #decreasing-webpack-bundle-size )
32
32
- [ Take a look at our other products] ( #take-a-look-at-our-other-products )
33
33
- [ License] ( #license )
@@ -113,9 +113,9 @@ Basic authentication allows you to log in with credentials. You can use username
113
113
Username and password example:
114
114
115
115
` ` ` typescript
116
- import { Version2Client } from ' jira.js' ;
116
+ import { Version3Client } from ' jira.js' ;
117
117
118
- const client = new Version2Client ({
118
+ const client = new Version3Client ({
119
119
host: ' https://your-domain.atlassian.net' ,
120
120
authentication: {
121
121
basic: {
@@ -129,9 +129,9 @@ const client = new Version2Client({
129
129
Email and API Token example:
130
130
131
131
``` typescript
132
- import { Version2Client } from ' jira.js' ;
132
+ import { Version3Client } from ' jira.js' ;
133
133
134
- const client = new Version2Client ({
134
+ const client = new Version3Client ({
135
135
host: ' https://your-domain.atlassian.net' ,
136
136
authentication: {
137
137
basic: {
@@ -145,9 +145,9 @@ const client = new Version2Client({
145
145
##### [ OAuth] ( https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/ )
146
146
147
147
``` typescript
148
- import { Version2Client } from ' jira.js' ;
148
+ import { Version3Client } from ' jira.js' ;
149
149
150
- const client = new Version2Client ({
150
+ const client = new Version3Client ({
151
151
host: ' https://your-domain.atlassian.net' ,
152
152
authentication: {
153
153
oauth: {
@@ -167,9 +167,9 @@ Only the authorization token is currently supported. To release it, you need to
167
167
Example of usage
168
168
169
169
``` typescript
170
- import { Version2Client } from ' jira.js' ;
170
+ import { Version3Client } from ' jira.js' ;
171
171
172
- const client = new Version2Client ({
172
+ const client = new Version3Client ({
173
173
host: ' https://your-domain.atlassian.net' ,
174
174
authentication: {
175
175
oauth2: {
@@ -182,9 +182,9 @@ const client = new Version2Client({
182
182
##### [ JWT] ( https://developer.atlassian.com/cloud/jira/platform/understanding-jwt-for-connect-apps/ )
183
183
184
184
``` typescript
185
- import { Version2Client } from ' jira.js' ;
185
+ import { Version3Client } from ' jira.js' ;
186
186
187
- const client = new Version2Client ({
187
+ const client = new Version3Client ({
188
188
host: ' https://your-domain.atlassian.net' ,
189
189
authentication: {
190
190
jwt: {
@@ -199,65 +199,80 @@ const client = new Version2Client({
199
199
##### [ Personal access token] ( https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html )
200
200
201
201
``` typescript
202
- import { Version2Client } from ' jira.js' ;
202
+ import { Version3Client } from ' jira.js' ;
203
203
204
- const client = new Version2Client ({
204
+ const client = new Version3Client ({
205
205
host: ' https://your-domain.atlassian.net' ,
206
206
authentication: {
207
207
personalAccessToken: ' secrectPAT' ,
208
208
},
209
209
});
210
210
```
211
211
212
- #### Your first request and using algorithm
212
+ #### Example and using algorithm
213
+
214
+ 1 . Example
215
+
216
+ You can find out [ example project here] ( https://github.com/MrRefactoring/jira.js/tree/master/example ) or perform the following actions:
217
+
218
+ - Change the ` host ` , ` email ` and ` apiToken ` to your data
219
+ - Run script
213
220
214
221
``` typescript
215
- import { Version2Client } from ' jira.js' ;
222
+ import { Version3Client } from ' jira.js' ;
216
223
217
- const client = new Version2Client ({
218
- host: ' https://your-domain.atlassian.net ' ,
224
+ const client = new Version3Client ({
225
+ host ,
219
226
authentication: {
220
227
basic: {
221
- email: ' YOUR_EMAIL ' ,
222
- apiToken: ' YOUR_API_TOKEN ' ,
228
+ email ,
229
+ apiToken ,
223
230
},
224
231
},
232
+ newErrorHandling: true ,
225
233
});
226
234
227
235
async function main() {
228
236
const projects = await client .projects .getAllProjects ();
229
237
230
- console .log (projects );
238
+ if (projects .length ) {
239
+ const project = projects [0 ];
240
+
241
+ const { id } = await client .issues .createIssue ({
242
+ fields: {
243
+ summary: ' My first issue' ,
244
+ issuetype: {
245
+ name: ' Task'
246
+ },
247
+ project: {
248
+ key: project .key ,
249
+ },
250
+ }
251
+ });
252
+
253
+ const issue = await client .issues .getIssue ({ issueIdOrKey: id });
254
+
255
+ console .log (` Issue '${issue .fields .summary }' was successfully added to '${project .name }' project. ` );
256
+ } else {
257
+ const myself = await client .myself .getCurrentUser ();
258
+
259
+ const { id } = await client .projects .createProject ({
260
+ key: ' PROJECT' ,
261
+ name: " My Project" ,
262
+ leadAccountId: myself .accountId ,
263
+ projectTypeKey: ' software' ,
264
+ });
265
+
266
+ const project = await client .projects .getProject ({ projectIdOrKey: id .toString () });
267
+
268
+ console .log (` Project '${project .name }' was successfully created. ` );
269
+ }
231
270
}
232
271
233
272
main ();
234
-
235
- // Expected output:
236
- // [
237
- // {
238
- // expand: 'description,lead,issueTypes,url,projectKeys,permissions,insight',
239
- // self: 'https://your-domain.atlassian.net/rest/api/2/project/10000',
240
- // id: '10000',
241
- // key: 'TEST',
242
- // name: 'test',
243
- // avatarUrls: {
244
- // '48x48': 'https://your-domain.atlassian.net/secure/projectavatar?pid=10000&avatarId=10425',
245
- // '24x24': 'https://your-domain.atlassian.net/secure/projectavatar?size=small&s=small&pid=10000&avatarId=10425',
246
- // '16x16': 'https://your-domain.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10000&avatarId=10425',
247
- // '32x32': 'https://your-domain.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10000&avatarId=10425'
248
- // },
249
- // projectTypeKey: 'software',
250
- // simplified: true,
251
- // style: 'next-gen',
252
- // isPrivate: false,
253
- // properties: {},
254
- // entityId: 'e0a412bd-1510-4841-bdbc-84180db3ee3b',
255
- // uuid: 'e0a412bd-1510-4841-bdbc-84180db3ee3b'
256
- // }
257
- // ]
258
273
```
259
274
260
- The algorithm for using the library:
275
+ 2 . The algorithm for using the library:
261
276
262
277
``` typescript
263
278
client .< group > .< methodName > (parametersObject );
0 commit comments