public function getEntities($type = false, $offset = 0, $limit = 1000, $details = "on") {
        if ($type) {
            $url = $this->url . "contextTypes/" . $type;
        } else {
            $url = $this->url . "contextEntities/";
        }

        $ret = $this->restRequest($url . "?offset=$offset&limit=$limit&details=$details", 'GET')->getResponseBody();
        $Context = (new Context\Context($ret))->get();
        $Entities = [];
        
        if($Context instanceof \stdClass && isset($Context->errorCode)){
            switch ((int) $Context->errorCode->code) {
                case 404:
                case 500:
                    throw new Exception\GeneralException($Context->errorCode->reasonPhrase,(int)$Context->errorCode->code, null, $ret);
                default:
                case 200:
                    break;
            }
        }else{
            throw new Exception\GeneralException("Malformed Orion Response",500, null, $ret);
        }
        
        if(isset($Context->contextResponses) && count($Context->contextResponses) > 0){
            foreach ($Context->contextResponses as $entity) {
                $t = $entity->contextElement->type;
                $id = $entity->contextElement->id;
                
                if(!array_key_exists($t, $Entities)){
                    $Entities[$t] = [];
                }
                $Entities[$t][$id] = $entity->contextElement->attributes;
            }
        }




        return new Context\Context($Entities);
    }