/// <summary>
        /// Gets a list of envelopes in folders matching the specified criteria. Retrieves a list of envelopes that match the criteria specified in the query.\n\nIf the user ID of the user making the call is the same as the user ID for any returned recipient, then the userId property is added to the returned information for those recipients.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="searchFolderId">Specifies the envelope group that is searched by the request. These are logical groupings, not actual folder names. Valid values are: drafts, awaiting_my_signature, completed, out_for_signature.</param> <param name="options">Options for modifying the behavior of the function.</param>
		/// <returns>7Task of FolderItemResponse</returns>
        public async System.Threading.Tasks.Task<FolderItemResponse> SearchAsync (string accountId, string searchFolderId, FoldersApi.SearchOptions options = null)
        {
             ApiResponse<FolderItemResponse> response = await SearchAsyncWithHttpInfo(accountId, searchFolderId, options);
             return response.Data;

        }
        /// <summary>
        /// Gets a list of envelopes in folders matching the specified criteria. Retrieves a list of envelopes that match the criteria specified in the query.\n\nIf the user ID of the user making the call is the same as the user ID for any returned recipient, then the userId property is added to the returned information for those recipients.
        /// </summary>
	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="searchFolderId">Specifies the envelope group that is searched by the request. These are logical groupings, not actual folder names. Valid values are: drafts, awaiting_my_signature, completed, out_for_signature.</param> <param name="options">Options for modifying the behavior of the function.</param>
		/// <returns>8Task of ApiResponse (FolderItemResponse)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<FolderItemResponse>> SearchAsyncWithHttpInfo (string accountId, string searchFolderId, FoldersApi.SearchOptions options = null)
        {
            // verify the required parameter 'accountId' is set
            if (accountId == null) throw new ApiException(400, "Missing required parameter 'accountId' when calling Search");
            // verify the required parameter 'searchFolderId' is set
            if (searchFolderId == null) throw new ApiException(400, "Missing required parameter 'searchFolderId' when calling Search");
            
    
            var path_ = "/v2/accounts/{accountId}/search_folders/{searchFolderId}";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                "application/json"
            };
            String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
            if (http_header_accept != null)
                headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (accountId != null) pathParams.Add("accountId", Configuration.ApiClient.ParameterToString(accountId)); // path parameter
            if (searchFolderId != null) pathParams.Add("searchFolderId", Configuration.ApiClient.ParameterToString(searchFolderId)); // path parameter
            

						
			if (options != null)
			{
				if (options.includeRecipients != null) queryParams.Add("include_recipients", Configuration.ApiClient.ParameterToString(options.includeRecipients)); // query parameter
				if (options.all != null) queryParams.Add("all", Configuration.ApiClient.ParameterToString(options.all)); // query parameter
				if (options.order != null) queryParams.Add("order", Configuration.ApiClient.ParameterToString(options.order)); // query parameter
				if (options.count != null) queryParams.Add("count", Configuration.ApiClient.ParameterToString(options.count)); // query parameter
				if (options.startPosition != null) queryParams.Add("start_position", Configuration.ApiClient.ParameterToString(options.startPosition)); // query parameter
				if (options.fromDate != null) queryParams.Add("from_date", Configuration.ApiClient.ParameterToString(options.fromDate)); // query parameter
				if (options.toDate != null) queryParams.Add("to_date", Configuration.ApiClient.ParameterToString(options.toDate)); // query parameter
				if (options.orderBy != null) queryParams.Add("order_by", Configuration.ApiClient.ParameterToString(options.orderBy)); // query parameter
				
			}
			

            
            
            

            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling Search: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling Search: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<FolderItemResponse>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (FolderItemResponse) Configuration.ApiClient.Deserialize(response, typeof(FolderItemResponse)));
            
        }
        /// <summary>
        /// Gets a list of envelopes in folders matching the specified criteria. Retrieves a list of envelopes that match the criteria specified in the query.\n\nIf the user ID of the user making the call is the same as the user ID for any returned recipient, then the userId property is added to the returned information for those recipients.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="searchFolderId">Specifies the envelope group that is searched by the request. These are logical groupings, not actual folder names. Valid values are: drafts, awaiting_my_signature, completed, out_for_signature.</param> <param name="options">Options for modifying the behavior of the function.</param>
		/// <returns>5FolderItemResponse</returns>
        public FolderItemResponse Search (string accountId, string searchFolderId, FoldersApi.SearchOptions options = null)
        {
             ApiResponse<FolderItemResponse> response = SearchWithHttpInfo(accountId, searchFolderId, options);
             return response.Data;
        }