| 100 | |
| 101 | transformResponse: async (response: Response, params?: JiraGetCommentsParams) => { |
| 102 | const fetchComments = async (cloudId: string) => { |
| 103 | const startAt = params?.startAt ?? 0 |
| 104 | const maxResults = params?.maxResults ?? 50 |
| 105 | const orderBy = params?.orderBy ?? '-created' |
| 106 | const commentsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey?.trim() ?? ''}/comment?startAt=${startAt}&maxResults=${maxResults}&orderBy=${orderBy}` |
| 107 | const commentsResponse = await fetch(commentsUrl, { |
| 108 | method: 'GET', |
| 109 | headers: { |
| 110 | Accept: 'application/json', |
| 111 | Authorization: `Bearer ${params!.accessToken}`, |
| 112 | }, |
| 113 | }) |
| 114 | |
| 115 | if (!commentsResponse.ok) { |
| 116 | let message = `Failed to get comments from Jira issue (${commentsResponse.status})` |
| 117 | try { |
| 118 | const err = await commentsResponse.json() |
| 119 | message = err?.errorMessages?.join(', ') || err?.message || message |
| 120 | } catch (_e) {} |
| 121 | throw new Error(message) |
| 122 | } |
| 123 | |
| 124 | return commentsResponse.json() |
| 125 | } |
| 126 | |
| 127 | let data: any |
| 128 | |