code: func ReadJSONResponse(resp *http.Response, v interface{}) error {
  	defer resp.Body.Close()
  
  	switch {
  	case resp.StatusCode < 200, resp.StatusCode > 299:
  		return NewResponseErrorf(resp, "Invalid status code: %d", resp.StatusCode)
  	case v == nil:
  		return nil
  	default:
  		if err := json.NewDecoder(resp.Body).Decode(v); err != nil {
  			return NewResponseError(resp, err.Error())
  		}
  	}
  
  	return nil
  }
docs: // ReadJSONResponse attempts to marshal the response body into v
  // if and only if the response StatusCode is in the 200 range.
  // Otherwise, an error is thrown.
  // It assumes the response body is in JSON format.