public class RequestBuilder
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
RequestBuilder |
body(okhttp3.RequestBody body)
Sets the body.
|
RequestBuilder |
bodyContent(java.io.InputStream stream,
java.lang.String contentType)
Sets the file content (InputStream) to the request (used with POST/PUT).
|
RequestBuilder |
bodyContent(java.lang.String contentType,
java.lang.Object jsonContent,
java.lang.Object jsonPatchContent,
java.io.InputStream nonJsonContent)
Sets the request body content from one of three different sources, based on the content type.
|
RequestBuilder |
bodyContent(java.lang.String contentType,
java.lang.Object jsonContent,
java.lang.Object jsonPatchContent,
java.lang.String nonJsonContent)
Sets the request body content from one of three different sources, based on the content type.
|
RequestBuilder |
bodyContent(java.lang.String content,
java.lang.String contentType)
Sets the string content to the request (used with POST/PUT).
|
RequestBuilder |
bodyJson(com.google.gson.JsonObject json)
Adds a JSON content to the request (used with POST/PUT).
|
RequestBuilder |
bodyJson(com.google.gson.JsonObject json,
java.lang.String mediaType)
Adds a JSON content to the request (used with POST/PUT/PATCH).
|
okhttp3.Request |
build()
Builds the.
|
static okhttp3.HttpUrl |
constructHttpUrl(java.lang.String endPoint,
java.lang.String[] pathSegments)
Creates a properly encoded HttpUrl object with no path parameters.
|
static okhttp3.HttpUrl |
constructHttpUrl(java.lang.String endPoint,
java.lang.String[] pathSegments,
java.lang.String[] pathParameters)
Creates a properly encoded HttpUrl object with path parameters.
|
static RequestBuilder |
delete(okhttp3.HttpUrl url)
The DELETE method requests that the origin server delete the resource identified by the Request-URI.
|
RequestBuilder |
form(java.lang.Object... args)
Adds form parameters.
|
static RequestBuilder |
get(okhttp3.HttpUrl url)
The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI.
|
static RequestBuilder |
head(okhttp3.HttpUrl url)
The HEAD method means retrieve the headers for the resource identified by the Request-URI.
|
RequestBuilder |
header(java.lang.Object... args)
Adds header parameters.
|
static RequestBuilder |
patch(okhttp3.HttpUrl url)
The PUT method requests that the enclosed entity be stored under the supplied Request-URI.
|
static RequestBuilder |
post(okhttp3.HttpUrl url)
The POST request method is designed to request that a web server accept the data enclosed in the request
message's body for storage.
|
static RequestBuilder |
put(okhttp3.HttpUrl url)
The PUT method requests that the enclosed entity be stored under the supplied Request-URI.
|
RequestBuilder |
query(java.lang.Object... args)
Adds query parameters.
|
java.lang.String |
toString() |
public static RequestBuilder delete(okhttp3.HttpUrl url)
url
- the URLpublic static RequestBuilder get(okhttp3.HttpUrl url)
url
- the URLpublic static RequestBuilder post(okhttp3.HttpUrl url)
url
- the URLpublic static RequestBuilder put(okhttp3.HttpUrl url)
url
- the URLpublic static RequestBuilder patch(okhttp3.HttpUrl url)
url
- the URLpublic static RequestBuilder head(okhttp3.HttpUrl url)
url
- the URLpublic static okhttp3.HttpUrl constructHttpUrl(java.lang.String endPoint, java.lang.String[] pathSegments)
endPoint
- the API end pointpathSegments
- the path segments for a specific API callpublic static okhttp3.HttpUrl constructHttpUrl(java.lang.String endPoint, java.lang.String[] pathSegments, java.lang.String[] pathParameters)
endPoint
- the API end pointpathSegments
- the path segments for a specific API callpathParameters
- the path parameters for a specific API callpublic okhttp3.Request build()
public java.lang.String toString()
toString
in class java.lang.Object
public RequestBuilder body(okhttp3.RequestBody body)
body
- the bodypublic RequestBuilder bodyContent(java.lang.String content, java.lang.String contentType)
RequestBody
encoded with UTF-8content
- the content to POST/PUTcontentType
- the HTTP contentType to use.public RequestBuilder bodyContent(java.io.InputStream stream, java.lang.String contentType)
stream
- the InputStream to read the request body content fromcontentType
- the contentType associated with the data read from the InputStreampublic RequestBuilder bodyContent(java.lang.String contentType, java.lang.Object jsonContent, java.lang.Object jsonPatchContent, java.io.InputStream nonJsonContent)
contentType
- the value of the "Content-Type" header associated with the outgoing requestjsonContent
- the body content to be used if the content type indicates JSONjsonPatchContent
- the body content to be used if the content type indicates JsonPatchnonJsonContent
- the body content to be used if the content type indicates non-JSON contentpublic RequestBuilder bodyContent(java.lang.String contentType, java.lang.Object jsonContent, java.lang.Object jsonPatchContent, java.lang.String nonJsonContent)
contentType
- the value of the "Content-Type" header associated with the outgoing requestjsonContent
- the body content to be used if the content type indicates JSONjsonPatchContent
- the body content to be used if the content type indicates JsonPatchnonJsonContent
- the body content to be used if the content type indicates non-JSON contentpublic RequestBuilder bodyJson(com.google.gson.JsonObject json)
RequestBody
encoded with UTF-8 and use "application/json"
as Content-Typejson
- the JsonObject jsonpublic RequestBuilder bodyJson(com.google.gson.JsonObject json, java.lang.String mediaType)
RequestBody
encoded with UTF-8 and use "application/json"
as Content-Typejson
- the JsonObject jsonmediaType
- the contentType valuepublic RequestBuilder form(java.lang.Object... args)
args
- a list of name-value form parameterspublic RequestBuilder header(java.lang.Object... args)
args
- a list of name-value headerspublic RequestBuilder query(java.lang.Object... args)
args
- a list of name-value query parameters