CIOBrowseQueryBuilder

public class CIOBrowseQueryBuilder

Request builder for creating an browse query.

  • Create a Browse request query builder

    Declaration

    Swift

    public init(filterName: String, filterValue: String)

    Parameters

    filterName

    The primary filter name that the user browsed for

    filterValue

    The primary filter value that the user browsed for

  • Add additional filters

    Declaration

    Swift

    public func setFilters(_ filters: CIOQueryFilters) -> CIOBrowseQueryBuilder
  • Add a sort option

    Declaration

    Swift

    public func setSortOption(_ sortOption: CIOSortOption) -> CIOBrowseQueryBuilder
  • Add a page number

    Declaration

    Swift

    public func setPage(_ page: Int) -> CIOBrowseQueryBuilder
  • Add the number of results to return per page

    Declaration

    Swift

    public func setPerPage(_ perPage: Int) -> CIOBrowseQueryBuilder
  • Add the number of results to return per page

    Declaration

    Swift

    public func setSection(_ section: String) -> CIOBrowseQueryBuilder
  • Add a list of hidden metadata fields to return

    Declaration

    Swift

    public func setHiddenFields(_ hiddenFields: [String]) -> CIOBrowseQueryBuilder
  • Add a list of hidden facets to return

    Declaration

    Swift

    public func setHiddenFacets(_ hiddenFacets: [String]) -> CIOBrowseQueryBuilder
  • Add a variations map to return per variation

    Declaration

    Swift

    public func setVariationsMap(_ variationsMap: CIOQueryVariationsMap) -> CIOBrowseQueryBuilder
  • Add a groups sort option

    Declaration

    Swift

    public func setGroupsSortOption(_ groupsSortOption: CIOGroupsSortOption) -> CIOBrowseQueryBuilder
  • Add the pre filter expression

    Declaration

    Swift

    public func setPreFilterExpression(_ preFilterExpression: String) -> CIOBrowseQueryBuilder
  • Build the request object set all of the provided data

    Usage Example:

    let facetFilters = [(key: "Nutrition", value: "Organic"),
                        (key: "Nutrition", value: "Natural"),
                        (key: "Brand", value: "Kraft Foods")]
    
    let preFilterExpression = "{\"or\":[{\"and\":[{\"name\":\"group_id\",\"value\":\"electronics-group-id\"},{\"name\":\"Price\",\"range\":[\"-inf\",200.0]}]},{\"and\":[{\"name\":\"Type\",\"value\":\"Laptop\"},{\"not\":{\"name\":\"Price\",\"range\":[800.0,\"inf\"]}}]}]}"
    
    let query = CIOBrowseQueryBuilder(filterName: "potato", filterValue: "russet")
       .setFilters(CIOQueryFilters(groupFilter: nil, facetFilters: facetFilters))
       .setPage(2)
       .setPerPage(40)
       .setSection("Products")
       .setHiddenFields(["hidden_price_field", "color_swatches"])
       .setHiddenFacets(["hidden_facet"])
       .setPreFilterExpression(preFilterExpression)
       .build()
    
    constructor.browse(forQuery: query, completionHandler: { ... })
    

    Declaration

    Swift

    public func build() -> CIOBrowseQuery