diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af7798d..0ec8400a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ # History +## 4.0.0 +- Library: + - Migrated REST API support from v0.6 to v0.7. + - Removed the `UploadcareClient.storeGroup()` and `UploadcareGroup.store()` methods, as their + endpoints have been removed. + - Added support for new event types of webhooks. + - Removed sorting methods by file size, as the corresponding parameter has been removed from + the API query parameters. +- Example: + - Removed sorting options by file size from `UploadFragment`. + ## 3.3.0 - Library: - Added support for [signing your webhooks](https://uploadcare.com/docs/webhooks/#signed-webhooks) using the `signingSecret` parameter. diff --git a/README.md b/README.md index 7db35105..77de13ff 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Check out [demo app](/example). Supported features: -- File, group, and project API v0.6. +- File, group, and project API v0.7. - Paginated resource fetching. - CDN path builder. - File uploading from a file, byte array, URL, and URI. diff --git a/build.gradle b/build.gradle index 79d0718c..1e3c1e45 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { versions.androidx_core = "1.12.0" versions.material = "1.9.0" - versions.navigation = "2.7.2" + versions.navigation = "2.7.3" versions.lifecycle = "2.6.2" versions.constraintlayout = "2.1.4" versions.annotation = '1.7.0' diff --git a/documentation/LIBRARY.md b/documentation/LIBRARY.md index c9da7d6b..57bf478b 100644 --- a/documentation/LIBRARY.md +++ b/documentation/LIBRARY.md @@ -42,7 +42,7 @@ Java UploadcareClient uploadcare = new UploadcareClient("YOUR_PUBLIC_KEY", "YOUR_SECRET_KEY"); ``` -## List of files ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/filesList)) ## +## List of files ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/filesList)) ## ##### Asynchronous file fetch. @@ -112,7 +112,7 @@ FilesQueryBuilder filesQueryBuilder = uploadcare.getFiles() List files = filesQueryBuilder.asList(); ``` -## File info ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/fileInfo)) ## +## File info ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/fileInfo)) ## ##### Asynchronous file info fetch. @@ -160,7 +160,7 @@ Java UploadcareFile file = uploadcare.getFile("YOUR_FILE_UUID"); ``` -## Store a file ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/storeFile)) ## +## Store a file ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/storeFile)) ## ##### Asynchronous file store. @@ -184,7 +184,7 @@ Java uploadcare.saveFile("YOUR_FILE_UUID"); ``` -## Batch file store ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/filesStoring)) ## +## Batch file store ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/filesStoring)) ## ##### Asynchronous multiple files store. @@ -212,7 +212,7 @@ List fileIds = ... // list of file UUID's uploadcare.saveFiles(fileIds); ``` -## Delete file ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/deleteFile)) ## +## Delete file ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/deleteFileStorage)) ## ##### Asynchronous file delete. @@ -236,7 +236,7 @@ Java uploadcare.deleteFile("YOUR_FILE_UUID"); ``` -## Batch file delete ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/filesDelete)) ## +## Batch file delete ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/filesDelete)) ## ##### Asynchronous multiple files delete. @@ -264,7 +264,7 @@ List fileIds = ... // list of file UUID's uploadcare.deleteFiles(fileIds); ``` -## Copy file to local storage ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/copyFileLocal)) ## +## Copy file to local storage ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/createLocalCopy)) ## ##### Asynchronous file copy to local storage. @@ -321,7 +321,7 @@ UploadcareCopyFile copyResult = uploadcare.copyFileLocalStorage(source, true); // process result that will have either UploadcareFile or URI depending on source. ``` -## Copy file to remote storage ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/copyFile)) ## +## Copy file to remote storage ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/createRemoteCopy)) ## ##### Asynchronous copy file to remote storage. @@ -385,7 +385,7 @@ UploadcareCopyFile copyResult = uploadcare.copyFileRemoteStorage(source, target, // process result that will have either UploadcareFile or URI depending on source. ``` -## List of groups ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/groupsList)) ## +## List of groups ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/groupsList)) ## ##### Asynchronous group list fetch. @@ -451,7 +451,7 @@ GroupsQueryBuilder groupsQueryBuilder = uploadcare.getGroups() List groups = groupsQueryBuilder.asList(); ``` -## Group info ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/groupInfo)) ## +## Group info ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/groupInfo)) ## ##### Asynchronous group info fetch. @@ -499,31 +499,7 @@ Java UploadcareGroup group = uploadcare.getGroup("YOUR_GROUP_UUID"); ``` -## Store group ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#tag/Group/paths/~1groups~1%3Cuuid%3E~1storage~1/put)) ## - -##### Asynchronous group store. - -Kotlin -```kotlin -uploadcare.storeGroupAsync(context, "YOUR_GROUP_UUID") -``` -Java -```java -uploadcare.storeGroupAsync(context, "YOUR_GROUP_UUID", null); // callback is optional -``` - -##### Synchronous group store. - -Kotlin -```kotlin -uploadcare.storeGroup("YOUR_GROUP_UUID") -``` -Java -```java -uploadcare.storeGroup("YOUR_GROUP_UUID"); -``` - -## Project info ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/projectInfo)) ## +## Project info ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/projectInfo)) ## ##### Asynchronous project info fetch. @@ -569,7 +545,7 @@ Java Project project = uploadcare.getProject(); ``` -## List of webhooks ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/webhooksList)) ## +## List of webhooks ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/webhooksList)) ## ##### Asynchronous webhook list fetch. @@ -615,7 +591,7 @@ Java List webhooks = uploadcare.getWebhooks(); ``` -## Create webhook ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/webhookCreate)) ## +## Create webhook ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/webhookCreate)) ## ##### Asynchronous webhook create. @@ -624,7 +600,7 @@ Kotlin uploadcare.createWebhookAsync( context, // Context URI.create("YOUR_WEBHOOK_URL"), - "YOUR_WEBHOOK_EVENT", + EventType.UPLOADED, // Webhook event signingSecret = "YOUR_WEBHOOK_SIGNING_SECRET", callback = object : UploadcareWebhookCallback { override fun onFailure(e: UploadcareApiException) { @@ -641,7 +617,7 @@ Java uploadcare.createWebhookAsync( context, // Context URI.create("YOUR_WEBHOOK_URL"), - "YOUR_WEBHOOK_EVENT", + EventType.UPLOADED, // Webhook event true, // is webhook active or not. "YOUR_WEBHOOK_SIGNING_SECRET", new UploadcareWebhookCallback() { @@ -663,7 +639,7 @@ Kotlin ```kotlin val webhook = uploadcare.createWebhook( URI.create("YOUR_WEBHOOK_URL"), - "YOUR_WEBHOOK_EVENT", + EventType.UPLOADED, // Webhook event true, // is webhook active or not. "YOUR_WEBHOOK_SIGNING_SECRET" ) @@ -672,13 +648,13 @@ Java ```java UploadcareWebhook webhook = uploadcare.createWebhook( URI.create("YOUR_WEBHOOK_URL"), - "YOUR_WEBHOOK_EVENT", + EventType.UPLOADED, // Webhook event true, // is webhook active or not. "YOUR_WEBHOOK_SIGNING_SECRET" ); ``` -## Update webhook ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/updateWebhook)) ## +## Update webhook ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/updateWebhook)) ## ##### Asynchronous webhook update. @@ -688,7 +664,7 @@ uploadcare.updateWebhookAsync( context, // Context "YOUR_WEBHOOK_UUID", URI.create("YOUR_WEBHOOK_URL"), - "YOUR_WEBHOOK_EVENT", + EventType.UPLOADED, // Webhook event signingSecret = "YOUR_WEBHOOK_SIGNING_SECRET", callback = object : UploadcareWebhookCallback { override fun onFailure(e: UploadcareApiException) { @@ -706,7 +682,7 @@ uploadcare.updateWebhookAsync( context, // Context "YOUR_WEBHOOK_UUID", URI.create("YOUR_WEBHOOK_URL"), - "YOUR_WEBHOOK_EVENT", + EventType.UPLOADED, // Webhook event true, // is webhook active or not. "YOUR_WEBHOOK_SIGNING_SECRET", new UploadcareWebhookCallback() { @@ -729,7 +705,7 @@ Kotlin val webhook = uploadcare.updateWebhook( "YOUR_WEBHOOK_UUID", URI.create("YOUR_WEBHOOK_URL"), - "YOUR_WEBHOOK_EVENT", + EventType.UPLOADED, // Webhook event true, // is webhook active or not. "YOUR_WEBHOOK_SIGNING_SECRET" ) @@ -739,13 +715,13 @@ Java UploadcareWebhook webhook = uploadcare.updateWebhook( "YOUR_WEBHOOK_UUID", URI.create("YOUR_WEBHOOK_URL"), - "YOUR_WEBHOOK_EVENT", + EventType.UPLOADED, // Webhook event true, // is webhook active or not. "YOUR_WEBHOOK_SIGNING_SECRET" ); ``` -## Delete webhook ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/webhookUnsubscribe)) ## +## Delete webhook ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/webhookUnsubscribe)) ## ##### Asynchronous webhook delete. @@ -769,7 +745,7 @@ Java uploadcare.deleteWebhook(URI.create("YOUR_WEBHOOK_URL")); ``` -## Convert documents ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/documentConvert)) ## +## Convert documents ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/documentConvert)) ## ##### Asynchronous documents convert. @@ -858,7 +834,7 @@ DocumentConverter converter = new DocumentConverter(uploadcare, conversionJobs); List result = converter.convert(); ``` -## Convert videos ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/videoConvert)) ## +## Convert videos ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/videoConvert)) ## ##### Asynchronous videos convert. diff --git a/example/build.gradle b/example/build.gradle index 5ee12ac8..e22b85a6 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -14,7 +14,7 @@ android { applicationId "com.uploadcare.android.example" minSdkVersion versions.min_sdk targetSdkVersion versions.target_sdk - versionCode 9 + versionCode 10 versionName "${version}" } diff --git a/example/src/main/java/com/uploadcare/android/example/fragments/OrderDialogFragment.kt b/example/src/main/java/com/uploadcare/android/example/fragments/OrderDialogFragment.kt index a1a97e09..1c0f3b60 100644 --- a/example/src/main/java/com/uploadcare/android/example/fragments/OrderDialogFragment.kt +++ b/example/src/main/java/com/uploadcare/android/example/fragments/OrderDialogFragment.kt @@ -36,8 +36,6 @@ class OrderDialogFragment : DialogFragment() { private fun orderSelected(position: Int) { val order: Order = when (position) { 1 -> Order.UPLOAD_TIME_DESC - 2 -> Order.SIZE_ASC - 3 -> Order.SIZE_DESC 0 -> Order.UPLOAD_TIME_ASC else -> Order.UPLOAD_TIME_ASC } @@ -54,4 +52,4 @@ class OrderDialogFragment : DialogFragment() { interface OrderDialogListener { fun onOrderSelected(order: Order) -} \ No newline at end of file +} diff --git a/example/src/main/res/values/strings.xml b/example/src/main/res/values/strings.xml index 9177e253..20fde968 100644 --- a/example/src/main/res/values/strings.xml +++ b/example/src/main/res/values/strings.xml @@ -52,7 +52,5 @@ Upload time, Ascending (Default) Upload time, Descending - File size, Ascending - File size, Descending diff --git a/gradle.properties b/gradle.properties index 9bbcc750..95e20221 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project-wide Gradle settings. -version=3.3.0 +version=4.0.0-SNAPSHOT # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* diff --git a/library/README.md b/library/README.md index 306282d3..fd6b6bbc 100644 --- a/library/README.md +++ b/library/README.md @@ -7,7 +7,7 @@ This is an Android library for Uploadcare. Supported features: -- File, group, and project API v0.6. +- File, group, and project API v0.7. - Paginated resources fetching. - CDN path builder. - File uploading from a file, byte array, URL, and URI. diff --git a/library/build.gradle b/library/build.gradle index bc2dd352..d17b4be3 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -15,7 +15,7 @@ android { defaultConfig { minSdkVersion versions.min_sdk targetSdkVersion versions.target_sdk - versionCode 13 + versionCode 14 versionName "${version}" buildConfigField 'String', 'VERSION_NAME', "\"${version}\"" } diff --git a/library/src/main/java/com/uploadcare/android/library/api/FilesQueryBuilder.kt b/library/src/main/java/com/uploadcare/android/library/api/FilesQueryBuilder.kt index 73385eec..70bfc7f6 100644 --- a/library/src/main/java/com/uploadcare/android/library/api/FilesQueryBuilder.kt +++ b/library/src/main/java/com/uploadcare/android/library/api/FilesQueryBuilder.kt @@ -71,18 +71,6 @@ class FilesQueryBuilder(private val client: UploadcareClient) return this } - /** - * Adds a filter for datetime from objects will be returned. - * Order {@link Order#SIZE_ASC} will be used. - * - * @param fromSize File size in bytes. - */ - fun from(fromSize: Long): FilesQueryBuilder { - parameters["ordering"] = FilesOrderParameter(Order.SIZE_ASC) - parameters["from"] = FilesFromParameter(fromSize) - return this - } - /** * Adds a filter for datetime to which objects will be returned. * Order {@link Order#UPLOAD_TIME_DESC} will be used. @@ -95,25 +83,13 @@ class FilesQueryBuilder(private val client: UploadcareClient) return this } - /** - * Adds a filter for datetime to which objects will be returned. - * Order {@link Order#SIZE_DESC} will be used. - * - * @param toSize File size in bytes. - */ - fun to(toSize: Long): FilesQueryBuilder { - parameters["ordering"] = FilesOrderParameter(Order.SIZE_DESC) - parameters["from"] = FilesFromParameter(toSize) - return this - } - /** * Add special fields to the file object in the result. * * @param fields Example: "rekognition_info" */ - fun addFields(fields: String): FilesQueryBuilder { - parameters["add_fields"] = AddFieldsParameter(fields) + fun include(fields: String): FilesQueryBuilder { + parameters["include"] = IncludeParameter(fields) return this } diff --git a/library/src/main/java/com/uploadcare/android/library/api/RequestHelper.kt b/library/src/main/java/com/uploadcare/android/library/api/RequestHelper.kt index 7aaecd77..b5762648 100644 --- a/library/src/main/java/com/uploadcare/android/library/api/RequestHelper.kt +++ b/library/src/main/java/com/uploadcare/android/library/api/RequestHelper.kt @@ -32,7 +32,7 @@ import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec /** - * A helper class for doing API calls to the Uploadcare API. Supports API version 0.6. + * A helper class for doing API calls to the Uploadcare API. Supports API version 0.7. */ @Suppress("unused") class RequestHelper(private val client: UploadcareClient) { @@ -72,7 +72,7 @@ class RequestHelper(private val client: UploadcareClient) { val formattedDate = rfc2822(calendar.time) requestBuilder.addHeader("Content-Type", contentType ?: JSON_CONTENT_TYPE) - requestBuilder.addHeader("Accept", "application/vnd.uploadcare-v0.6+json") + requestBuilder.addHeader("Accept", "application/vnd.uploadcare-v0.7+json") requestBuilder.addHeader("Date", formattedDate) requestBuilder.addHeader("User-Agent", String.format("javauploadcare-android/%s/%s", BuildConfig.VERSION_NAME, @@ -700,4 +700,4 @@ class RequestHelper(private val client: UploadcareClient) { } } -} \ No newline at end of file +} diff --git a/library/src/main/java/com/uploadcare/android/library/api/UploadcareClient.kt b/library/src/main/java/com/uploadcare/android/library/api/UploadcareClient.kt index 099abd98..6c85ba6c 100644 --- a/library/src/main/java/com/uploadcare/android/library/api/UploadcareClient.kt +++ b/library/src/main/java/com/uploadcare/android/library/api/UploadcareClient.kt @@ -11,7 +11,7 @@ import com.uploadcare.android.library.data.ObjectMapper import com.uploadcare.android.library.data.WebhookOptionsData import com.uploadcare.android.library.exceptions.UploadFailureException import com.uploadcare.android.library.exceptions.UploadcareApiException -import com.uploadcare.android.library.urls.AddFieldsParameter +import com.uploadcare.android.library.urls.IncludeParameter import com.uploadcare.android.library.urls.Urls import okhttp3.Interceptor import okhttp3.MultipartBody @@ -137,31 +137,31 @@ class UploadcareClient constructor(val publicKey: String, } /** - * Requests file data, with Rekognition Info if available. + * Requests file data, with Appdata if available. * * @param fileId Resource UUID * @return UploadcareFile resource */ - fun getFileWithRekognitionInfo(fileId: String): UploadcareFile { + fun getFileWithAppData(fileId: String): UploadcareFile { val url = Urls.apiFile(fileId) return requestHelper.executeQuery(RequestHelper.REQUEST_GET, url.toString(), true, UploadcareFile::class.java, - urlParameters = listOf(AddFieldsParameter("rekognition_info"))) + urlParameters = listOf(IncludeParameter("appdata"))) } /** - * Requests file data, with Rekognition Info if available, Asynchronously. + * Requests file data, with Appdata if available, Asynchronously. * * @param context Application context. [android.content.Context] * @param fileId Resource UUID * @param callback callback [UploadcareFileCallback] with either * an UploadcareFile response or a failure exception. */ - fun getFileWithRekognitionInfoAsync(context: Context, fileId: String, callback: UploadcareFileCallback? = null) { + fun getFileWithAppDataAsync(context: Context, fileId: String, callback: UploadcareFileCallback? = null) { val url = Urls.apiFile(fileId) requestHelper.executeQueryAsync(context, RequestHelper.REQUEST_GET, url.toString(), true, UploadcareFile::class.java, callback, - urlParameters = listOf(AddFieldsParameter("rekognition_info"))) + urlParameters = listOf(IncludeParameter("appdata"))) } /** @@ -202,32 +202,6 @@ class UploadcareClient constructor(val publicKey: String, UploadcareGroup::class.java, callback) } - /** - * Mark all files in a group as stored (available on CDN). - * - * @param groupId Group ID - */ - fun storeGroup(groupId: String) { - val requestBody = groupId.encodeUtf8().toRequestBody(RequestHelper.JSON) - val url = Urls.apiGroupStorage(groupId) - requestHelper.executeCommand(RequestHelper.REQUEST_PUT, url.toString(), true, requestBody, groupId.md5()) - } - - /** - * Mark all files in a group as stored (available on CDN). Asynchronously. - * - * @param context Application context. [android.content.Context] - * @param groupId Group ID - * @param callback callback [RequestCallback] with either - * an HTTP response or a failure exception. - */ - fun storeGroupAsync(context: Context, groupId: String, callback: RequestCallback? = null) { - val requestBody = groupId.encodeUtf8().toRequestBody(RequestHelper.JSON) - val url = Urls.apiGroupStorage(groupId) - requestHelper.executeCommandAsync(context, RequestHelper.REQUEST_PUT, url.toString(), - true, callback, requestBody, groupId.md5()) - } - /** * Begins to build a request for uploaded files for the current account. * @@ -252,7 +226,7 @@ class UploadcareClient constructor(val publicKey: String, * @param fileId Resource UUID */ fun deleteFile(fileId: String) { - val url = Urls.apiFile(fileId) + val url = Urls.apiFileStorage(fileId) requestHelper.executeCommand(RequestHelper.REQUEST_DELETE, url.toString(), true) } @@ -263,7 +237,7 @@ class UploadcareClient constructor(val publicKey: String, * @param fileId Resource UUID */ fun deleteFileAsync(context: Context, fileId: String) { - val url = Urls.apiFile(fileId) + val url = Urls.apiFileStorage(fileId) requestHelper.executeCommandAsync(context, RequestHelper.REQUEST_DELETE, url.toString(), true) } @@ -787,7 +761,7 @@ class UploadcareClient constructor(val publicKey: String, */ fun createWebhook( targetUrl: URI, - event: String, + event: EventType, isActive: Boolean = true, signingSecret: String? = null ): UploadcareWebhook { @@ -816,7 +790,7 @@ class UploadcareClient constructor(val publicKey: String, */ fun createWebhookAsync(context: Context, targetUrl: URI, - event: String, + event: EventType, isActive: Boolean = true, signingSecret: String? = null, callback: UploadcareWebhookCallback) { @@ -846,7 +820,7 @@ class UploadcareClient constructor(val publicKey: String, */ fun updateWebhook(webhookId: Int, targetUrl: URI, - event: String, + event: EventType, isActive: Boolean = true, signingSecret: String? = null ): UploadcareWebhook { @@ -878,7 +852,7 @@ class UploadcareClient constructor(val publicKey: String, fun updateWebhookAsync(context: Context, webhookId: Int, targetUrl: URI, - event: String, + event: EventType, isActive: Boolean = true, signingSecret: String? = null, callback: UploadcareWebhookCallback) { diff --git a/library/src/main/java/com/uploadcare/android/library/api/UploadcareFile.kt b/library/src/main/java/com/uploadcare/android/library/api/UploadcareFile.kt index 12d6f898..1a72d7fc 100644 --- a/library/src/main/java/com/uploadcare/android/library/api/UploadcareFile.kt +++ b/library/src/main/java/com/uploadcare/android/library/api/UploadcareFile.kt @@ -8,24 +8,26 @@ import java.net.URI import java.util.* @Parcelize -@Suppress("unused") @SuppressWarnings("WeakerAccess") -data class UploadcareFile(val uuid: String, - val url: URI? = null, - val size: Int, - val source: String? = null, - @Json(name = "is_ready") val isReady: Boolean, - @Json(name = "is_image") val isImage: Boolean? = false, - @Json(name = "mime_type") val mimeType: String? = null, - @Json(name = "original_filename") val originalFilename: String? = null, - @Json(name = "original_file_url") val originalFileUrl: URI? = null, - @Json(name = "datetime_uploaded") val datetimeUploaded: Date? = null, - @Json(name = "datetime_stored") val datetimeStored: Date? = null, - @Json(name = "datetime_removed") val datetimeRemoved: Date? = null, - @Json(name = "image_info") val imageInfo: ImageInfo? = null, - @Json(name = "video_info") val videoInfo: VideoInfo? = null, - @Json(name = "rekognition_info") val rekognitionInfo: Map? = null, - val variations: Map? = null) - : Parcelable { +@Suppress("unused") +@SuppressWarnings("WeakerAccess") +data class UploadcareFile( + val uuid: String, + val url: URI? = null, + val size: Int, + val source: String? = null, + @Json(name = "is_ready") val isReady: Boolean, + @Json(name = "is_image") val isImage: Boolean? = false, + @Json(name = "mime_type") val mimeType: String? = null, + @Json(name = "original_filename") val originalFilename: String? = null, + @Json(name = "original_file_url") val originalFileUrl: URI? = null, + @Json(name = "datetime_uploaded") val datetimeUploaded: Date? = null, + @Json(name = "datetime_stored") val datetimeStored: Date? = null, + @Json(name = "datetime_removed") val datetimeRemoved: Date? = null, + val variations: Map? = null, + val appdata: Appdata? = null, + @Json(name = "content_info") val contentInfo: ContentInfo? = null, + val metadata: Map? = null +) : Parcelable { fun hasOriginalFileUrl() = originalFileUrl != null @@ -82,66 +84,198 @@ data class UploadcareFile(val uuid: String, } override fun toString(): String { - val newline = System.getProperty("line.separator") return StringBuilder().apply { - append(UploadcareFile::class.simpleName).append(newline) - append("File id: $uuid").append(newline) - append("Url: $url").append(newline) - append("Size: $size").append(newline) - append("Mime type: $mimeType").append(newline) - append("is Ready: $isReady").append(newline) - append("is Image: $isImage").append(newline) - append("Original Filename: $originalFilename").append(newline) - append("Original File Url: $originalFileUrl").append(newline) - append("Date uploaded: $datetimeUploaded").append(newline) - append("is Stored: ${isStored()}").append(newline) - append("Date stored: $datetimeStored").append(newline) - append("is Removed: ${isRemoved()}").append(newline) - append("Date removed: $datetimeRemoved").append(newline) - append("Source: $source").append(newline) - append("Image Info: $imageInfo").append(newline) - append("Video Info: $videoInfo").append(newline) - append("Variations: $variations").append(newline) - append("Rekognition Info: $rekognitionInfo").append(newline) + appendLine(UploadcareFile::class.simpleName) + appendLine("File id: $uuid") + appendLine("Url: $url") + appendLine("Size: $size") + appendLine("Mime type: $mimeType") + appendLine("is Ready: $isReady") + appendLine("is Image: $isImage") + appendLine("Original Filename: $originalFilename") + appendLine("Original File Url: $originalFileUrl") + appendLine("Date uploaded: $datetimeUploaded") + appendLine("is Stored: ${isStored()}") + appendLine("Date stored: $datetimeStored") + appendLine("is Removed: ${isRemoved()}") + appendLine("Date removed: $datetimeRemoved") + appendLine("Source: $source") + appendLine("Variations: $variations") + appendLine("Appdata: $appdata") + appendLine("Content info: $contentInfo") + appendLine("Metadata: $metadata") }.toString() } } @Parcelize -data class ImageInfo(val format: String, - val height: Int, - val width: Int, - val orientation: Int? = null, - val sequence: Boolean? = false, - @Json(name = "color_mode") val colorMode: ColorMode? = null, - @Json(name = "geo_location") val geoLocation: GeoLocation? = null, - @Json(name = "datetime_original") val datetimeOriginal: String? = null, - val dpi: List? = null) : Parcelable +data class ContentInfo( + val mime: Mime? = null, + val image: ImageInfo? = null, + val video: VideoInfo? = null +) : Parcelable + +@Parcelize +data class Mime( + val mime: String, + val type: String, + val subtype: String +) : Parcelable + +@Parcelize +data class ImageInfo( + val format: String, + val height: Int, + val width: Int, + val orientation: Int? = null, + val sequence: Boolean? = false, + @Json(name = "color_mode") val colorMode: ColorMode? = null, + @Json(name = "geo_location") val geoLocation: GeoLocation? = null, + @Json(name = "datetime_original") val datetimeOriginal: String? = null, + val dpi: List? = null +) : Parcelable @Parcelize -data class VideoInfo(val format: String, - val duration: Int, - val bitrate: Int, - val audio: Audio? = null, - val video: Video) : Parcelable +data class VideoInfo( + val format: String, + val duration: Int, + val bitrate: Int, + val audio: List