title: Volley REST client using JSON
body: <p>I want to interact with a RESTful webservice that responds only in JSON.
  Any successful response from the server has this syntax:</p>
  
  <pre><code>{
      "code": int code,
      "data": object or list of objects
  }
  </code></pre>
  
  <p>while on error response:</p>
  
  <pre><code>{
      "code": int code,
      "error": string,
      "details": string
  }
  </code></pre>
  
  <p>So I made two classes in my Android project like this (for GSON reflection):</p>
  
  <pre><code>public class ErrorEntity {
      private String details;
      private String error;
      private int    code;
  
      public ErrorEntity() {
          // Stub constructor
      }
  
      public String getDetails() {
          return details;
      }
  
      public String getError() {
          return error;
      }
  
      public int getCode() {
          return code;
      }
  }
  </code></pre>
  
  <p>For a successful response I made a generic because I don't want to parse JSON data on overridden parseNetworkResponse:</p>
  
  <pre><code>public class SuccessfulEntity&lt;T&gt; {
  
      private T   data;
      private int code;
  
      public SuccessfulEntity() {
          // Stub content
      }
  
      public T getData() {
          return data;
      }
  
      public int getCode() {
          return code;
      }
  }
  </code></pre>
  
  <p>Now, because my RESTful server requires some custom headers, I need to make a Request subclass, but I don't know from which class I need to inherit.<br />
  I saw this question: <a href="https://stackoverflow.com/questions/23220695/send-post-request-with-json-data-using-volley">Send POST request with JSON data using Volley</a> and though to do something like that.</p>
  
  <p>Basically, I want to make a new class (VolleyRestClient) which has GET, POST, DELETE methods and API routings, and with this class make all requests I need to do.<br /><br />
  Methods of this class need to make a new custom request and parse new objects response like SuccessfulEntity and ErrorEntity, and then parsing data in service/thread that make the VolleyRestClient call.</p>
  
  <p>How can I do that?</p>