@RequestMapping(
      method = RequestMethod.GET,
      value = "{refsetId}/{memberId}/allStates",
      produces = "application/json",
      consumes = "application/json")
  @ApiOperation(
      value = "Get all previous states of a member",
      notes =
          "This api call retrieves all previous published state of a member for given member uuid provided in api path")
  @PreAuthorize("hasRole('ROLE_USER')")
  public ResponseEntity<Result<Map<String, Object>>> getMemberStateHistory(
      @PathVariable String memberId, @PathVariable String refsetId) throws Exception {

    logger.debug("geting member's all previous state history for member id {}", memberId);

    Result<Map<String, Object>> r = getResult();

    ChangeRecord<Member> history = service.getMemberStateHistory(memberId, refsetId);

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("history", history);
    r.getMeta()
        .add(
            linkTo(
                    methodOn(ChangeHistoryController.class)
                        .getMemberStateHistory(memberId, refsetId))
                .withRel("All previous Member states"));

    r.setData(data);

    r.getMeta().setMessage(SUCCESS);
    r.getMeta().setStatus(HttpStatus.OK);

    return new ResponseEntity<Result<Map<String, Object>>>(r, HttpStatus.OK);
  }
  @RequestMapping(
      method = RequestMethod.GET,
      value = "/{refsetId}/member/{memberId}/history",
      produces = "application/json",
      consumes = "application/json")
  @ApiOperation(
      value = "Get a member history ",
      notes =
          "This api call is to get last 10 days of history of given members under given refset and for given range. "
              + "It is sorted by latest first."
              + "If user of this api want to retrieve specific dates history, they should provide from date and to date"
              + "in the format of yyyy-mm-dd")
  @PreAuthorize("hasRole('ROLE_USER')")
  public ResponseEntity<Result<Map<String, Object>>> getMemberHistory(
      @PathVariable String refsetId,
      @PathVariable String memberId,
      @RequestParam(value = "fromDate", required = false) String fromDate,
      @RequestParam(value = "toDate", required = false) String toDate,
      @RequestParam(value = "from", defaultValue = "0", required = false) int from,
      @RequestParam(value = "to", defaultValue = "10", required = false) int to)
      throws Exception {

    logger.debug("getting member history {}", refsetId, memberId);

    Result<Map<String, Object>> r = getResult();

    ChangeRecord<Member> history =
        service.getMemberHistory(
            refsetId, memberId, getFromDate(fromDate, 10), getToDate(toDate), from, to);

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("history", history);
    r.getMeta()
        .add(
            linkTo(
                    methodOn(ChangeHistoryController.class)
                        .getMemberHistory(refsetId, memberId, fromDate, toDate, from, to))
                .withRel("Member History"));

    r.setData(data);

    r.getMeta().setMessage(SUCCESS);
    r.getMeta().setStatus(HttpStatus.OK);

    return new ResponseEntity<Result<Map<String, Object>>>(r, HttpStatus.OK);
  }