anchor.diff:  (in-package :potato-client)
   
   (define-condition potato-client-error (error)
  +  ())
  +
  +(define-condition request-error (potato-client-error)
     ((code :type integer
            :initarg :code
  -         :reader potato-client-error/code)
  +         :reader request-error/code)
      (reason :type string
              :initarg :reason
  -           :reader potato-client-error/reason)))
  +           :reader request-error/reason))
  +  (:report (lambda (condition out)
  +             (format out "Error from server. code: ~a, reason: ~a"
  +                     (request-error/code condition)
  +                     (request-error/reason condition)))))
   
   (defclass connection ()
     ((api-key    :type string
  
positive.code:       (:group-type . ,(st-json:getjso "group_type" res))
        (:domain . ,(st-json:getjso "domain" res))
        (:private-user . ,(if (eq private-user :null) nil private-user)))))
  
negative.code:             (if (eql (aref prefix (1- (length prefix))) #\/) "" "/")
              suffix)))
  
  (defun authenticated-request (conn suffix &key (method :get) content)
    (multiple-value-bind (content code headers uri stream should-close reason)
        (drakma:http-request (make-potato-url conn suffix)
                             :additional-headers `(("API-Token" . ,(connection/api-key conn)))
                             :want-stream t
                             :method method
                             :content content
                             :force-binary t)
      (declare (ignore content headers uri))
      (unwind-protect
           (progn
             (unless (= code 200)
               (error 'request-error :code code :reason reason))
             (st-json:read-json (flexi-streams:make-flexi-stream stream :external-format :utf-8)))
        (when should-close (close stream)))))
  
  