Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add promise-based methods for GitHub client service #618

Merged
merged 1 commit into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,21 @@ public interface GitHubClientService {
* the repository name.
* @param callback
* callback called when operation is done.
* @deprecated use {@link #getForks(String user, String repository)}
*/
@Deprecated
void getForks(@NotNull String user, @NotNull String repository, @NotNull AsyncRequestCallback<GitHubRepositoryList> callback);

/**
* Get list of forks for given repository
*
* @param user
* the owner of the repository.
* @param repository
* the repository name.
*/
Promise<GitHubRepositoryList> getForks(String user, String repository);

/**
* Fork the given repository for the authorized user.
*
Expand All @@ -82,9 +94,21 @@ public interface GitHubClientService {
* the repository name.
* @param callback
* callback called when operation is done.
* @deprecated use {@link #fork(String, String)}
*/
@Deprecated
void fork(@NotNull String user, @NotNull String repository, @NotNull AsyncRequestCallback<GitHubRepository> callback);

/**
* Fork the given repository for the authorized user.
*
* @param user
* the owner of the repository to fork.
* @param repository
* the repository name.
*/
Promise<GitHubRepository> fork(String user, String repository);

/**
* Add a comment to the issue on the given repository.
*
Expand All @@ -111,9 +135,21 @@ void commentIssue(@NotNull String user, @NotNull String repository, @NotNull Str
* the repository name.
* @param callback
* callback called when operation is done.
* @deprecated use {@link #getPullRequests(String, String)}
*/
@Deprecated
void getPullRequests(@NotNull String owner, @NotNull String repository, @NotNull AsyncRequestCallback<GitHubPullRequestList> callback);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Deprecated annotation.


/**
* Get pull requests for given repository.
*
* @param owner
* the repository owner.
* @param repository
* the repository name.
*/
Promise<GitHubPullRequestList> getPullRequests(@NotNull String owner, @NotNull String repository);

/**
* Get a pull request by id for a given repository.
*
Expand Down Expand Up @@ -142,10 +178,28 @@ void getPullRequest(@NotNull String owner,
* the pull request information.
* @param callback
* callback called when operation is done.
* @deprecated use {@link #createPullRequest(String, String, GitHubPullRequestCreationInput)}
*/
void createPullRequest(@NotNull String user, @NotNull String repository, @NotNull GitHubPullRequestCreationInput input,
@Deprecated
void createPullRequest(@NotNull String user,
@NotNull String repository,
@NotNull GitHubPullRequestCreationInput input,
@NotNull AsyncRequestCallback<GitHubPullRequest> callback);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this method changed directly instead of deprecation old method and new method addition just like for other methods you did?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we just fixed the formatting, and do the same things as with other methods (writing new one)


/**
* Create a pull request on origin repository
*
* @param user
* the owner of the repository.
* @param repository
* the repository name.
* @param input
* the pull request information.
*/
Promise<GitHubPullRequest> createPullRequest(@NotNull String user,
@NotNull String repository,
@NotNull GitHubPullRequestCreationInput input);

/**
* Get the list of available public repositories for a GitHub user.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,34 @@ public Promise<List<GitHubRepository>> getRepositoriesList() {

/** {@inheritDoc} */
@Override
public void getForks(@NotNull String user, @NotNull String repository,
public void getForks(@NotNull String user,
@NotNull String repository,
@NotNull AsyncRequestCallback<GitHubRepositoryList> callback) {
String url = baseUrl + FORKS + "/" + user + "/" + repository;
asyncRequestFactory.createGetRequest(url).loader(loader).send(callback);
}

@Override
public Promise<GitHubRepositoryList> getForks(String user, String repository) {
return asyncRequestFactory.createGetRequest(baseUrl + FORKS + '/' + user + '/' + repository)
.loader(loader)
.send(dtoUnmarshallerFactory.newUnmarshaller(GitHubRepositoryList.class));
}

/** {@inheritDoc} */
@Override
public void fork(@NotNull String user, @NotNull String repository, @NotNull AsyncRequestCallback<GitHubRepository> callback) {
String url = baseUrl + CREATE_FORK + "/" + user + "/" + repository;
asyncRequestFactory.createGetRequest(url).loader(loader).send(callback);
}

@Override
public Promise<GitHubRepository> fork(String user, String repository) {
return asyncRequestFactory.createGetRequest(baseUrl + CREATE_FORK + '/' + user + '/' + repository)
.loader(loader)
.send(dtoUnmarshallerFactory.newUnmarshaller(GitHubRepository.class));
}

@Override
public void commentIssue(@NotNull String user, @NotNull String repository, @NotNull String issue,
@NotNull GitHubIssueCommentInput input, @NotNull AsyncRequestCallback<GitHubIssueComment> callback) {
Expand All @@ -126,6 +141,14 @@ public void getPullRequests(@NotNull String owner, @NotNull String repository,
asyncRequestFactory.createGetRequest(url).loader(loader).send(callback);
}

@Override
public Promise<GitHubPullRequestList> getPullRequests(@NotNull String owner, @NotNull String repository) {
final String url = baseUrl + PULL_REQUESTS + '/' + owner + '/' + repository;
return asyncRequestFactory.createGetRequest(url)
.loader(loader)
.send(dtoUnmarshallerFactory.newUnmarshaller(GitHubPullRequestList.class));
}

@Override
public void getPullRequest(final String owner, final String repository, final String pullRequestId,
final AsyncRequestCallback<GitHubPullRequest> callback) {
Expand All @@ -141,6 +164,16 @@ public void createPullRequest(@NotNull String user, @NotNull String repository,
asyncRequestFactory.createPostRequest(url, input).loader(loader).send(callback);
}

@Override
public Promise<GitHubPullRequest> createPullRequest(@NotNull String user,
@NotNull String repository,
@NotNull GitHubPullRequestCreationInput input) {
final String url = baseUrl + PULL_REQUEST + '/' + user + '/' + repository;
return asyncRequestFactory.createPostRequest(url, input)
.loader(loader)
.send(dtoUnmarshallerFactory.newUnmarshaller(GitHubPullRequest.class));
}

/** {@inheritDoc} */
@Override
public void getRepositoriesByUser(String userName, @NotNull AsyncRequestCallback<GitHubRepositoryList> callback) {
Expand Down