Esempio n. 1
0
 /**
  * Retrieve a object of JSON-RPC request.
  *
  * @return  object  The request object.
  */
 public static function getRequest()
 {
     if (static::$request == null) {
         $http = Http\Request::getInstance();
         $body = $http->getBody();
         static::$request = Request::fromJson($body);
     }
     return static::$request;
 }
Esempio n. 2
0
 /**
  * Set request parametes based on JSON
  *
  * @param   string   The formatted JSON as string.
  * @return  Request  An object of JSON-RPC request.
  */
 public static function fromJson($json)
 {
     $data = json_decode($json, $assoc = true, $depth = 512);
     if (strlen($json) && $data === null) {
         $code = JsonRPCException::E_PARSE;
         $message = 'Invalid JSON was received by the server.' . 'An error occurred on the server while parsing the JSON text.';
         throw new JsonRPCException($message, $code, ['json' => $json]);
     }
     $request = new Request();
     return $request->setOptions($data);
 }