<commit_before>package de.pascaldierich.model;

/**
 * Created by <NAME> on Feb, 2017.
 */

import android.support.annotation.IntRange;
import android.support.annotation.NonNull;

import java.io.IOException;

import de.pascaldierich.model.network.ConstantsApi;
import de.pascaldierich.model.network.GoogleClient;
import de.pascaldierich.model.network.models.youtube.channel.YouTubeChannelsPage;
import de.pascaldierich.model.network.models.youtube.search.YouTubeSearchPage;
import de.pascaldierich.model.network.services.YouTubeService;

/**
 * Singleton Repository Class for interacting with 'model' module
 *      -> lazy instantiation
 */
public class Model {
    /*
        Instantiation
     */
    private static Model sInstance = null;

    private Model() {

    }

    public static Model getInstance() {
        if (sInstance == null) {
            sInstance = new Model();
        }
        return sInstance;
    }

    public static void finished() {
        sInstance = null;
    }

    /*
        Network Methods
     */

    /**
     * Model consists of 2 kinds of network methods.
     * <b>search</b> and <b>getId</b>.
     * on both methods you have to append the intern network name (@interface SupportedNetworks).
     *
     * search:
     *      returns ApiResponse for latest News as POJO
     *
     * getId:
     *      return ApiResponse as POJO whith one or more possibly Id's
     */

    /**
     * Call the YouTube Search Service
     * <p>
     * @param id, String: userId defined as key in 'Sites' table
     * @param time, String as RFC3339: publishedAfter Parameter in Api-Request
     * @param range, int: number of maxResults in Api-Response
     * @return POJO, YouTubeSearchPage
     * @throws IOException
     */
    public YouTubeSearchPage searchYouTube(@NonNull String id,
                                           @NonNull String time,
                                           @IntRange(from = 1, to = 50) int range) throws IOException {
        return GoogleClient.getService(YouTubeService.class)
                .getVideos(
                        ConstantsApi.YOUTUBE_API_KEY,
                        ConstantsApi.YOUTUBE_SEARCH_PART,
                        id,
                        time,
                        ConstantsApi.YOUTUBE_SEARCH_EVENT_TYPE,
                        range,
                        ConstantsApi.YOUTUBE_SEARCH_ORDER,
                        ConstantsApi.YOUTUBE_SEARCH_TYPE
                ).execute().body();
    }

    /**
     * Get possibly YouTube-intern-Id's for given name
     * <p>
     * @param name, String: (@WARNING: UserInput) Name of the requested Observable
     * @param range, int: number of maxResults in Api-Response
     * @return POJO, YouTubeChannelsPage
     * @throws IOException
     */
    public YouTubeChannelsPage getIdYouTube(@NonNull String name,
                                            @IntRange(from = 1, to = 50) int range) throws IOException {
        return GoogleClient.getService(YouTubeService.class)
                .getChannelId(
                        ConstantsApi.YOUTUBE_API_KEY,
                        ConstantsApi.YOUTUBE_CHANNEL_PART,
                        name,
                        range
                ).execute().body();
    }

}<commit_msg>doc: add TODO inside Model class<commit_after>package de.pascaldierich.model;

/**
 * Created by <NAME> on Feb, 2017.
 */

import android.support.annotation.IntRange;
import android.support.annotation.NonNull;

import java.io.IOException;

import de.pascaldierich.model.network.ConstantsApi;
import de.pascaldierich.model.network.GoogleClient;
import de.pascaldierich.model.network.models.youtube.channel.YouTubeChannelsPage;
import de.pascaldierich.model.network.models.youtube.search.YouTubeSearchPage;
import de.pascaldierich.model.network.services.YouTubeService;

/**
 * Singleton Repository Class for interacting with 'model' module
 *      -> lazy instantiation
 */
public class Model {
    /*
        Instantiation
     */
    private static Model sInstance = null;

    private Model() {

    }

    public static Model getInstance() {
        if (sInstance == null) {
            sInstance = new Model();
        }
        return sInstance;
    }

    public static void finished() {
        sInstance = null;
    }

    /*
        Network Methods
     */

    /**
     * Model consists of 2 kinds of network methods.
     * <b>search</b> and <b>getId</b>.
     * on both methods you have to append the intern network name (@interface SupportedNetworks).
     *
     * search:
     *      returns ApiResponse for latest News as POJO
     *
     * getId:
     *      return ApiResponse as POJO whith one or more possibly Id's
     */

    /**
     * Call the YouTube Search Service
     * <p>
     * @param id, String: userId defined as key in 'Sites' table
     * @param time, String as RFC3339: publishedAfter Parameter in Api-Request
     * @param range, int: number of maxResults in Api-Response
     * @return POJO, YouTubeSearchPage
     * @throws IOException
     */
    public YouTubeSearchPage searchYouTube(@NonNull String id,
                                           @NonNull String time,
                                           @IntRange(from = 1, to = 50) int range) throws IOException {

        // TODO: 21.02.17 change return POJO.
        // 1. Problem Dependency goes inside domain-layer
        // 2. POJO is too big and most information is not usable.
        //   --> define model class inside domain-layer
        //      --> return model class from domain-layer

        return GoogleClient.getService(YouTubeService.class)
                .getVideos(
                        ConstantsApi.YOUTUBE_API_KEY,
                        ConstantsApi.YOUTUBE_SEARCH_PART,
                        id,
                        time,
                        ConstantsApi.YOUTUBE_SEARCH_EVENT_TYPE,
                        range,
                        ConstantsApi.YOUTUBE_SEARCH_ORDER,
                        ConstantsApi.YOUTUBE_SEARCH_TYPE
                ).execute().body();
    }

    /**
     * Get possibly YouTube-intern-Id's for given name
     * <p>
     * @param name, String: (@WARNING: UserInput) Name of the requested Observable
     * @param range, int: number of maxResults in Api-Response
     * @return POJO, YouTubeChannelsPage
     * @throws IOException
     */
    public YouTubeChannelsPage getIdYouTube(@NonNull String name,
                                            @IntRange(from = 1, to = 50) int range) throws IOException {

        // TODO: 21.02.17 change return POJO.
        // 1. Problem Dependency goes inside domain-layer
        // 2. POJO is too big and most information is not usable.
        //   --> define model class inside domain-layer
        //      --> return model class from domain-layer

        return GoogleClient.getService(YouTubeService.class)
                .getChannelId(
                        ConstantsApi.YOUTUBE_API_KEY,
                        ConstantsApi.YOUTUBE_CHANNEL_PART,
                        name,
                        range
                ).execute().body();
    }

}
{'fraction_non_alphanumeric': 0.08311216650370164, 'fraction_numerical': 0.0064254784187735715, 'mean_word_length': 1.8166797797010228, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1366570', 'n_tokens_mistral': 1951, 'n_tokens_neox': 1851, 'n_words': 519}