Skip to content

Commit

Permalink
fix: update github response format
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 8, 2019
1 parent 8b709aa commit 834797f
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/controller/github/PRController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,14 @@ export const QUERY_PR_MERGE = `
`;

interface GithubGetResponse {
data: {
repository: {
pullRequest: {
author: {
login: string;
};
id: string;
number: number;
title: string;
repository: {
pullRequest: {
author: {
login: string;
};
id: string;
number: number;
title: string;
};
};
}
Expand Down Expand Up @@ -130,12 +128,13 @@ export class GithubPRController extends BaseController<GithubPRControllerData> i
}

this.logger.debug({ requestData }, 'updating pull request');
const requestID = requestData.data.repository.pullRequest.id;
const requestID = requestData.repository.pullRequest.id;

this.logger.debug({ owner, project, requestID, requestNumber }, 'closing pull request');
await this.client(QUERY_PR_CLOSE, {
requestID,
});

return this.reply(ctx, `closed pull request ${requestNumber}`);
}

Expand All @@ -147,7 +146,7 @@ export class GithubPRController extends BaseController<GithubPRControllerData> i
const requestNumber = cmd.getHead('number');

const response = await this.getRequestData(owner, project, requestNumber);
return this.transformJSON(cmd, [response.data.repository.pullRequest]);
return this.transformJSON(cmd, [response.repository.pullRequest]);
}

@Handler(NOUN_PULL_REQUEST, CommandVerb.List)
Expand All @@ -160,7 +159,7 @@ export class GithubPRController extends BaseController<GithubPRControllerData> i
owner,
project,
});
return this.transformJSON(cmd, response.data.repository.pullRequests.nodes);
return this.transformJSON(cmd, response.repository.pullRequests.nodes);
}

@Handler(NOUN_PULL_REQUEST, CommandVerb.Update)
Expand All @@ -177,7 +176,7 @@ export class GithubPRController extends BaseController<GithubPRControllerData> i
}

this.logger.debug({ requestData }, 'updating pull request');
const requestID = requestData.data.repository.pullRequest.id;
const requestID = requestData.repository.pullRequest.id;

this.logger.debug({ owner, project, requestID, requestNumber }, 'merging pull request');
await this.client(QUERY_PR_MERGE, {
Expand Down

0 comments on commit 834797f

Please sign in to comment.