Package com.zappos.model

Examples of com.zappos.model.JsonFacetObj$Values


      filter = "{\"priceFacet\":[\"$200.00 and Under\"]}";
    } else{
      filter = "{\"priceFacet\":[\"$200.00 and Over\"]}";
    }

    JsonFacetObj facetobj = new JsonFacetObj();

    try{
      //API call that returns a Json object that consists of counts of the products of a particular price.
      facetobj = mapper.readValue(restTemplate.getForObject("http://api.zappos.com/Search?limit=100&excludes=[{facetexcludeterms}]&includes=[\"facets\"]&facets=[\"price\"]&filters={filter}&facetSort=name&key={apikey}", String.class, facetexcludeterms, filter, apikey), JsonFacetObj.class);
    }
    catch(HttpClientErrorException e){
      ModelAndView mv = new ModelAndView("index");
      mv.addObject("error", "Oops! Something went wrong. Please try again!");
      return mv;
    }

    //Zappos API call ends here

    System.out.println(facetobj.getStatusCode());

    //Displays error to the user if the call fails due to some reason.
    if(!facetobj.getStatusCode().equals("200")){
      ModelAndView mv = new ModelAndView("index");
      mv.addObject("error", facetobj.getError());
      return mv;
    }

    ArrayList<Values> facetvalues = facetobj.getFacets().get(0).getValues(); //the objects containing the counts of products of a particular price are stored in an array list
    HashMap<Double, Integer> facethash = new HashMap<Double, Integer>();
    ArrayList<Double> searchlist = new ArrayList<Double>();
    Iterator<Values> it = facetvalues.iterator();

    //the objects copied to a hash map with cost as key and count as value. The costs are also copied into an array list which will be used later
View Full Code Here

TOP

Related Classes of com.zappos.model.JsonFacetObj$Values

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.