Add promise-based methods for GitHub service client
parent
ea13a4dc30
commit
dfd56e437f
|
|
@ -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.
|
||||
*
|
||||
|
|
@ -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.
|
||||
*
|
||||
|
|
@ -111,9 +135,21 @@ public interface GitHubClientService {
|
|||
* 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);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
@ -142,10 +178,28 @@ public interface GitHubClientService {
|
|||
* 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);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -99,12 +99,20 @@ public class GitHubClientServiceImpl implements GitHubClientService {
|
|||
|
||||
/** {@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) {
|
||||
|
|
@ -112,6 +120,13 @@ public class GitHubClientServiceImpl implements GitHubClientService {
|
|||
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) {
|
||||
|
|
@ -126,6 +141,14 @@ public class GitHubClientServiceImpl implements GitHubClientService {
|
|||
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) {
|
||||
|
|
@ -141,6 +164,16 @@ public class GitHubClientServiceImpl implements GitHubClientService {
|
|||
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue