
"""
    This code was generated by Codezu.     

    Changes to this file may cause incorrect behavior and will be lost if
    the code is regenerated.
"""


from mozurestsdk.mozuclient import default as default_client
from mozurestsdk.mozuurl import MozuUrl;
from mozurestsdk.urllocation import UrlLocation
from mozurestsdk.apicontext import ApiContext;

class ProductSearchResult(object):
	def __init__(self, apiContext: ApiContext = None, mozuClient = None):
		self.client = mozuClient or default_client();
		if (apiContext is not None):
			self.client.withApiContext(apiContext);
		else:
			self.client.withApiContext(ApiContext());
	
	def getRandomAccessCursor(self,query = None, filter = None, pageSize = None, responseFields = None):
		""" Random access paging computes a set of , which can each then be provided to the  operation in the  resource or the  operation in the  resource. You can provide the computed groups in any order to the operations, and can therefore parallelize calls to retrieve products more quickly. To generate the set of , call this () operation, in which you can optionally provide query and/or filter parameters to limit the products matched by the cursor. After executing this operation, pass one of the returned  to the  parameter of the  or  operations.
		
		Args:
			| query (string) - Properties for the product location inventory provided for queries to locate products by their location.
			| filter (string) - A set of filter expressions representing the search parameters for a query. This parameter is optional. Refer to [Sorting and Filtering](../../../../Developer/api-guides/sorting-filtering.htm) for a list of supported filters.
			| pageSize (int) - When creating paged results from a query, this value indicates the zero-based offset in the complete result set where the returned entities begin. For example, with this parameter set to 25, to get the 51st through the 75th items, set startIndex to 50.
			| responseFields (string) - Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
		
		Returns:
			| ProductSearchRandomAccessCursor 
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/catalog/storefront/productsearch/randomAccessCursor/?query={query}&filter={filter}&pageSize={pageSize}&responseFields={responseFields}", "GET", UrlLocation.TenantPod, False);
		url.formatUrl("filter", filter);
		url.formatUrl("pageSize", pageSize);
		url.formatUrl("query", query);
		url.formatUrl("responseFields", responseFields);
		self.client.withResourceUrl(url).execute();
		return self.client.result();

	
		
	def search(self,query = None, filter = None, facetTemplate = None, facetTemplateSubset = None, facet = None, facetFieldRangeQuery = None, facetHierPrefix = None, facetHierValue = None, facetHierDepth = None, facetStartIndex = None, facetPageSize = None, facetSettings = None, facetValueFilter = None, sortBy = None, pageSize = None, startIndex = None, searchSettings = None, enableSearchTuningRules = False, searchTuningRuleContext = None, searchTuningRuleCode = None, facetTemplateExclude = None, facetPrefix = None, responseOptions = None, cursorMark = None, responseFields = None):
		""" Searches the categories displayed on the web storefront for products or product options that the shopper types in a search query.
		
		Args:
			| query (string) - Properties for the product location inventory provided for queries to locate products by their location.
			| filter (string) - A set of filter expressions representing the search parameters for a query. This parameter is optional. Refer to [Sorting and Filtering](../../../../Developer/api-guides/sorting-filtering.htm) for a list of supported filters.
			| facetTemplate (string) - The facet template to use on the storefront. A template displays all facets associated with the template on the web storefront product search. Currently, only category-level facet templates are available.
			| facetTemplateSubset (string) - Display a subset of the facets defined in the template specified in facetTemplate parameter.
			| facet (string) - Individually list the facet fields you want to display in a web storefront product search.
			| facetFieldRangeQuery (string) - Display a range facet not specified in a template in a web storefront product search by listing the facet field and the range to display.
			| facetHierPrefix (string) - If filtering using category facets in a hierarchy, the parent categories you want to skip in the storefront product search. This parameter is only available for category facets.
			| facetHierValue (string) - If filtering using category facets in a hierarchy, the category in the hierarchy to begin faceting on. This parameter is only available for category facets.
			| facetHierDepth (string) - If filtering using category facets in a hierarchy, the number of category hierarchy levels to return for the facet. This option is only available for category facets.
			| facetStartIndex (string) - When paging through multiple facets, the startIndex value for each facet.
			| facetPageSize (string) - The number of facet values to return for one or more facets.
			| facetSettings (string) - Settings reserved for future facet search functionality on a web storefront product search.
			| facetValueFilter (string) - The facet values to apply to the filter.
			| sortBy (string) - 
			| pageSize (int) - The number of results to display on each page when creating paged results from a query. The maximum value is 200.
			| startIndex (int) - 
			| searchSettings (string) - The settings to control product search and indexing behavior.
			| enableSearchTuningRules (bool) - Enables search tuning rules on your site.
			| searchTuningRuleContext (string) - The category ID that the search tuning rule applies to.
			| searchTuningRuleCode (string) - The unique identifier of the search tuning rule.
			| facetTemplateExclude (string) - A comma-separated list of the facets to exclude from the facetTemplate.
        
			| facetPrefix (string) - Use this parameter to filter facet values that are returned by an associated search result by a prefix.For example, to filter on colors that start with b, such as blue, black, or brown you can specify the following:
			| responseOptions (string) - Options you can specify for the response. This parameter is null by default.You can primarily use this parameter to return volume price band information in product details, which you can then display on category pages and search results depanding on your theme configuration. To return volume price band information, set this parameter to .
			| cursorMark (string) - In your first deep paged request, set this parameter to . Then, in all subsequent requests, set this parameter to the subsequent values of  that's returned in each response to continue paging through the results. Continue this pattern until  is null, which signifies the end of the paged results.
			| responseFields (string) - Use this field to include those fields which are not included by default.
		
		Returns:
			| ProductSearchResult 
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/catalog/storefront/productsearch/search/?query={query}&filter={filter}&facetTemplate={facetTemplate}&facetTemplateSubset={facetTemplateSubset}&facet={facet}&facetFieldRangeQuery={facetFieldRangeQuery}&facetHierPrefix={facetHierPrefix}&facetHierValue={facetHierValue}&facetHierDepth={facetHierDepth}&facetStartIndex={facetStartIndex}&facetPageSize={facetPageSize}&facetSettings={facetSettings}&facetValueFilter={facetValueFilter}&sortBy={sortBy}&pageSize={pageSize}&startIndex={startIndex}&searchSettings={searchSettings}&enableSearchTuningRules={enableSearchTuningRules}&searchTuningRuleContext={searchTuningRuleContext}&searchTuningRuleCode={searchTuningRuleCode}&facetTemplateExclude={facetTemplateExclude}&facetPrefix={facetPrefix}&responseOptions={responseOptions}&cursorMark={cursorMark}&responseFields={responseFields}", "GET", UrlLocation.TenantPod, False);
		url.formatUrl("cursorMark", cursorMark);
		url.formatUrl("enableSearchTuningRules", enableSearchTuningRules);
		url.formatUrl("facet", facet);
		url.formatUrl("facetFieldRangeQuery", facetFieldRangeQuery);
		url.formatUrl("facetHierDepth", facetHierDepth);
		url.formatUrl("facetHierPrefix", facetHierPrefix);
		url.formatUrl("facetHierValue", facetHierValue);
		url.formatUrl("facetPageSize", facetPageSize);
		url.formatUrl("facetPrefix", facetPrefix);
		url.formatUrl("facetSettings", facetSettings);
		url.formatUrl("facetStartIndex", facetStartIndex);
		url.formatUrl("facetTemplate", facetTemplate);
		url.formatUrl("facetTemplateExclude", facetTemplateExclude);
		url.formatUrl("facetTemplateSubset", facetTemplateSubset);
		url.formatUrl("facetValueFilter", facetValueFilter);
		url.formatUrl("filter", filter);
		url.formatUrl("pageSize", pageSize);
		url.formatUrl("query", query);
		url.formatUrl("responseFields", responseFields);
		url.formatUrl("responseOptions", responseOptions);
		url.formatUrl("searchSettings", searchSettings);
		url.formatUrl("searchTuningRuleCode", searchTuningRuleCode);
		url.formatUrl("searchTuningRuleContext", searchTuningRuleContext);
		url.formatUrl("sortBy", sortBy);
		url.formatUrl("startIndex", startIndex);
		self.client.withResourceUrl(url).execute();
		return self.client.result();

	
		
	def suggest(self,query = None, groups = None, pageSize = None, responseFields = None):
		""" Suggests possible search terms as the shopper enters search text.
		
		Args:
			| query (string) - Properties for the product location inventory provided for queries to locate products by their location.
			| groups (string) - Specifies the group that you want this operation to return in the response. This parameter accepts one or more values, separated by comma.For example, if you set this parameter to , then this operation returns a  object that contains suggestions for products that match the user entered characters in the search field.The valid values for this parameter are the following:
*  — Indicates that products should be matched against and returned in the response. The search  value is compared against product name and code. The response contains a  with a name of  and a collection of . Each collection item has a  of Product and contains a  equal to a complete product object.

*  — Indicates that categories should be matched against and returned in the response. The search  value is compared to category name.  The response contains a  with a name of  and a collection of . Each collection item has a  of Category and contains a  equal to a complete category object.

*  — Indicates that previously used search terms (keywords) should be matched against and returned in the response, sorted by frequency of use. Keep in mind that it is not currently possible to edit or remove search terms that may be considered undesirable via the  API. The response contains a  with a name of  and a collection of . Each collection item has a  of Term and contains a  equal to a string value of the matched search term.
The default value is ; however, the  Core Theme only integrates  and ignores the  group.This operation only returns data that is then made available to your theme. If you set this paramter to multiple values,  returns multiple  in the response. Depending on your requirements, you can then customize your theme to display the groups together or as separate lists in the displayed search suggestions.
			| pageSize (int) - The number of results to display on each page when creating paged results from a query. The maximum value is 200.
			| responseFields (string) - Use this field to include those fields which are not included by default.
		
		Returns:
			| SearchSuggestionResult 
		
		Raises:
			| ApiException
		
		"""

		url = MozuUrl("/api/commerce/catalog/storefront/productsearch/suggest?query={query}&groups={groups}&pageSize={pageSize}&responseFields={responseFields}", "GET", UrlLocation.TenantPod, False);
		url.formatUrl("groups", groups);
		url.formatUrl("pageSize", pageSize);
		url.formatUrl("query", query);
		url.formatUrl("responseFields", responseFields);
		self.client.withResourceUrl(url).execute();
		return self.client.result();

	
	
	