예제 #1
0
 /**
  * Constructor
  *
  * @param object $entity Entity
  */
 public function __construct($entity = null)
 {
     parent::__construct($entity);
     if ($entity === null) {
         $this->entity->state = self::STATE_DRAFT;
     }
 }
예제 #2
0
 /**
  * Updates an item through an object endpoint.
  *
  * @param Entity $object API Entity object
  *
  * @return mixed
  * @throws \Exception
  */
 public function update($object)
 {
     if ($object->validate()) {
         $data = array($this->recordKey => $object->toArray());
         $response = $this->put($this->url . '/' . $object->getID(), $data);
         $this->validateResponse($response);
         return $response->getBody();
     } else {
         // @todo: Better exception.
         throw new \Exception('API Entity did not have required properties');
     }
 }