CloudPlugs REST Library  1.0.0
for Android
Request Class Reference

An instance of this class is a HTTP request to send or already sent to the server. More...

Public Member Functions

 Request (String method, String baseUrl, String path, String[] headers, String body)
 
 Request (String json)
 
 Request (JSONObject jso)
 
int getId ()
 
String getMethod ()
 
String getBaseUrl ()
 
String getPath ()
 
String getUrl ()
 
String [] getHeaders ()
 
String getBody ()
 
boolean hasSSL ()
 
JSONObject toJSON ()
 
String toString ()
 

Static Public Attributes

static final String GET = "GET"
 
static final String POST = "POST"
 
static final String PUT = "PUT"
 
static final String PATCH = "PATCH"
 
static final String DELETE = "DELETE"
 
static final String K_METHOD = "method"
 
static final String K_HEADER = "headers"
 
static final String K_BODY = "body"
 
static final String K_BASEURL = "baseurl"
 
static final String K_PATH = "path"
 

Protected Member Functions

void fromJSON (JSONObject jso)
 
void fromJSON (String json)
 
void fromString (String json)
 

Package Attributes

int id = 0
 

Detailed Description

An instance of this class is a HTTP request to send or already sent to the server.

Constructor & Destructor Documentation

◆ Request() [1/3]

Request ( String  method,
String  baseUrl,
String  path,
String []  headers,
String  body 
)

Create a new instance of this class.

Parameters
methodthe HTTP method, one of GET, POST, PUT, PATCH or DELETE
baseUrlthe base URL (without the path part) of this request
paththe path part of the request URL
headersarray of headers to send during the request; the even elements are the header names, while the odd ones are the corresponding values
bodythe body of the HTTP request or null for empty body

◆ Request() [2/3]

Request ( String  json)

Create a new instance of this class from a JSON string (previously produced by calling toString()).

Parameters
jsonthe JSON string to parse for creating this request

◆ Request() [3/3]

Request ( JSONObject  jso)

Create a new instance of this class from a JSON object (previously produced by calling toJSON()).

Parameters
jsothe JSON object to use for creating this request

Member Function Documentation

◆ fromJSON() [1/2]

void fromJSON ( JSONObject  jso)
protected

◆ fromJSON() [2/2]

void fromJSON ( String  json)
protected

◆ fromString()

void fromString ( String  json)
protected

◆ getBaseUrl()

String getBaseUrl ( )

HTTP base URL getter.

Returns
the HTTP base URL of this request

◆ getBody()

String getBody ( )

HTTP body getter.

Returns
the HTTP body of this request of null for empty body

◆ getHeaders()

String [] getHeaders ( )

HTTP headers getter.

Returns
the array of all headers of this request; the even elements are the header names, while the odd ones are the corresponding values

◆ getId()

int getId ( )
Returns
the asynchronous execution identifier of this request or 0 if it was not been enqueued

◆ getMethod()

String getMethod ( )

HTTP method getter.

Returns
the HTTP method of this request

◆ getPath()

String getPath ( )

HTTP URL path getter.

Returns
the HTTP URL path of this request

◆ getUrl()

String getUrl ( )

HTTP full URL getter.

Returns
the HTTP full URL of this request

◆ hasSSL()

boolean hasSSL ( )
Returns
true if the URL of this request is using HTTPS, false if it is a plain HTTP or if this request has not any URL

◆ toJSON()

JSONObject toJSON ( )

Make a JSON object representation of this request. Such JSON instance can be used to create a new request instance by calling Request(JSONObject).

Returns
the JSON object representation of this request

◆ toString()

String toString ( )

Make a JSON string representation of this request. Such JSON instance can be used to create a new request instance by calling Request(String).

Returns
the JSON string representation of this request

Member Data Documentation

◆ DELETE

final String DELETE = "DELETE"
static

◆ GET

final String GET = "GET"
static

◆ id

int id = 0
package

◆ K_BASEURL

final String K_BASEURL = "baseurl"
static

◆ K_BODY

final String K_BODY = "body"
static

◆ K_HEADER

final String K_HEADER = "headers"
static

◆ K_METHOD

final String K_METHOD = "method"
static

◆ K_PATH

final String K_PATH = "path"
static

◆ PATCH

final String PATCH = "PATCH"
static

◆ POST

final String POST = "POST"
static

◆ PUT

final String PUT = "PUT"
static