Class OneDriveConnection
java.lang.Object
com.amilesend.client.connection.Connection<GsonFactory>
com.amilesend.onedrive.connection.OneDriveConnection
Wraps a
OkHttpClient
that manages authentication refresh and parsing responses to corresponding POJO types.
Construct a new instance via the OneDriveConnection.OneDriveConnectionBuilder
that simplifies configuration of the
OneDriveAuthManager
and automatically sets a pre-configured Gson
instance for proper request/response
serialization.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
OneDriveConnection.OneDriveConnectionBuilder<C extends OneDriveConnection,
B extends OneDriveConnection.OneDriveConnectionBuilder<C, B>> Nested classes/interfaces inherited from class com.amilesend.client.connection.Connection
com.amilesend.client.connection.Connection.ConnectionBuilder<G extends com.amilesend.client.parse.GsonFactoryBase,
C extends com.amilesend.client.connection.Connection<G>, B extends com.amilesend.client.connection.Connection.ConnectionBuilder<G, C, B>> -
Field Summary
Fields inherited from class com.amilesend.client.connection.Connection
JSON_CONTENT_TYPE, JSON_MEDIA_TYPE
-
Method Summary
Modifier and TypeMethodDescriptionstatic OneDriveConnection.OneDriveConnectionBuilder
<?, ?> builder()
long
download
(@NonNull okhttp3.Request request, @NonNull Path folderPath, String name, long sizeBytes, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) Downloads the contents for the givenrequest
to the specifiedfolderPath
andname
.downloadAsync
(@NonNull okhttp3.Request request, @NonNull Path folderPath, String name, long sizeBytes, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) Downloads the contents for the givenrequest
asynchronously to the specifiedfolderPath
andname
.<T> CompletableFuture
<T> executeAsync
(@NonNull okhttp3.Request request, @NonNull com.amilesend.client.parse.parser.GsonParser<T> parser) Executes the givenRequest
and parses the JSON-formatted response with givenGsonParser
.executeRemoteAsync
(@NonNull okhttp3.Request request) Executes the givenRequest
for a remote asynchronous operation and returns the monitoring URL.okhttp3.Request.Builder
Creates a newRequest.Builder
with pre-configured headers for a request that contains both a JSON-formatted request and response body.Methods inherited from class com.amilesend.client.connection.Connection
execute, execute, getAuthManager, getBaseUrl, getGsonFactory, getHttpClient, getUserAgent, isGzipContentEncodingEnabled, newRequestBuilder
-
Method Details
-
newWithBodyRequestBuilder
public okhttp3.Request.Builder newWithBodyRequestBuilder()Creates a newRequest.Builder
with pre-configured headers for a request that contains both a JSON-formatted request and response body.- Returns:
- the request builder
-
executeRemoteAsync
public String executeRemoteAsync(@NonNull okhttp3.Request request) throws com.amilesend.client.connection.ConnectionException Executes the givenRequest
for a remote asynchronous operation and returns the monitoring URL.- Parameters:
request
- the request- Returns:
- the monitoring URL to track the remote asynchronous operation
- Throws:
com.amilesend.client.connection.ConnectionException
- if an error occurred during the transaction
-
executeAsync
public <T> CompletableFuture<T> executeAsync(@NonNull okhttp3.Request request, @NonNull com.amilesend.client.parse.parser.GsonParser<T> parser) Executes the givenRequest
and parses the JSON-formatted response with givenGsonParser
.- Type Parameters:
T
- the POJO resource type- Parameters:
request
- the requestparser
- the parser to decode the response body- Returns:
- the CompletableFuture used to fetch the parsed response or failure exception reason
-
download
public long download(@NonNull okhttp3.Request request, @NonNull Path folderPath, String name, long sizeBytes, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) throws com.amilesend.client.connection.ConnectionException Downloads the contents for the givenrequest
to the specifiedfolderPath
andname
.- Parameters:
request
- the requestfolderPath
- the path of the folder to download the contents toname
- the name of the file to download the contents tosizeBytes
- the total size of the expected file in bytescallback
- theTransferProgressCallback
call to invoke to report download transfer progress- Returns:
- the size of the downloaded file in bytes
- Throws:
com.amilesend.client.connection.ConnectionException
- if an error occurred while downloading the content for the request
-
downloadAsync
public CompletableFuture<Long> downloadAsync(@NonNull okhttp3.Request request, @NonNull Path folderPath, String name, long sizeBytes, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) Downloads the contents for the givenrequest
asynchronously to the specifiedfolderPath
andname
.- Parameters:
request
- the requestfolderPath
- the path of the folder to download the contents toname
- the name of the file to download the contents tosizeBytes
- the total size of the expected file in bytescallback
- theTransferProgressCallback
call to invoke to report download transfer progress- Returns:
- the CompletableFuture used to fetch the number of bytes downloaded
-
builder
-