Skip to content

Commit

Permalink
duplicate class removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
syslogic committed Aug 9, 2024
1 parent ff0a5c1 commit c33601f
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 93 deletions.
12 changes: 6 additions & 6 deletions library/src/main/java/io/syslogic/github/api/GithubClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import io.syslogic.github.api.model.Repository;
import io.syslogic.github.api.model.RepositorySearch;
import io.syslogic.github.api.model.User;
import io.syslogic.github.api.model.WorkflowJobsResponse;
import io.syslogic.github.api.model.WorkflowJobs;
import io.syslogic.github.api.model.WorkflowRun;
import io.syslogic.github.api.model.WorkflowRunsResponse;
import io.syslogic.github.api.model.WorkflowsResponse;
import io.syslogic.github.api.model.WorkflowRuns;
import io.syslogic.github.api.model.Workflows;

import okhttp3.OkHttpClient;
import okhttp3.ResponseBody;
Expand Down Expand Up @@ -197,7 +197,7 @@ public class GithubClient {
* @param repo the name of the repository.
* @return Retrofit2 call.
*/
@NonNull public static Call<WorkflowsResponse> getWorkflows(@Nullable String token, @NonNull String owner, @NonNull String repo) {
@NonNull public static Call<Workflows> getWorkflows(@Nullable String token, @NonNull String owner, @NonNull String repo) {
return getService().getWorkflows("token " + token, owner, repo);
}

Expand All @@ -209,7 +209,7 @@ public class GithubClient {
* @param repo the name of the repository.
* @return Retrofit2 call.
*/
@NonNull public static Call<WorkflowRunsResponse> getWorkflowRuns(@Nullable String token, @NonNull String owner, @NonNull String repo) {
@NonNull public static Call<WorkflowRuns> getWorkflowRuns(@Nullable String token, @NonNull String owner, @NonNull String repo) {
return getService().getWorkflowRuns("token " + token, owner, repo);
}

Expand All @@ -235,7 +235,7 @@ public class GithubClient {
* @param runId the ID of the run to list jobs for.
* @return Retrofit2 call.
*/
@NonNull public static Call<WorkflowJobsResponse> getWorkflowJobs(@Nullable String token, @NonNull String owner, @NonNull String repo, @NonNull Long runId) {
@NonNull public static Call<WorkflowJobs> getWorkflowJobs(@Nullable String token, @NonNull String owner, @NonNull String repo, @NonNull Long runId) {
return getService().getWorkflowJobs("token " + token, owner, repo, runId);
}

Expand Down
15 changes: 8 additions & 7 deletions library/src/main/java/io/syslogic/github/api/GithubService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import io.syslogic.github.api.model.RepositorySearch;
import io.syslogic.github.api.model.User;

import io.syslogic.github.api.model.WorkflowJobsResponse;
import io.syslogic.github.api.model.WorkflowJobs;
import io.syslogic.github.api.model.WorkflowRun;
import io.syslogic.github.api.model.WorkflowRunsResponse;
import io.syslogic.github.api.model.WorkflowsResponse;
import io.syslogic.github.api.model.WorkflowRuns;
import io.syslogic.github.api.model.Workflows;

import okhttp3.ResponseBody;

Expand Down Expand Up @@ -231,7 +231,7 @@ Call<RepositorySearch> getRepositories(
*/
@NonNull
@GET("/repos/{owner}/{repo}/actions/workflows")
Call<WorkflowsResponse> getWorkflows(
Call<Workflows> getWorkflows(
@NonNull @Header("Authorization") String token,
@NonNull @Path(value = "owner") String owner,
@NonNull @Path(value = "repo") String repo
Expand All @@ -246,7 +246,7 @@ Call<WorkflowsResponse> getWorkflows(
*/
@NonNull
@GET("/repos/{owner}/{repo}/actions/runs")
Call<WorkflowRunsResponse> getWorkflowRuns(
Call<WorkflowRuns> getWorkflowRuns(
@NonNull @Header("Authorization") String token,
@NonNull @Path(value = "owner") String owner,
@NonNull @Path(value = "repo") String repo
Expand All @@ -271,15 +271,16 @@ Call<WorkflowRun> getWorkflowRun(

/**
* GitHub Actions: Workflow Run Jobs.
*
* @param token the personal access token.
* @param owner the owner of the repository.
* @param repo the name of the repository.
* @param repo the name of the repository.
* @param runId the ID of the workflow run.
* @return Retrofit2 call.
*/
@NonNull
@GET("/repos/{owner}/{repo}/actions/runs/{runId}/jobs")
Call<WorkflowJobsResponse> getWorkflowJobs(
Call<WorkflowJobs> getWorkflowJobs(
@NonNull @Header("Authorization") String token,
@NonNull @Path(value = "owner") String owner,
@NonNull @Path(value = "repo") String repo,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @author Martin Zeitler
*/
public class WorkflowRunsResponse {
public class WorkflowRuns {

@SerializedName("workflow_runs")
private ArrayList<WorkflowRun> workflowRuns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @author Martin Zeitler
*/
public class WorkflowsResponse {
public class Workflows {

/** Items */
@SerializedName("workflows")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import io.syslogic.github.api.GithubClient;
import io.syslogic.github.api.model.Repository;
import io.syslogic.github.api.model.Workflow;
import io.syslogic.github.api.model.WorkflowsResponse;
import io.syslogic.github.api.model.Workflows;
import io.syslogic.github.databinding.CardviewRepositoryBinding;
import io.syslogic.github.databinding.FragmentRepositoriesBinding;
import io.syslogic.github.model.PagerState;
Expand Down Expand Up @@ -154,15 +154,15 @@ void getWorkflows(int positionStart) {
final int[] index = {0};
for (Repository item : this.getItems()) {

Call<WorkflowsResponse> api = GithubClient.getWorkflows(accessToken, username, item.getName());
Call<Workflows> api = GithubClient.getWorkflows(accessToken, username, item.getName());
GithubClient.logUrl(LOG_TAG, api);

api.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<WorkflowsResponse> call, @NonNull Response<WorkflowsResponse> response) {
public void onResponse(@NonNull Call<Workflows> call, @NonNull Response<Workflows> response) {
if (response.code() == 200) { // OK
if (response.body() != null) {
WorkflowsResponse items = response.body();
Workflows items = response.body();
if (BuildConfig.DEBUG) {
if (items.getWorkflows() != null && items.getWorkflows().size() > 0) {

Expand All @@ -182,7 +182,7 @@ public void onResponse(@NonNull Call<WorkflowsResponse> call, @NonNull Response<
}

@Override
public void onFailure(@NonNull Call<WorkflowsResponse> call, @NonNull Throwable t) {
public void onFailure(@NonNull Call<Workflows> call, @NonNull Throwable t) {
if (BuildConfig.DEBUG) {Log.e(LOG_TAG, "onFailure: " + t.getMessage());}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.syslogic.github.activity.BaseActivity;
import io.syslogic.github.api.GithubClient;
import io.syslogic.github.api.model.WorkflowRun;
import io.syslogic.github.api.model.WorkflowRunsResponse;
import io.syslogic.github.api.model.WorkflowRuns;
import io.syslogic.github.api.room.Abstraction;
import io.syslogic.github.databinding.CardviewWorkflowRunBinding;

Expand Down Expand Up @@ -95,15 +95,15 @@ protected Context getContext() {

public void getWorkflowRuns(String accessToken, String username, String repositoryName) {

Call<WorkflowRunsResponse> api = GithubClient.getWorkflowRuns(accessToken, username, repositoryName);
Call<WorkflowRuns> api = GithubClient.getWorkflowRuns(accessToken, username, repositoryName);
GithubClient.logUrl(LOG_TAG, api);

api.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<WorkflowRunsResponse> call, @NonNull Response<WorkflowRunsResponse> response) {
public void onResponse(@NonNull Call<WorkflowRuns> call, @NonNull Response<WorkflowRuns> response) {
if (response.code() == 200) { // OK
if (response.body() != null) {
WorkflowRunsResponse items = response.body();
WorkflowRuns items = response.body();
if (items.getWorkflowRuns() != null && items.getWorkflowRuns().size() > 0) {
mItems = items.getWorkflowRuns();
notifyItemRangeChanged(0, mItems.size());
Expand All @@ -115,7 +115,7 @@ public void onResponse(@NonNull Call<WorkflowRunsResponse> call, @NonNull Respon
}

@Override
public void onFailure(@NonNull Call<WorkflowRunsResponse> call, @NonNull Throwable t) {
public void onFailure(@NonNull Call<WorkflowRuns> call, @NonNull Throwable t) {
if (BuildConfig.DEBUG) {Log.e(LOG_TAG, "onFailure: " + t.getMessage());}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.syslogic.github.BuildConfig;
import io.syslogic.github.R;
import io.syslogic.github.api.GithubClient;
import io.syslogic.github.api.model.WorkflowJobsResponse;
import io.syslogic.github.api.model.WorkflowJobs;
import io.syslogic.github.api.model.WorkflowStep;
import io.syslogic.github.api.room.Abstraction;
import io.syslogic.github.databinding.CardviewWorkflowStepBinding;
Expand Down Expand Up @@ -86,16 +86,16 @@ protected Context getContext() {

public void getWorkflowSteps(String accessToken, String username, String repositoryName, Long runId) {

Call<WorkflowJobsResponse> api = GithubClient.getWorkflowJobs(accessToken, username, repositoryName, runId);
Call<WorkflowJobs> api = GithubClient.getWorkflowJobs(accessToken, username, repositoryName, runId);
GithubClient.logUrl(LOG_TAG, api);

api.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<WorkflowJobsResponse> call, @NonNull Response<WorkflowJobsResponse> response) {
public void onResponse(@NonNull Call<WorkflowJobs> call, @NonNull Response<WorkflowJobs> response) {
if (response.code() == 200) { // OK
if (response.body() != null) {
WorkflowJobsResponse items = response.body();
if (items.getJobs() != null && items.getJobs().get(0).getSteps().size() > 0) {
WorkflowJobs items = response.body();
if (! items.getJobs().get(0).getSteps().isEmpty()) {
setItems(items.getJobs().get(0).getSteps());
notifyItemRangeChanged(0, mItems.size());
}
Expand All @@ -106,7 +106,7 @@ public void onResponse(@NonNull Call<WorkflowJobsResponse> call, @NonNull Respon
}

@Override
public void onFailure(@NonNull Call<WorkflowJobsResponse> call, @NonNull Throwable t) {
public void onFailure(@NonNull Call<WorkflowJobs> call, @NonNull Throwable t) {
if (BuildConfig.DEBUG) {Log.e(LOG_TAG, "onFailure: " + t.getMessage());}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.syslogic.github.activity.BaseActivity;
import io.syslogic.github.api.GithubClient;
import io.syslogic.github.api.model.Workflow;
import io.syslogic.github.api.model.WorkflowsResponse;
import io.syslogic.github.api.model.Workflows;
import io.syslogic.github.api.room.Abstraction;
import io.syslogic.github.databinding.CardviewWorkflowBinding;

Expand Down Expand Up @@ -98,15 +98,15 @@ public void setRepositoryId(Long value) {

public void getWorkflows(String accessToken, String username, String repositoryName) {

Call<WorkflowsResponse> api = GithubClient.getWorkflows(accessToken, username, repositoryName);
Call<Workflows> api = GithubClient.getWorkflows(accessToken, username, repositoryName);
GithubClient.logUrl(LOG_TAG, api);

api.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<WorkflowsResponse> call, @NonNull Response<WorkflowsResponse> response) {
public void onResponse(@NonNull Call<Workflows> call, @NonNull Response<Workflows> response) {
if (response.code() == 200) { // OK
if (response.body() != null) {
WorkflowsResponse items = response.body();
Workflows items = response.body();
if (items.getWorkflows() != null && items.getWorkflows().size() > 0) {
mItems = items.getWorkflows();
for (Workflow item : mItems) {item.setRepositoryId(repositoryId);}
Expand All @@ -119,7 +119,7 @@ public void onResponse(@NonNull Call<WorkflowsResponse> call, @NonNull Response<
}

@Override
public void onFailure(@NonNull Call<WorkflowsResponse> call, @NonNull Throwable t) {
public void onFailure(@NonNull Call<Workflows> call, @NonNull Throwable t) {
if (BuildConfig.DEBUG) {Log.e(LOG_TAG, "onFailure: " + t.getMessage());}
}
});
Expand Down

0 comments on commit c33601f

Please sign in to comment.