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 classOneDriveConnection.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,C, B>, com.amilesend.client.connection.Connection.Headers -
Field Summary
Fields inherited from class com.amilesend.client.connection.Connection
FORM_DATA_CONTENT_TYPE, FORM_DATA_MEDIA_TYPE, JSON_CONTENT_TYPE, JSON_MEDIA_TYPE -
Method Summary
Modifier and TypeMethodDescriptionstatic OneDriveConnection.OneDriveConnectionBuilder<?, ?> builder()longdownload(@NonNull okhttp3.Request request, @NonNull Path folderPath, String name, long sizeBytes, @NonNull com.amilesend.client.connection.file.TransferProgressCallback callback) Downloads the contents for the givenrequestto the specifiedfolderPathandname.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 givenrequestasynchronously to the specifiedfolderPathandname.<T> CompletableFuture<T> executeAsync(@NonNull okhttp3.Request request, @NonNull com.amilesend.client.parse.parser.GsonParser<T> parser) Executes the givenRequestand parses the JSON-formatted response with givenGsonParser.executeRemoteAsync(@NonNull okhttp3.Request request) Executes the givenRequestfor a remote asynchronous operation and returns the monitoring URL.okhttp3.Request.BuilderCreates a newRequest.Builderwith 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, getRetryStrategy, getUserAgent, isGzipContentEncodingEnabled, newRequestBuilder
-
Method Details
-
newWithBodyRequestBuilder
public okhttp3.Request.Builder newWithBodyRequestBuilder()Creates a newRequest.Builderwith 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 givenRequestfor 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 givenRequestand 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 givenrequestto the specifiedfolderPathandname.- 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- theTransferProgressCallbackcall 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 givenrequestasynchronously to the specifiedfolderPathandname.- 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- theTransferProgressCallbackcall to invoke to report download transfer progress- Returns:
- the CompletableFuture used to fetch the number of bytes downloaded
-
builder
-