// Path: src/main/java/com/mb3364/twitch/api/handlers/ChannelsResponseHandler.java
// public interface ChannelsResponseHandler extends BaseFailureHandler {
//     void onSuccess(int total, List<Channel> channels);
// }
// 
// Path: src/main/java/com/mb3364/twitch/api/handlers/GamesResponseHandler.java
// public interface GamesResponseHandler extends BaseFailureHandler {
//     void onSuccess(int total, List<Game> streams);
// }
// 
// Path: src/main/java/com/mb3364/twitch/api/handlers/StreamsResponseHandler.java
// public interface StreamsResponseHandler extends BaseFailureHandler {
//     void onSuccess(int total, List<Stream> streams);
// }
// 
// Path: src/main/java/com/mb3364/twitch/api/models/SearchResultContainer.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SearchResultContainer {
// 
//     @JsonProperty("_total")
//     private int total;
//     private List<Channel> channels;
//     private List<Stream> streams;
//     private List<Game> games;
// 
//     @Override
//     public String toString() {
//         return "SearchResultContainer{" +
//                 "total=" + total +
//                 ", channels=" + channels +
//                 ", streams=" + streams +
//                 ", games=" + games +
//                 '}';
//     }
// 
//     public int getTotal() {
//         return total;
//     }
// 
//     public void setTotal(int total) {
//         this.total = total;
//     }
// 
//     public List<Channel> getChannels() {
//         return channels;
//     }
// 
//     public void setChannels(List<Channel> channels) {
//         this.channels = channels;
//     }
// 
//     public List<Stream> getStreams() {
//         return streams;
//     }
// 
//     public void setStreams(List<Stream> streams) {
//         this.streams = streams;
//     }
// 
//     public List<Game> getGames() {
//         return games;
//     }
// 
//     public void setGames(List<Game> games) {
//         this.games = games;
//     }
// }


import com.mb3364.http.RequestParams;
import com.mb3364.twitch.api.handlers.ChannelsResponseHandler;
import com.mb3364.twitch.api.handlers.GamesResponseHandler;
import com.mb3364.twitch.api.handlers.StreamsResponseHandler;
import com.mb3364.twitch.api.models.SearchResultContainer;
import java.io.IOException;
import java.util.List;
import java.util.Map;
     * @param params  the optional request parameters:
     *                <ul>
     *                <li><code>live</code>:  If true, only returns games that are live on at least one channel.</li>
     *                </ul>
     * @param handler the response handler
     */
    public void games(final String query, final RequestParams params, final GamesResponseHandler handler) {
        String url = String.format("%s/search/games", getBaseUrl());
        params.put("q", query);
        params.put("type", "suggest");

        http.get(url, params, new TwitchHttpResponseHandler(handler) {
            @Override
            public void onSuccess(int statusCode, Map<String, List<String>> headers, String content) {
                try {
                    SearchResultContainer value = objectMapper.readValue(content, SearchResultContainer.class);
                    handler.onSuccess(value.getGames().size(), value.getGames());
                } catch (IOException e) {
                    handler.onFailure(e);
                }
            }
        });
    }

    /**
     * Returns a list of game objects matching the search query.
     *
     * @param query   the search query
     * @param handler the response handler
     */
// Path: src/main/java/com/mb3364/twitch/api/handlers/ChannelsResponseHandler.java
// public interface ChannelsResponseHandler extends BaseFailureHandler {
//     void onSuccess(int total, List<Channel> channels);
// }
// 
// Path: src/main/java/com/mb3364/twitch/api/handlers/GamesResponseHandler.java
// public interface GamesResponseHandler extends BaseFailureHandler {
//     void onSuccess(int total, List<Game> streams);
// }
// 
// Path: src/main/java/com/mb3364/twitch/api/handlers/StreamsResponseHandler.java
// public interface StreamsResponseHandler extends BaseFailureHandler {
//     void onSuccess(int total, List<Stream> streams);
// }
// 
// Path: src/main/java/com/mb3364/twitch/api/models/SearchResultContainer.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class SearchResultContainer {
// 
//     @JsonProperty("_total")
//     private int total;
//     private List<Channel> channels;
//     private List<Stream> streams;
//     private List<Game> games;
// 
//     @Override
//     public String toString() {
//         return "SearchResultContainer{" +
//                 "total=" + total +
//                 ", channels=" + channels +
//                 ", streams=" + streams +
//                 ", games=" + games +
//                 '}';
//     }
// 
//     public int getTotal() {
//         return total;
//     }
// 
//     public void setTotal(int total) {
//         this.total = total;
//     }
// 
//     public List<Channel> getChannels() {
//         return channels;
//     }
// 
//     public void setChannels(List<Channel> channels) {
//         this.channels = channels;
//     }
// 
//     public List<Stream> getStreams() {
//         return streams;
//     }
// 
//     public void setStreams(List<Stream> streams) {
//         this.streams = streams;
//     }
// 
//     public List<Game> getGames() {
//         return games;
//     }
// 
//     public void setGames(List<Game> games) {
//         this.games = games;
//     }
// }


// Path: src/main/java/com/mb3364/twitch/api/resources/SearchResource.java
import com.mb3364.http.RequestParams;
import com.mb3364.twitch.api.handlers.ChannelsResponseHandler;
import com.mb3364.twitch.api.handlers.GamesResponseHandler;
import com.mb3364.twitch.api.handlers.StreamsResponseHandler;
import com.mb3364.twitch.api.models.SearchResultContainer;
import java.io.IOException;
import java.util.List;
import java.util.Map;

     * @param params  the optional request parameters:
     *                <ul>
     *                <li><code>live</code>:  If true, only returns games that are live on at least one channel.</li>
     *                </ul>
     * @param handler the response handler
     */
    public void games(final String query, final RequestParams params, final GamesResponseHandler handler) {
        String url = String.format("%s/search/games", getBaseUrl());
        params.put("q", query);
        params.put("type", "suggest");

        http.get(url, params, new TwitchHttpResponseHandler(handler) {
            @Override
            public void onSuccess(int statusCode, Map<String, List<String>> headers, String content) {
                try {
                    SearchResultContainer value = objectMapper.readValue(content, SearchResultContainer.class);
                    handler.onSuccess(value.getGames().size(), value.getGames());
                } catch (IOException e) {
                    handler.onFailure(e);
                }
            }
        });
    }

    /**
     * Returns a list of game objects matching the search query.
     *
     * @param query   the search query
     * @param handler the response handler
     */
    public void games(final String query, final GamesResponseHandler handler) {