Skip to content

Commit

Permalink
Add Pull Request Manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Aug 29, 2014
1 parent 009c653 commit 37c5323
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/src/common/pull_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,31 @@ class PullRequest extends PullRequestInformation {
return new PaginationHelper(github).objects("GET", "${this.json['url'].replaceFirst("/pulls/", "/issues/")}/comments", IssueComment.fromJSON);
}

Stream<Commit> commits() {
return new PaginationHelper(github).objects("GET", json['commits_url'], Commit.fromJSON);
}

Future<PullRequest> changeState(String newState) {
return github.request("PATCH", json['url'], body: JSON.encode({ "state": newState })).then((response) {
return PullRequest.fromJSON(github, JSON.decode(response.body));
});
}

Future<PullRequest> close() => changeState("closed");
Future<PullRequest> open() => changeState("open");
Future<PullRequest> reopen() => changeState("open");

Future<PullRequest> changeTitle(String newTitle) {
return github.request("PATCH", json['url'], body: JSON.encode({ "title": newTitle })).then((response) {
return PullRequest.fromJSON(github, JSON.decode(response.body));
});
}

Future<PullRequest> changeBody(String newBody) {
return github.request("PATCH", json['url'], body: JSON.encode({ "body": newBody })).then((response) {
return PullRequest.fromJSON(github, JSON.decode(response.body));
});
}
}

RepositorySlug _slugFromAPIUrl(String url) {
Expand Down

0 comments on commit 37c5323

Please sign in to comment.