class Attio::Client

def handle_response(response)

def handle_response(response)
  case response.status
  when 200..299
    response.body
  when 400
    error_message = response.body["error"] || response.body["message"] || "Bad request"
    raise BadRequestError.new("Bad request: #{error_message}", response_to_hash(response))
  when 401
    raise AuthenticationError.new("Authentication failed", response_to_hash(response))
  when 403
    raise ForbiddenError.new("Access forbidden", response_to_hash(response))
  when 404
    raise NotFoundError.new("Resource not found", response_to_hash(response))
  when 409
    raise ConflictError.new("Resource conflict", response_to_hash(response))
  when 422
    raise UnprocessableEntityError.new("Unprocessable entity", response_to_hash(response))
  when 429
    raise RateLimitError.new("Rate limit exceeded", response_to_hash(response))
  when 500..599
    raise ServerError.new("Server error", response_to_hash(response))
  else
    raise Error.new("Unexpected response status: #{response.status}", response_to_hash(response))
  end
end