Надеюсь понимаю, что вы хотите
public void getUser(String api_token) {
CheckInternetConnection connectionCheck = new CheckInternetConnection(getContext());
if (connectionCheck.haveNetworkConnection()) {
ApiInterface apiService =
ApiClient.getClient().create(ApiInterface.class);
Call<UserResponse> call = apiService.getUserByToken(api_token);;
call.enqueue(new Callback<UserResponse>() {
@Override
public void onResponse(Call<UserResponse > call, Response<UserResponse > response) {
if (response.isSuccessful()) {
userName.setText(response.body().getName());
}
}
@Override
public void onFailure(Call<UserResponse > call, Throwable t) {
Log.d("sucess", String.valueOf(t));
}
});
} else {
Toasty.info(getContext(), (getResources().getString(R.string.check_connection)), Toast.LENGTH_LONG).show();
}
}
и интерфейс класса
public interface ApiInterface {
@GET("nameofapi")
Call<UserResponse> getUserByToken(@Header("Access-Token") String access_token);
}