<commit_before>package es.craftsmanship.toledo.katangapp.interactors;

import java.io.IOException;

import es.craftsmanship.toledo.katangapp.models.Route;
import es.craftsmanship.toledo.katangapp.services.BusStopsService;
import es.craftsmanship.toledo.katangapp.utils.AndroidBus;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;

/**
 * @author <NAME>
 */
public class RoutesInteractor implements Runnable{
    private static final String BACKEND_ENDPOINT = "https://secret-depths-4660.herokuapp.com";
    private final String route;

    public RoutesInteractor(String route) {
        this.route = route;
    }

    @Override
    public void run() {
        try {
            Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BACKEND_ENDPOINT)
                .addConverterFactory(JacksonConverterFactory.create())
                .build();

            BusStopsService service = retrofit.create(BusStopsService.class);

            Response<Route> response = null;

            response = service.getRouteId(route).execute();

            Object event = new Error(response.message());

            if (response.isSuccessful()) {
                event = response.body();
            }

            AndroidBus.getInstance().post(event);
        }
        catch (IOException e) {
            AndroidBus.getInstance().post(e);
        }<commit_msg>[#14] Apply interactor pattern to RoutesInteractor<commit_after>package es.craftsmanship.toledo.katangapp.interactors;

import es.craftsmanship.toledo.katangapp.models.Route;
import es.craftsmanship.toledo.katangapp.services.BusStopsService;
import es.craftsmanship.toledo.katangapp.services.KatangaResponseWrapper;

import java.io.IOException;

import retrofit2.Response;

/**
 * @author <NAME>
 * @author <NAME>
 */
public class RoutesInteractor extends BaseKatangaInteractor {

    private final String route;

    public RoutesInteractor(String route) {
        this.route = route;
    }

    @Override
    protected KatangaResponseWrapper<Response<Route>> getResponse(BusStopsService busStopsService)
        throws IOException {

        Response<Route> response = busStopsService.getRouteId(route).execute();

        return new KatangaResponseWrapper<>(response);
{'fraction_non_alphanumeric': 0.09687228496959166, 'fraction_numerical': 0.004344048653344918, 'mean_word_length': 3.272727272727273, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4559375', 'n_tokens_mistral': 670, 'n_tokens_neox': 639, 'n_words': 119}