Skip to content

Commit 1d764b6

Browse files
Merge pull request #315 from atlassian/SUN-516-replace-requestConnectedData-with-requestJira
Replace `requestConnectedData` with `requestJira`
2 parents 4e07017 + 128333c commit 1d764b6

8 files changed

Lines changed: 21 additions & 21 deletions

app/src/jira-client/delete-builds.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InvalidPayloadError } from '../common/error';
66
jest.mock('@forge/api', () => ({
77
...jest.requireActual('@forge/api'),
88
asApp: jest.fn().mockReturnValue({
9-
requestConnectedData: jest.fn()
9+
requestJira: jest.fn()
1010
})
1111
}));
1212

@@ -18,7 +18,7 @@ describe('deleteBuilds suite', () => {
1818

1919
it('Should return status for successful response', async () => {
2020
const mockResponse = { status: 200 };
21-
api.asApp().requestConnectedData = jest.fn().mockImplementation(() => ({
21+
api.asApp().requestJira = jest.fn().mockImplementation(() => ({
2222
then: (callback: any) => Promise.resolve(callback(mockResponse))
2323
}));
2424

app/src/jira-client/delete-builds.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ async function deleteBuilds(cloudId: string, jenkinsServerUuid?: string): Promis
1515
let deleteBuildsRoute: Route;
1616
if (jenkinsServerUuid) {
1717
// eslint-disable-next-line max-len
18-
deleteBuildsRoute = route`/builds/0.1/cloud/${cloudId}/bulkByProperties?jenkinsServerUuid=${jenkinsServerUuid}`;
18+
deleteBuildsRoute = route`/rest/builds/0.1/bulkByProperties?jenkinsServerUuid=${jenkinsServerUuid}`;
1919
} else {
20-
deleteBuildsRoute = route`/builds/0.1/cloud/${cloudId}/bulkByProperties?cloudId=${cloudId}`;
20+
deleteBuildsRoute = route`/rest/builds/0.1/bulkByProperties?cloudId=${cloudId}`;
2121
}
2222

2323
const apiResponse = await api
2424
.asApp()
25-
.requestConnectedData(deleteBuildsRoute, {
25+
.requestJira(deleteBuildsRoute, {
2626
method: 'DELETE'
2727
});
2828

app/src/jira-client/delete-deployments.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InvalidPayloadError } from '../common/error';
66
jest.mock('@forge/api', () => ({
77
...jest.requireActual('@forge/api'),
88
asApp: jest.fn().mockReturnValue({
9-
requestConnectedData: jest.fn()
9+
requestJira: jest.fn()
1010
})
1111
}));
1212

@@ -18,7 +18,7 @@ describe('deleteDeployments suite', () => {
1818

1919
it('Should return status for successful response', async () => {
2020
const mockResponse = { status: 200 };
21-
api.asApp().requestConnectedData = jest.fn().mockImplementation(() => ({
21+
api.asApp().requestJira = jest.fn().mockImplementation(() => ({
2222
then: (callback: any) => Promise.resolve(callback(mockResponse))
2323
}));
2424

app/src/jira-client/delete-deployments.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ async function deleteDeployments(cloudId: string, jenkinsServerUuid?: string): P
1515
let deleteDeploymentsRoute: Route;
1616
if (jenkinsServerUuid) {
1717
// eslint-disable-next-line max-len
18-
deleteDeploymentsRoute = route`/deployments/0.1/cloud/${cloudId}/bulkByProperties?cloudId=${cloudId}&jenkinsServerUuid=${jenkinsServerUuid}`;
18+
deleteDeploymentsRoute = route`/rest/deployments/0.1/bulkByProperties?cloudId=${cloudId}&jenkinsServerUuid=${jenkinsServerUuid}`;
1919
} else {
20-
deleteDeploymentsRoute = route`/deployments/0.1/cloud/${cloudId}/bulkByProperties?cloudId=${cloudId}`;
20+
deleteDeploymentsRoute = route`/rest/deployments/0.1/bulkByProperties?cloudId=${cloudId}`;
2121
}
2222

2323
// @ts-ignore // required so that Typescript doesn't complain about the missing "api" property
2424
// eslint-disable-next-line no-underscore-dangle
2525
const apiResponse = await api
2626
.asApp()
27-
.requestConnectedData(deleteDeploymentsRoute, {
27+
.requestJira(deleteDeploymentsRoute, {
2828
method: 'DELETE'
2929
});
3030

app/src/jira-client/get-gating-status-from-jira.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InvalidPayloadError } from '../common/error';
66
jest.mock('@forge/api', () => ({
77
...jest.requireActual('@forge/api'),
88
asApp: jest.fn().mockReturnValue({
9-
requestConnectedData: jest.fn()
9+
requestJira: jest.fn()
1010
})
1111
}));
1212

@@ -33,7 +33,7 @@ describe('getGatingStatusFromJira suite', () => {
3333

3434
it('Should return status with empty body if no responseString is returned', async () => {
3535
const mockResponse = { status: 200, text: jest.fn() };
36-
api.asApp().requestConnectedData = jest.fn().mockImplementation(() => ({
36+
api.asApp().requestJira = jest.fn().mockImplementation(() => ({
3737
then: (callback: any) => Promise.resolve(callback(mockResponse))
3838
}));
3939

@@ -60,7 +60,7 @@ describe('getGatingStatusFromJira suite', () => {
6060
});
6161

6262
const mockResponse = { status: 200, text: mockText };
63-
api.asApp().requestConnectedData = jest.fn().mockImplementation(() => ({
63+
api.asApp().requestJira = jest.fn().mockImplementation(() => ({
6464
then: (callback: any) => Promise.resolve(callback(mockResponse))
6565
}));
6666

app/src/jira-client/get-gating-status-from-jira.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ async function getGatingStatusFromJira(
1919
}
2020

2121
// eslint-disable-next-line max-len
22-
const getGatingStatusRoute = route`/deployments/0.1/cloud/${encodeURIComponent(cloudId)}/pipelines/${encodeURIComponent(pipelineId)}/environments/${encodeURIComponent(environmentId)}/deployments/${encodeURIComponent(deploymentId)}/gating-status`;
22+
const getGatingStatusRoute = route`/rest/deployments/0.1/pipelines/${encodeURIComponent(pipelineId)}/environments/${encodeURIComponent(environmentId)}/deployments/${encodeURIComponent(deploymentId)}/gating-status`;
2323

2424
const apiResponse = await api
2525
.asApp()
26-
.requestConnectedData(getGatingStatusRoute, {
26+
.requestJira(getGatingStatusRoute, {
2727
method: 'GET',
2828
headers: {
2929
'content-type': 'application/json'

app/src/jira-client/send-event-to-jira.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { InvalidPayloadError } from '../common/error';
77
jest.mock('@forge/api', () => ({
88
...jest.requireActual('@forge/api'),
99
asApp: jest.fn().mockReturnValue({
10-
requestConnectedData: jest.fn()
10+
requestJira: jest.fn()
1111
})
1212
}));
1313

@@ -34,7 +34,7 @@ describe('Send event to Jira suite', () => {
3434

3535
it('Should return status with empty body if no responseString is returned', async () => {
3636
const mockResponse = { status: 200, text: jest.fn() };
37-
api.asApp().requestConnectedData = jest.fn().mockImplementation(() => ({
37+
api.asApp().requestJira = jest.fn().mockImplementation(() => ({
3838
then: (callback: any) => Promise.resolve(callback(mockResponse))
3939
}));
4040

@@ -61,7 +61,7 @@ describe('Send event to Jira suite', () => {
6161
}));
6262
});
6363
const mockResponse = { status: 200, text: mockText };
64-
api.asApp().requestConnectedData = jest.fn().mockImplementation(() => ({
64+
api.asApp().requestJira = jest.fn().mockImplementation(() => ({
6565
then: (callback: any) => Promise.resolve(callback(mockResponse))
6666
}));
6767

app/src/jira-client/send-event-to-jira.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async function invokeApi(
3434
): Promise<JiraResponse> {
3535
const apiResponse = await api
3636
.asApp()
37-
.requestConnectedData(sendEventToJiraRoute, {
37+
.requestJira(sendEventToJiraRoute, {
3838
method: 'POST',
3939
headers: {
4040
'content-type': 'application/json',
@@ -80,9 +80,9 @@ async function sendEventToJira(
8080

8181
switch (eventType) {
8282
case EventType.BUILD:
83-
return invokeApi(route`/builds/0.1/cloud/${cloudId}/bulk`, payload, logger);
83+
return invokeApi(route`/rest/builds/0.1/bulk`, payload, logger);
8484
case EventType.DEPLOYMENT:
85-
return invokeApi(route`/deployments/0.1/cloud/${cloudId}/bulk`, payload, logger);
85+
return invokeApi(route`/rest/deployments/0.1/bulk`, payload, logger);
8686
default:
8787
logger.error(Errors.INVALID_EVENT_TYPE);
8888
throw new InvalidPayloadError(Errors.INVALID_EVENT_TYPE);

0 commit comments

Comments
 (0)