XeroPHP\Application::delete PHP Method

delete() public method

public delete ( Object $object ) : Response
$object XeroPHP\Remote\Object
return XeroPHP\Remote\Response
    public function delete(Remote\Object $object)
    {
        if (!$object::supportsMethod(Request::METHOD_DELETE)) {
            throw new Exception(sprintf('%s doesn\'t support [DELETE] via the API', get_class($object)));
        }
        $uri = sprintf('%s/%s', $object::getResourceURI(), $object->getGUID());
        $url = new URL($this, $uri);
        $request = new Request($this, $url, Request::METHOD_DELETE);
        $request->send();
        return $request->getResponse();
    }

Usage Example

Example #1
0
 /**
  * Shorthand delete an object if it is instantiated with app context.
  *
  * @return Response|null
  * @throws Exception
  */
 public function delete()
 {
     if ($this->_application === null) {
         throw new Exception('->delete() is only available on objects that have an injected application context.');
     }
     return $this->_application->delete($this);
 }