/*
 * Copyright 2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.iod.client.search;

import com.hp.autonomy.iod.client.error.IodErrorException;
import retrofit.http.GET;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.Part;
import retrofit.http.PartMap;
import retrofit.http.Query;
import retrofit.http.QueryMap;
import retrofit.mime.TypedInput;

import java.util.List;
import java.util.Map;

/**
 * Interface representing the QueryTextIndex API.
 */
public interface QueryTextIndexService {

    String URL = "/sync/querytextindex/v1";

    /**
     * Query IDOL OnDemand for documents matching query text
     * @param apiKey The API key to use to authenticate the request
     * @param text The query text
     * @param indexes List of indexes to query for documents. Set this to null if you wish to query all the indexes
     * @param params Additional parameters to be sent as part of the request
     * @return A list of documents that match the query text
     */
    @GET(URL)
    Documents queryTextIndexWithText(@Query("apiKey") String apiKey, @Query("text") String text, @Query("indexes") List<String> indexes, @QueryMap Map<String, Object> params) throws IodErrorException;

    /**
     * Query IDOL OnDemand for documents using query text from an object store object
     * @param apiKey The API key to use to authenticate the request
     * @param reference An IDOL OnDemand reference obtained from either the Expand Container or Store Object API. The contents of the object will be used as the query text
     * @param indexes List of indexes to query for documents. Set this to null if you wish to query all the indexes
     * @param params Additional parameters to be sent as part of the request
     * @return A list of documents that match the query text
     */
    @GET(URL)
    Documents queryTextIndexWithReference(@Query("apiKey") String apiKey, @Query("reference") String reference, @Query("indexes") List<String> indexes, @QueryMap Map<String, Object> params) throws IodErrorException;

    /**
     * Query IDOL OnDemand for documents using query text from a url
     * @param apiKey The API key to use to authenticate the request
     * @param url A publicly accessible HTTP URL from which the query text can be retrieved
     * @param indexes List of indexes to query for documents. Set this to null if you wish to query all the indexes
     * @param params Additional parameters to be sent as part of the request
     * @return A list of documents that match the query text
     */
    @GET(URL)
    Documents queryTextIndexWithUrl(@Query("apiKey") String apiKey, @Query("url") String url, @Query("indexes") List<String> indexes, @QueryMap Map<String, Object> params) throws IodErrorException;

    /**
     * Query IDOL OnDemand for documents using query text in a file
     * @param apiKey The API key to use to authenticate the request
     * @param file A file containing the query text
     * @param indexes List of indexes to query for documents. Set this to null if you wish to query all the indexes
     * @param params Additional parameters to be sent as part of the request
     * @return A list of documents that match the query text
     */
    @Multipart
    @POST(URL)
    Documents queryTextIndexWithFile(@Part("apiKey") String apiKey, @Part("file") TypedInput file, @Part("indexes") List<String> indexes, @PartMap Map<String, Object> params) throws IodErrorException;

}

@@ -1190,16 +1190,29 @@
 ithText(
+%0A            
 @Query(%22
@@ -1226,32 +1226,44 @@
 ) String apiKey,
+%0A           
  @Query(%22text%22) 
@@ -1274,16 +1274,28 @@
 ng text,
+%0A           
  @Query(
@@ -1318,32 +1318,44 @@
 String%3E indexes,
+%0A           
  @QueryMap Map%3CS
@@ -1367,32 +1367,37 @@
 , Object%3E params
+%0A    
 ) throws IodErro
@@ -1684,16 +1684,40 @@
 ect API.
+%0A     *                 
  The con
@@ -2085,16 +2085,29 @@
 ference(
+%0A            
 @Query(%22
@@ -2121,32 +2121,44 @@
 ) String apiKey,
+%0A           
  @Query(%22referen
@@ -2179,16 +2179,28 @@
 ference,
+%0A           
  @Query(
@@ -2223,32 +2223,44 @@
 String%3E indexes,
+%0A           
  @QueryMap Map%3CS
@@ -2272,32 +2272,37 @@
 , Object%3E params
+%0A    
 ) throws IodErro
@@ -2863,16 +2863,29 @@
 WithUrl(
+%0A            
 @Query(%22
@@ -2907,16 +2907,28 @@
  apiKey,
+%0A           
  @Query(
@@ -2945,16 +2945,28 @@
 ing url,
+%0A           
  @Query(
@@ -2997,16 +2997,28 @@
 indexes,
+%0A           
  @QueryM
@@ -3038,32 +3038,37 @@
 , Object%3E params
+%0A    
 ) throws IodErro
@@ -3605,16 +3605,29 @@
 ithFile(
+%0A            
 @Part(%22a
@@ -3648,16 +3648,28 @@
  apiKey,
+%0A           
  @Part(%22
@@ -3691,16 +3691,28 @@
 ut file,
+%0A           
  @Part(%22
@@ -3742,16 +3742,28 @@
 indexes,
+%0A           
  @PartMa
@@ -3790,16 +3790,21 @@
 %3E params
+%0A    
 ) throws

Improve whitespace to make the code easier to read.