Skip to content

Commit

Permalink
Refactoring of Pull Request API
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Aug 29, 2014
1 parent 82020c2 commit 009c653
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/src/common/github.dart
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,8 @@ class GitHub {
}
}

Future<FullPullRequest> pullRequest(RepositorySlug slug, int number) {
return getJSON("/repos/${slug.fullName}/pulls/${number}", convert: FullPullRequest.fromJSON, statusCode: 200);
Future<PullRequest> pullRequest(RepositorySlug slug, int number) {
return getJSON("/repos/${slug.fullName}/pulls/${number}", convert: PullRequest.fromJSON, statusCode: 200);
}

/**
Expand Down
26 changes: 13 additions & 13 deletions lib/src/common/pull_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ part of github.common;
/**
* A Pull Request
*/
class PullRequest {
class PullRequestInformation {
final GitHub github;

/**
* If this is a full pull request
* If this is a complete pull request
*/
final bool isFullPullRequest;
final bool isCompletePullRequest;

/**
* Url to the Pull Request Page
Expand Down Expand Up @@ -90,10 +90,10 @@ class PullRequest {

Map<String, dynamic> json;

PullRequest(this.github, [this.isFullPullRequest = false]);
PullRequestInformation(this.github, [this.isCompletePullRequest = false]);

static PullRequest fromJSON(GitHub github, input, [PullRequest into]) {
var pr = into != null ? into : new PullRequest(github);
static PullRequestInformation fromJSON(GitHub github, input, [PullRequestInformation into]) {
var pr = into != null ? into : new PullRequestInformation(github);
pr.head = PullRequestHead.fromJSON(github, input['head']);
pr.base = PullRequestHead.fromJSON(github, input['head']);
pr.url = input['html_url'];
Expand All @@ -115,18 +115,18 @@ class PullRequest {
/**
* Fetches the Full Pull Request
*/
Future<FullPullRequest> fetchFullRequest() {
if (isFullPullRequest) {
Future<PullRequest> fetchPullRequest() {
if (isCompletePullRequest) {
return new Future.value(this);
}
return github.getJSON(json['url'], convert: FullPullRequest.fromJSON);
return github.getJSON(json['url'], convert: PullRequest.fromJSON);
}
}

/**
* A Complete Pull Request
*/
class FullPullRequest extends PullRequest {
class PullRequest extends PullRequestInformation {
@ApiName("merge_commit_sha")
String mergeCommitSha;

Expand Down Expand Up @@ -171,11 +171,11 @@ class FullPullRequest extends PullRequest {
*/
int changedFilesCount;

FullPullRequest(GitHub github) : super(github, true);
PullRequest(GitHub github) : super(github, true);

static FullPullRequest fromJSON(GitHub github, input) {
static PullRequest fromJSON(GitHub github, input) {
if (input == null) return null;
FullPullRequest pr = PullRequest.fromJSON(github, input, new FullPullRequest(github));
PullRequest pr = PullRequestInformation.fromJSON(github, input, new PullRequest(github));
pr.mergeable = input['mergeable'];
pr.merged = input['merged'];
pr.mergedBy = User.fromJSON(github, input['merged_by']);
Expand Down
8 changes: 4 additions & 4 deletions lib/src/common/repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ class Repository {
/**
* Gets the Repository Pull Requests
*/
Stream<PullRequest> pullRequests() {
return new PaginationHelper(github).objects("GET", "/repos/${fullName}/pulls", PullRequest.fromJSON);
Stream<PullRequestInformation> pullRequests() {
return new PaginationHelper(github).objects("GET", "/repos/${fullName}/pulls", PullRequestInformation.fromJSON);
}

/**
Expand Down Expand Up @@ -290,8 +290,8 @@ class Repository {
/**
* Creates a Pull Request based on the given [request].
*/
Future<PullRequest> createPullRequest(CreateReleaseRequest request) {
return github.postJSON("/repos/${fullName}/pulls", convert: PullRequest.fromJSON, body: request.toJSON());
Future<PullRequestInformation> createPullRequest(CreateReleaseRequest request) {
return github.postJSON("/repos/${fullName}/pulls", convert: PullRequestInformation.fromJSON, body: request.toJSON());
}

Future<Commit> merge(CreateMerge request) {
Expand Down

0 comments on commit 009c653

Please sign in to comment.