fun.freechat.client.model.UserDetailsDTO Maven / Gradle / Ivy
/*
* FreeChat OpenAPI Definition
* # FreeChat: Create Some Friends for Yourself with AI English | [中文版](https://github.com/freechat-fun/freechat/blob/main/README.zh-CN.md) ## Introduction Welcome! FreeChat aims to build a cloud-native, robust, and quickly commercializable enterprise-level AI virtual character platform. It also serves as a prompt engineering platform. ## Features - Primarily uses Java and emphasizes **security, robustness, scalability, traceability, and maintainability**. - Boasts **account systems and permission management**, supporting OAuth2 authentication. Introduces the \"organization\" concept and related permission constraint functions. - Extensively employs distributed technologies and caching to support **high concurrency** access. - Provides flexible character customization options, supports direct intervention in prompts, and supports **configuring multiple backends for each character**. - **Offers a comprehensive range of Open APIs**, with more than 180 interfaces and provides java/python/typescript SDKs. These interfaces enable easy construction of systems for end-users. - Supports setting **RAG** (Retrieval Augmented Generation) for characters. - Supports **long-term memory, preset memory** for characters. - Supports characters evoking **proactive chat**. - Supports setting **quota limits** for characters. - Supports characters **importing and exporting**. - Supports individual **debugging and sharing prompts**. ## Snapshots ### On PC #### Home Page ![Home Page Snapshot](/img/snapshot_w1.jpg) #### Development View ![Development View Snapshot](/img/snapshot_w2.jpg) #### Chat View ![Chat View Snapshot](/img/snapshot_w3.jpg) ### On Mobile ![Chat Snapshot 1](/img/snapshot_m1.jpg) ![Chat Snapshot 2](/img/snapshot_m2.jpg)
![Chat Snapshot 3](/img/snapshot_m3.jpg) ![Chat Snapshot 4](/img/snapshot_m4.jpg) ## Character Design ```mermaid flowchart TD A(Character) --> B(Profile) A --> C(Knowledge/RAG) A --> D(Album) A --> E(Backend-1) A --> F(Backend-n...) E --> G(Message Window) E --> H(Long Term Memory Settings) E --> I(Quota Limit) E --> J(Chat Prompt Task) E --> K(Greeting Prompt Task) E --> L(Moderation Settings) J --> M(Model & Parameters) J --> N(API Keys) J --> O(Prompt Refence) J --> P(Tool Specifications) O --> Q(Template) O --> R(Variables) O --> S(Version) O --> T(...) style K stroke-dasharray: 5, 5 style L stroke-dasharray: 5, 5 style P stroke-dasharray: 5, 5 ``` After setting up an unified persona and knowledge for a character, different backends can be configured. For example, different model may be adopted for different users based on cost considerations. ## How to Play ### Online Website You can visit [freechat.fun](https://www.freechat.fun) to experience FreeChat. Share your designed AI character! ### Running in a Kubernetes Cluster FreeChat is dedicated to the principles of cloud-native design. If you have a Kubernetes cluster, you can deploy FreeChat to your environment by following these steps: 1. Put the Kubernetes configuration file in the `configs/helm/` directory, named `kube-private.conf`. 2. Place the Helm configuration file in the same directory, named `values-private.yaml`. Make sure to reference the default `values.yaml` and customize the variables as needed. 3. Switch to the `scripts/` directory. 4. If needed, run `install-in.sh` to deploy `ingress-nginx` on the Kubernetes cluster. 5. If needed, run `install-cm.sh` to deploy `cert-manager` on the Kubernetes cluster, which automatically issues certificates for domains specified in `ingress.hosts`. 6. Run `install-pvc.sh` to install PersistentVolumeClaim resources. > By default, FreeChat operates files by accessing the \"local file system.\" You may want to use high-availability distributed storage in the cloud. As a cloud-native-designed system, we recommend interfacing through Kubernetes CSI to avoid individually adapting storage products for each cloud platform. Most cloud service providers offer cloud storage drivers for Kubernetes, with a series of predefined StorageClass resources. Please choose the appropriate configuration according to your actual needs and set it in Helm's `global.storageClass` option. > > *In the future, FreeChat may be refactored to use MinIO's APIs directly, as it is now installed in the Kubernetes cluster as a dependency (serving Milvus).* 7. Run `install.sh` script to install FreeChat and its dependencies. 8. FreeChat aims to provide Open API services. If you like the interactive experience of [freechat.fun](https://freechat.fun), run `install-web.sh` to deploy the front-end application. 9. Run `restart.sh` to restart the service. 10. If you modified any Helm configuration files, use `upgrade.sh` to update the corresponding Kubernetes resources. 11. To remove specific resources, run the `uninstall*.sh` script corresponding to the resource you want to uninstall. As a cloud-native application, the services FreeChat relies on are obtained and deployed to your cluster through the helm repository. If you prefer cloud services with SLA (Service Level Agreement) guarantees, simply make the relevant settings in `configs/helm/values-private.yaml`: ```yaml mysql: deployment: enabled: false url: auth: rootPassword: username: password: redis: deployment: enabled: false url: auth: password: milvus: deployment: enabled: false url: milvus: auth: token: ``` With this, FreeChat will not automatically install these services, but rather use the configuration information to connect directly. If your Kubernetes cluster does not have a standalone monitoring system, you can enable the following switch. This will install Prometheus and Grafana services in the same namespace, dedicated to monitoring the status of the services under the FreeChat application: ```yaml prometheus: deployment: enabled: true grafana: deployment: enabled: true ``` ### Running Locally You can also run FreeChat locally. Currently supported on MacOS and Linux (although only tested on MacOS). You need to install the Docker toolset and have a network that can access [Docker Hub](https://hub.docker.com/). Once ready, enter the `scripts/` directory and run `local-run.sh`, which will download and run the necessary docker containers. After a successful startup, you can access `http://localhost` via a browser to see the locally running freechat.fun. The built-in administrator username and password are \"admin:freechat\". Use `local-run.sh --help` to view the supported options of the script. Good luck! ### Running in an IDE To run FreeChat in an IDE, you need to start all dependent services first but do not need to run the container for the FreeChat application itself. You can execute the `scripts/local-deps.sh` script to start services like `MySQL`, `Redis`, `Milvus`, etc., locally. Once done, open and debug `freechat-start/src/main/java/fun/freechat/Application.java`。Make sure you have set the following startup VM options: ```shell -Dspring.config.location=classpath:/application.yml,classpath:/application-local.yml \\ -DAPP_HOME=local-data/freechat \\ -Dspring.profiles.active=local ``` ### Use SDK #### Java - **Dependency** ```xml fun.freechat freechat-sdk ${freechat-sdk.version} ``` - **Example** ```java import fun.freechat.client.ApiClient; import fun.freechat.client.ApiException; import fun.freechat.client.Configuration; import fun.freechat.client.api.AccountApi; import fun.freechat.client.auth.ApiKeyAuth; import fun.freechat.client.model.UserDetailsDTO; public class AccountClientExample { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath(\"https://freechat.fun\"); // Configure HTTP bearer authorization: bearerAuth HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication(\"bearerAuth\"); bearerAuth.setBearerToken(\"FREECHAT_TOKEN\"); AccountApi apiInstance = new AccountApi(defaultClient); try { UserDetailsDTO result = apiInstance.getUserDetails(); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } } } ``` #### Python - **Installation** ```shell pip install freechat-sdk ``` - **Example** ```python import freechat_sdk from freechat_sdk.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://freechat.fun # See configuration.py for a list of all supported configuration parameters. configuration = freechat_sdk.Configuration( host = \"https://freechat.fun\" ) # Configure Bearer authorization: bearerAuth configuration = freechat_sdk.Configuration( access_token = os.environ[\"FREECHAT_TOKEN\"] ) # Enter a context with an instance of the API client with freechat_sdk.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = freechat_sdk.AccountApi(api_client) try: details = api_instance.get_user_details() pprint(details) except ApiException as e: print(\"Exception when calling AccountClient->get_user_details: %s\\n\" % e) ``` #### TypeScript - **Installation** ```shell npm install freechat-sdk --save ``` - **Example** Refer to [FreeChatApiContext.tsx](https://github.com/freechat-fun/freechat/blob/main/freechat-web/src/contexts/FreeChatApiProvider.tsx) ## System Dependencies | | Projects | ---- | ---- | Application Framework | [Spring Boot](https://spring.io/projects/spring-boot/) | LLM Framework | [LangChain4j](https://docs.langchain4j.dev/) | Model Providers | [OpenAI](https://platform.openai.com/), [Azure OpenAI](https://oai.azure.com/), [DashScope(Alibaba)](https://dashscope.aliyun.com/) | Database Systems | [MySQL](https://www.mysql.com/), [Redis](https://redis.io/), [Milvus](https://milvus.io/) | Monitoring & Alerting | [Prometheus](https://prometheus.io/), [Grafana](https://grafana.com/) | OpenAPI Tools | [Springdoc-openapi](https://springdoc.org/), [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator), [OpenAPI Explorer](https://github.com/Authress-Engineering/openapi-explorer) ## Collaboration ### Application Integration The FreeChat system is entirely oriented towards Open APIs. The site [freechat.fun](https://freechat.fun) is developed using its TypeScript SDK and hardly depends on private interfaces. You can use these online interfaces to develop your own applications or sites, making them fit your preferences. Currently, FreeChat is completely free with no paid plans (after all, users use their own API Key to call LLM services). ### Model Integration FreeChat aims to explore AI virtual character technology with anthropomorphic characteristics. So far, it supports model services from OpenAI GPT and Alibaba Qwen series models. However, we are more interested in supporting models that are under research and can endow AI with more personality traits. If you are researching this area and hope FreeChat supports your model, please contact us. We look forward to AI technology helping people create their own \"soul mates\" in the future.
*
* The version of the OpenAPI document: 1.4.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package fun.freechat.client.model;
import java.util.Objects;
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.time.OffsetDateTime;
import java.util.Arrays;
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.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import fun.freechat.client.JSON;
/**
* Account detailed information
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.7.0")
public class UserDetailsDTO {
public static final String SERIALIZED_NAME_REQUEST_ID = "requestId";
@SerializedName(SERIALIZED_NAME_REQUEST_ID)
private String requestId;
public static final String SERIALIZED_NAME_USERNAME = "username";
@SerializedName(SERIALIZED_NAME_USERNAME)
private String username;
public static final String SERIALIZED_NAME_NICKNAME = "nickname";
@SerializedName(SERIALIZED_NAME_NICKNAME)
private String nickname;
public static final String SERIALIZED_NAME_GIVEN_NAME = "givenName";
@SerializedName(SERIALIZED_NAME_GIVEN_NAME)
private String givenName;
public static final String SERIALIZED_NAME_MIDDLE_NAME = "middleName";
@SerializedName(SERIALIZED_NAME_MIDDLE_NAME)
private String middleName;
public static final String SERIALIZED_NAME_FAMILY_NAME = "familyName";
@SerializedName(SERIALIZED_NAME_FAMILY_NAME)
private String familyName;
public static final String SERIALIZED_NAME_PREFERRED_USERNAME = "preferredUsername";
@SerializedName(SERIALIZED_NAME_PREFERRED_USERNAME)
private String preferredUsername;
public static final String SERIALIZED_NAME_PROFILE = "profile";
@SerializedName(SERIALIZED_NAME_PROFILE)
private String profile;
public static final String SERIALIZED_NAME_PICTURE = "picture";
@SerializedName(SERIALIZED_NAME_PICTURE)
private String picture;
public static final String SERIALIZED_NAME_WEBSITE = "website";
@SerializedName(SERIALIZED_NAME_WEBSITE)
private String website;
public static final String SERIALIZED_NAME_EMAIL = "email";
@SerializedName(SERIALIZED_NAME_EMAIL)
private String email;
public static final String SERIALIZED_NAME_GENDER = "gender";
@SerializedName(SERIALIZED_NAME_GENDER)
private String gender;
public static final String SERIALIZED_NAME_BIRTHDATE = "birthdate";
@SerializedName(SERIALIZED_NAME_BIRTHDATE)
private OffsetDateTime birthdate;
public static final String SERIALIZED_NAME_ZONEINFO = "zoneinfo";
@SerializedName(SERIALIZED_NAME_ZONEINFO)
private String zoneinfo;
public static final String SERIALIZED_NAME_LOCALE = "locale";
@SerializedName(SERIALIZED_NAME_LOCALE)
private String locale;
public static final String SERIALIZED_NAME_PHONE_NUMBER = "phoneNumber";
@SerializedName(SERIALIZED_NAME_PHONE_NUMBER)
private String phoneNumber;
public static final String SERIALIZED_NAME_UPDATED_AT = "updatedAt";
@SerializedName(SERIALIZED_NAME_UPDATED_AT)
private OffsetDateTime updatedAt;
public static final String SERIALIZED_NAME_PLATFORM = "platform";
@SerializedName(SERIALIZED_NAME_PLATFORM)
private String platform;
public static final String SERIALIZED_NAME_ENABLED = "enabled";
@SerializedName(SERIALIZED_NAME_ENABLED)
private Boolean enabled;
public static final String SERIALIZED_NAME_LOCKED = "locked";
@SerializedName(SERIALIZED_NAME_LOCKED)
private Boolean locked;
public static final String SERIALIZED_NAME_EXPIRES_AT = "expiresAt";
@SerializedName(SERIALIZED_NAME_EXPIRES_AT)
private OffsetDateTime expiresAt;
public static final String SERIALIZED_NAME_PASSWORD_EXPIRES_AT = "passwordExpiresAt";
@SerializedName(SERIALIZED_NAME_PASSWORD_EXPIRES_AT)
private OffsetDateTime passwordExpiresAt;
public static final String SERIALIZED_NAME_ADDRESS = "address";
@SerializedName(SERIALIZED_NAME_ADDRESS)
private String address;
public UserDetailsDTO() {
}
public UserDetailsDTO requestId(String requestId) {
this.requestId = requestId;
return this;
}
/**
* Request identifier
* @return requestId
*/
@javax.annotation.Nullable
public String getRequestId() {
return requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public UserDetailsDTO username(String username) {
this.username = username;
return this;
}
/**
* Get username
* @return username
*/
@javax.annotation.Nullable
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public UserDetailsDTO nickname(String nickname) {
this.nickname = nickname;
return this;
}
/**
* Get nickname
* @return nickname
*/
@javax.annotation.Nullable
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public UserDetailsDTO givenName(String givenName) {
this.givenName = givenName;
return this;
}
/**
* Get givenName
* @return givenName
*/
@javax.annotation.Nullable
public String getGivenName() {
return givenName;
}
public void setGivenName(String givenName) {
this.givenName = givenName;
}
public UserDetailsDTO middleName(String middleName) {
this.middleName = middleName;
return this;
}
/**
* Get middleName
* @return middleName
*/
@javax.annotation.Nullable
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public UserDetailsDTO familyName(String familyName) {
this.familyName = familyName;
return this;
}
/**
* Get familyName
* @return familyName
*/
@javax.annotation.Nullable
public String getFamilyName() {
return familyName;
}
public void setFamilyName(String familyName) {
this.familyName = familyName;
}
public UserDetailsDTO preferredUsername(String preferredUsername) {
this.preferredUsername = preferredUsername;
return this;
}
/**
* Get preferredUsername
* @return preferredUsername
*/
@javax.annotation.Nullable
public String getPreferredUsername() {
return preferredUsername;
}
public void setPreferredUsername(String preferredUsername) {
this.preferredUsername = preferredUsername;
}
public UserDetailsDTO profile(String profile) {
this.profile = profile;
return this;
}
/**
* Get profile
* @return profile
*/
@javax.annotation.Nullable
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
public UserDetailsDTO picture(String picture) {
this.picture = picture;
return this;
}
/**
* Get picture
* @return picture
*/
@javax.annotation.Nullable
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public UserDetailsDTO website(String website) {
this.website = website;
return this;
}
/**
* Get website
* @return website
*/
@javax.annotation.Nullable
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
public UserDetailsDTO email(String email) {
this.email = email;
return this;
}
/**
* Get email
* @return email
*/
@javax.annotation.Nullable
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public UserDetailsDTO gender(String gender) {
this.gender = gender;
return this;
}
/**
* Get gender
* @return gender
*/
@javax.annotation.Nullable
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public UserDetailsDTO birthdate(OffsetDateTime birthdate) {
this.birthdate = birthdate;
return this;
}
/**
* Get birthdate
* @return birthdate
*/
@javax.annotation.Nullable
public OffsetDateTime getBirthdate() {
return birthdate;
}
public void setBirthdate(OffsetDateTime birthdate) {
this.birthdate = birthdate;
}
public UserDetailsDTO zoneinfo(String zoneinfo) {
this.zoneinfo = zoneinfo;
return this;
}
/**
* Get zoneinfo
* @return zoneinfo
*/
@javax.annotation.Nullable
public String getZoneinfo() {
return zoneinfo;
}
public void setZoneinfo(String zoneinfo) {
this.zoneinfo = zoneinfo;
}
public UserDetailsDTO locale(String locale) {
this.locale = locale;
return this;
}
/**
* Get locale
* @return locale
*/
@javax.annotation.Nullable
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public UserDetailsDTO phoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
return this;
}
/**
* Get phoneNumber
* @return phoneNumber
*/
@javax.annotation.Nullable
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public UserDetailsDTO updatedAt(OffsetDateTime updatedAt) {
this.updatedAt = updatedAt;
return this;
}
/**
* Get updatedAt
* @return updatedAt
*/
@javax.annotation.Nullable
public OffsetDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(OffsetDateTime updatedAt) {
this.updatedAt = updatedAt;
}
public UserDetailsDTO platform(String platform) {
this.platform = platform;
return this;
}
/**
* Get platform
* @return platform
*/
@javax.annotation.Nullable
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public UserDetailsDTO enabled(Boolean enabled) {
this.enabled = enabled;
return this;
}
/**
* Get enabled
* @return enabled
*/
@javax.annotation.Nullable
public Boolean isEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public UserDetailsDTO locked(Boolean locked) {
this.locked = locked;
return this;
}
/**
* Get locked
* @return locked
*/
@javax.annotation.Nullable
public Boolean isLocked() {
return locked;
}
public void setLocked(Boolean locked) {
this.locked = locked;
}
public UserDetailsDTO expiresAt(OffsetDateTime expiresAt) {
this.expiresAt = expiresAt;
return this;
}
/**
* Get expiresAt
* @return expiresAt
*/
@javax.annotation.Nullable
public OffsetDateTime getExpiresAt() {
return expiresAt;
}
public void setExpiresAt(OffsetDateTime expiresAt) {
this.expiresAt = expiresAt;
}
public UserDetailsDTO passwordExpiresAt(OffsetDateTime passwordExpiresAt) {
this.passwordExpiresAt = passwordExpiresAt;
return this;
}
/**
* Get passwordExpiresAt
* @return passwordExpiresAt
*/
@javax.annotation.Nullable
public OffsetDateTime getPasswordExpiresAt() {
return passwordExpiresAt;
}
public void setPasswordExpiresAt(OffsetDateTime passwordExpiresAt) {
this.passwordExpiresAt = passwordExpiresAt;
}
public UserDetailsDTO address(String address) {
this.address = address;
return this;
}
/**
* Get address
* @return address
*/
@javax.annotation.Nullable
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
/**
* 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 UserDetailsDTO instance itself
*/
public UserDetailsDTO 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;
}
UserDetailsDTO userDetailsDTO = (UserDetailsDTO) o;
return Objects.equals(this.requestId, userDetailsDTO.requestId) &&
Objects.equals(this.username, userDetailsDTO.username) &&
Objects.equals(this.nickname, userDetailsDTO.nickname) &&
Objects.equals(this.givenName, userDetailsDTO.givenName) &&
Objects.equals(this.middleName, userDetailsDTO.middleName) &&
Objects.equals(this.familyName, userDetailsDTO.familyName) &&
Objects.equals(this.preferredUsername, userDetailsDTO.preferredUsername) &&
Objects.equals(this.profile, userDetailsDTO.profile) &&
Objects.equals(this.picture, userDetailsDTO.picture) &&
Objects.equals(this.website, userDetailsDTO.website) &&
Objects.equals(this.email, userDetailsDTO.email) &&
Objects.equals(this.gender, userDetailsDTO.gender) &&
Objects.equals(this.birthdate, userDetailsDTO.birthdate) &&
Objects.equals(this.zoneinfo, userDetailsDTO.zoneinfo) &&
Objects.equals(this.locale, userDetailsDTO.locale) &&
Objects.equals(this.phoneNumber, userDetailsDTO.phoneNumber) &&
Objects.equals(this.updatedAt, userDetailsDTO.updatedAt) &&
Objects.equals(this.platform, userDetailsDTO.platform) &&
Objects.equals(this.enabled, userDetailsDTO.enabled) &&
Objects.equals(this.locked, userDetailsDTO.locked) &&
Objects.equals(this.expiresAt, userDetailsDTO.expiresAt) &&
Objects.equals(this.passwordExpiresAt, userDetailsDTO.passwordExpiresAt) &&
Objects.equals(this.address, userDetailsDTO.address)&&
Objects.equals(this.additionalProperties, userDetailsDTO.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(requestId, username, nickname, givenName, middleName, familyName, preferredUsername, profile, picture, website, email, gender, birthdate, zoneinfo, locale, phoneNumber, updatedAt, platform, enabled, locked, expiresAt, passwordExpiresAt, address, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UserDetailsDTO {\n");
sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n");
sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" nickname: ").append(toIndentedString(nickname)).append("\n");
sb.append(" givenName: ").append(toIndentedString(givenName)).append("\n");
sb.append(" middleName: ").append(toIndentedString(middleName)).append("\n");
sb.append(" familyName: ").append(toIndentedString(familyName)).append("\n");
sb.append(" preferredUsername: ").append(toIndentedString(preferredUsername)).append("\n");
sb.append(" profile: ").append(toIndentedString(profile)).append("\n");
sb.append(" picture: ").append(toIndentedString(picture)).append("\n");
sb.append(" website: ").append(toIndentedString(website)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" gender: ").append(toIndentedString(gender)).append("\n");
sb.append(" birthdate: ").append(toIndentedString(birthdate)).append("\n");
sb.append(" zoneinfo: ").append(toIndentedString(zoneinfo)).append("\n");
sb.append(" locale: ").append(toIndentedString(locale)).append("\n");
sb.append(" phoneNumber: ").append(toIndentedString(phoneNumber)).append("\n");
sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n");
sb.append(" platform: ").append(toIndentedString(platform)).append("\n");
sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n");
sb.append(" locked: ").append(toIndentedString(locked)).append("\n");
sb.append(" expiresAt: ").append(toIndentedString(expiresAt)).append("\n");
sb.append(" passwordExpiresAt: ").append(toIndentedString(passwordExpiresAt)).append("\n");
sb.append(" address: ").append(toIndentedString(address)).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();
openapiFields.add("requestId");
openapiFields.add("username");
openapiFields.add("nickname");
openapiFields.add("givenName");
openapiFields.add("middleName");
openapiFields.add("familyName");
openapiFields.add("preferredUsername");
openapiFields.add("profile");
openapiFields.add("picture");
openapiFields.add("website");
openapiFields.add("email");
openapiFields.add("gender");
openapiFields.add("birthdate");
openapiFields.add("zoneinfo");
openapiFields.add("locale");
openapiFields.add("phoneNumber");
openapiFields.add("updatedAt");
openapiFields.add("platform");
openapiFields.add("enabled");
openapiFields.add("locked");
openapiFields.add("expiresAt");
openapiFields.add("passwordExpiresAt");
openapiFields.add("address");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* 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 UserDetailsDTO
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!UserDetailsDTO.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in UserDetailsDTO is not found in the empty JSON string", UserDetailsDTO.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("requestId") != null && !jsonObj.get("requestId").isJsonNull()) && !jsonObj.get("requestId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `requestId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("requestId").toString()));
}
if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString()));
}
if ((jsonObj.get("nickname") != null && !jsonObj.get("nickname").isJsonNull()) && !jsonObj.get("nickname").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `nickname` to be a primitive type in the JSON string but got `%s`", jsonObj.get("nickname").toString()));
}
if ((jsonObj.get("givenName") != null && !jsonObj.get("givenName").isJsonNull()) && !jsonObj.get("givenName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `givenName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("givenName").toString()));
}
if ((jsonObj.get("middleName") != null && !jsonObj.get("middleName").isJsonNull()) && !jsonObj.get("middleName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `middleName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("middleName").toString()));
}
if ((jsonObj.get("familyName") != null && !jsonObj.get("familyName").isJsonNull()) && !jsonObj.get("familyName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `familyName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("familyName").toString()));
}
if ((jsonObj.get("preferredUsername") != null && !jsonObj.get("preferredUsername").isJsonNull()) && !jsonObj.get("preferredUsername").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `preferredUsername` to be a primitive type in the JSON string but got `%s`", jsonObj.get("preferredUsername").toString()));
}
if ((jsonObj.get("profile") != null && !jsonObj.get("profile").isJsonNull()) && !jsonObj.get("profile").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `profile` to be a primitive type in the JSON string but got `%s`", jsonObj.get("profile").toString()));
}
if ((jsonObj.get("picture") != null && !jsonObj.get("picture").isJsonNull()) && !jsonObj.get("picture").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `picture` to be a primitive type in the JSON string but got `%s`", jsonObj.get("picture").toString()));
}
if ((jsonObj.get("website") != null && !jsonObj.get("website").isJsonNull()) && !jsonObj.get("website").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `website` to be a primitive type in the JSON string but got `%s`", jsonObj.get("website").toString()));
}
if ((jsonObj.get("email") != null && !jsonObj.get("email").isJsonNull()) && !jsonObj.get("email").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString()));
}
if ((jsonObj.get("gender") != null && !jsonObj.get("gender").isJsonNull()) && !jsonObj.get("gender").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `gender` to be a primitive type in the JSON string but got `%s`", jsonObj.get("gender").toString()));
}
if ((jsonObj.get("zoneinfo") != null && !jsonObj.get("zoneinfo").isJsonNull()) && !jsonObj.get("zoneinfo").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `zoneinfo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("zoneinfo").toString()));
}
if ((jsonObj.get("locale") != null && !jsonObj.get("locale").isJsonNull()) && !jsonObj.get("locale").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `locale` to be a primitive type in the JSON string but got `%s`", jsonObj.get("locale").toString()));
}
if ((jsonObj.get("phoneNumber") != null && !jsonObj.get("phoneNumber").isJsonNull()) && !jsonObj.get("phoneNumber").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `phoneNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("phoneNumber").toString()));
}
if ((jsonObj.get("platform") != null && !jsonObj.get("platform").isJsonNull()) && !jsonObj.get("platform").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `platform` to be a primitive type in the JSON string but got `%s`", jsonObj.get("platform").toString()));
}
if ((jsonObj.get("address") != null && !jsonObj.get("address").isJsonNull()) && !jsonObj.get("address").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!UserDetailsDTO.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'UserDetailsDTO' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(UserDetailsDTO.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, UserDetailsDTO 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 UserDetailsDTO read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
UserDetailsDTO 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("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 UserDetailsDTO given an JSON string
*
* @param jsonString JSON string
* @return An instance of UserDetailsDTO
* @throws IOException if the JSON string is invalid with respect to UserDetailsDTO
*/
public static UserDetailsDTO fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, UserDetailsDTO.class);
}
/**
* Convert an instance of UserDetailsDTO to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy