From c3c9c253f7224a1ad65c783bb2baeb098b46262b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 10 Apr 2026 07:30:42 +0000 Subject: [PATCH] Update SDK to version v3.61.1 - Generated from OpenAPI spec version v3.61.1 - Auto-generated by GitHub Actions --- .sdk-version | 2 +- README.md | 6 +- build.gradle | 4 +- build.sbt | 2 +- docs/AuthenticationUsersApi.md | 71 ++++ docs/SubmitUserFeedbackRequest.md | 15 + pom.xml | 2 +- .../ai/reveng/api/AuthenticationUsersApi.java | 132 +++++++ .../java/ai/reveng/invoker/ApiClient.java | 2 +- .../java/ai/reveng/invoker/Configuration.java | 2 +- src/main/java/ai/reveng/invoker/JSON.java | 1 + .../model/SubmitUserFeedbackRequest.java | 364 ++++++++++++++++++ 12 files changed, 594 insertions(+), 9 deletions(-) create mode 100644 docs/SubmitUserFeedbackRequest.md create mode 100644 src/main/java/ai/reveng/model/SubmitUserFeedbackRequest.java diff --git a/.sdk-version b/.sdk-version index ed4d981..533191e 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v3.60.0 +v3.61.1 diff --git a/README.md b/README.md index 90302d9..2b875ed 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Add this dependency to your project's POM: ai.reveng sdk - 3.60.0 + 3.61.1 compile ``` @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation "ai.reveng:sdk:3.60.0" + implementation "ai.reveng:sdk:3.61.1" } ``` @@ -122,6 +122,7 @@ Class | Method | HTTP request | Description *AuthenticationUsersApi* | [**getUserActivity**](docs/AuthenticationUsersApi.md#getUserActivity) | **GET** /v2/users/activity | Get auth user activity *AuthenticationUsersApi* | [**getUserComments**](docs/AuthenticationUsersApi.md#getUserComments) | **GET** /v2/users/me/comments | Get comments by user *AuthenticationUsersApi* | [**loginUser**](docs/AuthenticationUsersApi.md#loginUser) | **POST** /v2/auth/login | Authenticate a user +*AuthenticationUsersApi* | [**submitUserFeedback**](docs/AuthenticationUsersApi.md#submitUserFeedback) | **POST** /v2/users/feedback | Submit feedback about the application *BinariesApi* | [**downloadZippedBinary**](docs/BinariesApi.md#downloadZippedBinary) | **GET** /v2/binaries/{binary_id}/download-zipped | Downloads a zipped binary with password protection *BinariesApi* | [**getBinaryAdditionalDetails**](docs/BinariesApi.md#getBinaryAdditionalDetails) | **GET** /v2/binaries/{binary_id}/additional-details | Gets the additional details of a binary *BinariesApi* | [**getBinaryAdditionalDetailsStatus**](docs/BinariesApi.md#getBinaryAdditionalDetailsStatus) | **GET** /v2/binaries/{binary_id}/additional-details/status | Gets the status of the additional details task for a binary @@ -481,6 +482,7 @@ Class | Method | HTTP request | Description - [StringSource](docs/StringSource.md) - [Structure](docs/Structure.md) - [StructureMember](docs/StructureMember.md) + - [SubmitUserFeedbackRequest](docs/SubmitUserFeedbackRequest.md) - [Symbols](docs/Symbols.md) - [TTPS](docs/TTPS.md) - [TTPSAttack](docs/TTPSAttack.md) diff --git a/build.gradle b/build.gradle index 9d11e05..e3c0e28 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'ai.reveng' -version = '3.60.0' +version = '3.61.1' @@ -171,7 +171,7 @@ mavenPublishing { publishToMavenCentral(true) signAllPublications() - coordinates("ai.reveng", "sdk", "3.60.0") + coordinates("ai.reveng", "sdk", "3.61.1") pom { name = "sdk" diff --git a/build.sbt b/build.sbt index 6eba656..a91f5e8 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "ai.reveng", name := "sdk", - version := "3.60.0", + version := "3.61.1", scalaVersion := "2.11.12", scalacOptions ++= Seq("-feature"), compile / javacOptions ++= Seq("-Xlint:deprecation"), diff --git a/docs/AuthenticationUsersApi.md b/docs/AuthenticationUsersApi.md index 0868a64..f542f43 100644 --- a/docs/AuthenticationUsersApi.md +++ b/docs/AuthenticationUsersApi.md @@ -9,6 +9,7 @@ All URIs are relative to *https://api.reveng.ai* | [**getUserActivity**](AuthenticationUsersApi.md#getUserActivity) | **GET** /v2/users/activity | Get auth user activity | | [**getUserComments**](AuthenticationUsersApi.md#getUserComments) | **GET** /v2/users/me/comments | Get comments by user | | [**loginUser**](AuthenticationUsersApi.md#loginUser) | **POST** /v2/auth/login | Authenticate a user | +| [**submitUserFeedback**](AuthenticationUsersApi.md#submitUserFeedback) | **POST** /v2/users/feedback | Submit feedback about the application | @@ -358,3 +359,73 @@ public class Example { | **422** | Invalid request parameters | - | | **401** | Invalid credentials | - | + +# **submitUserFeedback** +> BaseResponse submitUserFeedback(submitUserFeedbackRequest) + +Submit feedback about the application + +Submits feedback about the application and forwards it to the RevEng.ai project management tool. + +### Example +```java +// Import classes: +import ai.reveng.invoker.ApiClient; +import ai.reveng.invoker.ApiException; +import ai.reveng.invoker.Configuration; +import ai.reveng.invoker.auth.*; +import ai.reveng.invoker.models.*; +import ai.reveng.api.AuthenticationUsersApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://api.reveng.ai"); + + // Configure API key authorization: APIKey + ApiKeyAuth APIKey = (ApiKeyAuth) defaultClient.getAuthentication("APIKey"); + APIKey.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //APIKey.setApiKeyPrefix("Token"); + + AuthenticationUsersApi apiInstance = new AuthenticationUsersApi(defaultClient); + SubmitUserFeedbackRequest submitUserFeedbackRequest = new SubmitUserFeedbackRequest(); // SubmitUserFeedbackRequest | + try { + BaseResponse result = apiInstance.submitUserFeedback(submitUserFeedbackRequest); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AuthenticationUsersApi#submitUserFeedback"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **submitUserFeedbackRequest** | [**SubmitUserFeedbackRequest**](SubmitUserFeedbackRequest.md)| | | + +### Return type + +[**BaseResponse**](BaseResponse.md) + +### Authorization + +[APIKey](../README.md#APIKey) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful Response | - | +| **422** | Invalid request parameters | - | + diff --git a/docs/SubmitUserFeedbackRequest.md b/docs/SubmitUserFeedbackRequest.md new file mode 100644 index 0000000..6662fd9 --- /dev/null +++ b/docs/SubmitUserFeedbackRequest.md @@ -0,0 +1,15 @@ + + +# SubmitUserFeedbackRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**currentRoute** | **String** | The route from where the feedback was submitted | | +|**feedback** | **String** | The user's feedback | | +|**screenCaptureUrl** | **String** | | [optional] | + + + diff --git a/pom.xml b/pom.xml index 7dc8b12..83074ba 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ sdk jar sdk - 3.60.0 + 3.61.1 https://github.com/RevEngAI/sdk-java Java SDK for the RevEng.AI API diff --git a/src/main/java/ai/reveng/api/AuthenticationUsersApi.java b/src/main/java/ai/reveng/api/AuthenticationUsersApi.java index c772851..5afaba5 100644 --- a/src/main/java/ai/reveng/api/AuthenticationUsersApi.java +++ b/src/main/java/ai/reveng/api/AuthenticationUsersApi.java @@ -33,6 +33,7 @@ import ai.reveng.model.BaseResponseListUserActivityResponse; import ai.reveng.model.BaseResponseLoginResponse; import ai.reveng.model.LoginRequest; +import ai.reveng.model.SubmitUserFeedbackRequest; import java.lang.reflect.Type; import java.util.ArrayList; @@ -754,4 +755,135 @@ public okhttp3.Call loginUserAsync(@javax.annotation.Nonnull LoginRequest loginR localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for submitUserFeedback + * @param submitUserFeedbackRequest (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ */ + public okhttp3.Call submitUserFeedbackCall(@javax.annotation.Nonnull SubmitUserFeedbackRequest submitUserFeedbackRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = submitUserFeedbackRequest; + + // create path and map variables + String localVarPath = "/v2/users/feedback"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "APIKey" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call submitUserFeedbackValidateBeforeCall(@javax.annotation.Nonnull SubmitUserFeedbackRequest submitUserFeedbackRequest, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'submitUserFeedbackRequest' is set + if (submitUserFeedbackRequest == null) { + throw new ApiException("Missing the required parameter 'submitUserFeedbackRequest' when calling submitUserFeedback(Async)"); + } + + return submitUserFeedbackCall(submitUserFeedbackRequest, _callback); + + } + + /** + * Submit feedback about the application + * Submits feedback about the application and forwards it to the RevEng.ai project management tool. + * @param submitUserFeedbackRequest (required) + * @return BaseResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ */ + public BaseResponse submitUserFeedback(@javax.annotation.Nonnull SubmitUserFeedbackRequest submitUserFeedbackRequest) throws ApiException { + ApiResponse localVarResp = submitUserFeedbackWithHttpInfo(submitUserFeedbackRequest); + return localVarResp.getData(); + } + + /** + * Submit feedback about the application + * Submits feedback about the application and forwards it to the RevEng.ai project management tool. + * @param submitUserFeedbackRequest (required) + * @return ApiResponse<BaseResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ */ + public ApiResponse submitUserFeedbackWithHttpInfo(@javax.annotation.Nonnull SubmitUserFeedbackRequest submitUserFeedbackRequest) throws ApiException { + okhttp3.Call localVarCall = submitUserFeedbackValidateBeforeCall(submitUserFeedbackRequest, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Submit feedback about the application (asynchronously) + * Submits feedback about the application and forwards it to the RevEng.ai project management tool. + * @param submitUserFeedbackRequest (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 Successful Response -
422 Invalid request parameters -
+ */ + public okhttp3.Call submitUserFeedbackAsync(@javax.annotation.Nonnull SubmitUserFeedbackRequest submitUserFeedbackRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = submitUserFeedbackValidateBeforeCall(submitUserFeedbackRequest, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } } diff --git a/src/main/java/ai/reveng/invoker/ApiClient.java b/src/main/java/ai/reveng/invoker/ApiClient.java index 38449cc..21a7cfe 100644 --- a/src/main/java/ai/reveng/invoker/ApiClient.java +++ b/src/main/java/ai/reveng/invoker/ApiClient.java @@ -146,7 +146,7 @@ protected void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/3.60.0/java"); + setUserAgent("OpenAPI-Generator/3.61.1/java"); authentications = new HashMap(); } diff --git a/src/main/java/ai/reveng/invoker/Configuration.java b/src/main/java/ai/reveng/invoker/Configuration.java index d757083..4f60078 100644 --- a/src/main/java/ai/reveng/invoker/Configuration.java +++ b/src/main/java/ai/reveng/invoker/Configuration.java @@ -18,7 +18,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Configuration { - public static final String VERSION = "3.60.0"; + public static final String VERSION = "3.61.1"; private static final AtomicReference defaultApiClient = new AtomicReference<>(); private static volatile Supplier apiClientFactory = ApiClient::new; diff --git a/src/main/java/ai/reveng/invoker/JSON.java b/src/main/java/ai/reveng/invoker/JSON.java index 131ffd7..cb5bd0f 100644 --- a/src/main/java/ai/reveng/invoker/JSON.java +++ b/src/main/java/ai/reveng/invoker/JSON.java @@ -362,6 +362,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StringFunctions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Structure.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.StructureMember.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SubmitUserFeedbackRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.Symbols.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TTPS.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.TTPSAttack.CustomTypeAdapterFactory()); diff --git a/src/main/java/ai/reveng/model/SubmitUserFeedbackRequest.java b/src/main/java/ai/reveng/model/SubmitUserFeedbackRequest.java new file mode 100644 index 0000000..cd9c6e8 --- /dev/null +++ b/src/main/java/ai/reveng/model/SubmitUserFeedbackRequest.java @@ -0,0 +1,364 @@ +/* + * RevEng.AI API + * RevEng.AI is an AI-powered binary analysis platform for reverse engineering and malware analysis. It provides similarity search across executable binaries and functions, AI-driven decompilation, dynamic execution analysis, firmware unpacking, and integration with external threat intelligence sources like VirusTotal. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package ai.reveng.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import ai.reveng.invoker.JSON; + +/** + * SubmitUserFeedbackRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SubmitUserFeedbackRequest { + public static final String SERIALIZED_NAME_CURRENT_ROUTE = "current_route"; + @SerializedName(SERIALIZED_NAME_CURRENT_ROUTE) + @javax.annotation.Nonnull + private String currentRoute; + + public static final String SERIALIZED_NAME_FEEDBACK = "feedback"; + @SerializedName(SERIALIZED_NAME_FEEDBACK) + @javax.annotation.Nonnull + private String feedback; + + public static final String SERIALIZED_NAME_SCREEN_CAPTURE_URL = "screen_capture_url"; + @SerializedName(SERIALIZED_NAME_SCREEN_CAPTURE_URL) + @javax.annotation.Nullable + private String screenCaptureUrl; + + public SubmitUserFeedbackRequest() { + } + + public SubmitUserFeedbackRequest currentRoute(@javax.annotation.Nonnull String currentRoute) { + this.currentRoute = currentRoute; + return this; + } + + /** + * The route from where the feedback was submitted + * @return currentRoute + */ + @javax.annotation.Nonnull + public String getCurrentRoute() { + return currentRoute; + } + + public void setCurrentRoute(@javax.annotation.Nonnull String currentRoute) { + this.currentRoute = currentRoute; + } + + + public SubmitUserFeedbackRequest feedback(@javax.annotation.Nonnull String feedback) { + this.feedback = feedback; + return this; + } + + /** + * The user's feedback + * @return feedback + */ + @javax.annotation.Nonnull + public String getFeedback() { + return feedback; + } + + public void setFeedback(@javax.annotation.Nonnull String feedback) { + this.feedback = feedback; + } + + + public SubmitUserFeedbackRequest screenCaptureUrl(@javax.annotation.Nullable String screenCaptureUrl) { + this.screenCaptureUrl = screenCaptureUrl; + return this; + } + + /** + * Get screenCaptureUrl + * @return screenCaptureUrl + */ + @javax.annotation.Nullable + public String getScreenCaptureUrl() { + return screenCaptureUrl; + } + + public void setScreenCaptureUrl(@javax.annotation.Nullable String screenCaptureUrl) { + this.screenCaptureUrl = screenCaptureUrl; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SubmitUserFeedbackRequest instance itself + */ + public SubmitUserFeedbackRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubmitUserFeedbackRequest submitUserFeedbackRequest = (SubmitUserFeedbackRequest) o; + return Objects.equals(this.currentRoute, submitUserFeedbackRequest.currentRoute) && + Objects.equals(this.feedback, submitUserFeedbackRequest.feedback) && + Objects.equals(this.screenCaptureUrl, submitUserFeedbackRequest.screenCaptureUrl)&& + Objects.equals(this.additionalProperties, submitUserFeedbackRequest.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(currentRoute, feedback, screenCaptureUrl, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubmitUserFeedbackRequest {\n"); + sb.append(" currentRoute: ").append(toIndentedString(currentRoute)).append("\n"); + sb.append(" feedback: ").append(toIndentedString(feedback)).append("\n"); + sb.append(" screenCaptureUrl: ").append(toIndentedString(screenCaptureUrl)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("current_route", "feedback", "screen_capture_url")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("current_route", "feedback")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SubmitUserFeedbackRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SubmitUserFeedbackRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SubmitUserFeedbackRequest is not found in the empty JSON string", SubmitUserFeedbackRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SubmitUserFeedbackRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("current_route").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `current_route` to be a primitive type in the JSON string but got `%s`", jsonObj.get("current_route").toString())); + } + if (!jsonObj.get("feedback").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `feedback` to be a primitive type in the JSON string but got `%s`", jsonObj.get("feedback").toString())); + } + if ((jsonObj.get("screen_capture_url") != null && !jsonObj.get("screen_capture_url").isJsonNull()) && !jsonObj.get("screen_capture_url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `screen_capture_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("screen_capture_url").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SubmitUserFeedbackRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SubmitUserFeedbackRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SubmitUserFeedbackRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SubmitUserFeedbackRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SubmitUserFeedbackRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SubmitUserFeedbackRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SubmitUserFeedbackRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of SubmitUserFeedbackRequest + * @throws IOException if the JSON string is invalid with respect to SubmitUserFeedbackRequest + */ + public static SubmitUserFeedbackRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SubmitUserFeedbackRequest.class); + } + + /** + * Convert an instance of SubmitUserFeedbackRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +