XeroPHP\Application::loadByGUID PHP Method

loadByGUID() public method

As you should never have a GUID for a non-existent object, will throw a NotFoundExceptioon
public loadByGUID ( $model, $guid ) : Object | null
$model
$guid
return XeroPHP\Remote\Object | null
    public function loadByGUID($model, $guid)
    {
        /**
         * @var Remote\Object $class
         */
        $class = $this->validateModelClass($model);
        $uri = sprintf('%s/%s', $class::getResourceURI(), $guid);
        $api = $class::getAPIStem();
        $url = new URL($this, $uri, $api);
        $request = new Request($this, $url, Request::METHOD_GET);
        $request->send();
        //Return the first (if any) element from the response.
        foreach ($request->getResponse()->getElements() as $element) {
            /**
             * @var Remote\Object $object
             */
            $object = new $class($this);
            $object->fromStringArray($element);
            return $object;
        }
        return null;
    }