/**
  * resolves an action from a stdClass
  *
  * @param \stdClass $stdClass
  *
  * @return Action
  */
 protected function resolveActionFromStdClass(stdClass $stdClass)
 {
     if (isset($stdClass->data)) {
         $stdClass->data = $this->cryptographyEngine->decrypt($stdClass->data, $this->email);
     }
     return Action::createFromStdClass($stdClass);
 }
 /**
  * returns the body
  *
  * hash: email will be hashed before requesting the server
  * action: action will be transmitted in plain text
  * scope: optional scope will be transmitted in plain text
  * data: optional data will be encrypted before requesting the server
  *
  * @param CryptographyEngine $cryptographyEngine
  *
  * @return array|\Guzzle\Http\EntityBodyInterface|null|resource|string
  */
 public function body(CryptographyEngine $cryptographyEngine)
 {
     $body = array('hash' => $cryptographyEngine->hash($this->email), 'action' => $this->action);
     if (!empty($this->scope)) {
         $body['scope'] = $this->scope;
     }
     if (!empty($this->data)) {
         $body['data'] = $cryptographyEngine->encrypt(json_encode($this->data), $this->email);
     }
     //  add overwriting data when possible
     if (!empty($this->ip)) {
         $body['ip'] = $this->ip;
     }
     if (!empty($this->useragent)) {
         $body['useragent'] = $this->useragent;
     }
     if (!empty($this->created_at)) {
         $body['created_at'] = $this->created_at;
     }
     return json_encode($body);
 }