Search in sources :

Example 1 with CreateReview

use of com.meisolsson.githubsdk.model.request.pull_request.CreateReview in project gh4a by slapperwan.

the class CreateReviewActivity method onEditorDoSend.

@Override
public Single<?> onEditorDoSend(String body) {
    int position = mReviewEventSpinner.getSelectedItemPosition();
    @SuppressWarnings("ConstantConditions") ReviewEventDesc desc = mReviewEventAdapter.getItem(position);
    PullRequestReviewService service = ServiceFactory.get(PullRequestReviewService.class, false);
    final Single<Response<Review>> resultSingle;
    if (mPendingReview == null) {
        CreateReview request = CreateReview.builder().body(body).event(desc.mCreateEvent).build();
        resultSingle = service.createReview(mRepoOwner, mRepoName, mPullRequestNumber, request);
    } else {
        SubmitReview request = SubmitReview.builder().body(body).event(desc.mSubmitEvent).build();
        resultSingle = service.submitReview(mRepoOwner, mRepoName, mPullRequestNumber, mPendingReview.id(), request);
    }
    return resultSingle.map(ApiHelpers::throwOnFailure);
}
Also used : Response(retrofit2.Response) SubmitReview(com.meisolsson.githubsdk.model.request.pull_request.SubmitReview) ApiHelpers(com.gh4a.utils.ApiHelpers) CreateReview(com.meisolsson.githubsdk.model.request.pull_request.CreateReview) PullRequestReviewService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewService)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)1 CreateReview (com.meisolsson.githubsdk.model.request.pull_request.CreateReview)1 SubmitReview (com.meisolsson.githubsdk.model.request.pull_request.SubmitReview)1 PullRequestReviewService (com.meisolsson.githubsdk.service.pull_request.PullRequestReviewService)1 Response (retrofit2.Response)1