diff --git a/clients/web3-common/pom.xml b/clients/web3-common/pom.xml index 136b9c4..7b68867 100644 --- a/clients/web3-common/pom.xml +++ b/clients/web3-common/pom.xml @@ -10,7 +10,7 @@ binance-web3-common web3-common - 1.0.0 + 1.1.0 jar diff --git a/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/auth/SignatureAuthentication.java b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/auth/SignatureAuthentication.java index 2a5c2a1..594352d 100644 --- a/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/auth/SignatureAuthentication.java +++ b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/auth/SignatureAuthentication.java @@ -43,7 +43,7 @@ public void applyToParams( allParametersAsString += payload; } - String preHash = timestamp + method + uri.getPath() + "?" + allParametersAsString; + String preHash = timestamp + method + uri.getPath() + (StringUtils.isNotEmpty(allParametersAsString) ? "?" + allParametersAsString : ""); try { headerParams.put("X-OC-SIGN", Base64.getEncoder().encodeToString(generator.sign(preHash))); } catch (CryptoException e) { diff --git a/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/dtos/GetWebSocketAuthTokenResponse.java b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/dtos/GetWebSocketAuthTokenResponse.java new file mode 100644 index 0000000..9f11af8 --- /dev/null +++ b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/dtos/GetWebSocketAuthTokenResponse.java @@ -0,0 +1,172 @@ +/* + * Binance Web3 API + * Cross-chain wallet, market, trading, transaction, and B402 payment APIs for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3.common.dtos; + +import com.google.gson.annotations.SerializedName; +import jakarta.validation.Valid; + +import java.util.Objects; + +/** GetWebSocketAuthTokenResponse */ +public class GetWebSocketAuthTokenResponse { + public static final String SERIALIZED_NAME_CODE = "code"; + + @SerializedName(SERIALIZED_NAME_CODE) + @jakarta.annotation.Nullable + private Integer code; + + public static final String SERIALIZED_NAME_MSG = "msg"; + + @SerializedName(SERIALIZED_NAME_MSG) + @jakarta.annotation.Nullable + private String msg; + + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @jakarta.annotation.Nullable + private GetWebSocketAuthTokenResponseData data; + + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + @jakarta.annotation.Nullable + private Long timestamp; + + public static final String SERIALIZED_NAME_SUCCESS = "success"; + + @SerializedName(SERIALIZED_NAME_SUCCESS) + @jakarta.annotation.Nullable + private Boolean success; + + public GetWebSocketAuthTokenResponse() {} + + public GetWebSocketAuthTokenResponse code(@jakarta.annotation.Nullable Integer code) { + this.code = code; + return this; + } + + /** + * Response code. 0 indicates success. + * + * @return code + */ + @jakarta.annotation.Nullable + public Integer getCode() { + return code; + } + + public void setCode(@jakarta.annotation.Nullable Integer code) { + this.code = code; + } + + public GetWebSocketAuthTokenResponse msg(@jakarta.annotation.Nullable String msg) { + this.msg = msg; + return this; + } + + /** + * Response message. + * + * @return msg + */ + @jakarta.annotation.Nullable + public String getMsg() { + return msg; + } + + public void setMsg(@jakarta.annotation.Nullable String msg) { + this.msg = msg; + } + + public GetWebSocketAuthTokenResponse data( + @jakarta.annotation.Nullable GetWebSocketAuthTokenResponseData data) { + this.data = data; + return this; + } + + /** + * Get data + * + * @return data + */ + @jakarta.annotation.Nullable + @Valid + public GetWebSocketAuthTokenResponseData getData() { + return data; + } + + public void setData(@jakarta.annotation.Nullable GetWebSocketAuthTokenResponseData data) { + this.data = data; + } + + public GetWebSocketAuthTokenResponse timestamp(@jakarta.annotation.Nullable Long timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Server timestamp in milliseconds. + * + * @return timestamp + */ + @jakarta.annotation.Nullable + public Long getTimestamp() { + return timestamp; + } + + public void setTimestamp(@jakarta.annotation.Nullable Long timestamp) { + this.timestamp = timestamp; + } + + public GetWebSocketAuthTokenResponse success(@jakarta.annotation.Nullable Boolean success) { + this.success = success; + return this; + } + + /** + * Whether the request was successful. + * + * @return success + */ + @jakarta.annotation.Nullable + public Boolean getSuccess() { + return success; + } + + public void setSuccess(@jakarta.annotation.Nullable Boolean success) { + this.success = success; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetWebSocketAuthTokenResponse getWebSocketAuthTokenResponse = + (GetWebSocketAuthTokenResponse) o; + return Objects.equals(this.code, getWebSocketAuthTokenResponse.code) + && Objects.equals(this.msg, getWebSocketAuthTokenResponse.msg) + && Objects.equals(this.data, getWebSocketAuthTokenResponse.data) + && Objects.equals(this.timestamp, getWebSocketAuthTokenResponse.timestamp) + && Objects.equals(this.success, getWebSocketAuthTokenResponse.success); + } + + @Override + public int hashCode() { + return Objects.hash(code, msg, data, timestamp, success); + } +} diff --git a/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/dtos/GetWebSocketAuthTokenResponseData.java b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/dtos/GetWebSocketAuthTokenResponseData.java new file mode 100644 index 0000000..7c57b3e --- /dev/null +++ b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/dtos/GetWebSocketAuthTokenResponseData.java @@ -0,0 +1,65 @@ +/* + * Binance Web3 API + * Cross-chain wallet, market, trading, transaction, and B402 payment APIs for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3.common.dtos; + +import com.google.gson.annotations.SerializedName; + +import java.util.Objects; + +/** GetWebSocketAuthTokenResponseData */ +public class GetWebSocketAuthTokenResponseData { + public static final String SERIALIZED_NAME_TOKEN = "token"; + + @SerializedName(SERIALIZED_NAME_TOKEN) + @jakarta.annotation.Nullable + private String token; + + public GetWebSocketAuthTokenResponseData() {} + + public GetWebSocketAuthTokenResponseData token(@jakarta.annotation.Nullable String token) { + this.token = token; + return this; + } + + /** + * WebSocket auth token (JWT). + * + * @return token + */ + @jakarta.annotation.Nullable + public String getToken() { + return token; + } + + public void setToken(@jakarta.annotation.Nullable String token) { + this.token = token; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetWebSocketAuthTokenResponseData getWebSocketAuthTokenResponseData = + (GetWebSocketAuthTokenResponseData) o; + return Objects.equals(this.token, getWebSocketAuthTokenResponseData.token); + } + + @Override + public int hashCode() { + return Objects.hash(token); + } +} diff --git a/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/adapter/stream/Web3StreamConnectionPoolWrapper.java b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/adapter/stream/Web3StreamConnectionPoolWrapper.java new file mode 100644 index 0000000..ffb69d4 --- /dev/null +++ b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/adapter/stream/Web3StreamConnectionPoolWrapper.java @@ -0,0 +1,166 @@ +package com.binance.connector.client.web3.common.websocket.adapter.stream; + +import com.binance.connector.client.common.SystemUtil; +import com.binance.connector.client.common.websocket.adapter.ConnectionWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionInterface; +import com.binance.connector.client.common.websocket.dtos.RequestWrapperDTO; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueue; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.google.gson.Gson; + +import java.util.*; + +public class Web3StreamConnectionPoolWrapper implements StreamConnectionInterface { + + private final LinkedList connectionList = new LinkedList<>(); + private ListIterator pool; + private Boolean isConnected = false; + private String userAgent = + String.format( + "binance-web3-connector-java/1.1.0 (Java/%s; %s; %s)", + SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); + + private final Map connectionStreamMap = new HashMap<>(); + + public Web3StreamConnectionPoolWrapper(Web3WebSocketClientConfiguration clientConfiguration) { + this(clientConfiguration, null); + } + + public Web3StreamConnectionPoolWrapper( + Web3WebSocketClientConfiguration clientConfiguration, Gson gson) { + this(clientConfiguration, gson, null); + } + + public Web3StreamConnectionPoolWrapper( + Web3WebSocketClientConfiguration clientConfiguration, Gson gson, String userToken) { + Integer poolSize = clientConfiguration.getPoolSize(); + Integer batchSize = clientConfiguration.getReconnectBatchSize(); + Integer reconnectAfter = clientConfiguration.getReconnectIntervalTime(); + for (int i = 0; i < poolSize; i++) { + Web3StreamConnectionWrapper connectionWrapper = + new Web3StreamConnectionWrapper(clientConfiguration, gson, userToken); + connectionList.add(connectionWrapper); + } + + // Scheduler to reconnect by batch every 6 days (configurable) + new Timer() + .scheduleAtFixedRate( + new TimerTask() { + @Override + public void run() { + try { + for (int i = 0; i < batchSize; i++) { + int currentBatchSize = (poolSize / batchSize); + if (i == batchSize - 1) { + currentBatchSize += poolSize % batchSize; + } + + for (int j = 0; j < currentBatchSize; j++) { + int connectionIndex = ((poolSize / batchSize) * i) + j; + ConnectionWrapper connectionWrapper = + connectionList.get(connectionIndex); + if (connectionWrapper.canReconnect()) { + connectionWrapper.connect(); + } + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }, + reconnectAfter, + reconnectAfter); + + pool = connectionList.listIterator(); + } + + @Override + public void connect() { + for (ConnectionWrapper connectionWrapper : connectionList) { + connectionWrapper.setUserAgent(userAgent); + connectionWrapper.connect(); + } + isConnected = true; + } + + @Override + public void disconnect() { + for (ConnectionWrapper connectionWrapper : connectionList) { + connectionWrapper.disconnect(); + } + isConnected = false; + } + + public Map> subscribe( + RequestWrapperDTO, Object> requestWrapperDTO) { + Set params = requestWrapperDTO.getParams(); + Map> queueMap = new HashMap<>(); + for (String identifier : params) { + Web3StreamConnectionWrapper connection = getConnection(identifier); + queueMap.putAll(connection.subscribe(requestWrapperDTO)); + } + return queueMap; + } + + @Override + public void unsubscribe(StreamBlockingQueueWrapper queue) { + unsubscribe(queue.getInnerQueue()); + } + + @Override + public void unsubscribe(StreamBlockingQueue queue) { + Web3StreamConnectionWrapper connection = getConnection(queue.getOperationId()); + connection.unsubscribe(queue); + connectionStreamMap.remove(queue.getOperationId()); + } + + public Web3StreamConnectionWrapper getConnection(String identifier) { + if (connectionStreamMap.containsKey(identifier)) { + return connectionStreamMap.get(identifier); + } + + Web3StreamConnectionWrapper connection = getConnection(); + connectionStreamMap.put(identifier, connection); + + return connection; + } + + /** + * @return the next connection from the pool, using round-robin + */ + public Web3StreamConnectionWrapper getConnection() { + if (!pool.hasNext()) { + pool = connectionList.listIterator(); + } + Web3StreamConnectionWrapper connection = pool.next(); + while (!connection.isReady()) { + if (!pool.hasNext()) { + pool = connectionList.listIterator(); + } else { + connection = pool.next(); + } + } + + return connection; + } + + @Override + public void setUserAgent(String userAgent) { + this.userAgent = userAgent; + } + + @Override + public boolean isConnected() { + return isConnected; + } + + @Override + public void stop() throws Exception { + for (ConnectionWrapper connectionWrapper : connectionList) { + connectionWrapper.stop(); + } + isConnected = false; + } +} diff --git a/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/adapter/stream/Web3StreamConnectionWrapper.java b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/adapter/stream/Web3StreamConnectionWrapper.java new file mode 100644 index 0000000..71b1161 --- /dev/null +++ b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/adapter/stream/Web3StreamConnectionWrapper.java @@ -0,0 +1,119 @@ +package com.binance.connector.client.web3.common.websocket.adapter.stream; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.ApiResponse; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionWrapper; +import com.binance.connector.client.web3.common.ApiClient; +import com.binance.connector.client.web3.common.dtos.GetWebSocketAuthTokenResponse; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import okhttp3.Call; +import org.eclipse.jetty.websocket.client.WebSocketClient; +import org.jetbrains.annotations.Nullable; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; + +public class Web3StreamConnectionWrapper extends StreamConnectionWrapper { + private final ApiClient apiClient; + private final String tokenBaseUrl; + private final String tokenEndpoint; + private String userToken = null; + + public Web3StreamConnectionWrapper(Web3WebSocketClientConfiguration configuration, Gson json) { + super(configuration, json); + this.apiClient = new ApiClient(configuration); + this.tokenBaseUrl = configuration.getTokenBaseUrl(); + this.tokenEndpoint = configuration.getTokenEndpoint(); + } + + public Web3StreamConnectionWrapper(Web3WebSocketClientConfiguration configuration, Gson json, String userToken) { + super(configuration, json); + this.apiClient = new ApiClient(configuration); + this.tokenBaseUrl = configuration.getTokenBaseUrl(); + this.tokenEndpoint = configuration.getTokenEndpoint(); + this.userToken = userToken; + } + + public Web3StreamConnectionWrapper(Web3WebSocketClientConfiguration configuration, WebSocketClient websocketClient, ApiClient apiClient) { + super(configuration, websocketClient); + this.apiClient = apiClient; + this.tokenBaseUrl = configuration.getTokenBaseUrl(); + this.tokenEndpoint = configuration.getTokenEndpoint(); + } + + @Override + public URI getUri(String uri) throws URISyntaxException { + URI oldUri = new URI(uri); + String newQuery = oldUri.getQuery(); + + String token = getUserToken(); + + String appendQuery = "token=" + token; + if (newQuery == null) { + newQuery = appendQuery; + } else { + newQuery += "&" + appendQuery; + } + + return new URI( + oldUri.getScheme(), + oldUri.getAuthority(), + oldUri.getPath(), + newQuery, + oldUri.getFragment()); + } + + @Nullable + private String getUserToken() { + String token; + if (this.userToken != null) { + token = this.userToken; + } else { + ApiResponse webSocketAuthToken = getWebSocketAuthToken(); + if (webSocketAuthToken == null || + webSocketAuthToken.getData() == null || + webSocketAuthToken.getData().getData() == null || + webSocketAuthToken.getData().getData().getToken() == null + ) { + throw new IllegalStateException("Missing token from the api response"); + } + token = webSocketAuthToken.getData().getData().getToken(); + } + return token; + } + + private ApiResponse getWebSocketAuthToken() + throws ApiException { + + Map localVarHeaderParams = new HashMap<>(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + Set localVarAuthNames = new HashSet<>(); + localVarAuthNames.add("binanceWeb3Signature"); + + Call buildCall = apiClient.buildCall( + tokenBaseUrl, + tokenEndpoint, + "GET", + new ArrayList<>(), + new ArrayList<>(), + null, + localVarHeaderParams, + new HashMap<>(), + new HashMap<>(), + localVarAuthNames); + + java.lang.reflect.Type localVarReturnType = + new TypeToken() { + }.getType(); + return apiClient.execute(buildCall, localVarReturnType); + } +} diff --git a/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/configuration/Web3WebSocketClientConfiguration.java b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/configuration/Web3WebSocketClientConfiguration.java new file mode 100644 index 0000000..de4580c --- /dev/null +++ b/clients/web3-common/src/main/java/com/binance/connector/client/web3/common/websocket/configuration/Web3WebSocketClientConfiguration.java @@ -0,0 +1,39 @@ +package com.binance.connector.client.web3.common.websocket.configuration; + +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; + +public class Web3WebSocketClientConfiguration extends WebSocketClientConfiguration { + public static final int DEFAULT_RECONNECT_INTERVAL_TIME = (6 * 24 * 60 * 60 * 1000); + + public static final String WEB3_TOKEN_API_BASE_URL = "https://web3.binance.com/build"; + public static final String WEB3_TOKEN_API_PATH = "/api/v1/dex/market/wss/auth/token"; + + protected String url = "wss://web3-stream.binance.com/w3w/stream"; + protected String tokenBaseUrl = WEB3_TOKEN_API_BASE_URL; + protected String tokenEndpoint = WEB3_TOKEN_API_PATH; + + public Integer getReconnectIntervalTime() { + return DEFAULT_RECONNECT_INTERVAL_TIME; + } + + @Override + public String getUrl() { + return url; + } + + public String getTokenBaseUrl() { + return tokenBaseUrl; + } + + public void setTokenBaseUrl(String tokenBaseUrl) { + this.tokenBaseUrl = tokenBaseUrl; + } + + public String getTokenEndpoint() { + return tokenEndpoint; + } + + public void setTokenEndpoint(String tokenEndpoint) { + this.tokenEndpoint = tokenEndpoint; + } +} diff --git a/clients/web3-wallet/CHANGELOG.md b/clients/web3-wallet/CHANGELOG.md index 5efa8f8..869e9ab 100644 --- a/clients/web3-wallet/CHANGELOG.md +++ b/clients/web3-wallet/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 4.4.0 - 2026-09-21 + +### Added (1) + +- Support WS Streams. + +### Changed (1) + +- Update `web3-common` to version `1.1.0`. + ## 4.3.0 - 2026-09-21 ### Changed (2) diff --git a/clients/web3-wallet/example_websocket_stream.md b/clients/web3-wallet/example_websocket_stream.md new file mode 100644 index 0000000..b1235ca --- /dev/null +++ b/clients/web3-wallet/example_websocket_stream.md @@ -0,0 +1,10 @@ +## Market + +[w3w@onchainos@pub@candles@@@](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/ws-streams/market#candlestick-stream) - candlestickStream - [CandlestickStreamExample.java:37](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/CandlestickStreamExample.java#L37) + +[w3w@onchainos@pub@tx-data@@](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/ws-streams/market#market-stats-stream) - marketStatsStream - [MarketStatsStreamExample.java:39](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/MarketStatsStreamExample.java#L39) + +[w3w@onchainos@pub@price@@](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/ws-streams/market#price-stream) - priceStream - [PriceStreamExample.java:37](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/PriceStreamExample.java#L37) + +[w3w@onchainos@pub@tx@@](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/ws-streams/market#real-time-trades-stream) - realTimeTradesStream - [RealTimeTradesStreamExample.java:37](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/RealTimeTradesStreamExample.java#L37) + diff --git a/clients/web3-wallet/pom.xml b/clients/web3-wallet/pom.xml index 9bf21a4..7b8846e 100644 --- a/clients/web3-wallet/pom.xml +++ b/clients/web3-wallet/pom.xml @@ -5,7 +5,7 @@ 4.0.0 binance-web3-wallet web3-wallet - 4.3.0 + 4.4.0 jar @@ -31,7 +31,7 @@ io.github.binance binance-web3-common - 1.0.0 + 1.1.0 \ No newline at end of file diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java index 18e5266..dabd027 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java @@ -53,7 +53,7 @@ public class AddressPortfolioApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/B402PaymentsApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/B402PaymentsApi.java index 24859d4..34fac45 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/B402PaymentsApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/B402PaymentsApi.java @@ -55,7 +55,7 @@ public class B402PaymentsApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/DefiDataApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/DefiDataApi.java index e53a37c..e84671b 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/DefiDataApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/DefiDataApi.java @@ -52,7 +52,7 @@ public class DefiDataApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/DefiTransactionApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/DefiTransactionApi.java index 955417c..22a86d9 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/DefiTransactionApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/DefiTransactionApi.java @@ -55,7 +55,7 @@ public class DefiTransactionApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java index e6507d2..6c90ace 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java @@ -58,7 +58,7 @@ public class GeneralDataApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java index 5c54605..316be2a 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java @@ -48,7 +48,7 @@ public class RwaDataApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java index f435623..7e5116f 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java @@ -59,7 +59,7 @@ public class TradingApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java index 4cc0450..9e3fb42 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java @@ -53,7 +53,7 @@ public class TransactionApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java index cc9960d..cc29079 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java @@ -49,7 +49,7 @@ public class WalletApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WebSocketApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WebSocketApi.java index f286f89..f325f07 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WebSocketApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WebSocketApi.java @@ -42,7 +42,7 @@ public class WebSocketApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/4.3.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.4.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/JSON.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/JSON.java new file mode 100644 index 0000000..f3c1afc --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/JSON.java @@ -0,0 +1,440 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream; + +import com.binance.connector.client.common.DecimalFormatter; +import com.binance.connector.client.common.websocket.service.DeserializeExclusionStrategy; +import com.binance.connector.client.common.websocket.service.SerializeExclusionStrategy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializer; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.gsonfire.GsonFireBuilder; +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Map; +import okio.ByteString; + +/* + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ +public class JSON { + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = + new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder(); + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue( + JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException( + "missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator + * value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator( + Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException( + "cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + static { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder + .registerTypeAdapter( + Double.class, + (JsonSerializer) + (src, typeOfSrc, context) -> { + DecimalFormat df = DecimalFormatter.getFormatter(); + return new JsonPrimitive(df.format(src)); + }) + .addSerializationExclusionStrategy(new SerializeExclusionStrategy()) + .addDeserializationExclusionStrategy(new DeserializeExclusionStrategy()); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .CandlestickStreamRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .CandlestickStreamResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .CandlestickStreamResponseInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .MarketStatsStreamRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .MarketStatsStreamResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .PriceStreamRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .PriceStreamResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .RealTimeTradesStreamRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .RealTimeTradesStreamResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.web3_wallet.websocket.stream.model + .RealTimeTradesStreamResponseTokensInner.CustomTypeAdapterFactory()); + gson = gsonBuilder.create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see + // https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } + } + } + + /** Gson TypeAdapter for Byte Array type */ + public static class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** Gson TypeAdapter for JSR310 OffsetDateTime type */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length() - 5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** Gson TypeAdapter for JSR310 LocalDate type */ + public static class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } + + /** + * Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a simple "yyyy-MM-dd" + * format will be used (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date( + ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils will be + * used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } + + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/Web3WalletWebSocketStreamsUtil.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/Web3WalletWebSocketStreamsUtil.java new file mode 100644 index 0000000..06d508c --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/Web3WalletWebSocketStreamsUtil.java @@ -0,0 +1,21 @@ +package com.binance.connector.client.web3_wallet.websocket.stream; + +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; + +public class Web3WalletWebSocketStreamsUtil { + private static final boolean HAS_TIME_UNIT = false; + + public static Web3WebSocketClientConfiguration getClientConfiguration() { + return getClientConfiguration(""); + } + + public static Web3WebSocketClientConfiguration getClientConfiguration(String path) { + Web3WebSocketClientConfiguration clientConfiguration = + new Web3WebSocketClientConfiguration(); + if (!HAS_TIME_UNIT) { + clientConfiguration.setTimeUnit(null); + } + clientConfiguration.setAutoLogon(false); + return clientConfiguration; + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/api/MarketApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/api/MarketApi.java new file mode 100644 index 0000000..7c6abff --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/api/MarketApi.java @@ -0,0 +1,441 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.api; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.SystemUtil; +import com.binance.connector.client.common.exception.ConstraintViolationException; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionInterface; +import com.binance.connector.client.common.websocket.dtos.RequestWrapperDTO; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueue; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.web3.common.websocket.adapter.stream.Web3StreamConnectionPoolWrapper; +import com.binance.connector.client.web3.common.websocket.adapter.stream.Web3StreamConnectionWrapper; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.binance.connector.client.web3_wallet.websocket.stream.model.CandlestickStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.CandlestickStreamResponse; +import com.binance.connector.client.web3_wallet.websocket.stream.model.MarketStatsStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.MarketStatsStreamResponse; +import com.binance.connector.client.web3_wallet.websocket.stream.model.PriceStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.PriceStreamResponse; +import com.binance.connector.client.web3_wallet.websocket.stream.model.RealTimeTradesStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.RealTimeTradesStreamResponse; +import com.google.gson.reflect.TypeToken; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import jakarta.validation.constraints.*; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator; + +public class MarketApi { + private static final String USER_AGENT = + String.format( + "binance-web3-wallet/5.0.0 (Java/%s; %s; %s)", + SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); + + private StreamConnectionInterface connection; + + public MarketApi() {} + + public MarketApi(Web3WebSocketClientConfiguration configuration) { + this( + configuration.getUsePool() + ? new Web3StreamConnectionPoolWrapper(configuration, JSON.getGson()) + : new Web3StreamConnectionWrapper(configuration, JSON.getGson())); + } + + public MarketApi(StreamConnectionInterface connection) { + connection.setUserAgent(USER_AGENT); + if (!connection.isConnected()) { + connection.connect(); + } + this.connection = connection; + } + + public StreamConnectionInterface getConnection() { + return connection; + } + + /** + * Candlestick Stream Push token candlestick (K-line) data in real time. The current (unclosed) + * candle keeps updating as new trades occur. Update Speed: Real-time + * + * @param candlestickStreamRequest (required) + * @return CandlestickStreamResponse + * @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 Candles stream payload. -
+ * + * @see Candlestick + * Stream Documentation + */ + public StreamBlockingQueueWrapper candlestickStream( + CandlestickStreamRequest candlestickStreamRequest) throws ApiException { + StreamBlockingQueue queue = candlestickStreamRaw(candlestickStreamRequest); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue candlestickStreamRaw( + CandlestickStreamRequest candlestickStreamRequest) throws ApiException { + candlestickStreamValidateBeforeCall(candlestickStreamRequest); + + String methodName = + "/w3w@onchainos@pub@candles@@@" + .substring(1) + .replace( + "", + candlestickStreamRequest.getId() != null + ? candlestickStreamRequest.getId().toString() + : "") + .replace( + "", + candlestickStreamRequest.getBar() != null + ? candlestickStreamRequest.getBar().toString() + : "") + .replace( + "", + candlestickStreamRequest.getChainId() != null + ? candlestickStreamRequest.getChainId().toString() + : "") + .replace( + "", + candlestickStreamRequest.getContractAddress() != null + ? candlestickStreamRequest.getContractAddress().toString() + : ""); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .id(getRequestID()) + .method("SUBSCRIBE") + .params(Collections.singleton(methodName)) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void candlestickStreamValidateBeforeCall( + CandlestickStreamRequest candlestickStreamRequest) throws ApiException { + try { + Validator validator = + Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory() + .getValidator(); + + Set> violations = + validator.validate(candlestickStreamRequest); + + if (!violations.isEmpty()) { + throw new ConstraintViolationException(violations); + } + } catch (SecurityException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } + } + + /** + * Market Stats Stream Push token market data. Rate-limited to at most once per second per + * token: if a token's data changes within a 1-second window, the latest snapshot is pushed + * once (multiple changes are coalesced into the latest value); if there is no change, nothing + * is pushed. Update Speed: Real-time + * + * @param marketStatsStreamRequest (required) + * @return MarketStatsStreamResponse + * @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 TX data stream payload. -
+ * + * @see Market + * Stats Stream Documentation + */ + public StreamBlockingQueueWrapper marketStatsStream( + MarketStatsStreamRequest marketStatsStreamRequest) throws ApiException { + StreamBlockingQueue queue = marketStatsStreamRaw(marketStatsStreamRequest); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue marketStatsStreamRaw( + MarketStatsStreamRequest marketStatsStreamRequest) throws ApiException { + marketStatsStreamValidateBeforeCall(marketStatsStreamRequest); + + String methodName = + "/w3w@onchainos@pub@tx-data@@" + .substring(1) + .replace( + "", + marketStatsStreamRequest.getId() != null + ? marketStatsStreamRequest.getId().toString() + : "") + .replace( + "", + marketStatsStreamRequest.getChainId() != null + ? marketStatsStreamRequest.getChainId().toString() + : "") + .replace( + "", + marketStatsStreamRequest.getContractAddress() != null + ? marketStatsStreamRequest.getContractAddress().toString() + : ""); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .id(getRequestID()) + .method("SUBSCRIBE") + .params(Collections.singleton(methodName)) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void marketStatsStreamValidateBeforeCall( + MarketStatsStreamRequest marketStatsStreamRequest) throws ApiException { + try { + Validator validator = + Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory() + .getValidator(); + + Set> violations = + validator.validate(marketStatsStreamRequest); + + if (!violations.isEmpty()) { + throw new ConstraintViolationException(violations); + } + } catch (SecurityException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } + } + + /** + * Price Stream Push token price updates. Triggered every time a token's price changes. + * Update Speed: Real-time + * + * @param priceStreamRequest (required) + * @return PriceStreamResponse + * @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 Price stream payload. -
+ * + * @see Price + * Stream Documentation + */ + public StreamBlockingQueueWrapper priceStream( + PriceStreamRequest priceStreamRequest) throws ApiException { + StreamBlockingQueue queue = priceStreamRaw(priceStreamRequest); + + TypeToken typeToken = new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue priceStreamRaw(PriceStreamRequest priceStreamRequest) + throws ApiException { + priceStreamValidateBeforeCall(priceStreamRequest); + + String methodName = + "/w3w@onchainos@pub@price@@" + .substring(1) + .replace( + "", + priceStreamRequest.getId() != null + ? priceStreamRequest.getId().toString() + : "") + .replace( + "", + priceStreamRequest.getChainId() != null + ? priceStreamRequest.getChainId().toString() + : "") + .replace( + "", + priceStreamRequest.getContractAddress() != null + ? priceStreamRequest.getContractAddress().toString() + : ""); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .id(getRequestID()) + .method("SUBSCRIBE") + .params(Collections.singleton(methodName)) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void priceStreamValidateBeforeCall(PriceStreamRequest priceStreamRequest) + throws ApiException { + try { + Validator validator = + Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory() + .getValidator(); + + Set> violations = + validator.validate(priceStreamRequest); + + if (!violations.isEmpty()) { + throw new ConstraintViolationException(violations); + } + } catch (SecurityException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } + } + + /** + * Real-Time Trades Stream Push real-time token trade history. Triggered on every new + * transaction. Update Speed: Real-time + * + * @param realTimeTradesStreamRequest (required) + * @return RealTimeTradesStreamResponse + * @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 Trade history stream payload. -
+ * + * @see Real-Time + * Trades Stream Documentation + */ + public StreamBlockingQueueWrapper realTimeTradesStream( + RealTimeTradesStreamRequest realTimeTradesStreamRequest) throws ApiException { + StreamBlockingQueue queue = realTimeTradesStreamRaw(realTimeTradesStreamRequest); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue realTimeTradesStreamRaw( + RealTimeTradesStreamRequest realTimeTradesStreamRequest) throws ApiException { + realTimeTradesStreamValidateBeforeCall(realTimeTradesStreamRequest); + + String methodName = + "/w3w@onchainos@pub@tx@@" + .substring(1) + .replace( + "", + realTimeTradesStreamRequest.getId() != null + ? realTimeTradesStreamRequest.getId().toString() + : "") + .replace( + "", + realTimeTradesStreamRequest.getChainId() != null + ? realTimeTradesStreamRequest.getChainId().toString() + : "") + .replace( + "", + realTimeTradesStreamRequest.getContractAddress() != null + ? realTimeTradesStreamRequest + .getContractAddress() + .toString() + : ""); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .id(getRequestID()) + .method("SUBSCRIBE") + .params(Collections.singleton(methodName)) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void realTimeTradesStreamValidateBeforeCall( + RealTimeTradesStreamRequest realTimeTradesStreamRequest) throws ApiException { + try { + Validator validator = + Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory() + .getValidator(); + + Set> violations = + validator.validate(realTimeTradesStreamRequest); + + if (!violations.isEmpty()) { + throw new ConstraintViolationException(violations); + } + } catch (SecurityException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } + } + + public String getRequestID() { + return UUID.randomUUID().toString(); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/api/Web3WalletWebSocketStreams.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/api/Web3WalletWebSocketStreams.java new file mode 100644 index 0000000..ff09dd6 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/api/Web3WalletWebSocketStreams.java @@ -0,0 +1,84 @@ +package com.binance.connector.client.web3_wallet.websocket.stream.api; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.SystemUtil; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionInterface; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.web3.common.websocket.adapter.stream.Web3StreamConnectionPoolWrapper; +import com.binance.connector.client.web3.common.websocket.adapter.stream.Web3StreamConnectionWrapper; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.binance.connector.client.web3_wallet.websocket.stream.model.CandlestickStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.CandlestickStreamResponse; +import com.binance.connector.client.web3_wallet.websocket.stream.model.MarketStatsStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.MarketStatsStreamResponse; +import com.binance.connector.client.web3_wallet.websocket.stream.model.PriceStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.PriceStreamResponse; +import com.binance.connector.client.web3_wallet.websocket.stream.model.RealTimeTradesStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.RealTimeTradesStreamResponse; +import java.util.UUID; + +public class Web3WalletWebSocketStreams { + private static final String USER_AGENT = + String.format( + "binance-web3-wallet/5.0.0 (Java/%s; %s; %s)", + SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); + + private final StreamConnectionInterface connection; + + private MarketApi marketApi; + + public Web3WalletWebSocketStreams(Web3WebSocketClientConfiguration configuration) { + this( + configuration.getUsePool() + ? new Web3StreamConnectionPoolWrapper(configuration, JSON.getGson()) + : new Web3StreamConnectionWrapper(configuration, JSON.getGson())); + } + + public Web3WalletWebSocketStreams(Web3WebSocketClientConfiguration configuration, String userToken) { + this( + configuration.getUsePool() + ? new Web3StreamConnectionPoolWrapper(configuration, JSON.getGson(), userToken) + : new Web3StreamConnectionWrapper(configuration, JSON.getGson(), userToken)); + } + + public Web3WalletWebSocketStreams(StreamConnectionInterface connection) { + connection.setUserAgent(USER_AGENT); + if (!connection.isConnected()) { + connection.connect(); + } + this.connection = connection; + + this.marketApi = new MarketApi(connection); + } + + public void stop() throws Exception { + if (connection != null && connection.isConnected()) { + connection.stop(); + } + } + + public StreamBlockingQueueWrapper candlestickStream( + CandlestickStreamRequest candlestickStreamRequest) throws ApiException { + return marketApi.candlestickStream(candlestickStreamRequest); + } + + public StreamBlockingQueueWrapper marketStatsStream( + MarketStatsStreamRequest marketStatsStreamRequest) throws ApiException { + return marketApi.marketStatsStream(marketStatsStreamRequest); + } + + public StreamBlockingQueueWrapper priceStream( + PriceStreamRequest priceStreamRequest) throws ApiException { + return marketApi.priceStream(priceStreamRequest); + } + + public StreamBlockingQueueWrapper realTimeTradesStream( + RealTimeTradesStreamRequest realTimeTradesStreamRequest) throws ApiException { + return marketApi.realTimeTradesStream(realTimeTradesStreamRequest); + } + + public String getRequestID() { + return UUID.randomUUID().toString(); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/AbstractOpenApiSchema.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/AbstractOpenApiSchema.java new file mode 100644 index 0000000..7c6bf92 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/AbstractOpenApiSchema.java @@ -0,0 +1,145 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + // @JsonValue + public Object getActualInstance() { + return instance; + } + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) { + this.instance = instance; + } + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf + * schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) + && Objects.equals(this.isNullable, a.isNullable) + && Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamRequest.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamRequest.java new file mode 100644 index 0000000..20f15aa --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamRequest.java @@ -0,0 +1,381 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** CandlestickStreamRequest */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class CandlestickStreamRequest extends BaseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @jakarta.annotation.Nullable + private String id; + + public static final String SERIALIZED_NAME_BAR = "bar"; + + @SerializedName(SERIALIZED_NAME_BAR) + @jakarta.annotation.Nullable + private String bar; + + public static final String SERIALIZED_NAME_CHAIN_ID = "chainId"; + + @SerializedName(SERIALIZED_NAME_CHAIN_ID) + @jakarta.annotation.Nullable + private String chainId; + + public static final String SERIALIZED_NAME_CONTRACT_ADDRESS = "contractAddress"; + + @SerializedName(SERIALIZED_NAME_CONTRACT_ADDRESS) + @jakarta.annotation.Nullable + private String contractAddress; + + public CandlestickStreamRequest() {} + + public CandlestickStreamRequest id(@jakarta.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * Unique WebSocket request ID. + * + * @return id + */ + @jakarta.annotation.Nullable + public String getId() { + return id; + } + + public void setId(@jakarta.annotation.Nullable String id) { + this.id = id; + } + + public CandlestickStreamRequest bar(@jakarta.annotation.Nullable String bar) { + this.bar = bar; + return this; + } + + /** + * K-line interval. Enum: 1s, 5s, 30s, 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, + * 1w, 1M. + * + * @return bar + */ + @jakarta.annotation.Nullable + public String getBar() { + return bar; + } + + public void setBar(@jakarta.annotation.Nullable String bar) { + this.bar = bar; + } + + public CandlestickStreamRequest chainId(@jakarta.annotation.Nullable String chainId) { + this.chainId = chainId; + return this; + } + + /** + * Chain identifier, e.g. \"1\"=Ethereum, \"56\"=BSC, + * \"CT_501\"=Solana. Full supported-chain list: same as the + * [\"supported/chain\"](/catalog/web3-wallet/api/rest-api/general-data#get-supported-chains) + * endpoint. + * + * @return chainId + */ + @jakarta.annotation.Nullable + public String getChainId() { + return chainId; + } + + public void setChainId(@jakarta.annotation.Nullable String chainId) { + this.chainId = chainId; + } + + public CandlestickStreamRequest contractAddress( + @jakarta.annotation.Nullable String contractAddress) { + this.contractAddress = contractAddress; + return this; + } + + /** + * Token contract address. + * + * @return contractAddress + */ + @jakarta.annotation.Nullable + public String getContractAddress() { + return contractAddress; + } + + public void setContractAddress(@jakarta.annotation.Nullable String contractAddress) { + this.contractAddress = contractAddress; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CandlestickStreamRequest candlestickStreamRequest = (CandlestickStreamRequest) o; + return Objects.equals(this.id, candlestickStreamRequest.id) + && Objects.equals(this.bar, candlestickStreamRequest.bar) + && Objects.equals(this.chainId, candlestickStreamRequest.chainId) + && Objects.equals(this.contractAddress, candlestickStreamRequest.contractAddress); + } + + @Override + public int hashCode() { + return Objects.hash(id, bar, chainId, contractAddress); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CandlestickStreamRequest {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" chainId: ").append(toIndentedString(chainId)).append("\n"); + sb.append(" contractAddress: ").append(toIndentedString(contractAddress)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String idValue = getId(); + if (idValue != null) { + String idValueAsString = idValue.toString(); + valMap.put("id", idValueAsString); + } + String barValue = getBar(); + if (barValue != null) { + String barValueAsString = barValue.toString(); + valMap.put("bar", barValueAsString); + } + String chainIdValue = getChainId(); + if (chainIdValue != null) { + String chainIdValueAsString = chainIdValue.toString(); + valMap.put("chainId", chainIdValueAsString); + } + String contractAddressValue = getContractAddress(); + if (contractAddressValue != null) { + String contractAddressValueAsString = contractAddressValue.toString(); + valMap.put("contractAddress", contractAddressValueAsString); + } + + valMap.put("timestamp", getTimestamp()); + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Object idValue = getId(); + if (idValue != null) { + valMap.put("id", idValue); + } + Object barValue = getBar(); + if (barValue != null) { + valMap.put("bar", barValue); + } + Object chainIdValue = getChainId(); + if (chainIdValue != null) { + valMap.put("chainId", chainIdValue); + } + Object contractAddressValue = getContractAddress(); + if (contractAddressValue != null) { + valMap.put("contractAddress", contractAddressValue); + } + + valMap.put("timestamp", getTimestamp()); + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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("id"); + openapiFields.add("bar"); + openapiFields.add("chainId"); + openapiFields.add("contractAddress"); + + // 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 CandlestickStreamRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CandlestickStreamRequest.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CandlestickStreamRequest is not found" + + " in the empty JSON string", + CandlestickStreamRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CandlestickStreamRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `CandlestickStreamRequest` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("bar") != null && !jsonObj.get("bar").isJsonNull()) + && !jsonObj.get("bar").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bar` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("bar").toString())); + } + if ((jsonObj.get("chainId") != null && !jsonObj.get("chainId").isJsonNull()) + && !jsonObj.get("chainId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `chainId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("chainId").toString())); + } + if ((jsonObj.get("contractAddress") != null && !jsonObj.get("contractAddress").isJsonNull()) + && !jsonObj.get("contractAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `contractAddress` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("contractAddress").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CandlestickStreamRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CandlestickStreamRequest' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CandlestickStreamRequest.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CandlestickStreamRequest value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CandlestickStreamRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CandlestickStreamRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CandlestickStreamRequest + * @throws IOException if the JSON string is invalid with respect to CandlestickStreamRequest + */ + public static CandlestickStreamRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CandlestickStreamRequest.class); + } + + /** + * Convert an instance of CandlestickStreamRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamResponse.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamResponse.java new file mode 100644 index 0000000..37bc7a1 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamResponse.java @@ -0,0 +1,194 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** + * Candle data is a fixed 6-element positional array: [0]=open, [1]=high, [2]=low, + * [3]=close, [4]=volume (USD), [5]=start time in ms. Close [3] keeps changing while + * the candle is still open. + */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class CandlestickStreamResponse extends ArrayList { + public CandlestickStreamResponse() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CandlestickStreamResponse {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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(); + + // 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 CandlestickStreamResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CandlestickStreamResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CandlestickStreamResponse is not found" + + " in the empty JSON string", + CandlestickStreamResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CandlestickStreamResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `CandlestickStreamResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CandlestickStreamResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CandlestickStreamResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CandlestickStreamResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CandlestickStreamResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonArray(); + elementAdapter.write(out, obj); + } + + @Override + public CandlestickStreamResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CandlestickStreamResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CandlestickStreamResponse + * @throws IOException if the JSON string is invalid with respect to CandlestickStreamResponse + */ + public static CandlestickStreamResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CandlestickStreamResponse.class); + } + + /** + * Convert an instance of CandlestickStreamResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamResponseInner.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamResponseInner.java new file mode 100644 index 0000000..138b41b --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/CandlestickStreamResponseInner.java @@ -0,0 +1,311 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.AbstractOpenApiSchema; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.hibernate.validator.constraints.*; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class CandlestickStreamResponseInner extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(CandlestickStreamResponseInner.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CandlestickStreamResponseInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CandlestickStreamResponseInner' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterString = + gson.getDelegateAdapter(this, TypeToken.get(String.class)); + final TypeAdapter adapterLong = + gson.getDelegateAdapter(this, TypeToken.get(Long.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CandlestickStreamResponseInner value) + throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `String` + if (value.getActualInstance() instanceof String) { + JsonPrimitive primitive = + adapterString + .toJsonTree((String) value.getActualInstance()) + .getAsJsonPrimitive(); + elementAdapter.write(out, primitive); + return; + } + // check if the actual instance is of the type `Long` + if (value.getActualInstance() instanceof Long) { + JsonPrimitive primitive = + adapterLong + .toJsonTree((Long) value.getActualInstance()) + .getAsJsonPrimitive(); + elementAdapter.write(out, primitive); + return; + } + throw new IOException( + "Failed to serialize as the type doesn't match oneOf schemas:" + + " Long, String"); + } + + @Override + public CandlestickStreamResponseInner read(JsonReader in) + throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize String + try { + // validate the JSON object to see if any exception is thrown + if (!jsonElement.getAsJsonPrimitive().isString()) { + throw new IllegalArgumentException( + String.format( + "Expected json element to be of type String in" + + " the JSON string but got `%s`", + jsonElement.toString())); + } + actualAdapter = adapterString; + match++; + log.log(Level.FINER, "Input data matches schema 'String'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add( + String.format( + "Deserialization for String failed with `%s`.", + e.getMessage())); + log.log( + Level.FINER, + "Input data does not match schema 'String'", + e); + } + // deserialize Long + try { + // validate the JSON object to see if any exception is thrown + if (!jsonElement.getAsJsonPrimitive().isNumber()) { + throw new IllegalArgumentException( + String.format( + "Expected json element to be of type Number in" + + " the JSON string but got `%s`", + jsonElement.toString())); + } + actualAdapter = adapterLong; + match++; + log.log(Level.FINER, "Input data matches schema 'Long'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add( + String.format( + "Deserialization for Long failed with `%s`.", + e.getMessage())); + log.log(Level.FINER, "Input data does not match schema 'Long'", e); + } + + if (match == 1) { + CandlestickStreamResponseInner ret = + new CandlestickStreamResponseInner(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } + + throw new IOException( + String.format( + "Failed deserialization for" + + " CandlestickStreamResponseInner: %d classes" + + " match result, expected 1. Detailed failure" + + " message for oneOf schemas: %s. JSON: %s", + match, errorMessages, jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap>(); + + public CandlestickStreamResponseInner() { + super("oneOf", Boolean.FALSE); + } + + public CandlestickStreamResponseInner(Object o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", String.class); + schemas.put("Long", Long.class); + } + + @Override + public Map> getSchemas() { + return CandlestickStreamResponseInner.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: Long, String + * + *

It could be an instance of the 'oneOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof String) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof Long) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be Long, String"); + } + + /** + * Get the actual instance, which can be the following: Long, String + * + * @return The actual instance (Long, String) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `Long`. If the actual instance is not `Long`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `Long` + * @throws ClassCastException if the instance is not `Long` + */ + public Long getLong() throws ClassCastException { + return (Long) super.getActualInstance(); + } + + /** + * 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 + * CandlestickStreamResponseInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with String + try { + if (!jsonElement.getAsJsonPrimitive().isString()) { + throw new IllegalArgumentException( + String.format( + "Expected json element to be of type String in the JSON string but" + + " got `%s`", + jsonElement.toString())); + } + validCount++; + } catch (Exception e) { + errorMessages.add( + String.format("Deserialization for String failed with `%s`.", e.getMessage())); + // continue to the next one + } + // validate the json string with Long + try { + if (!jsonElement.getAsJsonPrimitive().isNumber()) { + throw new IllegalArgumentException( + String.format( + "Expected json element to be of type Number in the JSON string but" + + " got `%s`", + jsonElement.toString())); + } + validCount++; + } catch (Exception e) { + errorMessages.add( + String.format("Deserialization for Long failed with `%s`.", e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException( + String.format( + "The JSON string is invalid for CandlestickStreamResponseInner with" + + " oneOf schemas: Long, String. %d class(es) match the result," + + " expected 1. Detailed failure message for oneOf schemas: %s." + + " JSON: %s", + validCount, errorMessages, jsonElement.toString())); + } + } + + /** + * Create an instance of CandlestickStreamResponseInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of CandlestickStreamResponseInner + * @throws IOException if the JSON string is invalid with respect to + * CandlestickStreamResponseInner + */ + public static CandlestickStreamResponseInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CandlestickStreamResponseInner.class); + } + + /** + * Convert an instance of CandlestickStreamResponseInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/MarketStatsStreamRequest.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/MarketStatsStreamRequest.java new file mode 100644 index 0000000..5212298 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/MarketStatsStreamRequest.java @@ -0,0 +1,335 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** MarketStatsStreamRequest */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class MarketStatsStreamRequest extends BaseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @jakarta.annotation.Nullable + private String id; + + public static final String SERIALIZED_NAME_CHAIN_ID = "chainId"; + + @SerializedName(SERIALIZED_NAME_CHAIN_ID) + @jakarta.annotation.Nullable + private String chainId; + + public static final String SERIALIZED_NAME_CONTRACT_ADDRESS = "contractAddress"; + + @SerializedName(SERIALIZED_NAME_CONTRACT_ADDRESS) + @jakarta.annotation.Nullable + private String contractAddress; + + public MarketStatsStreamRequest() {} + + public MarketStatsStreamRequest id(@jakarta.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * Unique WebSocket request ID. + * + * @return id + */ + @jakarta.annotation.Nullable + public String getId() { + return id; + } + + public void setId(@jakarta.annotation.Nullable String id) { + this.id = id; + } + + public MarketStatsStreamRequest chainId(@jakarta.annotation.Nullable String chainId) { + this.chainId = chainId; + return this; + } + + /** + * Chain identifier, e.g. \"1\"=Ethereum, \"56\"=BSC, + * \"CT_501\"=Solana. Full supported-chain list: same as the + * [\"supported/chain\"](/catalog/web3-wallet/api/rest-api/general-data#get-supported-chains) + * endpoint. + * + * @return chainId + */ + @jakarta.annotation.Nullable + public String getChainId() { + return chainId; + } + + public void setChainId(@jakarta.annotation.Nullable String chainId) { + this.chainId = chainId; + } + + public MarketStatsStreamRequest contractAddress( + @jakarta.annotation.Nullable String contractAddress) { + this.contractAddress = contractAddress; + return this; + } + + /** + * Token contract address. + * + * @return contractAddress + */ + @jakarta.annotation.Nullable + public String getContractAddress() { + return contractAddress; + } + + public void setContractAddress(@jakarta.annotation.Nullable String contractAddress) { + this.contractAddress = contractAddress; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MarketStatsStreamRequest marketStatsStreamRequest = (MarketStatsStreamRequest) o; + return Objects.equals(this.id, marketStatsStreamRequest.id) + && Objects.equals(this.chainId, marketStatsStreamRequest.chainId) + && Objects.equals(this.contractAddress, marketStatsStreamRequest.contractAddress); + } + + @Override + public int hashCode() { + return Objects.hash(id, chainId, contractAddress); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MarketStatsStreamRequest {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" chainId: ").append(toIndentedString(chainId)).append("\n"); + sb.append(" contractAddress: ").append(toIndentedString(contractAddress)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String idValue = getId(); + if (idValue != null) { + String idValueAsString = idValue.toString(); + valMap.put("id", idValueAsString); + } + String chainIdValue = getChainId(); + if (chainIdValue != null) { + String chainIdValueAsString = chainIdValue.toString(); + valMap.put("chainId", chainIdValueAsString); + } + String contractAddressValue = getContractAddress(); + if (contractAddressValue != null) { + String contractAddressValueAsString = contractAddressValue.toString(); + valMap.put("contractAddress", contractAddressValueAsString); + } + + valMap.put("timestamp", getTimestamp()); + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Object idValue = getId(); + if (idValue != null) { + valMap.put("id", idValue); + } + Object chainIdValue = getChainId(); + if (chainIdValue != null) { + valMap.put("chainId", chainIdValue); + } + Object contractAddressValue = getContractAddress(); + if (contractAddressValue != null) { + valMap.put("contractAddress", contractAddressValue); + } + + valMap.put("timestamp", getTimestamp()); + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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("id"); + openapiFields.add("chainId"); + openapiFields.add("contractAddress"); + + // 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 MarketStatsStreamRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MarketStatsStreamRequest.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in MarketStatsStreamRequest is not found" + + " in the empty JSON string", + MarketStatsStreamRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MarketStatsStreamRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `MarketStatsStreamRequest` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("chainId") != null && !jsonObj.get("chainId").isJsonNull()) + && !jsonObj.get("chainId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `chainId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("chainId").toString())); + } + if ((jsonObj.get("contractAddress") != null && !jsonObj.get("contractAddress").isJsonNull()) + && !jsonObj.get("contractAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `contractAddress` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("contractAddress").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MarketStatsStreamRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MarketStatsStreamRequest' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(MarketStatsStreamRequest.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, MarketStatsStreamRequest value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MarketStatsStreamRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of MarketStatsStreamRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of MarketStatsStreamRequest + * @throws IOException if the JSON string is invalid with respect to MarketStatsStreamRequest + */ + public static MarketStatsStreamRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MarketStatsStreamRequest.class); + } + + /** + * Convert an instance of MarketStatsStreamRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/MarketStatsStreamResponse.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/MarketStatsStreamResponse.java new file mode 100644 index 0000000..52e4a03 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/MarketStatsStreamResponse.java @@ -0,0 +1,2656 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** TX data event payload. */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class MarketStatsStreamResponse extends BaseDTO { + public static final String SERIALIZED_NAME_P_LOWER_CASE = "p"; + + @SerializedName(SERIALIZED_NAME_P_LOWER_CASE) + @jakarta.annotation.Nullable + private String pLowerCase; + + public static final String SERIALIZED_NAME_T_LOWER_CASE = "t"; + + @SerializedName(SERIALIZED_NAME_T_LOWER_CASE) + @jakarta.annotation.Nullable + private Long tLowerCase; + + public static final String SERIALIZED_NAME_PC5M = "pc5m"; + + @SerializedName(SERIALIZED_NAME_PC5M) + @jakarta.annotation.Nullable + private String pc5m; + + public static final String SERIALIZED_NAME_PC1H = "pc1h"; + + @SerializedName(SERIALIZED_NAME_PC1H) + @jakarta.annotation.Nullable + private String pc1h; + + public static final String SERIALIZED_NAME_PC4H = "pc4h"; + + @SerializedName(SERIALIZED_NAME_PC4H) + @jakarta.annotation.Nullable + private String pc4h; + + public static final String SERIALIZED_NAME_PC24H = "pc24h"; + + @SerializedName(SERIALIZED_NAME_PC24H) + @jakarta.annotation.Nullable + private String pc24h; + + public static final String SERIALIZED_NAME_VOL5M = "vol5m"; + + @SerializedName(SERIALIZED_NAME_VOL5M) + @jakarta.annotation.Nullable + private String vol5m; + + public static final String SERIALIZED_NAME_VOL1H = "vol1h"; + + @SerializedName(SERIALIZED_NAME_VOL1H) + @jakarta.annotation.Nullable + private String vol1h; + + public static final String SERIALIZED_NAME_VOL4H = "vol4h"; + + @SerializedName(SERIALIZED_NAME_VOL4H) + @jakarta.annotation.Nullable + private String vol4h; + + public static final String SERIALIZED_NAME_VOL24H = "vol24h"; + + @SerializedName(SERIALIZED_NAME_VOL24H) + @jakarta.annotation.Nullable + private String vol24h; + + public static final String SERIALIZED_NAME_VOL_B5M = "volB5m"; + + @SerializedName(SERIALIZED_NAME_VOL_B5M) + @jakarta.annotation.Nullable + private String volB5m; + + public static final String SERIALIZED_NAME_VOL_S5M = "volS5m"; + + @SerializedName(SERIALIZED_NAME_VOL_S5M) + @jakarta.annotation.Nullable + private String volS5m; + + public static final String SERIALIZED_NAME_VOL_B1H = "volB1h"; + + @SerializedName(SERIALIZED_NAME_VOL_B1H) + @jakarta.annotation.Nullable + private String volB1h; + + public static final String SERIALIZED_NAME_VOL_S1H = "volS1h"; + + @SerializedName(SERIALIZED_NAME_VOL_S1H) + @jakarta.annotation.Nullable + private String volS1h; + + public static final String SERIALIZED_NAME_VOL_B4H = "volB4h"; + + @SerializedName(SERIALIZED_NAME_VOL_B4H) + @jakarta.annotation.Nullable + private String volB4h; + + public static final String SERIALIZED_NAME_VOL_S4H = "volS4h"; + + @SerializedName(SERIALIZED_NAME_VOL_S4H) + @jakarta.annotation.Nullable + private String volS4h; + + public static final String SERIALIZED_NAME_VOL_B24H = "volB24h"; + + @SerializedName(SERIALIZED_NAME_VOL_B24H) + @jakarta.annotation.Nullable + private String volB24h; + + public static final String SERIALIZED_NAME_VOL_S24H = "volS24h"; + + @SerializedName(SERIALIZED_NAME_VOL_S24H) + @jakarta.annotation.Nullable + private String volS24h; + + public static final String SERIALIZED_NAME_TXS5M = "txs5m"; + + @SerializedName(SERIALIZED_NAME_TXS5M) + @jakarta.annotation.Nullable + private Integer txs5m; + + public static final String SERIALIZED_NAME_TXS1H = "txs1h"; + + @SerializedName(SERIALIZED_NAME_TXS1H) + @jakarta.annotation.Nullable + private Integer txs1h; + + public static final String SERIALIZED_NAME_TXS4H = "txs4h"; + + @SerializedName(SERIALIZED_NAME_TXS4H) + @jakarta.annotation.Nullable + private Integer txs4h; + + public static final String SERIALIZED_NAME_TXS24H = "txs24h"; + + @SerializedName(SERIALIZED_NAME_TXS24H) + @jakarta.annotation.Nullable + private Integer txs24h; + + public static final String SERIALIZED_NAME_TXS_B5M = "txsB5m"; + + @SerializedName(SERIALIZED_NAME_TXS_B5M) + @jakarta.annotation.Nullable + private Integer txsB5m; + + public static final String SERIALIZED_NAME_TXS_S5M = "txsS5m"; + + @SerializedName(SERIALIZED_NAME_TXS_S5M) + @jakarta.annotation.Nullable + private Integer txsS5m; + + public static final String SERIALIZED_NAME_TXS_B1H = "txsB1h"; + + @SerializedName(SERIALIZED_NAME_TXS_B1H) + @jakarta.annotation.Nullable + private Integer txsB1h; + + public static final String SERIALIZED_NAME_TXS_S1H = "txsS1h"; + + @SerializedName(SERIALIZED_NAME_TXS_S1H) + @jakarta.annotation.Nullable + private Integer txsS1h; + + public static final String SERIALIZED_NAME_TXS_B4H = "txsB4h"; + + @SerializedName(SERIALIZED_NAME_TXS_B4H) + @jakarta.annotation.Nullable + private Integer txsB4h; + + public static final String SERIALIZED_NAME_TXS_S4H = "txsS4h"; + + @SerializedName(SERIALIZED_NAME_TXS_S4H) + @jakarta.annotation.Nullable + private Integer txsS4h; + + public static final String SERIALIZED_NAME_TXS_B24H = "txsB24h"; + + @SerializedName(SERIALIZED_NAME_TXS_B24H) + @jakarta.annotation.Nullable + private Integer txsB24h; + + public static final String SERIALIZED_NAME_TXS_S24H = "txsS24h"; + + @SerializedName(SERIALIZED_NAME_TXS_S24H) + @jakarta.annotation.Nullable + private Integer txsS24h; + + public static final String SERIALIZED_NAME_CS = "cs"; + + @SerializedName(SERIALIZED_NAME_CS) + @jakarta.annotation.Nullable + private String cs; + + public static final String SERIALIZED_NAME_MC = "mc"; + + @SerializedName(SERIALIZED_NAME_MC) + @jakarta.annotation.Nullable + private String mc; + + public static final String SERIALIZED_NAME_LIQ = "liq"; + + @SerializedName(SERIALIZED_NAME_LIQ) + @jakarta.annotation.Nullable + private String liq; + + public static final String SERIALIZED_NAME_HOLDERS = "holders"; + + @SerializedName(SERIALIZED_NAME_HOLDERS) + @jakarta.annotation.Nullable + private Integer holders; + + public static final String SERIALIZED_NAME_BN_VOL5M = "bnVol5m"; + + @SerializedName(SERIALIZED_NAME_BN_VOL5M) + @jakarta.annotation.Nullable + private String bnVol5m; + + public static final String SERIALIZED_NAME_BN_VOL1H = "bnVol1h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL1H) + @jakarta.annotation.Nullable + private String bnVol1h; + + public static final String SERIALIZED_NAME_BN_VOL4H = "bnVol4h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL4H) + @jakarta.annotation.Nullable + private String bnVol4h; + + public static final String SERIALIZED_NAME_BN_VOL24H = "bnVol24h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL24H) + @jakarta.annotation.Nullable + private String bnVol24h; + + public static final String SERIALIZED_NAME_BN_VOL_B5M = "bnVolB5m"; + + @SerializedName(SERIALIZED_NAME_BN_VOL_B5M) + @jakarta.annotation.Nullable + private String bnVolB5m; + + public static final String SERIALIZED_NAME_BN_VOL_S5M = "bnVolS5m"; + + @SerializedName(SERIALIZED_NAME_BN_VOL_S5M) + @jakarta.annotation.Nullable + private String bnVolS5m; + + public static final String SERIALIZED_NAME_BN_VOL_B1H = "bnVolB1h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL_B1H) + @jakarta.annotation.Nullable + private String bnVolB1h; + + public static final String SERIALIZED_NAME_BN_VOL_S1H = "bnVolS1h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL_S1H) + @jakarta.annotation.Nullable + private String bnVolS1h; + + public static final String SERIALIZED_NAME_BN_VOL_B4H = "bnVolB4h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL_B4H) + @jakarta.annotation.Nullable + private String bnVolB4h; + + public static final String SERIALIZED_NAME_BN_VOL_S4H = "bnVolS4h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL_S4H) + @jakarta.annotation.Nullable + private String bnVolS4h; + + public static final String SERIALIZED_NAME_BN_VOL_B24H = "bnVolB24h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL_B24H) + @jakarta.annotation.Nullable + private String bnVolB24h; + + public static final String SERIALIZED_NAME_BN_VOL_S24H = "bnVolS24h"; + + @SerializedName(SERIALIZED_NAME_BN_VOL_S24H) + @jakarta.annotation.Nullable + private String bnVolS24h; + + public static final String SERIALIZED_NAME_BN_TXS5M = "bnTxs5m"; + + @SerializedName(SERIALIZED_NAME_BN_TXS5M) + @jakarta.annotation.Nullable + private Integer bnTxs5m; + + public static final String SERIALIZED_NAME_BN_TXS1H = "bnTxs1h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS1H) + @jakarta.annotation.Nullable + private Integer bnTxs1h; + + public static final String SERIALIZED_NAME_BN_TXS4H = "bnTxs4h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS4H) + @jakarta.annotation.Nullable + private Integer bnTxs4h; + + public static final String SERIALIZED_NAME_BN_TXS24H = "bnTxs24h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS24H) + @jakarta.annotation.Nullable + private Integer bnTxs24h; + + public static final String SERIALIZED_NAME_BN_TXS_B5M = "bnTxsB5m"; + + @SerializedName(SERIALIZED_NAME_BN_TXS_B5M) + @jakarta.annotation.Nullable + private Integer bnTxsB5m; + + public static final String SERIALIZED_NAME_BN_TXS_S5M = "bnTxsS5m"; + + @SerializedName(SERIALIZED_NAME_BN_TXS_S5M) + @jakarta.annotation.Nullable + private Integer bnTxsS5m; + + public static final String SERIALIZED_NAME_BN_TXS_B1H = "bnTxsB1h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS_B1H) + @jakarta.annotation.Nullable + private Integer bnTxsB1h; + + public static final String SERIALIZED_NAME_BN_TXS_S1H = "bnTxsS1h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS_S1H) + @jakarta.annotation.Nullable + private Integer bnTxsS1h; + + public static final String SERIALIZED_NAME_BN_TXS_B4H = "bnTxsB4h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS_B4H) + @jakarta.annotation.Nullable + private Integer bnTxsB4h; + + public static final String SERIALIZED_NAME_BN_TXS_S4H = "bnTxsS4h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS_S4H) + @jakarta.annotation.Nullable + private Integer bnTxsS4h; + + public static final String SERIALIZED_NAME_BN_TXS_B24H = "bnTxsB24h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS_B24H) + @jakarta.annotation.Nullable + private Integer bnTxsB24h; + + public static final String SERIALIZED_NAME_BN_TXS_S24H = "bnTxsS24h"; + + @SerializedName(SERIALIZED_NAME_BN_TXS_S24H) + @jakarta.annotation.Nullable + private Integer bnTxsS24h; + + public MarketStatsStreamResponse() {} + + public MarketStatsStreamResponse pLowerCase(@jakarta.annotation.Nullable String pLowerCase) { + this.pLowerCase = pLowerCase; + return this; + } + + /** + * Latest price in USD. + * + * @return pLowerCase + */ + @jakarta.annotation.Nullable + public String getpLowerCase() { + return pLowerCase; + } + + public void setpLowerCase(@jakarta.annotation.Nullable String pLowerCase) { + this.pLowerCase = pLowerCase; + } + + public MarketStatsStreamResponse tLowerCase(@jakarta.annotation.Nullable Long tLowerCase) { + this.tLowerCase = tLowerCase; + return this; + } + + /** + * Price timestamp in milliseconds. + * + * @return tLowerCase + */ + @jakarta.annotation.Nullable + public Long gettLowerCase() { + return tLowerCase; + } + + public void settLowerCase(@jakarta.annotation.Nullable Long tLowerCase) { + this.tLowerCase = tLowerCase; + } + + public MarketStatsStreamResponse pc5m(@jakarta.annotation.Nullable String pc5m) { + this.pc5m = pc5m; + return this; + } + + /** + * 5-minute price change, as a percentage (e.g. \"1.25\" means +1.25%). + * + * @return pc5m + */ + @jakarta.annotation.Nullable + public String getPc5m() { + return pc5m; + } + + public void setPc5m(@jakarta.annotation.Nullable String pc5m) { + this.pc5m = pc5m; + } + + public MarketStatsStreamResponse pc1h(@jakarta.annotation.Nullable String pc1h) { + this.pc1h = pc1h; + return this; + } + + /** + * 1-hour price change, as a percentage (e.g. \"1.25\" means +1.25%). + * + * @return pc1h + */ + @jakarta.annotation.Nullable + public String getPc1h() { + return pc1h; + } + + public void setPc1h(@jakarta.annotation.Nullable String pc1h) { + this.pc1h = pc1h; + } + + public MarketStatsStreamResponse pc4h(@jakarta.annotation.Nullable String pc4h) { + this.pc4h = pc4h; + return this; + } + + /** + * 4-hour price change, as a percentage (e.g. \"1.25\" means +1.25%). + * + * @return pc4h + */ + @jakarta.annotation.Nullable + public String getPc4h() { + return pc4h; + } + + public void setPc4h(@jakarta.annotation.Nullable String pc4h) { + this.pc4h = pc4h; + } + + public MarketStatsStreamResponse pc24h(@jakarta.annotation.Nullable String pc24h) { + this.pc24h = pc24h; + return this; + } + + /** + * 24-hour price change, as a percentage (e.g. \"1.25\" means +1.25%). + * + * @return pc24h + */ + @jakarta.annotation.Nullable + public String getPc24h() { + return pc24h; + } + + public void setPc24h(@jakarta.annotation.Nullable String pc24h) { + this.pc24h = pc24h; + } + + public MarketStatsStreamResponse vol5m(@jakarta.annotation.Nullable String vol5m) { + this.vol5m = vol5m; + return this; + } + + /** + * 5-minute total trading volume in USD. + * + * @return vol5m + */ + @jakarta.annotation.Nullable + public String getVol5m() { + return vol5m; + } + + public void setVol5m(@jakarta.annotation.Nullable String vol5m) { + this.vol5m = vol5m; + } + + public MarketStatsStreamResponse vol1h(@jakarta.annotation.Nullable String vol1h) { + this.vol1h = vol1h; + return this; + } + + /** + * 1-hour total trading volume in USD. + * + * @return vol1h + */ + @jakarta.annotation.Nullable + public String getVol1h() { + return vol1h; + } + + public void setVol1h(@jakarta.annotation.Nullable String vol1h) { + this.vol1h = vol1h; + } + + public MarketStatsStreamResponse vol4h(@jakarta.annotation.Nullable String vol4h) { + this.vol4h = vol4h; + return this; + } + + /** + * 4-hour total trading volume in USD. + * + * @return vol4h + */ + @jakarta.annotation.Nullable + public String getVol4h() { + return vol4h; + } + + public void setVol4h(@jakarta.annotation.Nullable String vol4h) { + this.vol4h = vol4h; + } + + public MarketStatsStreamResponse vol24h(@jakarta.annotation.Nullable String vol24h) { + this.vol24h = vol24h; + return this; + } + + /** + * 24-hour total trading volume in USD. + * + * @return vol24h + */ + @jakarta.annotation.Nullable + public String getVol24h() { + return vol24h; + } + + public void setVol24h(@jakarta.annotation.Nullable String vol24h) { + this.vol24h = vol24h; + } + + public MarketStatsStreamResponse volB5m(@jakarta.annotation.Nullable String volB5m) { + this.volB5m = volB5m; + return this; + } + + /** + * 5-minute buy volume in USD. + * + * @return volB5m + */ + @jakarta.annotation.Nullable + public String getVolB5m() { + return volB5m; + } + + public void setVolB5m(@jakarta.annotation.Nullable String volB5m) { + this.volB5m = volB5m; + } + + public MarketStatsStreamResponse volS5m(@jakarta.annotation.Nullable String volS5m) { + this.volS5m = volS5m; + return this; + } + + /** + * 5-minute sell volume in USD. + * + * @return volS5m + */ + @jakarta.annotation.Nullable + public String getVolS5m() { + return volS5m; + } + + public void setVolS5m(@jakarta.annotation.Nullable String volS5m) { + this.volS5m = volS5m; + } + + public MarketStatsStreamResponse volB1h(@jakarta.annotation.Nullable String volB1h) { + this.volB1h = volB1h; + return this; + } + + /** + * 1-hour buy volume in USD. + * + * @return volB1h + */ + @jakarta.annotation.Nullable + public String getVolB1h() { + return volB1h; + } + + public void setVolB1h(@jakarta.annotation.Nullable String volB1h) { + this.volB1h = volB1h; + } + + public MarketStatsStreamResponse volS1h(@jakarta.annotation.Nullable String volS1h) { + this.volS1h = volS1h; + return this; + } + + /** + * 1-hour sell volume in USD. + * + * @return volS1h + */ + @jakarta.annotation.Nullable + public String getVolS1h() { + return volS1h; + } + + public void setVolS1h(@jakarta.annotation.Nullable String volS1h) { + this.volS1h = volS1h; + } + + public MarketStatsStreamResponse volB4h(@jakarta.annotation.Nullable String volB4h) { + this.volB4h = volB4h; + return this; + } + + /** + * 4-hour buy volume in USD. + * + * @return volB4h + */ + @jakarta.annotation.Nullable + public String getVolB4h() { + return volB4h; + } + + public void setVolB4h(@jakarta.annotation.Nullable String volB4h) { + this.volB4h = volB4h; + } + + public MarketStatsStreamResponse volS4h(@jakarta.annotation.Nullable String volS4h) { + this.volS4h = volS4h; + return this; + } + + /** + * 4-hour sell volume in USD. + * + * @return volS4h + */ + @jakarta.annotation.Nullable + public String getVolS4h() { + return volS4h; + } + + public void setVolS4h(@jakarta.annotation.Nullable String volS4h) { + this.volS4h = volS4h; + } + + public MarketStatsStreamResponse volB24h(@jakarta.annotation.Nullable String volB24h) { + this.volB24h = volB24h; + return this; + } + + /** + * 24-hour buy volume in USD. + * + * @return volB24h + */ + @jakarta.annotation.Nullable + public String getVolB24h() { + return volB24h; + } + + public void setVolB24h(@jakarta.annotation.Nullable String volB24h) { + this.volB24h = volB24h; + } + + public MarketStatsStreamResponse volS24h(@jakarta.annotation.Nullable String volS24h) { + this.volS24h = volS24h; + return this; + } + + /** + * 24-hour sell volume in USD. + * + * @return volS24h + */ + @jakarta.annotation.Nullable + public String getVolS24h() { + return volS24h; + } + + public void setVolS24h(@jakarta.annotation.Nullable String volS24h) { + this.volS24h = volS24h; + } + + public MarketStatsStreamResponse txs5m(@jakarta.annotation.Nullable Integer txs5m) { + this.txs5m = txs5m; + return this; + } + + /** + * 5-minute total transaction count. + * + * @return txs5m + */ + @jakarta.annotation.Nullable + public Integer getTxs5m() { + return txs5m; + } + + public void setTxs5m(@jakarta.annotation.Nullable Integer txs5m) { + this.txs5m = txs5m; + } + + public MarketStatsStreamResponse txs1h(@jakarta.annotation.Nullable Integer txs1h) { + this.txs1h = txs1h; + return this; + } + + /** + * 1-hour total transaction count. + * + * @return txs1h + */ + @jakarta.annotation.Nullable + public Integer getTxs1h() { + return txs1h; + } + + public void setTxs1h(@jakarta.annotation.Nullable Integer txs1h) { + this.txs1h = txs1h; + } + + public MarketStatsStreamResponse txs4h(@jakarta.annotation.Nullable Integer txs4h) { + this.txs4h = txs4h; + return this; + } + + /** + * 4-hour total transaction count. + * + * @return txs4h + */ + @jakarta.annotation.Nullable + public Integer getTxs4h() { + return txs4h; + } + + public void setTxs4h(@jakarta.annotation.Nullable Integer txs4h) { + this.txs4h = txs4h; + } + + public MarketStatsStreamResponse txs24h(@jakarta.annotation.Nullable Integer txs24h) { + this.txs24h = txs24h; + return this; + } + + /** + * 24-hour total transaction count. + * + * @return txs24h + */ + @jakarta.annotation.Nullable + public Integer getTxs24h() { + return txs24h; + } + + public void setTxs24h(@jakarta.annotation.Nullable Integer txs24h) { + this.txs24h = txs24h; + } + + public MarketStatsStreamResponse txsB5m(@jakarta.annotation.Nullable Integer txsB5m) { + this.txsB5m = txsB5m; + return this; + } + + /** + * 5-minute buy transaction count. + * + * @return txsB5m + */ + @jakarta.annotation.Nullable + public Integer getTxsB5m() { + return txsB5m; + } + + public void setTxsB5m(@jakarta.annotation.Nullable Integer txsB5m) { + this.txsB5m = txsB5m; + } + + public MarketStatsStreamResponse txsS5m(@jakarta.annotation.Nullable Integer txsS5m) { + this.txsS5m = txsS5m; + return this; + } + + /** + * 5-minute sell transaction count. + * + * @return txsS5m + */ + @jakarta.annotation.Nullable + public Integer getTxsS5m() { + return txsS5m; + } + + public void setTxsS5m(@jakarta.annotation.Nullable Integer txsS5m) { + this.txsS5m = txsS5m; + } + + public MarketStatsStreamResponse txsB1h(@jakarta.annotation.Nullable Integer txsB1h) { + this.txsB1h = txsB1h; + return this; + } + + /** + * 1-hour buy transaction count. + * + * @return txsB1h + */ + @jakarta.annotation.Nullable + public Integer getTxsB1h() { + return txsB1h; + } + + public void setTxsB1h(@jakarta.annotation.Nullable Integer txsB1h) { + this.txsB1h = txsB1h; + } + + public MarketStatsStreamResponse txsS1h(@jakarta.annotation.Nullable Integer txsS1h) { + this.txsS1h = txsS1h; + return this; + } + + /** + * 1-hour sell transaction count. + * + * @return txsS1h + */ + @jakarta.annotation.Nullable + public Integer getTxsS1h() { + return txsS1h; + } + + public void setTxsS1h(@jakarta.annotation.Nullable Integer txsS1h) { + this.txsS1h = txsS1h; + } + + public MarketStatsStreamResponse txsB4h(@jakarta.annotation.Nullable Integer txsB4h) { + this.txsB4h = txsB4h; + return this; + } + + /** + * 4-hour buy transaction count. + * + * @return txsB4h + */ + @jakarta.annotation.Nullable + public Integer getTxsB4h() { + return txsB4h; + } + + public void setTxsB4h(@jakarta.annotation.Nullable Integer txsB4h) { + this.txsB4h = txsB4h; + } + + public MarketStatsStreamResponse txsS4h(@jakarta.annotation.Nullable Integer txsS4h) { + this.txsS4h = txsS4h; + return this; + } + + /** + * 4-hour sell transaction count. + * + * @return txsS4h + */ + @jakarta.annotation.Nullable + public Integer getTxsS4h() { + return txsS4h; + } + + public void setTxsS4h(@jakarta.annotation.Nullable Integer txsS4h) { + this.txsS4h = txsS4h; + } + + public MarketStatsStreamResponse txsB24h(@jakarta.annotation.Nullable Integer txsB24h) { + this.txsB24h = txsB24h; + return this; + } + + /** + * 24-hour buy transaction count. + * + * @return txsB24h + */ + @jakarta.annotation.Nullable + public Integer getTxsB24h() { + return txsB24h; + } + + public void setTxsB24h(@jakarta.annotation.Nullable Integer txsB24h) { + this.txsB24h = txsB24h; + } + + public MarketStatsStreamResponse txsS24h(@jakarta.annotation.Nullable Integer txsS24h) { + this.txsS24h = txsS24h; + return this; + } + + /** + * 24-hour sell transaction count. + * + * @return txsS24h + */ + @jakarta.annotation.Nullable + public Integer getTxsS24h() { + return txsS24h; + } + + public void setTxsS24h(@jakarta.annotation.Nullable Integer txsS24h) { + this.txsS24h = txsS24h; + } + + public MarketStatsStreamResponse cs(@jakarta.annotation.Nullable String cs) { + this.cs = cs; + return this; + } + + /** + * Circulating supply. + * + * @return cs + */ + @jakarta.annotation.Nullable + public String getCs() { + return cs; + } + + public void setCs(@jakarta.annotation.Nullable String cs) { + this.cs = cs; + } + + public MarketStatsStreamResponse mc(@jakarta.annotation.Nullable String mc) { + this.mc = mc; + return this; + } + + /** + * Market cap in USD. + * + * @return mc + */ + @jakarta.annotation.Nullable + public String getMc() { + return mc; + } + + public void setMc(@jakarta.annotation.Nullable String mc) { + this.mc = mc; + } + + public MarketStatsStreamResponse liq(@jakarta.annotation.Nullable String liq) { + this.liq = liq; + return this; + } + + /** + * Liquidity in USD. + * + * @return liq + */ + @jakarta.annotation.Nullable + public String getLiq() { + return liq; + } + + public void setLiq(@jakarta.annotation.Nullable String liq) { + this.liq = liq; + } + + public MarketStatsStreamResponse holders(@jakarta.annotation.Nullable Integer holders) { + this.holders = holders; + return this; + } + + /** + * Number of holder addresses. + * + * @return holders + */ + @jakarta.annotation.Nullable + public Integer getHolders() { + return holders; + } + + public void setHolders(@jakarta.annotation.Nullable Integer holders) { + this.holders = holders; + } + + public MarketStatsStreamResponse bnVol5m(@jakarta.annotation.Nullable String bnVol5m) { + this.bnVol5m = bnVol5m; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 5-minute total volume in USD. + * + * @return bnVol5m + */ + @jakarta.annotation.Nullable + public String getBnVol5m() { + return bnVol5m; + } + + public void setBnVol5m(@jakarta.annotation.Nullable String bnVol5m) { + this.bnVol5m = bnVol5m; + } + + public MarketStatsStreamResponse bnVol1h(@jakarta.annotation.Nullable String bnVol1h) { + this.bnVol1h = bnVol1h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 1-hour total volume in USD. + * + * @return bnVol1h + */ + @jakarta.annotation.Nullable + public String getBnVol1h() { + return bnVol1h; + } + + public void setBnVol1h(@jakarta.annotation.Nullable String bnVol1h) { + this.bnVol1h = bnVol1h; + } + + public MarketStatsStreamResponse bnVol4h(@jakarta.annotation.Nullable String bnVol4h) { + this.bnVol4h = bnVol4h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 4-hour total volume in USD. + * + * @return bnVol4h + */ + @jakarta.annotation.Nullable + public String getBnVol4h() { + return bnVol4h; + } + + public void setBnVol4h(@jakarta.annotation.Nullable String bnVol4h) { + this.bnVol4h = bnVol4h; + } + + public MarketStatsStreamResponse bnVol24h(@jakarta.annotation.Nullable String bnVol24h) { + this.bnVol24h = bnVol24h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 24-hour total volume in USD. + * + * @return bnVol24h + */ + @jakarta.annotation.Nullable + public String getBnVol24h() { + return bnVol24h; + } + + public void setBnVol24h(@jakarta.annotation.Nullable String bnVol24h) { + this.bnVol24h = bnVol24h; + } + + public MarketStatsStreamResponse bnVolB5m(@jakarta.annotation.Nullable String bnVolB5m) { + this.bnVolB5m = bnVolB5m; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 5-minute buy volume in USD. + * + * @return bnVolB5m + */ + @jakarta.annotation.Nullable + public String getBnVolB5m() { + return bnVolB5m; + } + + public void setBnVolB5m(@jakarta.annotation.Nullable String bnVolB5m) { + this.bnVolB5m = bnVolB5m; + } + + public MarketStatsStreamResponse bnVolS5m(@jakarta.annotation.Nullable String bnVolS5m) { + this.bnVolS5m = bnVolS5m; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 5-minute sell volume in USD. + * + * @return bnVolS5m + */ + @jakarta.annotation.Nullable + public String getBnVolS5m() { + return bnVolS5m; + } + + public void setBnVolS5m(@jakarta.annotation.Nullable String bnVolS5m) { + this.bnVolS5m = bnVolS5m; + } + + public MarketStatsStreamResponse bnVolB1h(@jakarta.annotation.Nullable String bnVolB1h) { + this.bnVolB1h = bnVolB1h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 1-hour buy volume in USD. + * + * @return bnVolB1h + */ + @jakarta.annotation.Nullable + public String getBnVolB1h() { + return bnVolB1h; + } + + public void setBnVolB1h(@jakarta.annotation.Nullable String bnVolB1h) { + this.bnVolB1h = bnVolB1h; + } + + public MarketStatsStreamResponse bnVolS1h(@jakarta.annotation.Nullable String bnVolS1h) { + this.bnVolS1h = bnVolS1h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 1-hour sell volume in USD. + * + * @return bnVolS1h + */ + @jakarta.annotation.Nullable + public String getBnVolS1h() { + return bnVolS1h; + } + + public void setBnVolS1h(@jakarta.annotation.Nullable String bnVolS1h) { + this.bnVolS1h = bnVolS1h; + } + + public MarketStatsStreamResponse bnVolB4h(@jakarta.annotation.Nullable String bnVolB4h) { + this.bnVolB4h = bnVolB4h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 4-hour buy volume in USD. + * + * @return bnVolB4h + */ + @jakarta.annotation.Nullable + public String getBnVolB4h() { + return bnVolB4h; + } + + public void setBnVolB4h(@jakarta.annotation.Nullable String bnVolB4h) { + this.bnVolB4h = bnVolB4h; + } + + public MarketStatsStreamResponse bnVolS4h(@jakarta.annotation.Nullable String bnVolS4h) { + this.bnVolS4h = bnVolS4h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 4-hour sell volume in USD. + * + * @return bnVolS4h + */ + @jakarta.annotation.Nullable + public String getBnVolS4h() { + return bnVolS4h; + } + + public void setBnVolS4h(@jakarta.annotation.Nullable String bnVolS4h) { + this.bnVolS4h = bnVolS4h; + } + + public MarketStatsStreamResponse bnVolB24h(@jakarta.annotation.Nullable String bnVolB24h) { + this.bnVolB24h = bnVolB24h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 24-hour buy volume in USD. + * + * @return bnVolB24h + */ + @jakarta.annotation.Nullable + public String getBnVolB24h() { + return bnVolB24h; + } + + public void setBnVolB24h(@jakarta.annotation.Nullable String bnVolB24h) { + this.bnVolB24h = bnVolB24h; + } + + public MarketStatsStreamResponse bnVolS24h(@jakarta.annotation.Nullable String bnVolS24h) { + this.bnVolS24h = bnVolS24h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 24-hour sell volume in USD. + * + * @return bnVolS24h + */ + @jakarta.annotation.Nullable + public String getBnVolS24h() { + return bnVolS24h; + } + + public void setBnVolS24h(@jakarta.annotation.Nullable String bnVolS24h) { + this.bnVolS24h = bnVolS24h; + } + + public MarketStatsStreamResponse bnTxs5m(@jakarta.annotation.Nullable Integer bnTxs5m) { + this.bnTxs5m = bnTxs5m; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 5-minute total transaction count. + * + * @return bnTxs5m + */ + @jakarta.annotation.Nullable + public Integer getBnTxs5m() { + return bnTxs5m; + } + + public void setBnTxs5m(@jakarta.annotation.Nullable Integer bnTxs5m) { + this.bnTxs5m = bnTxs5m; + } + + public MarketStatsStreamResponse bnTxs1h(@jakarta.annotation.Nullable Integer bnTxs1h) { + this.bnTxs1h = bnTxs1h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 1-hour total transaction count. + * + * @return bnTxs1h + */ + @jakarta.annotation.Nullable + public Integer getBnTxs1h() { + return bnTxs1h; + } + + public void setBnTxs1h(@jakarta.annotation.Nullable Integer bnTxs1h) { + this.bnTxs1h = bnTxs1h; + } + + public MarketStatsStreamResponse bnTxs4h(@jakarta.annotation.Nullable Integer bnTxs4h) { + this.bnTxs4h = bnTxs4h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 4-hour total transaction count. + * + * @return bnTxs4h + */ + @jakarta.annotation.Nullable + public Integer getBnTxs4h() { + return bnTxs4h; + } + + public void setBnTxs4h(@jakarta.annotation.Nullable Integer bnTxs4h) { + this.bnTxs4h = bnTxs4h; + } + + public MarketStatsStreamResponse bnTxs24h(@jakarta.annotation.Nullable Integer bnTxs24h) { + this.bnTxs24h = bnTxs24h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 24-hour total transaction count. + * + * @return bnTxs24h + */ + @jakarta.annotation.Nullable + public Integer getBnTxs24h() { + return bnTxs24h; + } + + public void setBnTxs24h(@jakarta.annotation.Nullable Integer bnTxs24h) { + this.bnTxs24h = bnTxs24h; + } + + public MarketStatsStreamResponse bnTxsB5m(@jakarta.annotation.Nullable Integer bnTxsB5m) { + this.bnTxsB5m = bnTxsB5m; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 5-minute buy transaction count. + * + * @return bnTxsB5m + */ + @jakarta.annotation.Nullable + public Integer getBnTxsB5m() { + return bnTxsB5m; + } + + public void setBnTxsB5m(@jakarta.annotation.Nullable Integer bnTxsB5m) { + this.bnTxsB5m = bnTxsB5m; + } + + public MarketStatsStreamResponse bnTxsS5m(@jakarta.annotation.Nullable Integer bnTxsS5m) { + this.bnTxsS5m = bnTxsS5m; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 5-minute sell transaction count. + * + * @return bnTxsS5m + */ + @jakarta.annotation.Nullable + public Integer getBnTxsS5m() { + return bnTxsS5m; + } + + public void setBnTxsS5m(@jakarta.annotation.Nullable Integer bnTxsS5m) { + this.bnTxsS5m = bnTxsS5m; + } + + public MarketStatsStreamResponse bnTxsB1h(@jakarta.annotation.Nullable Integer bnTxsB1h) { + this.bnTxsB1h = bnTxsB1h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 1-hour buy transaction count. + * + * @return bnTxsB1h + */ + @jakarta.annotation.Nullable + public Integer getBnTxsB1h() { + return bnTxsB1h; + } + + public void setBnTxsB1h(@jakarta.annotation.Nullable Integer bnTxsB1h) { + this.bnTxsB1h = bnTxsB1h; + } + + public MarketStatsStreamResponse bnTxsS1h(@jakarta.annotation.Nullable Integer bnTxsS1h) { + this.bnTxsS1h = bnTxsS1h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 1-hour sell transaction count. + * + * @return bnTxsS1h + */ + @jakarta.annotation.Nullable + public Integer getBnTxsS1h() { + return bnTxsS1h; + } + + public void setBnTxsS1h(@jakarta.annotation.Nullable Integer bnTxsS1h) { + this.bnTxsS1h = bnTxsS1h; + } + + public MarketStatsStreamResponse bnTxsB4h(@jakarta.annotation.Nullable Integer bnTxsB4h) { + this.bnTxsB4h = bnTxsB4h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 4-hour buy transaction count. + * + * @return bnTxsB4h + */ + @jakarta.annotation.Nullable + public Integer getBnTxsB4h() { + return bnTxsB4h; + } + + public void setBnTxsB4h(@jakarta.annotation.Nullable Integer bnTxsB4h) { + this.bnTxsB4h = bnTxsB4h; + } + + public MarketStatsStreamResponse bnTxsS4h(@jakarta.annotation.Nullable Integer bnTxsS4h) { + this.bnTxsS4h = bnTxsS4h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 4-hour sell transaction count. + * + * @return bnTxsS4h + */ + @jakarta.annotation.Nullable + public Integer getBnTxsS4h() { + return bnTxsS4h; + } + + public void setBnTxsS4h(@jakarta.annotation.Nullable Integer bnTxsS4h) { + this.bnTxsS4h = bnTxsS4h; + } + + public MarketStatsStreamResponse bnTxsB24h(@jakarta.annotation.Nullable Integer bnTxsB24h) { + this.bnTxsB24h = bnTxsB24h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 24-hour buy transaction count. + * + * @return bnTxsB24h + */ + @jakarta.annotation.Nullable + public Integer getBnTxsB24h() { + return bnTxsB24h; + } + + public void setBnTxsB24h(@jakarta.annotation.Nullable Integer bnTxsB24h) { + this.bnTxsB24h = bnTxsB24h; + } + + public MarketStatsStreamResponse bnTxsS24h(@jakarta.annotation.Nullable Integer bnTxsS24h) { + this.bnTxsS24h = bnTxsS24h; + return this; + } + + /** + * Binance MPC wallet (trading via Binance Web3 DEX) 24-hour sell transaction count. + * + * @return bnTxsS24h + */ + @jakarta.annotation.Nullable + public Integer getBnTxsS24h() { + return bnTxsS24h; + } + + public void setBnTxsS24h(@jakarta.annotation.Nullable Integer bnTxsS24h) { + this.bnTxsS24h = bnTxsS24h; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MarketStatsStreamResponse marketStatsStreamResponse = (MarketStatsStreamResponse) o; + return Objects.equals(this.pLowerCase, marketStatsStreamResponse.pLowerCase) + && Objects.equals(this.tLowerCase, marketStatsStreamResponse.tLowerCase) + && Objects.equals(this.pc5m, marketStatsStreamResponse.pc5m) + && Objects.equals(this.pc1h, marketStatsStreamResponse.pc1h) + && Objects.equals(this.pc4h, marketStatsStreamResponse.pc4h) + && Objects.equals(this.pc24h, marketStatsStreamResponse.pc24h) + && Objects.equals(this.vol5m, marketStatsStreamResponse.vol5m) + && Objects.equals(this.vol1h, marketStatsStreamResponse.vol1h) + && Objects.equals(this.vol4h, marketStatsStreamResponse.vol4h) + && Objects.equals(this.vol24h, marketStatsStreamResponse.vol24h) + && Objects.equals(this.volB5m, marketStatsStreamResponse.volB5m) + && Objects.equals(this.volS5m, marketStatsStreamResponse.volS5m) + && Objects.equals(this.volB1h, marketStatsStreamResponse.volB1h) + && Objects.equals(this.volS1h, marketStatsStreamResponse.volS1h) + && Objects.equals(this.volB4h, marketStatsStreamResponse.volB4h) + && Objects.equals(this.volS4h, marketStatsStreamResponse.volS4h) + && Objects.equals(this.volB24h, marketStatsStreamResponse.volB24h) + && Objects.equals(this.volS24h, marketStatsStreamResponse.volS24h) + && Objects.equals(this.txs5m, marketStatsStreamResponse.txs5m) + && Objects.equals(this.txs1h, marketStatsStreamResponse.txs1h) + && Objects.equals(this.txs4h, marketStatsStreamResponse.txs4h) + && Objects.equals(this.txs24h, marketStatsStreamResponse.txs24h) + && Objects.equals(this.txsB5m, marketStatsStreamResponse.txsB5m) + && Objects.equals(this.txsS5m, marketStatsStreamResponse.txsS5m) + && Objects.equals(this.txsB1h, marketStatsStreamResponse.txsB1h) + && Objects.equals(this.txsS1h, marketStatsStreamResponse.txsS1h) + && Objects.equals(this.txsB4h, marketStatsStreamResponse.txsB4h) + && Objects.equals(this.txsS4h, marketStatsStreamResponse.txsS4h) + && Objects.equals(this.txsB24h, marketStatsStreamResponse.txsB24h) + && Objects.equals(this.txsS24h, marketStatsStreamResponse.txsS24h) + && Objects.equals(this.cs, marketStatsStreamResponse.cs) + && Objects.equals(this.mc, marketStatsStreamResponse.mc) + && Objects.equals(this.liq, marketStatsStreamResponse.liq) + && Objects.equals(this.holders, marketStatsStreamResponse.holders) + && Objects.equals(this.bnVol5m, marketStatsStreamResponse.bnVol5m) + && Objects.equals(this.bnVol1h, marketStatsStreamResponse.bnVol1h) + && Objects.equals(this.bnVol4h, marketStatsStreamResponse.bnVol4h) + && Objects.equals(this.bnVol24h, marketStatsStreamResponse.bnVol24h) + && Objects.equals(this.bnVolB5m, marketStatsStreamResponse.bnVolB5m) + && Objects.equals(this.bnVolS5m, marketStatsStreamResponse.bnVolS5m) + && Objects.equals(this.bnVolB1h, marketStatsStreamResponse.bnVolB1h) + && Objects.equals(this.bnVolS1h, marketStatsStreamResponse.bnVolS1h) + && Objects.equals(this.bnVolB4h, marketStatsStreamResponse.bnVolB4h) + && Objects.equals(this.bnVolS4h, marketStatsStreamResponse.bnVolS4h) + && Objects.equals(this.bnVolB24h, marketStatsStreamResponse.bnVolB24h) + && Objects.equals(this.bnVolS24h, marketStatsStreamResponse.bnVolS24h) + && Objects.equals(this.bnTxs5m, marketStatsStreamResponse.bnTxs5m) + && Objects.equals(this.bnTxs1h, marketStatsStreamResponse.bnTxs1h) + && Objects.equals(this.bnTxs4h, marketStatsStreamResponse.bnTxs4h) + && Objects.equals(this.bnTxs24h, marketStatsStreamResponse.bnTxs24h) + && Objects.equals(this.bnTxsB5m, marketStatsStreamResponse.bnTxsB5m) + && Objects.equals(this.bnTxsS5m, marketStatsStreamResponse.bnTxsS5m) + && Objects.equals(this.bnTxsB1h, marketStatsStreamResponse.bnTxsB1h) + && Objects.equals(this.bnTxsS1h, marketStatsStreamResponse.bnTxsS1h) + && Objects.equals(this.bnTxsB4h, marketStatsStreamResponse.bnTxsB4h) + && Objects.equals(this.bnTxsS4h, marketStatsStreamResponse.bnTxsS4h) + && Objects.equals(this.bnTxsB24h, marketStatsStreamResponse.bnTxsB24h) + && Objects.equals(this.bnTxsS24h, marketStatsStreamResponse.bnTxsS24h); + } + + @Override + public int hashCode() { + return Objects.hash( + pLowerCase, + tLowerCase, + pc5m, + pc1h, + pc4h, + pc24h, + vol5m, + vol1h, + vol4h, + vol24h, + volB5m, + volS5m, + volB1h, + volS1h, + volB4h, + volS4h, + volB24h, + volS24h, + txs5m, + txs1h, + txs4h, + txs24h, + txsB5m, + txsS5m, + txsB1h, + txsS1h, + txsB4h, + txsS4h, + txsB24h, + txsS24h, + cs, + mc, + liq, + holders, + bnVol5m, + bnVol1h, + bnVol4h, + bnVol24h, + bnVolB5m, + bnVolS5m, + bnVolB1h, + bnVolS1h, + bnVolB4h, + bnVolS4h, + bnVolB24h, + bnVolS24h, + bnTxs5m, + bnTxs1h, + bnTxs4h, + bnTxs24h, + bnTxsB5m, + bnTxsS5m, + bnTxsB1h, + bnTxsS1h, + bnTxsB4h, + bnTxsS4h, + bnTxsB24h, + bnTxsS24h); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MarketStatsStreamResponse {\n"); + sb.append(" pLowerCase: ").append(toIndentedString(pLowerCase)).append("\n"); + sb.append(" tLowerCase: ").append(toIndentedString(tLowerCase)).append("\n"); + sb.append(" pc5m: ").append(toIndentedString(pc5m)).append("\n"); + sb.append(" pc1h: ").append(toIndentedString(pc1h)).append("\n"); + sb.append(" pc4h: ").append(toIndentedString(pc4h)).append("\n"); + sb.append(" pc24h: ").append(toIndentedString(pc24h)).append("\n"); + sb.append(" vol5m: ").append(toIndentedString(vol5m)).append("\n"); + sb.append(" vol1h: ").append(toIndentedString(vol1h)).append("\n"); + sb.append(" vol4h: ").append(toIndentedString(vol4h)).append("\n"); + sb.append(" vol24h: ").append(toIndentedString(vol24h)).append("\n"); + sb.append(" volB5m: ").append(toIndentedString(volB5m)).append("\n"); + sb.append(" volS5m: ").append(toIndentedString(volS5m)).append("\n"); + sb.append(" volB1h: ").append(toIndentedString(volB1h)).append("\n"); + sb.append(" volS1h: ").append(toIndentedString(volS1h)).append("\n"); + sb.append(" volB4h: ").append(toIndentedString(volB4h)).append("\n"); + sb.append(" volS4h: ").append(toIndentedString(volS4h)).append("\n"); + sb.append(" volB24h: ").append(toIndentedString(volB24h)).append("\n"); + sb.append(" volS24h: ").append(toIndentedString(volS24h)).append("\n"); + sb.append(" txs5m: ").append(toIndentedString(txs5m)).append("\n"); + sb.append(" txs1h: ").append(toIndentedString(txs1h)).append("\n"); + sb.append(" txs4h: ").append(toIndentedString(txs4h)).append("\n"); + sb.append(" txs24h: ").append(toIndentedString(txs24h)).append("\n"); + sb.append(" txsB5m: ").append(toIndentedString(txsB5m)).append("\n"); + sb.append(" txsS5m: ").append(toIndentedString(txsS5m)).append("\n"); + sb.append(" txsB1h: ").append(toIndentedString(txsB1h)).append("\n"); + sb.append(" txsS1h: ").append(toIndentedString(txsS1h)).append("\n"); + sb.append(" txsB4h: ").append(toIndentedString(txsB4h)).append("\n"); + sb.append(" txsS4h: ").append(toIndentedString(txsS4h)).append("\n"); + sb.append(" txsB24h: ").append(toIndentedString(txsB24h)).append("\n"); + sb.append(" txsS24h: ").append(toIndentedString(txsS24h)).append("\n"); + sb.append(" cs: ").append(toIndentedString(cs)).append("\n"); + sb.append(" mc: ").append(toIndentedString(mc)).append("\n"); + sb.append(" liq: ").append(toIndentedString(liq)).append("\n"); + sb.append(" holders: ").append(toIndentedString(holders)).append("\n"); + sb.append(" bnVol5m: ").append(toIndentedString(bnVol5m)).append("\n"); + sb.append(" bnVol1h: ").append(toIndentedString(bnVol1h)).append("\n"); + sb.append(" bnVol4h: ").append(toIndentedString(bnVol4h)).append("\n"); + sb.append(" bnVol24h: ").append(toIndentedString(bnVol24h)).append("\n"); + sb.append(" bnVolB5m: ").append(toIndentedString(bnVolB5m)).append("\n"); + sb.append(" bnVolS5m: ").append(toIndentedString(bnVolS5m)).append("\n"); + sb.append(" bnVolB1h: ").append(toIndentedString(bnVolB1h)).append("\n"); + sb.append(" bnVolS1h: ").append(toIndentedString(bnVolS1h)).append("\n"); + sb.append(" bnVolB4h: ").append(toIndentedString(bnVolB4h)).append("\n"); + sb.append(" bnVolS4h: ").append(toIndentedString(bnVolS4h)).append("\n"); + sb.append(" bnVolB24h: ").append(toIndentedString(bnVolB24h)).append("\n"); + sb.append(" bnVolS24h: ").append(toIndentedString(bnVolS24h)).append("\n"); + sb.append(" bnTxs5m: ").append(toIndentedString(bnTxs5m)).append("\n"); + sb.append(" bnTxs1h: ").append(toIndentedString(bnTxs1h)).append("\n"); + sb.append(" bnTxs4h: ").append(toIndentedString(bnTxs4h)).append("\n"); + sb.append(" bnTxs24h: ").append(toIndentedString(bnTxs24h)).append("\n"); + sb.append(" bnTxsB5m: ").append(toIndentedString(bnTxsB5m)).append("\n"); + sb.append(" bnTxsS5m: ").append(toIndentedString(bnTxsS5m)).append("\n"); + sb.append(" bnTxsB1h: ").append(toIndentedString(bnTxsB1h)).append("\n"); + sb.append(" bnTxsS1h: ").append(toIndentedString(bnTxsS1h)).append("\n"); + sb.append(" bnTxsB4h: ").append(toIndentedString(bnTxsB4h)).append("\n"); + sb.append(" bnTxsS4h: ").append(toIndentedString(bnTxsS4h)).append("\n"); + sb.append(" bnTxsB24h: ").append(toIndentedString(bnTxsB24h)).append("\n"); + sb.append(" bnTxsS24h: ").append(toIndentedString(bnTxsS24h)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pLowerCaseValue = getpLowerCase(); + if (pLowerCaseValue != null) { + String pLowerCaseValueAsString = pLowerCaseValue.toString(); + valMap.put("pLowerCase", pLowerCaseValueAsString); + } + Long tLowerCaseValue = gettLowerCase(); + if (tLowerCaseValue != null) { + String tLowerCaseValueAsString = tLowerCaseValue.toString(); + valMap.put("tLowerCase", tLowerCaseValueAsString); + } + String pc5mValue = getPc5m(); + if (pc5mValue != null) { + String pc5mValueAsString = pc5mValue.toString(); + valMap.put("pc5m", pc5mValueAsString); + } + String pc1hValue = getPc1h(); + if (pc1hValue != null) { + String pc1hValueAsString = pc1hValue.toString(); + valMap.put("pc1h", pc1hValueAsString); + } + String pc4hValue = getPc4h(); + if (pc4hValue != null) { + String pc4hValueAsString = pc4hValue.toString(); + valMap.put("pc4h", pc4hValueAsString); + } + String pc24hValue = getPc24h(); + if (pc24hValue != null) { + String pc24hValueAsString = pc24hValue.toString(); + valMap.put("pc24h", pc24hValueAsString); + } + String vol5mValue = getVol5m(); + if (vol5mValue != null) { + String vol5mValueAsString = vol5mValue.toString(); + valMap.put("vol5m", vol5mValueAsString); + } + String vol1hValue = getVol1h(); + if (vol1hValue != null) { + String vol1hValueAsString = vol1hValue.toString(); + valMap.put("vol1h", vol1hValueAsString); + } + String vol4hValue = getVol4h(); + if (vol4hValue != null) { + String vol4hValueAsString = vol4hValue.toString(); + valMap.put("vol4h", vol4hValueAsString); + } + String vol24hValue = getVol24h(); + if (vol24hValue != null) { + String vol24hValueAsString = vol24hValue.toString(); + valMap.put("vol24h", vol24hValueAsString); + } + String volB5mValue = getVolB5m(); + if (volB5mValue != null) { + String volB5mValueAsString = volB5mValue.toString(); + valMap.put("volB5m", volB5mValueAsString); + } + String volS5mValue = getVolS5m(); + if (volS5mValue != null) { + String volS5mValueAsString = volS5mValue.toString(); + valMap.put("volS5m", volS5mValueAsString); + } + String volB1hValue = getVolB1h(); + if (volB1hValue != null) { + String volB1hValueAsString = volB1hValue.toString(); + valMap.put("volB1h", volB1hValueAsString); + } + String volS1hValue = getVolS1h(); + if (volS1hValue != null) { + String volS1hValueAsString = volS1hValue.toString(); + valMap.put("volS1h", volS1hValueAsString); + } + String volB4hValue = getVolB4h(); + if (volB4hValue != null) { + String volB4hValueAsString = volB4hValue.toString(); + valMap.put("volB4h", volB4hValueAsString); + } + String volS4hValue = getVolS4h(); + if (volS4hValue != null) { + String volS4hValueAsString = volS4hValue.toString(); + valMap.put("volS4h", volS4hValueAsString); + } + String volB24hValue = getVolB24h(); + if (volB24hValue != null) { + String volB24hValueAsString = volB24hValue.toString(); + valMap.put("volB24h", volB24hValueAsString); + } + String volS24hValue = getVolS24h(); + if (volS24hValue != null) { + String volS24hValueAsString = volS24hValue.toString(); + valMap.put("volS24h", volS24hValueAsString); + } + Integer txs5mValue = getTxs5m(); + if (txs5mValue != null) { + String txs5mValueAsString = txs5mValue.toString(); + valMap.put("txs5m", txs5mValueAsString); + } + Integer txs1hValue = getTxs1h(); + if (txs1hValue != null) { + String txs1hValueAsString = txs1hValue.toString(); + valMap.put("txs1h", txs1hValueAsString); + } + Integer txs4hValue = getTxs4h(); + if (txs4hValue != null) { + String txs4hValueAsString = txs4hValue.toString(); + valMap.put("txs4h", txs4hValueAsString); + } + Integer txs24hValue = getTxs24h(); + if (txs24hValue != null) { + String txs24hValueAsString = txs24hValue.toString(); + valMap.put("txs24h", txs24hValueAsString); + } + Integer txsB5mValue = getTxsB5m(); + if (txsB5mValue != null) { + String txsB5mValueAsString = txsB5mValue.toString(); + valMap.put("txsB5m", txsB5mValueAsString); + } + Integer txsS5mValue = getTxsS5m(); + if (txsS5mValue != null) { + String txsS5mValueAsString = txsS5mValue.toString(); + valMap.put("txsS5m", txsS5mValueAsString); + } + Integer txsB1hValue = getTxsB1h(); + if (txsB1hValue != null) { + String txsB1hValueAsString = txsB1hValue.toString(); + valMap.put("txsB1h", txsB1hValueAsString); + } + Integer txsS1hValue = getTxsS1h(); + if (txsS1hValue != null) { + String txsS1hValueAsString = txsS1hValue.toString(); + valMap.put("txsS1h", txsS1hValueAsString); + } + Integer txsB4hValue = getTxsB4h(); + if (txsB4hValue != null) { + String txsB4hValueAsString = txsB4hValue.toString(); + valMap.put("txsB4h", txsB4hValueAsString); + } + Integer txsS4hValue = getTxsS4h(); + if (txsS4hValue != null) { + String txsS4hValueAsString = txsS4hValue.toString(); + valMap.put("txsS4h", txsS4hValueAsString); + } + Integer txsB24hValue = getTxsB24h(); + if (txsB24hValue != null) { + String txsB24hValueAsString = txsB24hValue.toString(); + valMap.put("txsB24h", txsB24hValueAsString); + } + Integer txsS24hValue = getTxsS24h(); + if (txsS24hValue != null) { + String txsS24hValueAsString = txsS24hValue.toString(); + valMap.put("txsS24h", txsS24hValueAsString); + } + String csValue = getCs(); + if (csValue != null) { + String csValueAsString = csValue.toString(); + valMap.put("cs", csValueAsString); + } + String mcValue = getMc(); + if (mcValue != null) { + String mcValueAsString = mcValue.toString(); + valMap.put("mc", mcValueAsString); + } + String liqValue = getLiq(); + if (liqValue != null) { + String liqValueAsString = liqValue.toString(); + valMap.put("liq", liqValueAsString); + } + Integer holdersValue = getHolders(); + if (holdersValue != null) { + String holdersValueAsString = holdersValue.toString(); + valMap.put("holders", holdersValueAsString); + } + String bnVol5mValue = getBnVol5m(); + if (bnVol5mValue != null) { + String bnVol5mValueAsString = bnVol5mValue.toString(); + valMap.put("bnVol5m", bnVol5mValueAsString); + } + String bnVol1hValue = getBnVol1h(); + if (bnVol1hValue != null) { + String bnVol1hValueAsString = bnVol1hValue.toString(); + valMap.put("bnVol1h", bnVol1hValueAsString); + } + String bnVol4hValue = getBnVol4h(); + if (bnVol4hValue != null) { + String bnVol4hValueAsString = bnVol4hValue.toString(); + valMap.put("bnVol4h", bnVol4hValueAsString); + } + String bnVol24hValue = getBnVol24h(); + if (bnVol24hValue != null) { + String bnVol24hValueAsString = bnVol24hValue.toString(); + valMap.put("bnVol24h", bnVol24hValueAsString); + } + String bnVolB5mValue = getBnVolB5m(); + if (bnVolB5mValue != null) { + String bnVolB5mValueAsString = bnVolB5mValue.toString(); + valMap.put("bnVolB5m", bnVolB5mValueAsString); + } + String bnVolS5mValue = getBnVolS5m(); + if (bnVolS5mValue != null) { + String bnVolS5mValueAsString = bnVolS5mValue.toString(); + valMap.put("bnVolS5m", bnVolS5mValueAsString); + } + String bnVolB1hValue = getBnVolB1h(); + if (bnVolB1hValue != null) { + String bnVolB1hValueAsString = bnVolB1hValue.toString(); + valMap.put("bnVolB1h", bnVolB1hValueAsString); + } + String bnVolS1hValue = getBnVolS1h(); + if (bnVolS1hValue != null) { + String bnVolS1hValueAsString = bnVolS1hValue.toString(); + valMap.put("bnVolS1h", bnVolS1hValueAsString); + } + String bnVolB4hValue = getBnVolB4h(); + if (bnVolB4hValue != null) { + String bnVolB4hValueAsString = bnVolB4hValue.toString(); + valMap.put("bnVolB4h", bnVolB4hValueAsString); + } + String bnVolS4hValue = getBnVolS4h(); + if (bnVolS4hValue != null) { + String bnVolS4hValueAsString = bnVolS4hValue.toString(); + valMap.put("bnVolS4h", bnVolS4hValueAsString); + } + String bnVolB24hValue = getBnVolB24h(); + if (bnVolB24hValue != null) { + String bnVolB24hValueAsString = bnVolB24hValue.toString(); + valMap.put("bnVolB24h", bnVolB24hValueAsString); + } + String bnVolS24hValue = getBnVolS24h(); + if (bnVolS24hValue != null) { + String bnVolS24hValueAsString = bnVolS24hValue.toString(); + valMap.put("bnVolS24h", bnVolS24hValueAsString); + } + Integer bnTxs5mValue = getBnTxs5m(); + if (bnTxs5mValue != null) { + String bnTxs5mValueAsString = bnTxs5mValue.toString(); + valMap.put("bnTxs5m", bnTxs5mValueAsString); + } + Integer bnTxs1hValue = getBnTxs1h(); + if (bnTxs1hValue != null) { + String bnTxs1hValueAsString = bnTxs1hValue.toString(); + valMap.put("bnTxs1h", bnTxs1hValueAsString); + } + Integer bnTxs4hValue = getBnTxs4h(); + if (bnTxs4hValue != null) { + String bnTxs4hValueAsString = bnTxs4hValue.toString(); + valMap.put("bnTxs4h", bnTxs4hValueAsString); + } + Integer bnTxs24hValue = getBnTxs24h(); + if (bnTxs24hValue != null) { + String bnTxs24hValueAsString = bnTxs24hValue.toString(); + valMap.put("bnTxs24h", bnTxs24hValueAsString); + } + Integer bnTxsB5mValue = getBnTxsB5m(); + if (bnTxsB5mValue != null) { + String bnTxsB5mValueAsString = bnTxsB5mValue.toString(); + valMap.put("bnTxsB5m", bnTxsB5mValueAsString); + } + Integer bnTxsS5mValue = getBnTxsS5m(); + if (bnTxsS5mValue != null) { + String bnTxsS5mValueAsString = bnTxsS5mValue.toString(); + valMap.put("bnTxsS5m", bnTxsS5mValueAsString); + } + Integer bnTxsB1hValue = getBnTxsB1h(); + if (bnTxsB1hValue != null) { + String bnTxsB1hValueAsString = bnTxsB1hValue.toString(); + valMap.put("bnTxsB1h", bnTxsB1hValueAsString); + } + Integer bnTxsS1hValue = getBnTxsS1h(); + if (bnTxsS1hValue != null) { + String bnTxsS1hValueAsString = bnTxsS1hValue.toString(); + valMap.put("bnTxsS1h", bnTxsS1hValueAsString); + } + Integer bnTxsB4hValue = getBnTxsB4h(); + if (bnTxsB4hValue != null) { + String bnTxsB4hValueAsString = bnTxsB4hValue.toString(); + valMap.put("bnTxsB4h", bnTxsB4hValueAsString); + } + Integer bnTxsS4hValue = getBnTxsS4h(); + if (bnTxsS4hValue != null) { + String bnTxsS4hValueAsString = bnTxsS4hValue.toString(); + valMap.put("bnTxsS4h", bnTxsS4hValueAsString); + } + Integer bnTxsB24hValue = getBnTxsB24h(); + if (bnTxsB24hValue != null) { + String bnTxsB24hValueAsString = bnTxsB24hValue.toString(); + valMap.put("bnTxsB24h", bnTxsB24hValueAsString); + } + Integer bnTxsS24hValue = getBnTxsS24h(); + if (bnTxsS24hValue != null) { + String bnTxsS24hValueAsString = bnTxsS24hValue.toString(); + valMap.put("bnTxsS24h", bnTxsS24hValueAsString); + } + + valMap.put("timestamp", getTimestamp()); + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Object pLowerCaseValue = getpLowerCase(); + if (pLowerCaseValue != null) { + valMap.put("pLowerCase", pLowerCaseValue); + } + Object tLowerCaseValue = gettLowerCase(); + if (tLowerCaseValue != null) { + valMap.put("tLowerCase", tLowerCaseValue); + } + Object pc5mValue = getPc5m(); + if (pc5mValue != null) { + valMap.put("pc5m", pc5mValue); + } + Object pc1hValue = getPc1h(); + if (pc1hValue != null) { + valMap.put("pc1h", pc1hValue); + } + Object pc4hValue = getPc4h(); + if (pc4hValue != null) { + valMap.put("pc4h", pc4hValue); + } + Object pc24hValue = getPc24h(); + if (pc24hValue != null) { + valMap.put("pc24h", pc24hValue); + } + Object vol5mValue = getVol5m(); + if (vol5mValue != null) { + valMap.put("vol5m", vol5mValue); + } + Object vol1hValue = getVol1h(); + if (vol1hValue != null) { + valMap.put("vol1h", vol1hValue); + } + Object vol4hValue = getVol4h(); + if (vol4hValue != null) { + valMap.put("vol4h", vol4hValue); + } + Object vol24hValue = getVol24h(); + if (vol24hValue != null) { + valMap.put("vol24h", vol24hValue); + } + Object volB5mValue = getVolB5m(); + if (volB5mValue != null) { + valMap.put("volB5m", volB5mValue); + } + Object volS5mValue = getVolS5m(); + if (volS5mValue != null) { + valMap.put("volS5m", volS5mValue); + } + Object volB1hValue = getVolB1h(); + if (volB1hValue != null) { + valMap.put("volB1h", volB1hValue); + } + Object volS1hValue = getVolS1h(); + if (volS1hValue != null) { + valMap.put("volS1h", volS1hValue); + } + Object volB4hValue = getVolB4h(); + if (volB4hValue != null) { + valMap.put("volB4h", volB4hValue); + } + Object volS4hValue = getVolS4h(); + if (volS4hValue != null) { + valMap.put("volS4h", volS4hValue); + } + Object volB24hValue = getVolB24h(); + if (volB24hValue != null) { + valMap.put("volB24h", volB24hValue); + } + Object volS24hValue = getVolS24h(); + if (volS24hValue != null) { + valMap.put("volS24h", volS24hValue); + } + Object txs5mValue = getTxs5m(); + if (txs5mValue != null) { + valMap.put("txs5m", txs5mValue); + } + Object txs1hValue = getTxs1h(); + if (txs1hValue != null) { + valMap.put("txs1h", txs1hValue); + } + Object txs4hValue = getTxs4h(); + if (txs4hValue != null) { + valMap.put("txs4h", txs4hValue); + } + Object txs24hValue = getTxs24h(); + if (txs24hValue != null) { + valMap.put("txs24h", txs24hValue); + } + Object txsB5mValue = getTxsB5m(); + if (txsB5mValue != null) { + valMap.put("txsB5m", txsB5mValue); + } + Object txsS5mValue = getTxsS5m(); + if (txsS5mValue != null) { + valMap.put("txsS5m", txsS5mValue); + } + Object txsB1hValue = getTxsB1h(); + if (txsB1hValue != null) { + valMap.put("txsB1h", txsB1hValue); + } + Object txsS1hValue = getTxsS1h(); + if (txsS1hValue != null) { + valMap.put("txsS1h", txsS1hValue); + } + Object txsB4hValue = getTxsB4h(); + if (txsB4hValue != null) { + valMap.put("txsB4h", txsB4hValue); + } + Object txsS4hValue = getTxsS4h(); + if (txsS4hValue != null) { + valMap.put("txsS4h", txsS4hValue); + } + Object txsB24hValue = getTxsB24h(); + if (txsB24hValue != null) { + valMap.put("txsB24h", txsB24hValue); + } + Object txsS24hValue = getTxsS24h(); + if (txsS24hValue != null) { + valMap.put("txsS24h", txsS24hValue); + } + Object csValue = getCs(); + if (csValue != null) { + valMap.put("cs", csValue); + } + Object mcValue = getMc(); + if (mcValue != null) { + valMap.put("mc", mcValue); + } + Object liqValue = getLiq(); + if (liqValue != null) { + valMap.put("liq", liqValue); + } + Object holdersValue = getHolders(); + if (holdersValue != null) { + valMap.put("holders", holdersValue); + } + Object bnVol5mValue = getBnVol5m(); + if (bnVol5mValue != null) { + valMap.put("bnVol5m", bnVol5mValue); + } + Object bnVol1hValue = getBnVol1h(); + if (bnVol1hValue != null) { + valMap.put("bnVol1h", bnVol1hValue); + } + Object bnVol4hValue = getBnVol4h(); + if (bnVol4hValue != null) { + valMap.put("bnVol4h", bnVol4hValue); + } + Object bnVol24hValue = getBnVol24h(); + if (bnVol24hValue != null) { + valMap.put("bnVol24h", bnVol24hValue); + } + Object bnVolB5mValue = getBnVolB5m(); + if (bnVolB5mValue != null) { + valMap.put("bnVolB5m", bnVolB5mValue); + } + Object bnVolS5mValue = getBnVolS5m(); + if (bnVolS5mValue != null) { + valMap.put("bnVolS5m", bnVolS5mValue); + } + Object bnVolB1hValue = getBnVolB1h(); + if (bnVolB1hValue != null) { + valMap.put("bnVolB1h", bnVolB1hValue); + } + Object bnVolS1hValue = getBnVolS1h(); + if (bnVolS1hValue != null) { + valMap.put("bnVolS1h", bnVolS1hValue); + } + Object bnVolB4hValue = getBnVolB4h(); + if (bnVolB4hValue != null) { + valMap.put("bnVolB4h", bnVolB4hValue); + } + Object bnVolS4hValue = getBnVolS4h(); + if (bnVolS4hValue != null) { + valMap.put("bnVolS4h", bnVolS4hValue); + } + Object bnVolB24hValue = getBnVolB24h(); + if (bnVolB24hValue != null) { + valMap.put("bnVolB24h", bnVolB24hValue); + } + Object bnVolS24hValue = getBnVolS24h(); + if (bnVolS24hValue != null) { + valMap.put("bnVolS24h", bnVolS24hValue); + } + Object bnTxs5mValue = getBnTxs5m(); + if (bnTxs5mValue != null) { + valMap.put("bnTxs5m", bnTxs5mValue); + } + Object bnTxs1hValue = getBnTxs1h(); + if (bnTxs1hValue != null) { + valMap.put("bnTxs1h", bnTxs1hValue); + } + Object bnTxs4hValue = getBnTxs4h(); + if (bnTxs4hValue != null) { + valMap.put("bnTxs4h", bnTxs4hValue); + } + Object bnTxs24hValue = getBnTxs24h(); + if (bnTxs24hValue != null) { + valMap.put("bnTxs24h", bnTxs24hValue); + } + Object bnTxsB5mValue = getBnTxsB5m(); + if (bnTxsB5mValue != null) { + valMap.put("bnTxsB5m", bnTxsB5mValue); + } + Object bnTxsS5mValue = getBnTxsS5m(); + if (bnTxsS5mValue != null) { + valMap.put("bnTxsS5m", bnTxsS5mValue); + } + Object bnTxsB1hValue = getBnTxsB1h(); + if (bnTxsB1hValue != null) { + valMap.put("bnTxsB1h", bnTxsB1hValue); + } + Object bnTxsS1hValue = getBnTxsS1h(); + if (bnTxsS1hValue != null) { + valMap.put("bnTxsS1h", bnTxsS1hValue); + } + Object bnTxsB4hValue = getBnTxsB4h(); + if (bnTxsB4hValue != null) { + valMap.put("bnTxsB4h", bnTxsB4hValue); + } + Object bnTxsS4hValue = getBnTxsS4h(); + if (bnTxsS4hValue != null) { + valMap.put("bnTxsS4h", bnTxsS4hValue); + } + Object bnTxsB24hValue = getBnTxsB24h(); + if (bnTxsB24hValue != null) { + valMap.put("bnTxsB24h", bnTxsB24hValue); + } + Object bnTxsS24hValue = getBnTxsS24h(); + if (bnTxsS24hValue != null) { + valMap.put("bnTxsS24h", bnTxsS24hValue); + } + + valMap.put("timestamp", getTimestamp()); + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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("p"); + openapiFields.add("t"); + openapiFields.add("pc5m"); + openapiFields.add("pc1h"); + openapiFields.add("pc4h"); + openapiFields.add("pc24h"); + openapiFields.add("vol5m"); + openapiFields.add("vol1h"); + openapiFields.add("vol4h"); + openapiFields.add("vol24h"); + openapiFields.add("volB5m"); + openapiFields.add("volS5m"); + openapiFields.add("volB1h"); + openapiFields.add("volS1h"); + openapiFields.add("volB4h"); + openapiFields.add("volS4h"); + openapiFields.add("volB24h"); + openapiFields.add("volS24h"); + openapiFields.add("txs5m"); + openapiFields.add("txs1h"); + openapiFields.add("txs4h"); + openapiFields.add("txs24h"); + openapiFields.add("txsB5m"); + openapiFields.add("txsS5m"); + openapiFields.add("txsB1h"); + openapiFields.add("txsS1h"); + openapiFields.add("txsB4h"); + openapiFields.add("txsS4h"); + openapiFields.add("txsB24h"); + openapiFields.add("txsS24h"); + openapiFields.add("cs"); + openapiFields.add("mc"); + openapiFields.add("liq"); + openapiFields.add("holders"); + openapiFields.add("bnVol5m"); + openapiFields.add("bnVol1h"); + openapiFields.add("bnVol4h"); + openapiFields.add("bnVol24h"); + openapiFields.add("bnVolB5m"); + openapiFields.add("bnVolS5m"); + openapiFields.add("bnVolB1h"); + openapiFields.add("bnVolS1h"); + openapiFields.add("bnVolB4h"); + openapiFields.add("bnVolS4h"); + openapiFields.add("bnVolB24h"); + openapiFields.add("bnVolS24h"); + openapiFields.add("bnTxs5m"); + openapiFields.add("bnTxs1h"); + openapiFields.add("bnTxs4h"); + openapiFields.add("bnTxs24h"); + openapiFields.add("bnTxsB5m"); + openapiFields.add("bnTxsS5m"); + openapiFields.add("bnTxsB1h"); + openapiFields.add("bnTxsS1h"); + openapiFields.add("bnTxsB4h"); + openapiFields.add("bnTxsS4h"); + openapiFields.add("bnTxsB24h"); + openapiFields.add("bnTxsS24h"); + + // 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 MarketStatsStreamResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MarketStatsStreamResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in MarketStatsStreamResponse is not found" + + " in the empty JSON string", + MarketStatsStreamResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MarketStatsStreamResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `MarketStatsStreamResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("p") != null && !jsonObj.get("p").isJsonNull()) + && !jsonObj.get("p").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `p` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("p").toString())); + } + if ((jsonObj.get("pc5m") != null && !jsonObj.get("pc5m").isJsonNull()) + && !jsonObj.get("pc5m").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pc5m` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pc5m").toString())); + } + if ((jsonObj.get("pc1h") != null && !jsonObj.get("pc1h").isJsonNull()) + && !jsonObj.get("pc1h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pc1h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pc1h").toString())); + } + if ((jsonObj.get("pc4h") != null && !jsonObj.get("pc4h").isJsonNull()) + && !jsonObj.get("pc4h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pc4h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pc4h").toString())); + } + if ((jsonObj.get("pc24h") != null && !jsonObj.get("pc24h").isJsonNull()) + && !jsonObj.get("pc24h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pc24h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pc24h").toString())); + } + if ((jsonObj.get("vol5m") != null && !jsonObj.get("vol5m").isJsonNull()) + && !jsonObj.get("vol5m").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `vol5m` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("vol5m").toString())); + } + if ((jsonObj.get("vol1h") != null && !jsonObj.get("vol1h").isJsonNull()) + && !jsonObj.get("vol1h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `vol1h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("vol1h").toString())); + } + if ((jsonObj.get("vol4h") != null && !jsonObj.get("vol4h").isJsonNull()) + && !jsonObj.get("vol4h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `vol4h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("vol4h").toString())); + } + if ((jsonObj.get("vol24h") != null && !jsonObj.get("vol24h").isJsonNull()) + && !jsonObj.get("vol24h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `vol24h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("vol24h").toString())); + } + if ((jsonObj.get("volB5m") != null && !jsonObj.get("volB5m").isJsonNull()) + && !jsonObj.get("volB5m").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `volB5m` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("volB5m").toString())); + } + if ((jsonObj.get("volS5m") != null && !jsonObj.get("volS5m").isJsonNull()) + && !jsonObj.get("volS5m").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `volS5m` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("volS5m").toString())); + } + if ((jsonObj.get("volB1h") != null && !jsonObj.get("volB1h").isJsonNull()) + && !jsonObj.get("volB1h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `volB1h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("volB1h").toString())); + } + if ((jsonObj.get("volS1h") != null && !jsonObj.get("volS1h").isJsonNull()) + && !jsonObj.get("volS1h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `volS1h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("volS1h").toString())); + } + if ((jsonObj.get("volB4h") != null && !jsonObj.get("volB4h").isJsonNull()) + && !jsonObj.get("volB4h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `volB4h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("volB4h").toString())); + } + if ((jsonObj.get("volS4h") != null && !jsonObj.get("volS4h").isJsonNull()) + && !jsonObj.get("volS4h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `volS4h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("volS4h").toString())); + } + if ((jsonObj.get("volB24h") != null && !jsonObj.get("volB24h").isJsonNull()) + && !jsonObj.get("volB24h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `volB24h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("volB24h").toString())); + } + if ((jsonObj.get("volS24h") != null && !jsonObj.get("volS24h").isJsonNull()) + && !jsonObj.get("volS24h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `volS24h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("volS24h").toString())); + } + if ((jsonObj.get("cs") != null && !jsonObj.get("cs").isJsonNull()) + && !jsonObj.get("cs").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `cs` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("cs").toString())); + } + if ((jsonObj.get("mc") != null && !jsonObj.get("mc").isJsonNull()) + && !jsonObj.get("mc").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `mc` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("mc").toString())); + } + if ((jsonObj.get("liq") != null && !jsonObj.get("liq").isJsonNull()) + && !jsonObj.get("liq").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `liq` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("liq").toString())); + } + if ((jsonObj.get("bnVol5m") != null && !jsonObj.get("bnVol5m").isJsonNull()) + && !jsonObj.get("bnVol5m").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVol5m` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("bnVol5m").toString())); + } + if ((jsonObj.get("bnVol1h") != null && !jsonObj.get("bnVol1h").isJsonNull()) + && !jsonObj.get("bnVol1h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVol1h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("bnVol1h").toString())); + } + if ((jsonObj.get("bnVol4h") != null && !jsonObj.get("bnVol4h").isJsonNull()) + && !jsonObj.get("bnVol4h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVol4h` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("bnVol4h").toString())); + } + if ((jsonObj.get("bnVol24h") != null && !jsonObj.get("bnVol24h").isJsonNull()) + && !jsonObj.get("bnVol24h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVol24h` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVol24h").toString())); + } + if ((jsonObj.get("bnVolB5m") != null && !jsonObj.get("bnVolB5m").isJsonNull()) + && !jsonObj.get("bnVolB5m").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVolB5m` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVolB5m").toString())); + } + if ((jsonObj.get("bnVolS5m") != null && !jsonObj.get("bnVolS5m").isJsonNull()) + && !jsonObj.get("bnVolS5m").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVolS5m` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVolS5m").toString())); + } + if ((jsonObj.get("bnVolB1h") != null && !jsonObj.get("bnVolB1h").isJsonNull()) + && !jsonObj.get("bnVolB1h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVolB1h` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVolB1h").toString())); + } + if ((jsonObj.get("bnVolS1h") != null && !jsonObj.get("bnVolS1h").isJsonNull()) + && !jsonObj.get("bnVolS1h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVolS1h` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVolS1h").toString())); + } + if ((jsonObj.get("bnVolB4h") != null && !jsonObj.get("bnVolB4h").isJsonNull()) + && !jsonObj.get("bnVolB4h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVolB4h` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVolB4h").toString())); + } + if ((jsonObj.get("bnVolS4h") != null && !jsonObj.get("bnVolS4h").isJsonNull()) + && !jsonObj.get("bnVolS4h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVolS4h` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVolS4h").toString())); + } + if ((jsonObj.get("bnVolB24h") != null && !jsonObj.get("bnVolB24h").isJsonNull()) + && !jsonObj.get("bnVolB24h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVolB24h` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVolB24h").toString())); + } + if ((jsonObj.get("bnVolS24h") != null && !jsonObj.get("bnVolS24h").isJsonNull()) + && !jsonObj.get("bnVolS24h").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bnVolS24h` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("bnVolS24h").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MarketStatsStreamResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MarketStatsStreamResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(MarketStatsStreamResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, MarketStatsStreamResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MarketStatsStreamResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of MarketStatsStreamResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of MarketStatsStreamResponse + * @throws IOException if the JSON string is invalid with respect to MarketStatsStreamResponse + */ + public static MarketStatsStreamResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MarketStatsStreamResponse.class); + } + + /** + * Convert an instance of MarketStatsStreamResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/PriceStreamRequest.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/PriceStreamRequest.java new file mode 100644 index 0000000..a16c164 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/PriceStreamRequest.java @@ -0,0 +1,333 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** PriceStreamRequest */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class PriceStreamRequest extends BaseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @jakarta.annotation.Nullable + private String id; + + public static final String SERIALIZED_NAME_CHAIN_ID = "chainId"; + + @SerializedName(SERIALIZED_NAME_CHAIN_ID) + @jakarta.annotation.Nullable + private String chainId; + + public static final String SERIALIZED_NAME_CONTRACT_ADDRESS = "contractAddress"; + + @SerializedName(SERIALIZED_NAME_CONTRACT_ADDRESS) + @jakarta.annotation.Nullable + private String contractAddress; + + public PriceStreamRequest() {} + + public PriceStreamRequest id(@jakarta.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * Unique WebSocket request ID. + * + * @return id + */ + @jakarta.annotation.Nullable + public String getId() { + return id; + } + + public void setId(@jakarta.annotation.Nullable String id) { + this.id = id; + } + + public PriceStreamRequest chainId(@jakarta.annotation.Nullable String chainId) { + this.chainId = chainId; + return this; + } + + /** + * Chain identifier, e.g. \"1\"=Ethereum, \"56\"=BSC, + * \"CT_501\"=Solana. Full supported-chain list: same as the + * [\"supported/chain\"](/catalog/web3-wallet/api/rest-api/general-data#get-supported-chains) + * endpoint. + * + * @return chainId + */ + @jakarta.annotation.Nullable + public String getChainId() { + return chainId; + } + + public void setChainId(@jakarta.annotation.Nullable String chainId) { + this.chainId = chainId; + } + + public PriceStreamRequest contractAddress(@jakarta.annotation.Nullable String contractAddress) { + this.contractAddress = contractAddress; + return this; + } + + /** + * Token contract address. + * + * @return contractAddress + */ + @jakarta.annotation.Nullable + public String getContractAddress() { + return contractAddress; + } + + public void setContractAddress(@jakarta.annotation.Nullable String contractAddress) { + this.contractAddress = contractAddress; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PriceStreamRequest priceStreamRequest = (PriceStreamRequest) o; + return Objects.equals(this.id, priceStreamRequest.id) + && Objects.equals(this.chainId, priceStreamRequest.chainId) + && Objects.equals(this.contractAddress, priceStreamRequest.contractAddress); + } + + @Override + public int hashCode() { + return Objects.hash(id, chainId, contractAddress); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PriceStreamRequest {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" chainId: ").append(toIndentedString(chainId)).append("\n"); + sb.append(" contractAddress: ").append(toIndentedString(contractAddress)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String idValue = getId(); + if (idValue != null) { + String idValueAsString = idValue.toString(); + valMap.put("id", idValueAsString); + } + String chainIdValue = getChainId(); + if (chainIdValue != null) { + String chainIdValueAsString = chainIdValue.toString(); + valMap.put("chainId", chainIdValueAsString); + } + String contractAddressValue = getContractAddress(); + if (contractAddressValue != null) { + String contractAddressValueAsString = contractAddressValue.toString(); + valMap.put("contractAddress", contractAddressValueAsString); + } + + valMap.put("timestamp", getTimestamp()); + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Object idValue = getId(); + if (idValue != null) { + valMap.put("id", idValue); + } + Object chainIdValue = getChainId(); + if (chainIdValue != null) { + valMap.put("chainId", chainIdValue); + } + Object contractAddressValue = getContractAddress(); + if (contractAddressValue != null) { + valMap.put("contractAddress", contractAddressValue); + } + + valMap.put("timestamp", getTimestamp()); + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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("id"); + openapiFields.add("chainId"); + openapiFields.add("contractAddress"); + + // 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 PriceStreamRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PriceStreamRequest.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in PriceStreamRequest is not found in the" + + " empty JSON string", + PriceStreamRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PriceStreamRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `PriceStreamRequest` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("chainId") != null && !jsonObj.get("chainId").isJsonNull()) + && !jsonObj.get("chainId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `chainId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("chainId").toString())); + } + if ((jsonObj.get("contractAddress") != null && !jsonObj.get("contractAddress").isJsonNull()) + && !jsonObj.get("contractAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `contractAddress` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("contractAddress").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PriceStreamRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PriceStreamRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(PriceStreamRequest.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, PriceStreamRequest value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PriceStreamRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of PriceStreamRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of PriceStreamRequest + * @throws IOException if the JSON string is invalid with respect to PriceStreamRequest + */ + public static PriceStreamRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PriceStreamRequest.class); + } + + /** + * Convert an instance of PriceStreamRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/PriceStreamResponse.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/PriceStreamResponse.java new file mode 100644 index 0000000..68e4222 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/PriceStreamResponse.java @@ -0,0 +1,277 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** Price stream event payload. */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class PriceStreamResponse extends BaseDTO { + public static final String SERIALIZED_NAME_P_LOWER_CASE = "p"; + + @SerializedName(SERIALIZED_NAME_P_LOWER_CASE) + @jakarta.annotation.Nullable + private String pLowerCase; + + public static final String SERIALIZED_NAME_T_LOWER_CASE = "t"; + + @SerializedName(SERIALIZED_NAME_T_LOWER_CASE) + @jakarta.annotation.Nullable + private Long tLowerCase; + + public PriceStreamResponse() {} + + public PriceStreamResponse pLowerCase(@jakarta.annotation.Nullable String pLowerCase) { + this.pLowerCase = pLowerCase; + return this; + } + + /** + * Latest price. + * + * @return pLowerCase + */ + @jakarta.annotation.Nullable + public String getpLowerCase() { + return pLowerCase; + } + + public void setpLowerCase(@jakarta.annotation.Nullable String pLowerCase) { + this.pLowerCase = pLowerCase; + } + + public PriceStreamResponse tLowerCase(@jakarta.annotation.Nullable Long tLowerCase) { + this.tLowerCase = tLowerCase; + return this; + } + + /** + * Price timestamp in milliseconds. + * + * @return tLowerCase + */ + @jakarta.annotation.Nullable + public Long gettLowerCase() { + return tLowerCase; + } + + public void settLowerCase(@jakarta.annotation.Nullable Long tLowerCase) { + this.tLowerCase = tLowerCase; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PriceStreamResponse priceStreamResponse = (PriceStreamResponse) o; + return Objects.equals(this.pLowerCase, priceStreamResponse.pLowerCase) + && Objects.equals(this.tLowerCase, priceStreamResponse.tLowerCase); + } + + @Override + public int hashCode() { + return Objects.hash(pLowerCase, tLowerCase); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PriceStreamResponse {\n"); + sb.append(" pLowerCase: ").append(toIndentedString(pLowerCase)).append("\n"); + sb.append(" tLowerCase: ").append(toIndentedString(tLowerCase)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pLowerCaseValue = getpLowerCase(); + if (pLowerCaseValue != null) { + String pLowerCaseValueAsString = pLowerCaseValue.toString(); + valMap.put("pLowerCase", pLowerCaseValueAsString); + } + Long tLowerCaseValue = gettLowerCase(); + if (tLowerCaseValue != null) { + String tLowerCaseValueAsString = tLowerCaseValue.toString(); + valMap.put("tLowerCase", tLowerCaseValueAsString); + } + + valMap.put("timestamp", getTimestamp()); + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Object pLowerCaseValue = getpLowerCase(); + if (pLowerCaseValue != null) { + valMap.put("pLowerCase", pLowerCaseValue); + } + Object tLowerCaseValue = gettLowerCase(); + if (tLowerCaseValue != null) { + valMap.put("tLowerCase", tLowerCaseValue); + } + + valMap.put("timestamp", getTimestamp()); + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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("p"); + openapiFields.add("t"); + + // 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 PriceStreamResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PriceStreamResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in PriceStreamResponse is not found in" + + " the empty JSON string", + PriceStreamResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PriceStreamResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `PriceStreamResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("p") != null && !jsonObj.get("p").isJsonNull()) + && !jsonObj.get("p").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `p` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("p").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PriceStreamResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PriceStreamResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(PriceStreamResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, PriceStreamResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PriceStreamResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of PriceStreamResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of PriceStreamResponse + * @throws IOException if the JSON string is invalid with respect to PriceStreamResponse + */ + public static PriceStreamResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PriceStreamResponse.class); + } + + /** + * Convert an instance of PriceStreamResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamRequest.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamRequest.java new file mode 100644 index 0000000..89097ab --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamRequest.java @@ -0,0 +1,337 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** RealTimeTradesStreamRequest */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class RealTimeTradesStreamRequest extends BaseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @jakarta.annotation.Nullable + private String id; + + public static final String SERIALIZED_NAME_CHAIN_ID = "chainId"; + + @SerializedName(SERIALIZED_NAME_CHAIN_ID) + @jakarta.annotation.Nullable + private String chainId; + + public static final String SERIALIZED_NAME_CONTRACT_ADDRESS = "contractAddress"; + + @SerializedName(SERIALIZED_NAME_CONTRACT_ADDRESS) + @jakarta.annotation.Nullable + private String contractAddress; + + public RealTimeTradesStreamRequest() {} + + public RealTimeTradesStreamRequest id(@jakarta.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * Unique WebSocket request ID. + * + * @return id + */ + @jakarta.annotation.Nullable + public String getId() { + return id; + } + + public void setId(@jakarta.annotation.Nullable String id) { + this.id = id; + } + + public RealTimeTradesStreamRequest chainId(@jakarta.annotation.Nullable String chainId) { + this.chainId = chainId; + return this; + } + + /** + * Chain identifier, e.g. \"1\"=Ethereum, \"56\"=BSC, + * \"CT_501\"=Solana. Full supported-chain list: same as the + * [\"supported/chain\"](/catalog/web3-wallet/api/rest-api/general-data#get-supported-chains) + * endpoint. + * + * @return chainId + */ + @jakarta.annotation.Nullable + public String getChainId() { + return chainId; + } + + public void setChainId(@jakarta.annotation.Nullable String chainId) { + this.chainId = chainId; + } + + public RealTimeTradesStreamRequest contractAddress( + @jakarta.annotation.Nullable String contractAddress) { + this.contractAddress = contractAddress; + return this; + } + + /** + * Token contract address. + * + * @return contractAddress + */ + @jakarta.annotation.Nullable + public String getContractAddress() { + return contractAddress; + } + + public void setContractAddress(@jakarta.annotation.Nullable String contractAddress) { + this.contractAddress = contractAddress; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RealTimeTradesStreamRequest realTimeTradesStreamRequest = (RealTimeTradesStreamRequest) o; + return Objects.equals(this.id, realTimeTradesStreamRequest.id) + && Objects.equals(this.chainId, realTimeTradesStreamRequest.chainId) + && Objects.equals( + this.contractAddress, realTimeTradesStreamRequest.contractAddress); + } + + @Override + public int hashCode() { + return Objects.hash(id, chainId, contractAddress); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RealTimeTradesStreamRequest {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" chainId: ").append(toIndentedString(chainId)).append("\n"); + sb.append(" contractAddress: ").append(toIndentedString(contractAddress)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String idValue = getId(); + if (idValue != null) { + String idValueAsString = idValue.toString(); + valMap.put("id", idValueAsString); + } + String chainIdValue = getChainId(); + if (chainIdValue != null) { + String chainIdValueAsString = chainIdValue.toString(); + valMap.put("chainId", chainIdValueAsString); + } + String contractAddressValue = getContractAddress(); + if (contractAddressValue != null) { + String contractAddressValueAsString = contractAddressValue.toString(); + valMap.put("contractAddress", contractAddressValueAsString); + } + + valMap.put("timestamp", getTimestamp()); + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Object idValue = getId(); + if (idValue != null) { + valMap.put("id", idValue); + } + Object chainIdValue = getChainId(); + if (chainIdValue != null) { + valMap.put("chainId", chainIdValue); + } + Object contractAddressValue = getContractAddress(); + if (contractAddressValue != null) { + valMap.put("contractAddress", contractAddressValue); + } + + valMap.put("timestamp", getTimestamp()); + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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("id"); + openapiFields.add("chainId"); + openapiFields.add("contractAddress"); + + // 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 + * RealTimeTradesStreamRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RealTimeTradesStreamRequest.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in RealTimeTradesStreamRequest is not" + + " found in the empty JSON string", + RealTimeTradesStreamRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RealTimeTradesStreamRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `RealTimeTradesStreamRequest` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("chainId") != null && !jsonObj.get("chainId").isJsonNull()) + && !jsonObj.get("chainId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `chainId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("chainId").toString())); + } + if ((jsonObj.get("contractAddress") != null && !jsonObj.get("contractAddress").isJsonNull()) + && !jsonObj.get("contractAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `contractAddress` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("contractAddress").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RealTimeTradesStreamRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RealTimeTradesStreamRequest' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(RealTimeTradesStreamRequest.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, RealTimeTradesStreamRequest value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RealTimeTradesStreamRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of RealTimeTradesStreamRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of RealTimeTradesStreamRequest + * @throws IOException if the JSON string is invalid with respect to RealTimeTradesStreamRequest + */ + public static RealTimeTradesStreamRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RealTimeTradesStreamRequest.class); + } + + /** + * Convert an instance of RealTimeTradesStreamRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamResponse.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamResponse.java new file mode 100644 index 0000000..d754922 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamResponse.java @@ -0,0 +1,492 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** Trade history event payload. */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class RealTimeTradesStreamResponse extends BaseDTO { + public static final String SERIALIZED_NAME_TX = "tx"; + + @SerializedName(SERIALIZED_NAME_TX) + @jakarta.annotation.Nullable + private String tx; + + public static final String SERIALIZED_NAME_UA = "ua"; + + @SerializedName(SERIALIZED_NAME_UA) + @jakarta.annotation.Nullable + private String ua; + + public static final String SERIALIZED_NAME_TP = "tp"; + + @SerializedName(SERIALIZED_NAME_TP) + @jakarta.annotation.Nullable + private String tp; + + public static final String SERIALIZED_NAME_VOL = "vol"; + + @SerializedName(SERIALIZED_NAME_VOL) + @jakarta.annotation.Nullable + private String vol; + + public static final String SERIALIZED_NAME_T_LOWER_CASE = "t"; + + @SerializedName(SERIALIZED_NAME_T_LOWER_CASE) + @jakarta.annotation.Nullable + private Long tLowerCase; + + public static final String SERIALIZED_NAME_TOKENS = "tokens"; + + @SerializedName(SERIALIZED_NAME_TOKENS) + @jakarta.annotation.Nullable + private List<@Valid RealTimeTradesStreamResponseTokensInner> tokens; + + public RealTimeTradesStreamResponse() {} + + public RealTimeTradesStreamResponse tx(@jakarta.annotation.Nullable String tx) { + this.tx = tx; + return this; + } + + /** + * Transaction hash. + * + * @return tx + */ + @jakarta.annotation.Nullable + public String getTx() { + return tx; + } + + public void setTx(@jakarta.annotation.Nullable String tx) { + this.tx = tx; + } + + public RealTimeTradesStreamResponse ua(@jakarta.annotation.Nullable String ua) { + this.ua = ua; + return this; + } + + /** + * Transaction initiator wallet address (the wallet that initiated the swap). + * + * @return ua + */ + @jakarta.annotation.Nullable + public String getUa() { + return ua; + } + + public void setUa(@jakarta.annotation.Nullable String ua) { + this.ua = ua; + } + + public RealTimeTradesStreamResponse tp(@jakarta.annotation.Nullable String tp) { + this.tp = tp; + return this; + } + + /** + * Trade direction relative to the queried (base) token: buy or sell. + * + * @return tp + */ + @jakarta.annotation.Nullable + public String getTp() { + return tp; + } + + public void setTp(@jakarta.annotation.Nullable String tp) { + this.tp = tp; + } + + public RealTimeTradesStreamResponse vol(@jakarta.annotation.Nullable String vol) { + this.vol = vol; + return this; + } + + /** + * Trade amount in USD. + * + * @return vol + */ + @jakarta.annotation.Nullable + public String getVol() { + return vol; + } + + public void setVol(@jakarta.annotation.Nullable String vol) { + this.vol = vol; + } + + public RealTimeTradesStreamResponse tLowerCase(@jakarta.annotation.Nullable Long tLowerCase) { + this.tLowerCase = tLowerCase; + return this; + } + + /** + * Trade timestamp in milliseconds. + * + * @return tLowerCase + */ + @jakarta.annotation.Nullable + public Long gettLowerCase() { + return tLowerCase; + } + + public void settLowerCase(@jakarta.annotation.Nullable Long tLowerCase) { + this.tLowerCase = tLowerCase; + } + + public RealTimeTradesStreamResponse tokens( + @jakarta.annotation.Nullable + List<@Valid RealTimeTradesStreamResponseTokensInner> tokens) { + this.tokens = tokens; + return this; + } + + public RealTimeTradesStreamResponse addTokensItem( + RealTimeTradesStreamResponseTokensInner tokensItem) { + if (this.tokens == null) { + this.tokens = new ArrayList<>(); + } + this.tokens.add(tokensItem); + return this; + } + + /** + * Token pair info. Fixed 2 elements — first is the base token, second is the quote token. + * + * @return tokens + */ + @jakarta.annotation.Nullable + @Valid + public List<@Valid RealTimeTradesStreamResponseTokensInner> getTokens() { + return tokens; + } + + public void setTokens( + @jakarta.annotation.Nullable + List<@Valid RealTimeTradesStreamResponseTokensInner> tokens) { + this.tokens = tokens; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RealTimeTradesStreamResponse realTimeTradesStreamResponse = + (RealTimeTradesStreamResponse) o; + return Objects.equals(this.tx, realTimeTradesStreamResponse.tx) + && Objects.equals(this.ua, realTimeTradesStreamResponse.ua) + && Objects.equals(this.tp, realTimeTradesStreamResponse.tp) + && Objects.equals(this.vol, realTimeTradesStreamResponse.vol) + && Objects.equals(this.tLowerCase, realTimeTradesStreamResponse.tLowerCase) + && Objects.equals(this.tokens, realTimeTradesStreamResponse.tokens); + } + + @Override + public int hashCode() { + return Objects.hash(tx, ua, tp, vol, tLowerCase, tokens); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RealTimeTradesStreamResponse {\n"); + sb.append(" tx: ").append(toIndentedString(tx)).append("\n"); + sb.append(" ua: ").append(toIndentedString(ua)).append("\n"); + sb.append(" tp: ").append(toIndentedString(tp)).append("\n"); + sb.append(" vol: ").append(toIndentedString(vol)).append("\n"); + sb.append(" tLowerCase: ").append(toIndentedString(tLowerCase)).append("\n"); + sb.append(" tokens: ").append(toIndentedString(tokens)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String txValue = getTx(); + if (txValue != null) { + String txValueAsString = txValue.toString(); + valMap.put("tx", txValueAsString); + } + String uaValue = getUa(); + if (uaValue != null) { + String uaValueAsString = uaValue.toString(); + valMap.put("ua", uaValueAsString); + } + String tpValue = getTp(); + if (tpValue != null) { + String tpValueAsString = tpValue.toString(); + valMap.put("tp", tpValueAsString); + } + String volValue = getVol(); + if (volValue != null) { + String volValueAsString = volValue.toString(); + valMap.put("vol", volValueAsString); + } + Long tLowerCaseValue = gettLowerCase(); + if (tLowerCaseValue != null) { + String tLowerCaseValueAsString = tLowerCaseValue.toString(); + valMap.put("tLowerCase", tLowerCaseValueAsString); + } + List<@Valid RealTimeTradesStreamResponseTokensInner> tokensValue = getTokens(); + if (tokensValue != null) { + String tokensValueAsString = JSON.getGson().toJson(tokensValue); + valMap.put("tokens", tokensValueAsString); + } + + valMap.put("timestamp", getTimestamp()); + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Object txValue = getTx(); + if (txValue != null) { + valMap.put("tx", txValue); + } + Object uaValue = getUa(); + if (uaValue != null) { + valMap.put("ua", uaValue); + } + Object tpValue = getTp(); + if (tpValue != null) { + valMap.put("tp", tpValue); + } + Object volValue = getVol(); + if (volValue != null) { + valMap.put("vol", volValue); + } + Object tLowerCaseValue = gettLowerCase(); + if (tLowerCaseValue != null) { + valMap.put("tLowerCase", tLowerCaseValue); + } + Object tokensValue = getTokens(); + if (tokensValue != null) { + valMap.put("tokens", tokensValue); + } + + valMap.put("timestamp", getTimestamp()); + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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("tx"); + openapiFields.add("ua"); + openapiFields.add("tp"); + openapiFields.add("vol"); + openapiFields.add("t"); + openapiFields.add("tokens"); + + // 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 + * RealTimeTradesStreamResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RealTimeTradesStreamResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in RealTimeTradesStreamResponse is not" + + " found in the empty JSON string", + RealTimeTradesStreamResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RealTimeTradesStreamResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `RealTimeTradesStreamResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("tx") != null && !jsonObj.get("tx").isJsonNull()) + && !jsonObj.get("tx").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `tx` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("tx").toString())); + } + if ((jsonObj.get("ua") != null && !jsonObj.get("ua").isJsonNull()) + && !jsonObj.get("ua").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ua` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("ua").toString())); + } + if ((jsonObj.get("tp") != null && !jsonObj.get("tp").isJsonNull()) + && !jsonObj.get("tp").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `tp` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("tp").toString())); + } + if ((jsonObj.get("vol") != null && !jsonObj.get("vol").isJsonNull()) + && !jsonObj.get("vol").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `vol` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("vol").toString())); + } + if (jsonObj.get("tokens") != null && !jsonObj.get("tokens").isJsonNull()) { + JsonArray jsonArraytokens = jsonObj.getAsJsonArray("tokens"); + if (jsonArraytokens != null) { + // ensure the json data is an array + if (!jsonObj.get("tokens").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `tokens` to be an array in the JSON string" + + " but got `%s`", + jsonObj.get("tokens").toString())); + } + + // validate the optional field `tokens` (array) + for (int i = 0; i < jsonArraytokens.size(); i++) { + RealTimeTradesStreamResponseTokensInner.validateJsonElement( + jsonArraytokens.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RealTimeTradesStreamResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RealTimeTradesStreamResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(RealTimeTradesStreamResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, RealTimeTradesStreamResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RealTimeTradesStreamResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of RealTimeTradesStreamResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of RealTimeTradesStreamResponse + * @throws IOException if the JSON string is invalid with respect to + * RealTimeTradesStreamResponse + */ + public static RealTimeTradesStreamResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RealTimeTradesStreamResponse.class); + } + + /** + * Convert an instance of RealTimeTradesStreamResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamResponseTokensInner.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamResponseTokensInner.java new file mode 100644 index 0000000..d7886f5 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/model/RealTimeTradesStreamResponseTokensInner.java @@ -0,0 +1,345 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.web3_wallet.websocket.stream.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.hibernate.validator.constraints.*; + +/** RealTimeTradesStreamResponseTokensInner */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class RealTimeTradesStreamResponseTokensInner extends BaseDTO { + public static final String SERIALIZED_NAME_A_LOWER_CASE = "a"; + + @SerializedName(SERIALIZED_NAME_A_LOWER_CASE) + @jakarta.annotation.Nullable + private String aLowerCase; + + public static final String SERIALIZED_NAME_S_LOWER_CASE = "s"; + + @SerializedName(SERIALIZED_NAME_S_LOWER_CASE) + @jakarta.annotation.Nullable + private String sLowerCase; + + public static final String SERIALIZED_NAME_CA = "ca"; + + @SerializedName(SERIALIZED_NAME_CA) + @jakarta.annotation.Nullable + private String ca; + + public RealTimeTradesStreamResponseTokensInner() {} + + public RealTimeTradesStreamResponseTokensInner aLowerCase( + @jakarta.annotation.Nullable String aLowerCase) { + this.aLowerCase = aLowerCase; + return this; + } + + /** + * Token amount. + * + * @return aLowerCase + */ + @jakarta.annotation.Nullable + public String getaLowerCase() { + return aLowerCase; + } + + public void setaLowerCase(@jakarta.annotation.Nullable String aLowerCase) { + this.aLowerCase = aLowerCase; + } + + public RealTimeTradesStreamResponseTokensInner sLowerCase( + @jakarta.annotation.Nullable String sLowerCase) { + this.sLowerCase = sLowerCase; + return this; + } + + /** + * Token symbol. + * + * @return sLowerCase + */ + @jakarta.annotation.Nullable + public String getsLowerCase() { + return sLowerCase; + } + + public void setsLowerCase(@jakarta.annotation.Nullable String sLowerCase) { + this.sLowerCase = sLowerCase; + } + + public RealTimeTradesStreamResponseTokensInner ca(@jakarta.annotation.Nullable String ca) { + this.ca = ca; + return this; + } + + /** + * Token contract address. + * + * @return ca + */ + @jakarta.annotation.Nullable + public String getCa() { + return ca; + } + + public void setCa(@jakarta.annotation.Nullable String ca) { + this.ca = ca; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RealTimeTradesStreamResponseTokensInner realTimeTradesStreamResponseTokensInner = + (RealTimeTradesStreamResponseTokensInner) o; + return Objects.equals(this.aLowerCase, realTimeTradesStreamResponseTokensInner.aLowerCase) + && Objects.equals( + this.sLowerCase, realTimeTradesStreamResponseTokensInner.sLowerCase) + && Objects.equals(this.ca, realTimeTradesStreamResponseTokensInner.ca); + } + + @Override + public int hashCode() { + return Objects.hash(aLowerCase, sLowerCase, ca); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RealTimeTradesStreamResponseTokensInner {\n"); + sb.append(" aLowerCase: ").append(toIndentedString(aLowerCase)).append("\n"); + sb.append(" sLowerCase: ").append(toIndentedString(sLowerCase)).append("\n"); + sb.append(" ca: ").append(toIndentedString(ca)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String aLowerCaseValue = getaLowerCase(); + if (aLowerCaseValue != null) { + String aLowerCaseValueAsString = aLowerCaseValue.toString(); + valMap.put("aLowerCase", aLowerCaseValueAsString); + } + String sLowerCaseValue = getsLowerCase(); + if (sLowerCaseValue != null) { + String sLowerCaseValueAsString = sLowerCaseValue.toString(); + valMap.put("sLowerCase", sLowerCaseValueAsString); + } + String caValue = getCa(); + if (caValue != null) { + String caValueAsString = caValue.toString(); + valMap.put("ca", caValueAsString); + } + + valMap.put("timestamp", getTimestamp()); + return asciiEncode( + valMap.keySet().stream() + .map(key -> key + "=" + valMap.get(key)) + .collect(Collectors.joining("&"))); + } + + public Map toMap() { + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Object aLowerCaseValue = getaLowerCase(); + if (aLowerCaseValue != null) { + valMap.put("aLowerCase", aLowerCaseValue); + } + Object sLowerCaseValue = getsLowerCase(); + if (sLowerCaseValue != null) { + valMap.put("sLowerCase", sLowerCaseValue); + } + Object caValue = getCa(); + if (caValue != null) { + valMap.put("ca", caValue); + } + + valMap.put("timestamp", getTimestamp()); + return valMap; + } + + public static String asciiEncode(String s) { + return new String(s.getBytes(), StandardCharsets.US_ASCII); + } + + /** + * 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("a"); + openapiFields.add("s"); + openapiFields.add("ca"); + + // 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 + * RealTimeTradesStreamResponseTokensInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RealTimeTradesStreamResponseTokensInner.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in" + + " RealTimeTradesStreamResponseTokensInner is not found in the" + + " empty JSON string", + RealTimeTradesStreamResponseTokensInner.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RealTimeTradesStreamResponseTokensInner.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `RealTimeTradesStreamResponseTokensInner` properties. JSON:" + + " %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("a") != null && !jsonObj.get("a").isJsonNull()) + && !jsonObj.get("a").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `a` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("a").toString())); + } + if ((jsonObj.get("s") != null && !jsonObj.get("s").isJsonNull()) + && !jsonObj.get("s").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `s` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("s").toString())); + } + if ((jsonObj.get("ca") != null && !jsonObj.get("ca").isJsonNull()) + && !jsonObj.get("ca").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ca` to be a primitive type in the JSON string but" + + " got `%s`", + jsonObj.get("ca").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RealTimeTradesStreamResponseTokensInner.class.isAssignableFrom( + type.getRawType())) { + return null; // this class only serializes 'RealTimeTradesStreamResponseTokensInner' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(RealTimeTradesStreamResponseTokensInner.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, RealTimeTradesStreamResponseTokensInner value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RealTimeTradesStreamResponseTokensInner read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of RealTimeTradesStreamResponseTokensInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of RealTimeTradesStreamResponseTokensInner + * @throws IOException if the JSON string is invalid with respect to + * RealTimeTradesStreamResponseTokensInner + */ + public static RealTimeTradesStreamResponseTokensInner fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, RealTimeTradesStreamResponseTokensInner.class); + } + + /** + * Convert an instance of RealTimeTradesStreamResponseTokensInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/web3-wallet/src/test/java/com/binance/connector/client/web3_wallet/websocket/stream/api/MarketApiTest.java b/clients/web3-wallet/src/test/java/com/binance/connector/client/web3_wallet/websocket/stream/api/MarketApiTest.java new file mode 100644 index 0000000..01b16f0 --- /dev/null +++ b/clients/web3-wallet/src/test/java/com/binance/connector/client/web3_wallet/websocket/stream/api/MarketApiTest.java @@ -0,0 +1,244 @@ +/* + * Binance Web3 WebSocket Streams + * Real-time on-chain data streaming over WebSocket for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.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 com.binance.connector.client.web3_wallet.websocket.stream.api; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.ApiResponse; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.dtos.RequestWrapperDTO; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.web3.common.ApiClient; +import com.binance.connector.client.web3.common.dtos.GetWebSocketAuthTokenResponse; +import com.binance.connector.client.web3.common.dtos.GetWebSocketAuthTokenResponseData; +import com.binance.connector.client.web3.common.websocket.adapter.stream.Web3StreamConnectionWrapper; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.binance.connector.client.web3_wallet.websocket.stream.model.*; +import org.eclipse.jetty.websocket.api.RemoteEndpoint; +import org.eclipse.jetty.websocket.api.Session; +import org.eclipse.jetty.websocket.client.WebSocketClient; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; +import org.skyscreamer.jsonassert.JSONAssert; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Set; +import java.util.concurrent.CompletableFuture; + +/** + * API tests for MarketApi + */ +public class MarketApiTest { + + private MarketApi api; + private Web3StreamConnectionWrapper connectionSpy; + private Session sessionMock; + + @BeforeEach + public void initApiClient() throws Exception { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setSecretKey("apiSecret"); + Web3WebSocketClientConfiguration clientConfiguration = + new Web3WebSocketClientConfiguration(); + clientConfiguration.setAutoLogon(false); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + clientConfiguration.setUrl("wss://localhost:8080"); + + WebSocketClient webSocketClient = Mockito.mock(WebSocketClient.class); + CompletableFuture sessionCompletableFuture = new CompletableFuture<>(); + Mockito.doReturn(sessionCompletableFuture) + .when(webSocketClient) + .connect(Mockito.any(), Mockito.any(), Mockito.any()); + sessionMock = Mockito.mock(Session.class); + + RemoteEndpoint remoteEndpointMock = Mockito.mock(RemoteEndpoint.class); + Mockito.doReturn(remoteEndpointMock).when(sessionMock).getRemote(); + sessionCompletableFuture.complete(sessionMock); + + ApiClient httpClient = Mockito.mock(ApiClient.class); + + GetWebSocketAuthTokenResponseData getWebSocketAuthTokenResponseData = new GetWebSocketAuthTokenResponseData(); + getWebSocketAuthTokenResponseData.setToken("token123456"); + + GetWebSocketAuthTokenResponse getWebSocketAuthTokenResponse = new GetWebSocketAuthTokenResponse(); + getWebSocketAuthTokenResponse.setData(getWebSocketAuthTokenResponseData); + + ApiResponse getWebSocketAuthTokenResponseApiResponse = new ApiResponse<>(200, new HashMap<>(), getWebSocketAuthTokenResponse); + + Mockito.doReturn(getWebSocketAuthTokenResponseApiResponse).when(httpClient).execute(Mockito.any(), Mockito.any()); + + Web3StreamConnectionWrapper connectionWrapper = + new Web3StreamConnectionWrapper(clientConfiguration, webSocketClient, httpClient); + connectionSpy = Mockito.spy(connectionWrapper); + Mockito.doNothing().when(connectionSpy).setUserAgent(Mockito.anyString()); + Mockito.doReturn(1736393892000L).when(connectionSpy).getTimestamp(); + connectionSpy.connect(); + MarketApi apiClient = new MarketApi(connectionSpy); + api = Mockito.spy(apiClient); + Mockito.doReturn("eaf3292c-64b6-4c04-ad4f-4ca2608b42b4").when(api).getRequestID(); + } + + /** + * Candlestick Stream + * + *

Push token candlestick (K-line) data in real time. The current (unclosed) candle keeps + * updating as new trades occur. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void candlestickStreamTest() throws ApiException, URISyntaxException, IOException { + CandlestickStreamRequest candlestickStreamRequest = new CandlestickStreamRequest(); + candlestickStreamRequest.id("e9d6b4349871b40611412680b3445fac"); + candlestickStreamRequest.bar("1s"); + candlestickStreamRequest.chainId("CT_501"); + candlestickStreamRequest.contractAddress("C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump"); + + StreamBlockingQueueWrapper response = + api.candlestickStream(candlestickStreamRequest); + ArgumentCaptor, CandlestickStreamResponse>> + callArgumentCaptor = ArgumentCaptor.forClass(RequestWrapperDTO.class); + Mockito.verify(connectionSpy).innerSend(callArgumentCaptor.capture()); + ArgumentCaptor sendArgumentCaptor = ArgumentCaptor.forClass(String.class); + RemoteEndpoint remote = sessionMock.getRemote(); + Mockito.verify(remote).sendString(sendArgumentCaptor.capture(), Mockito.any()); + RequestWrapperDTO, CandlestickStreamResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + MarketApiTest.class.getResource( + "/expected/stream/MarketApi/w3w@onchainos@pub@candles@bar@chainId@contractAddress-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Market Stats Stream + * + *

Push token market data. Rate-limited to at most once per second per token: if a + * token's data changes within a 1-second window, the latest snapshot is pushed once + * (multiple changes are coalesced into the latest value); if there is no change, nothing is + * pushed. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void marketStatsStreamTest() throws ApiException, URISyntaxException, IOException { + MarketStatsStreamRequest marketStatsStreamRequest = new MarketStatsStreamRequest(); + marketStatsStreamRequest.id("e9d6b4349871b40611412680b3445fac"); + marketStatsStreamRequest.chainId("CT_501"); + marketStatsStreamRequest.contractAddress("C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump"); + + StreamBlockingQueueWrapper response = + api.marketStatsStream(marketStatsStreamRequest); + ArgumentCaptor, MarketStatsStreamResponse>> + callArgumentCaptor = ArgumentCaptor.forClass(RequestWrapperDTO.class); + Mockito.verify(connectionSpy).innerSend(callArgumentCaptor.capture()); + ArgumentCaptor sendArgumentCaptor = ArgumentCaptor.forClass(String.class); + RemoteEndpoint remote = sessionMock.getRemote(); + Mockito.verify(remote).sendString(sendArgumentCaptor.capture(), Mockito.any()); + RequestWrapperDTO, MarketStatsStreamResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + MarketApiTest.class.getResource( + "/expected/stream/MarketApi/w3w@onchainos@pub@tx-data@chainId@contractAddress-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Price Stream + * + *

Push token price updates. Triggered every time a token's price changes. Update Speed: + * Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void priceStreamTest() throws ApiException, URISyntaxException, IOException { + PriceStreamRequest priceStreamRequest = new PriceStreamRequest(); + priceStreamRequest.id("e9d6b4349871b40611412680b3445fac"); + priceStreamRequest.chainId("CT_501"); + priceStreamRequest.contractAddress("C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump"); + + StreamBlockingQueueWrapper response = + api.priceStream(priceStreamRequest); + ArgumentCaptor, PriceStreamResponse>> callArgumentCaptor = + ArgumentCaptor.forClass(RequestWrapperDTO.class); + Mockito.verify(connectionSpy).innerSend(callArgumentCaptor.capture()); + ArgumentCaptor sendArgumentCaptor = ArgumentCaptor.forClass(String.class); + RemoteEndpoint remote = sessionMock.getRemote(); + Mockito.verify(remote).sendString(sendArgumentCaptor.capture(), Mockito.any()); + RequestWrapperDTO, PriceStreamResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + MarketApiTest.class.getResource( + "/expected/stream/MarketApi/w3w@onchainos@pub@price@chainId@contractAddress-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Real-Time Trades Stream + * + *

Push real-time token trade history. Triggered on every new transaction. Update Speed: + * Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void realTimeTradesStreamTest() throws ApiException, URISyntaxException, IOException { + RealTimeTradesStreamRequest realTimeTradesStreamRequest = new RealTimeTradesStreamRequest(); + realTimeTradesStreamRequest.id("e9d6b4349871b40611412680b3445fac"); + realTimeTradesStreamRequest.chainId("CT_501"); + realTimeTradesStreamRequest.contractAddress("C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump"); + + StreamBlockingQueueWrapper response = + api.realTimeTradesStream(realTimeTradesStreamRequest); + ArgumentCaptor, RealTimeTradesStreamResponse>> + callArgumentCaptor = ArgumentCaptor.forClass(RequestWrapperDTO.class); + Mockito.verify(connectionSpy).innerSend(callArgumentCaptor.capture()); + ArgumentCaptor sendArgumentCaptor = ArgumentCaptor.forClass(String.class); + RemoteEndpoint remote = sessionMock.getRemote(); + Mockito.verify(remote).sendString(sendArgumentCaptor.capture(), Mockito.any()); + RequestWrapperDTO, RealTimeTradesStreamResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + MarketApiTest.class.getResource( + "/expected/stream/MarketApi/w3w@onchainos@pub@tx@chainId@contractAddress-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } +} diff --git a/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@candles@bar@chainId@contractAddress-test.json b/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@candles@bar@chainId@contractAddress-test.json new file mode 100644 index 0000000..4b72946 --- /dev/null +++ b/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@candles@bar@chainId@contractAddress-test.json @@ -0,0 +1,7 @@ +{ + "id": "eaf3292c-64b6-4c04-ad4f-4ca2608b42b4", + "params": [ + "w3w@onchainos@pub@candles@1s@CT_501@C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump" + ], + "method": "SUBSCRIBE" +} diff --git a/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@price@chainId@contractAddress-test.json b/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@price@chainId@contractAddress-test.json new file mode 100644 index 0000000..d719311 --- /dev/null +++ b/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@price@chainId@contractAddress-test.json @@ -0,0 +1,7 @@ +{ + "id": "eaf3292c-64b6-4c04-ad4f-4ca2608b42b4", + "params": [ + "w3w@onchainos@pub@price@CT_501@C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump" + ], + "method": "SUBSCRIBE" +} diff --git a/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@tx-data@chainId@contractAddress-test.json b/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@tx-data@chainId@contractAddress-test.json new file mode 100644 index 0000000..c5d4323 --- /dev/null +++ b/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@tx-data@chainId@contractAddress-test.json @@ -0,0 +1,7 @@ +{ + "id": "eaf3292c-64b6-4c04-ad4f-4ca2608b42b4", + "params": [ + "w3w@onchainos@pub@tx-data@CT_501@C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump" + ], + "method": "SUBSCRIBE" +} diff --git a/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@tx@chainId@contractAddress-test.json b/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@tx@chainId@contractAddress-test.json new file mode 100644 index 0000000..455470f --- /dev/null +++ b/clients/web3-wallet/src/test/resources/expected/stream/MarketApi/w3w@onchainos@pub@tx@chainId@contractAddress-test.json @@ -0,0 +1,7 @@ +{ + "id": "eaf3292c-64b6-4c04-ad4f-4ca2608b42b4", + "params": [ + "w3w@onchainos@pub@tx@CT_501@C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump" + ], + "method": "SUBSCRIBE" +} diff --git a/examples/web3-wallet/pom.xml b/examples/web3-wallet/pom.xml index d80d786..565f3dc 100644 --- a/examples/web3-wallet/pom.xml +++ b/examples/web3-wallet/pom.xml @@ -31,7 +31,7 @@ io.github.binance binance-web3-wallet - 4.3.0 + 4.4.0 \ No newline at end of file diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/SubmitRfqOrderExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/SubmitRfqOrderExample.java index 1200cb9..eb88229 100644 --- a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/SubmitRfqOrderExample.java +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/SubmitRfqOrderExample.java @@ -45,7 +45,7 @@ public void submitRfqOrderExample() throws ApiException { SubmitRfqOrderRequest submitRfqOrderRequest = new SubmitRfqOrderRequest(); submitRfqOrderRequest.requestId("550e8400-e29b-41d4-a716-446655440000"); submitRfqOrderRequest.userSignature("0x1234abcd...5678ef"); - submitRfqOrderRequest.vendor("PcsXRfq"); + submitRfqOrderRequest.vendor(SubmitRfqOrderRequest.VendorEnum.PcsXRfq); submitRfqOrderRequest.quoteId("a1b2c3d4e5f64a8b9c0d1e2f3a4b5c6d"); Long recvWindow = 5000L; String nonce = "unique-nonce-string"; diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/CandlestickStreamExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/CandlestickStreamExample.java new file mode 100644 index 0000000..15db6f5 --- /dev/null +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/CandlestickStreamExample.java @@ -0,0 +1,49 @@ +package com.binance.connector.client.web3_wallet.websocket.stream.market; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.binance.connector.client.web3_wallet.websocket.stream.Web3WalletWebSocketStreamsUtil; +import com.binance.connector.client.web3_wallet.websocket.stream.api.Web3WalletWebSocketStreams; +import com.binance.connector.client.web3_wallet.websocket.stream.model.CandlestickStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.CandlestickStreamResponse; + +/** API examples for MarketApi */ +public class CandlestickStreamExample { + private Web3WalletWebSocketStreams api; + + public Web3WalletWebSocketStreams getApi() { + if (api == null) { + Web3WebSocketClientConfiguration clientConfiguration = + Web3WalletWebSocketStreamsUtil.getClientConfiguration(); + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setSecretKey("secretKey"); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + api = new Web3WalletWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Candlestick Stream + * + *

Push token candlestick (K-line) data in real time. The current (unclosed) candle keeps + * updating as new trades occur. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void candlestickStreamExample() throws ApiException, InterruptedException { + CandlestickStreamRequest candlestickStreamRequest = new CandlestickStreamRequest(); + candlestickStreamRequest.id("e9d6b4349871b40611412680b3445fac"); + candlestickStreamRequest.bar("1s"); + candlestickStreamRequest.chainId("CT_501"); + candlestickStreamRequest.contractAddress("C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump"); + StreamBlockingQueueWrapper response = + getApi().candlestickStream(candlestickStreamRequest); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/MarketStatsStreamExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/MarketStatsStreamExample.java new file mode 100644 index 0000000..fc9e335 --- /dev/null +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/MarketStatsStreamExample.java @@ -0,0 +1,50 @@ +package com.binance.connector.client.web3_wallet.websocket.stream.market; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.binance.connector.client.web3_wallet.websocket.stream.Web3WalletWebSocketStreamsUtil; +import com.binance.connector.client.web3_wallet.websocket.stream.api.Web3WalletWebSocketStreams; +import com.binance.connector.client.web3_wallet.websocket.stream.model.MarketStatsStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.MarketStatsStreamResponse; + +/** API examples for MarketApi */ +public class MarketStatsStreamExample { + private Web3WalletWebSocketStreams api; + + public Web3WalletWebSocketStreams getApi() { + if (api == null) { + Web3WebSocketClientConfiguration clientConfiguration = + Web3WalletWebSocketStreamsUtil.getClientConfiguration(); + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setSecretKey("secretKey"); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + api = new Web3WalletWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Market Stats Stream + * + *

Push token market data. Rate-limited to at most once per second per token: if a + * token's data changes within a 1-second window, the latest snapshot is pushed once + * (multiple changes are coalesced into the latest value); if there is no change, nothing is + * pushed. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void marketStatsStreamExample() throws ApiException, InterruptedException { + MarketStatsStreamRequest marketStatsStreamRequest = new MarketStatsStreamRequest(); + marketStatsStreamRequest.id("e9d6b4349871b40611412680b3445fac"); + marketStatsStreamRequest.chainId("CT_501"); + marketStatsStreamRequest.contractAddress("C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump"); + StreamBlockingQueueWrapper response = + getApi().marketStatsStream(marketStatsStreamRequest); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/PriceStreamExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/PriceStreamExample.java new file mode 100644 index 0000000..b4c17a3 --- /dev/null +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/PriceStreamExample.java @@ -0,0 +1,48 @@ +package com.binance.connector.client.web3_wallet.websocket.stream.market; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.binance.connector.client.web3_wallet.websocket.stream.Web3WalletWebSocketStreamsUtil; +import com.binance.connector.client.web3_wallet.websocket.stream.api.Web3WalletWebSocketStreams; +import com.binance.connector.client.web3_wallet.websocket.stream.model.PriceStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.PriceStreamResponse; + +/** API examples for MarketApi */ +public class PriceStreamExample { + private Web3WalletWebSocketStreams api; + + public Web3WalletWebSocketStreams getApi() { + if (api == null) { + Web3WebSocketClientConfiguration clientConfiguration = + Web3WalletWebSocketStreamsUtil.getClientConfiguration(); + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setSecretKey("secretKey"); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + api = new Web3WalletWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Price Stream + * + *

Push token price updates. Triggered every time a token's price changes. Update Speed: + * Real-time + * + * @throws ApiException if the Api call fails + */ + public void priceStreamExample() throws ApiException, InterruptedException { + PriceStreamRequest priceStreamRequest = new PriceStreamRequest(); + priceStreamRequest.id("e9d6b4349871b40611412680b3445fac"); + priceStreamRequest.chainId("CT_501"); + priceStreamRequest.contractAddress("C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump"); + StreamBlockingQueueWrapper response = + getApi().priceStream(priceStreamRequest); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/RealTimeTradesStreamExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/RealTimeTradesStreamExample.java new file mode 100644 index 0000000..632368d --- /dev/null +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/websocket/stream/market/RealTimeTradesStreamExample.java @@ -0,0 +1,48 @@ +package com.binance.connector.client.web3_wallet.websocket.stream.market; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.web3.common.websocket.configuration.Web3WebSocketClientConfiguration; +import com.binance.connector.client.web3_wallet.websocket.stream.Web3WalletWebSocketStreamsUtil; +import com.binance.connector.client.web3_wallet.websocket.stream.api.Web3WalletWebSocketStreams; +import com.binance.connector.client.web3_wallet.websocket.stream.model.RealTimeTradesStreamRequest; +import com.binance.connector.client.web3_wallet.websocket.stream.model.RealTimeTradesStreamResponse; + +/** API examples for MarketApi */ +public class RealTimeTradesStreamExample { + private Web3WalletWebSocketStreams api; + + public Web3WalletWebSocketStreams getApi() { + if (api == null) { + Web3WebSocketClientConfiguration clientConfiguration = + Web3WalletWebSocketStreamsUtil.getClientConfiguration(); + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setSecretKey("secretKey"); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + api = new Web3WalletWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Real-Time Trades Stream + * + *

Push real-time token trade history. Triggered on every new transaction. Update Speed: + * Real-time + * + * @throws ApiException if the Api call fails + */ + public void realTimeTradesStreamExample() throws ApiException, InterruptedException { + RealTimeTradesStreamRequest realTimeTradesStreamRequest = new RealTimeTradesStreamRequest(); + realTimeTradesStreamRequest.id("e9d6b4349871b40611412680b3445fac"); + realTimeTradesStreamRequest.chainId("CT_501"); + realTimeTradesStreamRequest.contractAddress("C3DwDjT17gDvvCYC2nsdGHxDHVmQRdhKfpAdqQ29pump"); + StreamBlockingQueueWrapper response = + getApi().realTimeTradesStream(realTimeTradesStreamRequest); + while (true) { + System.out.println(response.take()); + } + } +}