/**
 * Create type search
 * @param {Object} search Parameters used in the search for products
 * @return {Object} The search of API
 */
export const Search = function() {
  // Query will live here
  this.query = { };
};

/**
 * Will search products by name
 * @param {String} name Search by product name
 * @return {Object} The name
 */
Search.prototype.byName = function(name) {
  // Set to query the name search
  this.query.name = name;

  //
  return this;
}

/**
 * Will search pages
 *@param {}
 *@return {Object}
 */
Search.prototype.page = function(number) {
  // Set to query the name search
  this.query.page = number;

  //
  return this;
}

/**
 * Will search for Filters
 * @param {Array[Object]} and Filters that relates 'and'
 * @return {Object} The API formatted filters
 */
Search.prototype.and = function(filters) {
  // Set to query the name search
  this.query.and = filters;

  //
  return this;
}

/**
 * Create Search
 *@param
 *@return
 */
export const createSearch = function() {
  // Initial state
  return new Search();
}

//
// getProdutcs(search)
// { } => Inicial
// { name } => searchByName
// { name, order } => setOrder
// { name, order, page } => setPage
//
// // Create Rules
// let rules = [
//   createFilter('taxons', 'permalink', ['merceria/peixes', 'marcas/...'], 'fixed')
// ]
// // name: taxons(Categorias) - filter(Filtros) - price(Preço)
// // type: fixed(Fixo) - range(Intervalo - só para preço)
//
// // Create search
// let busca = createSearch()
// busca.byName('manteiga')
//      .orderBy('name', 'asc')
//      .and(rules)
//      .or(fltrs)
//      .page(2)

@@ -92,46 +92,8 @@
 cts%0A
- * @return %7BObject%7D The search of API%0A
  */%0A
@@ -276,24 +276,30 @@
 rn %7B
-Object%7D The name
+Search%7D Current Search
 %0A */
@@ -453,24 +453,25 @@
 pages%0A *
+ 
 @param %7B
 %7D%0A *@ret
@@ -462,20 +462,67 @@
 @param %7B
-%7D
+Number%7D page Page number of the product listing
 %0A *
+ 
 @return 
@@ -522,23 +522,38 @@
 return %7B
-Object%7D
+Search%7D Current Search
 %0A */%0ASea
@@ -582,22 +582,268 @@
 unction(
-number
+page) %7B%0A  // Set to query the number search%0A  this.query.page = page;%0A%0A  //%0A  return this;%0A%7D%0A%0A/**%0A * Will search perPage%0A * @param %7BNumber%7D Quantity of products per page%0A * @return %7BSearch%7D Current Search%0A */%0ASearch.prototype.perPage = function(perPage
 ) %7B%0A  //
@@ -853,35 +853,37 @@
 t to query the n
-ame
+umber
  search%0A  this.q
@@ -891,21 +891,26 @@
 ery.
+per_
 page = 
-number
+perPage
 ;%0A%0A 
@@ -1035,41 +1035,30 @@
 rn %7B
-Object%7D The API formatted filters
+Search%7D Current Search
 %0A */
@@ -1115,36 +1115,39 @@
 et to query the 
-name
+filters
  search%0A  this.q
@@ -1217,24 +1217,40 @@
 h%0A *
-@param%0A *@return
+ @return %7BSearch%7D Current Search
 %0A */

CHange the Search in Products