@@ -27,7 +27,7 @@ Usability, consistency, and performance are key focuses of jira.js, and it also
2727 - [ OAuth 2.0] ( #oauth-20 )
2828 - [ JWT] ( #jwt )
2929 - [ 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 )
3131- [ Decreasing Webpack bundle size] ( #decreasing-webpack-bundle-size )
3232- [ Take a look at our other products] ( #take-a-look-at-our-other-products )
3333- [ License] ( #license )
@@ -113,9 +113,9 @@ Basic authentication allows you to log in with credentials. You can use username
113113Username and password example:
114114
115115` ` ` typescript
116- import { Version2Client } from ' jira.js' ;
116+ import { Version3Client } from ' jira.js' ;
117117
118- const client = new Version2Client ({
118+ const client = new Version3Client ({
119119 host: ' https://your-domain.atlassian.net' ,
120120 authentication: {
121121 basic: {
@@ -129,9 +129,9 @@ const client = new Version2Client({
129129Email and API Token example:
130130
131131``` typescript
132- import { Version2Client } from ' jira.js' ;
132+ import { Version3Client } from ' jira.js' ;
133133
134- const client = new Version2Client ({
134+ const client = new Version3Client ({
135135 host: ' https://your-domain.atlassian.net' ,
136136 authentication: {
137137 basic: {
@@ -145,9 +145,9 @@ const client = new Version2Client({
145145##### [ OAuth] ( https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/ )
146146
147147``` typescript
148- import { Version2Client } from ' jira.js' ;
148+ import { Version3Client } from ' jira.js' ;
149149
150- const client = new Version2Client ({
150+ const client = new Version3Client ({
151151 host: ' https://your-domain.atlassian.net' ,
152152 authentication: {
153153 oauth: {
@@ -167,9 +167,9 @@ Only the authorization token is currently supported. To release it, you need to
167167Example of usage
168168
169169``` typescript
170- import { Version2Client } from ' jira.js' ;
170+ import { Version3Client } from ' jira.js' ;
171171
172- const client = new Version2Client ({
172+ const client = new Version3Client ({
173173 host: ' https://your-domain.atlassian.net' ,
174174 authentication: {
175175 oauth2: {
@@ -182,9 +182,9 @@ const client = new Version2Client({
182182##### [ JWT] ( https://developer.atlassian.com/cloud/jira/platform/understanding-jwt-for-connect-apps/ )
183183
184184``` typescript
185- import { Version2Client } from ' jira.js' ;
185+ import { Version3Client } from ' jira.js' ;
186186
187- const client = new Version2Client ({
187+ const client = new Version3Client ({
188188 host: ' https://your-domain.atlassian.net' ,
189189 authentication: {
190190 jwt: {
@@ -199,65 +199,80 @@ const client = new Version2Client({
199199##### [ Personal access token] ( https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html )
200200
201201``` typescript
202- import { Version2Client } from ' jira.js' ;
202+ import { Version3Client } from ' jira.js' ;
203203
204- const client = new Version2Client ({
204+ const client = new Version3Client ({
205205 host: ' https://your-domain.atlassian.net' ,
206206 authentication: {
207207 personalAccessToken: ' secrectPAT' ,
208208 },
209209});
210210```
211211
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
213220
214221``` typescript
215- import { Version2Client } from ' jira.js' ;
222+ import { Version3Client } from ' jira.js' ;
216223
217- const client = new Version2Client ({
218- host: ' https://your-domain.atlassian.net ' ,
224+ const client = new Version3Client ({
225+ host ,
219226 authentication: {
220227 basic: {
221- email: ' YOUR_EMAIL ' ,
222- apiToken: ' YOUR_API_TOKEN ' ,
228+ email ,
229+ apiToken ,
223230 },
224231 },
232+ newErrorHandling: true ,
225233});
226234
227235async function main() {
228236 const projects = await client .projects .getAllProjects ();
229237
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+ }
231270}
232271
233272main ();
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- // ]
258273```
259274
260- The algorithm for using the library:
275+ 2 . The algorithm for using the library:
261276
262277``` typescript
263278client .< group > .< methodName > (parametersObject );
0 commit comments