From 3ed61fde1ecb14e3f213412f331daca2cbeb44ac Mon Sep 17 00:00:00 2001 From: theo-s68 <194042188+theo-s68@users.noreply.github.com> Date: Wed, 21 Oct 2026 10:05:37 +0700 Subject: [PATCH] Release w3w-prediction v2.2.0, cms v1.0.0 --- README.md | 4 +- clients/cms/docs/ComAnnouncementEnRequest.md | 13 + clients/cms/docs/ComAnnouncementEnResponse.md | 18 + clients/cms/docs/DefaultApi.md | 67 ++ clients/cms/example_websocket_stream.md | 4 + clients/cms/pom.xml | 37 + .../stream/CmsWebSocketStreamsUtil.java | 35 + .../client/cms/websocket/stream/JSON.java | 413 ++++++++ .../stream/api/CmsWebSocketStreams.java | 55 ++ .../cms/websocket/stream/api/DefaultApi.java | 112 +++ .../stream/model/AbstractOpenApiSchema.java | 145 +++ .../model/ComAnnouncementEnRequest.java | 241 +++++ .../model/ComAnnouncementEnResponse.java | 450 +++++++++ .../websocket/stream/api/DefaultApiTest.java | 112 +++ .../DefaultApi/com_announcement_en-test.json | 4 + .../test/resources/test-ed25519-prv-key.pem | 3 + clients/common/pom.xml | 2 +- .../configuration/ClientConfiguration.java | 2 + .../websocket/adapter/ConnectionWrapper.java | 119 +-- .../SignedStreamConnectionPoolWrapper.java | 24 + .../stream/SignedStreamConnectionWrapper.java | 241 +++++ .../stream/StreamConnectionInterface.java | 5 + .../stream/StreamConnectionPoolWrapper.java | 78 +- .../WebSocketClientConfiguration.java | 22 + .../websocket/dtos/RequestWrapperDTO.java | 32 + .../service/StreamBlockingQueueWrapper.java | 8 + clients/pom.xml | 3 +- clients/w3w-prediction/CHANGELOG.md | 18 + .../BatchClaimPartiallySucceededResponse.md | 13 + clients/w3w-prediction/docs/DefaultApi.md | 897 ++++++++++++++++++ .../docs/FundTransferFailedResponse.md | 14 + .../docs/FundTransferSucceededResponse.md | 14 + .../GetMarketDetailResponseMarketsInner.md | 2 +- ...DetailResponseMarketsInnerOutcomesInner.md | 1 + .../w3w-prediction/docs/GetQuoteRequest.md | 4 +- .../docs/LimitOrderFullyFilledResponse.md | 15 + .../docs/LimitOrderPartiallyFilledResponse.md | 15 + .../LimitOrderSubmissionFailedResponse.md | 14 + ...LimitOrderSubmittedSuccessfullyResponse.md | 15 + .../docs/MarketBuyOrderFailedResponse.md | 15 + .../docs/MarketBuyOrderFullyFilledResponse.md | 15 + clients/w3w-prediction/docs/MarketDataApi.md | 4 +- .../MarketResolutionNotificationResponse.md | 14 + .../MarketSellOrderFailedExpiredResponse.md | 15 + .../MarketSellOrderFullyFilledResponse.md | 15 + clients/w3w-prediction/docs/PositionApi.md | 2 +- .../PredictionOrderBookByMarketIdRequest.md | 13 + .../PredictionOrderBookByMarketIdResponse.md | 17 + .../docs/RewardClaimFailedResponse.md | 15 + .../docs/RewardClaimSucceededResponse.md | 14 + clients/w3w-prediction/docs/TradeApi.md | 2 +- clients/w3w-prediction/example_rest.md | 8 +- .../example_websocket_stream.md | 32 + clients/w3w-prediction/pom.xml | 4 +- .../rest/api/MarketDataApi.java | 26 +- .../w3w_prediction/rest/api/OtcApi.java | 2 +- .../w3w_prediction/rest/api/PositionApi.java | 9 +- .../w3w_prediction/rest/api/RedeemApi.java | 2 +- .../w3w_prediction/rest/api/TradeApi.java | 15 +- .../w3w_prediction/rest/api/TransferApi.java | 2 +- .../rest/api/W3WPredictionRestApi.java | 44 +- .../w3w_prediction/rest/api/WalletApi.java | 2 +- .../GetMarketDetailResponseMarketsInner.java | 4 +- ...tailResponseMarketsInnerOutcomesInner.java | 39 +- .../rest/model/GetQuoteRequest.java | 9 +- .../w3w_prediction/websocket/stream/JSON.java | 458 +++++++++ .../W3WPredictionWebSocketStreamsUtil.java | 35 + .../websocket/stream/api/DefaultApi.java | 859 +++++++++++++++++ .../api/W3WPredictionWebSocketStreams.java | 142 +++ .../stream/model/AbstractOpenApiSchema.java | 145 +++ .../BatchClaimPartiallySucceededResponse.java | 250 +++++ .../model/FundTransferFailedResponse.java | 287 ++++++ .../model/FundTransferSucceededResponse.java | 291 ++++++ .../model/LimitOrderFullyFilledResponse.java | 338 +++++++ .../LimitOrderPartiallyFilledResponse.java | 339 +++++++ .../LimitOrderSubmissionFailedResponse.java | 294 ++++++ ...mitOrderSubmittedSuccessfullyResponse.java | 347 +++++++ .../model/MarketBuyOrderFailedResponse.java | 337 +++++++ .../MarketBuyOrderFullyFilledResponse.java | 338 +++++++ .../MarketResolutionNotificationResponse.java | 296 ++++++ .../MarketSellOrderFailedExpiredResponse.java | 342 +++++++ .../MarketSellOrderFullyFilledResponse.java | 340 +++++++ .../PredictionOrderBookByMarketIdRequest.java | 256 +++++ ...PredictionOrderBookByMarketIdResponse.java | 452 +++++++++ .../model/RewardClaimFailedResponse.java | 333 +++++++ .../model/RewardClaimSucceededResponse.java | 290 ++++++ .../w3w_prediction/rest/api/OtcApiTest.java | 404 ++++++++ .../websocket/stream/api/DefaultApiTest.java | 591 ++++++++++++ .../web3_prediction_orderbook_data-test.json | 4 + ...b3_prediction_orderbook_marketId-test.json | 4 + .../web3_prediction_pm_claim_fail-test.json | 4 + ...diction_pm_claim_partial_success-test.json | 4 + ...web3_prediction_pm_claim_success-test.json | 4 + ...prediction_pm_limit_order_filled-test.json | 4 + ...tion_pm_limit_order_partial_fill-test.json | 4 + ..._prediction_pm_limit_submit_fail-test.json | 4 + ...ediction_pm_limit_submit_success-test.json | 4 + ...b3_prediction_pm_market_buy_fail-test.json | 4 + ...prediction_pm_market_buy_success-test.json | 4 + .../web3_prediction_pm_market_close-test.json | 4 + ...3_prediction_pm_market_sell_fail-test.json | 4 + ...rediction_pm_market_sell_success-test.json | 4 + ...web3_prediction_pm_transfer_fail-test.json | 4 + ...3_prediction_pm_transfer_success-test.json | 4 + .../test/resources/test-ed25519-prv-key.pem | 3 + examples/cms/pom.xml | 37 + .../defaultpkg/ComAnnouncementEnExample.java | 40 + examples/pom.xml | 1 + examples/w3w-prediction/pom.xml | 2 +- .../marketdata/GetMarketDetailExample.java | 21 +- .../ListPredictionMarketsExample.java | 3 +- .../QuerySettledPositionHistoryExample.java | 7 +- .../rest/trade/GetQuoteExample.java | 13 +- .../BatchClaimPartiallySucceededExample.java | 43 + .../defaultpkg/FundTransferFailedExample.java | 42 + .../FundTransferSucceededExample.java | 43 + .../LimitOrderFullyFilledExample.java | 42 + .../LimitOrderPartiallyFilledExample.java | 43 + .../LimitOrderSubmissionFailedExample.java | 43 + ...imitOrderSubmittedSuccessfullyExample.java | 43 + .../MarketBuyOrderFailedExample.java | 42 + .../MarketBuyOrderFullyFilledExample.java | 42 + .../MarketResolutionNotificationExample.java | 44 + .../MarketSellOrderFailedExpiredExample.java | 42 + .../MarketSellOrderFullyFilledExample.java | 42 + .../PredictionOrderBookByMarketIdExample.java | 46 + .../defaultpkg/RewardClaimFailedExample.java | 44 + .../RewardClaimSucceededExample.java | 43 + 128 files changed, 12056 insertions(+), 153 deletions(-) create mode 100644 clients/cms/docs/ComAnnouncementEnRequest.md create mode 100644 clients/cms/docs/ComAnnouncementEnResponse.md create mode 100644 clients/cms/docs/DefaultApi.md create mode 100644 clients/cms/example_websocket_stream.md create mode 100644 clients/cms/pom.xml create mode 100644 clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/CmsWebSocketStreamsUtil.java create mode 100644 clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/JSON.java create mode 100644 clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/api/CmsWebSocketStreams.java create mode 100644 clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/api/DefaultApi.java create mode 100644 clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/AbstractOpenApiSchema.java create mode 100644 clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/ComAnnouncementEnRequest.java create mode 100644 clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/ComAnnouncementEnResponse.java create mode 100644 clients/cms/src/test/java/com/binance/connector/client/cms/websocket/stream/api/DefaultApiTest.java create mode 100644 clients/cms/src/test/resources/expected/stream/DefaultApi/com_announcement_en-test.json create mode 100644 clients/cms/src/test/resources/test-ed25519-prv-key.pem create mode 100644 clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/SignedStreamConnectionPoolWrapper.java create mode 100644 clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/SignedStreamConnectionWrapper.java create mode 100644 clients/w3w-prediction/docs/BatchClaimPartiallySucceededResponse.md create mode 100644 clients/w3w-prediction/docs/DefaultApi.md create mode 100644 clients/w3w-prediction/docs/FundTransferFailedResponse.md create mode 100644 clients/w3w-prediction/docs/FundTransferSucceededResponse.md create mode 100644 clients/w3w-prediction/docs/LimitOrderFullyFilledResponse.md create mode 100644 clients/w3w-prediction/docs/LimitOrderPartiallyFilledResponse.md create mode 100644 clients/w3w-prediction/docs/LimitOrderSubmissionFailedResponse.md create mode 100644 clients/w3w-prediction/docs/LimitOrderSubmittedSuccessfullyResponse.md create mode 100644 clients/w3w-prediction/docs/MarketBuyOrderFailedResponse.md create mode 100644 clients/w3w-prediction/docs/MarketBuyOrderFullyFilledResponse.md create mode 100644 clients/w3w-prediction/docs/MarketResolutionNotificationResponse.md create mode 100644 clients/w3w-prediction/docs/MarketSellOrderFailedExpiredResponse.md create mode 100644 clients/w3w-prediction/docs/MarketSellOrderFullyFilledResponse.md create mode 100644 clients/w3w-prediction/docs/PredictionOrderBookByMarketIdRequest.md create mode 100644 clients/w3w-prediction/docs/PredictionOrderBookByMarketIdResponse.md create mode 100644 clients/w3w-prediction/docs/RewardClaimFailedResponse.md create mode 100644 clients/w3w-prediction/docs/RewardClaimSucceededResponse.md create mode 100644 clients/w3w-prediction/example_websocket_stream.md create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/JSON.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/W3WPredictionWebSocketStreamsUtil.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/DefaultApi.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/W3WPredictionWebSocketStreams.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/AbstractOpenApiSchema.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/BatchClaimPartiallySucceededResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/FundTransferFailedResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/FundTransferSucceededResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderFullyFilledResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderPartiallyFilledResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderSubmissionFailedResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderSubmittedSuccessfullyResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketBuyOrderFailedResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketBuyOrderFullyFilledResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketResolutionNotificationResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketSellOrderFailedExpiredResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketSellOrderFullyFilledResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/PredictionOrderBookByMarketIdRequest.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/PredictionOrderBookByMarketIdResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/RewardClaimFailedResponse.java create mode 100644 clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/RewardClaimSucceededResponse.java create mode 100644 clients/w3w-prediction/src/test/java/com/binance/connector/client/w3w_prediction/rest/api/OtcApiTest.java create mode 100644 clients/w3w-prediction/src/test/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/DefaultApiTest.java create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_orderbook_data-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_orderbook_marketId-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_fail-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_partial_success-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_success-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_order_filled-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_order_partial_fill-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_fail-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_success-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_buy_fail-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_buy_success-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_close-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_sell_fail-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_sell_success-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_transfer_fail-test.json create mode 100644 clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_transfer_success-test.json create mode 100644 clients/w3w-prediction/src/test/resources/test-ed25519-prv-key.pem create mode 100644 examples/cms/pom.xml create mode 100644 examples/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/defaultpkg/ComAnnouncementEnExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/BatchClaimPartiallySucceededExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferFailedExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferSucceededExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderFullyFilledExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderPartiallyFilledExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmissionFailedExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmittedSuccessfullyExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFailedExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFullyFilledExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketResolutionNotificationExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFailedExpiredExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFullyFilledExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/PredictionOrderBookByMarketIdExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimFailedExample.java create mode 100644 examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimSucceededExample.java diff --git a/README.md b/README.md index 09d372fcc..6b9e7d80b 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,8 @@ When creating WebSocket API clients (such as SpotWebSocketApi), you can follow: **C2c**: [Rest API](clients/c2c/example_rest.md) +**CMS**: [WebSocket Streams](clients/cms/example_websocket_stream.md) + **Convert**: [Rest API](clients/convert/example_rest.md) **Copy Trading**: [Rest API](clients/copy-trading/example_rest.md) @@ -259,7 +261,7 @@ When creating WebSocket API clients (such as SpotWebSocketApi), you can follow: **Vip Loan**: [Rest API](clients/vip-loan/example_rest.md) -**W3W Prediction**: [Rest API](clients/w3w-prediction/example_rest.md) +**W3W Prediction**: [Rest API](clients/w3w-prediction/example_rest.md) - [WebSocket Streams](clients/w3w-prediction/example_websocket_stream.md) **Wallet**: [Rest API](clients/wallet/example_rest.md) diff --git a/clients/cms/docs/ComAnnouncementEnRequest.md b/clients/cms/docs/ComAnnouncementEnRequest.md new file mode 100644 index 000000000..ecb8e3209 --- /dev/null +++ b/clients/cms/docs/ComAnnouncementEnRequest.md @@ -0,0 +1,13 @@ + + +# ComAnnouncementEnRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | Unique WebSocket request ID. | [optional] | + + + diff --git a/clients/cms/docs/ComAnnouncementEnResponse.md b/clients/cms/docs/ComAnnouncementEnResponse.md new file mode 100644 index 000000000..47e77e23c --- /dev/null +++ b/clients/cms/docs/ComAnnouncementEnResponse.md @@ -0,0 +1,18 @@ + + +# ComAnnouncementEnResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**catalogId** | **Long** | Catalog ID | [optional] | +|**catalogName** | **String** | Catalog Name | [optional] | +|**publishDate** | **Long** | Publish timestamp (milliseconds) | [optional] | +|**title** | **String** | Announcement title | [optional] | +|**body** | **String** | Announcement body | [optional] | +|**disclaimer** | **String** | Disclaimer | [optional] | + + + diff --git a/clients/cms/docs/DefaultApi.md b/clients/cms/docs/DefaultApi.md new file mode 100644 index 000000000..65e4f69a5 --- /dev/null +++ b/clients/cms/docs/DefaultApi.md @@ -0,0 +1,67 @@ +# DefaultApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**comAnnouncementEn**](DefaultApi.md#comAnnouncementEn) | **POST** /com_announcement_en | | + + + +# **comAnnouncementEn** +> ComAnnouncementEnResponse comAnnouncementEn() + + + +Receive push notifications hen Binance publishes announcements in English (language code: en). + +### Example +```java +// Import classes: +import com.binance.connector.client.cms.ApiClient; +import com.binance.connector.client.cms.ApiException; +import com.binance.connector.client.cms.Configuration; +import com.binance.connector.client.cms.models.*; +import com.binance.connector.client.cms.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + ComAnnouncementEnResponse result = apiInstance.comAnnouncementEn(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#comAnnouncementEn"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**ComAnnouncementEnResponse**](ComAnnouncementEnResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Binance announcements in English (language code: en) | - | + diff --git a/clients/cms/example_websocket_stream.md b/clients/cms/example_websocket_stream.md new file mode 100644 index 000000000..86bf385fe --- /dev/null +++ b/clients/cms/example_websocket_stream.md @@ -0,0 +1,4 @@ +## Default + +[com_announcement_en](https://developers.binance.com/en/docs/products/announcements/announcement) - comAnnouncementEn - [ComAnnouncementEnExample.java:33](/examples/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/defaultpkg/ComAnnouncementEnExample.java#L33) + diff --git a/clients/cms/pom.xml b/clients/cms/pom.xml new file mode 100644 index 000000000..22f95e37f --- /dev/null +++ b/clients/cms/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + binance-cms + cms + 1.0.0 + jar + + + io.github.binance + binance-connector-java-clients + 1.1.4 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + -parameters + + + + + + + + io.github.binance + binance-common + 2.6.0 + + + \ No newline at end of file diff --git a/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/CmsWebSocketStreamsUtil.java b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/CmsWebSocketStreamsUtil.java new file mode 100644 index 000000000..1b3f91baa --- /dev/null +++ b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/CmsWebSocketStreamsUtil.java @@ -0,0 +1,35 @@ +package com.binance.connector.client.cms.websocket.stream; + +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; + +public class CmsWebSocketStreamsUtil { + private static final String BASE_URL = "wss://api.binance.com/sapi/wss"; + private static final boolean HAS_TIME_UNIT = false; + + public static WebSocketClientConfiguration getClientConfiguration() { + return getClientConfiguration(""); + } + + public static WebSocketClientConfiguration getClientConfiguration(String path) { + WebSocketClientConfiguration clientConfiguration = new WebSocketClientConfiguration(); + if (!HAS_TIME_UNIT) { + clientConfiguration.setTimeUnit(null); + } + clientConfiguration.setAutoLogon(false); + return clientConfiguration; + } + + public static WebSocketClientConfiguration getClientConfiguration( + SignatureConfiguration signatureConfiguration) { + WebSocketClientConfiguration clientConfiguration = getClientConfiguration(); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + clientConfiguration.setUrl(getBaseUrl()); + clientConfiguration.setPingIntervalTime(30000L); + return clientConfiguration; + } + + public static String getBaseUrl() { + return BASE_URL; + } +} diff --git a/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/JSON.java b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/JSON.java new file mode 100644 index 000000000..1c5cec38b --- /dev/null +++ b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/JSON.java @@ -0,0 +1,413 @@ +/* + * Binance Announcements + * Binance announcements in English + * + * 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.cms.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.cms.websocket.stream.model + .ComAnnouncementEnResponse.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/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/api/CmsWebSocketStreams.java b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/api/CmsWebSocketStreams.java new file mode 100644 index 000000000..a87c4700a --- /dev/null +++ b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/api/CmsWebSocketStreams.java @@ -0,0 +1,55 @@ +package com.binance.connector.client.cms.websocket.stream.api; + +import com.binance.connector.client.cms.websocket.stream.JSON; +import com.binance.connector.client.cms.websocket.stream.model.ComAnnouncementEnResponse; +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.SystemUtil; +import com.binance.connector.client.common.websocket.adapter.stream.SignedStreamConnectionPoolWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.SignedStreamConnectionWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionInterface; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import java.util.UUID; + +public class CmsWebSocketStreams { + private static final String USER_AGENT = + String.format( + "binance-cms/1.0.0 (Java/%s; %s; %s)", + SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); + + private final StreamConnectionInterface connection; + + private DefaultApi defaultApi; + + public CmsWebSocketStreams(WebSocketClientConfiguration configuration) { + this( + configuration.getUsePool() + ? new SignedStreamConnectionPoolWrapper(configuration, JSON.getGson()) + : new SignedStreamConnectionWrapper(configuration, JSON.getGson())); + } + + public CmsWebSocketStreams(StreamConnectionInterface connection) { + connection.setUserAgent(USER_AGENT); + if (!connection.isConnected()) { + connection.connect(); + } + this.connection = connection; + + this.defaultApi = new DefaultApi(connection); + } + + public void stop() throws Exception { + if (connection != null && connection.isConnected()) { + connection.stop(); + } + } + + public StreamBlockingQueueWrapper comAnnouncementEn() + throws ApiException { + return defaultApi.comAnnouncementEn(); + } + + public String getRequestID() { + return UUID.randomUUID().toString(); + } +} diff --git a/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/api/DefaultApi.java b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/api/DefaultApi.java new file mode 100644 index 000000000..0a2e420eb --- /dev/null +++ b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/api/DefaultApi.java @@ -0,0 +1,112 @@ +/* + * Binance Announcements + * Binance announcements in English + * + * 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.cms.websocket.stream.api; + +import com.binance.connector.client.cms.websocket.stream.JSON; +import com.binance.connector.client.cms.websocket.stream.model.ComAnnouncementEnResponse; +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.SystemUtil; +import com.binance.connector.client.common.websocket.adapter.stream.SignedStreamConnectionPoolWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.SignedStreamConnectionWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionInterface; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +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.google.gson.reflect.TypeToken; +import jakarta.validation.constraints.*; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +public class DefaultApi { + private static final String USER_AGENT = + String.format( + "binance-cms/1.0.0 (Java/%s; %s; %s)", + SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); + + private StreamConnectionInterface connection; + + public DefaultApi() {} + + public DefaultApi(WebSocketClientConfiguration configuration) { + this( + configuration.getUsePool() + ? new SignedStreamConnectionPoolWrapper(configuration, JSON.getGson()) + : new SignedStreamConnectionWrapper(configuration, JSON.getGson())); + } + + public DefaultApi(StreamConnectionInterface connection) { + connection.setUserAgent(USER_AGENT); + if (!connection.isConnected()) { + connection.connect(); + } + this.connection = connection; + } + + public StreamConnectionInterface getConnection() { + return connection; + } + + /** + * Receive push notifications hen Binance publishes announcements in English (language code: + * en). + * + * @return ComAnnouncementEnResponse + * @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 Binance announcements in English (language code: en) -
+ * + * @see + * Documentation + */ + public StreamBlockingQueueWrapper comAnnouncementEn() + throws ApiException { + StreamBlockingQueue queue = comAnnouncementEnRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue comAnnouncementEnRaw() throws ApiException { + comAnnouncementEnValidateBeforeCall(); + + String methodName = "/com_announcement_en".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void comAnnouncementEnValidateBeforeCall() throws ApiException {} + + public String getRequestID() { + return UUID.randomUUID().toString(); + } +} diff --git a/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/AbstractOpenApiSchema.java b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/AbstractOpenApiSchema.java new file mode 100644 index 000000000..24ec70960 --- /dev/null +++ b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/AbstractOpenApiSchema.java @@ -0,0 +1,145 @@ +/* + * Binance Announcements + * Binance announcements in English + * + * 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.cms.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/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/ComAnnouncementEnRequest.java b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/ComAnnouncementEnRequest.java new file mode 100644 index 000000000..e0de40d40 --- /dev/null +++ b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/ComAnnouncementEnRequest.java @@ -0,0 +1,241 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 types of per-user business events in real time via the Binance SApi WebSocket channel, covering trading (market / limit), reward claim, fund transfer and market resolution, plus order book (bid/ask) quotes broadcast per topic. Business events are routed by exact `(topic, userId)` match; order book topics are broadcast to every subscriber. Delivery is at-most-once, ordering is not guaranteed, and offline messages are not cached — pull the latest state via the REST API after reconnecting and deduplicate on `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.cms.websocket.stream.model; + +import com.binance.connector.client.cms.websocket.stream.JSON; +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +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.*; + +/** ComAnnouncementEnRequest */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class ComAnnouncementEnRequest extends BaseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @jakarta.annotation.Nullable + private String id; + + public ComAnnouncementEnRequest() {} + + public ComAnnouncementEnRequest 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; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ComAnnouncementEnRequest comAnnouncementEnRequest = (ComAnnouncementEnRequest) o; + return Objects.equals(this.id, comAnnouncementEnRequest.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ComAnnouncementEnRequest {\n"); + sb.append(" id: ").append(toIndentedString(id)).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); + } + + 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); + } + + 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"); + + // 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 ComAnnouncementEnRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ComAnnouncementEnRequest.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ComAnnouncementEnRequest is not found" + + " in the empty JSON string", + ComAnnouncementEnRequest.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ComAnnouncementEnRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `ComAnnouncementEnRequest` 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())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ComAnnouncementEnRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ComAnnouncementEnRequest' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ComAnnouncementEnRequest.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ComAnnouncementEnRequest value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ComAnnouncementEnRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ComAnnouncementEnRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of ComAnnouncementEnRequest + * @throws IOException if the JSON string is invalid with respect to ComAnnouncementEnRequest + */ + public static ComAnnouncementEnRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ComAnnouncementEnRequest.class); + } + + /** + * Convert an instance of ComAnnouncementEnRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/ComAnnouncementEnResponse.java b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/ComAnnouncementEnResponse.java new file mode 100644 index 000000000..2782500a0 --- /dev/null +++ b/clients/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/model/ComAnnouncementEnResponse.java @@ -0,0 +1,450 @@ +/* + * Binance Announcements + * Binance announcements in English + * + * 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.cms.websocket.stream.model; + +import com.binance.connector.client.cms.websocket.stream.JSON; +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +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.*; + +/** ComAnnouncementEnResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class ComAnnouncementEnResponse extends BaseDTO { + public static final String SERIALIZED_NAME_CATALOG_ID = "catalogId"; + + @SerializedName(SERIALIZED_NAME_CATALOG_ID) + @jakarta.annotation.Nullable + private Long catalogId; + + public static final String SERIALIZED_NAME_CATALOG_NAME = "catalogName"; + + @SerializedName(SERIALIZED_NAME_CATALOG_NAME) + @jakarta.annotation.Nullable + private String catalogName; + + public static final String SERIALIZED_NAME_PUBLISH_DATE = "publishDate"; + + @SerializedName(SERIALIZED_NAME_PUBLISH_DATE) + @jakarta.annotation.Nullable + private Long publishDate; + + public static final String SERIALIZED_NAME_TITLE = "title"; + + @SerializedName(SERIALIZED_NAME_TITLE) + @jakarta.annotation.Nullable + private String title; + + public static final String SERIALIZED_NAME_BODY = "body"; + + @SerializedName(SERIALIZED_NAME_BODY) + @jakarta.annotation.Nullable + private String body; + + public static final String SERIALIZED_NAME_DISCLAIMER = "disclaimer"; + + @SerializedName(SERIALIZED_NAME_DISCLAIMER) + @jakarta.annotation.Nullable + private String disclaimer; + + public ComAnnouncementEnResponse() {} + + public ComAnnouncementEnResponse catalogId(@jakarta.annotation.Nullable Long catalogId) { + this.catalogId = catalogId; + return this; + } + + /** + * Catalog ID + * + * @return catalogId + */ + @jakarta.annotation.Nullable + public Long getCatalogId() { + return catalogId; + } + + public void setCatalogId(@jakarta.annotation.Nullable Long catalogId) { + this.catalogId = catalogId; + } + + public ComAnnouncementEnResponse catalogName(@jakarta.annotation.Nullable String catalogName) { + this.catalogName = catalogName; + return this; + } + + /** + * Catalog Name + * + * @return catalogName + */ + @jakarta.annotation.Nullable + public String getCatalogName() { + return catalogName; + } + + public void setCatalogName(@jakarta.annotation.Nullable String catalogName) { + this.catalogName = catalogName; + } + + public ComAnnouncementEnResponse publishDate(@jakarta.annotation.Nullable Long publishDate) { + this.publishDate = publishDate; + return this; + } + + /** + * Publish timestamp (milliseconds) + * + * @return publishDate + */ + @jakarta.annotation.Nullable + public Long getPublishDate() { + return publishDate; + } + + public void setPublishDate(@jakarta.annotation.Nullable Long publishDate) { + this.publishDate = publishDate; + } + + public ComAnnouncementEnResponse title(@jakarta.annotation.Nullable String title) { + this.title = title; + return this; + } + + /** + * Announcement title + * + * @return title + */ + @jakarta.annotation.Nullable + public String getTitle() { + return title; + } + + public void setTitle(@jakarta.annotation.Nullable String title) { + this.title = title; + } + + public ComAnnouncementEnResponse body(@jakarta.annotation.Nullable String body) { + this.body = body; + return this; + } + + /** + * Announcement body + * + * @return body + */ + @jakarta.annotation.Nullable + public String getBody() { + return body; + } + + public void setBody(@jakarta.annotation.Nullable String body) { + this.body = body; + } + + public ComAnnouncementEnResponse disclaimer(@jakarta.annotation.Nullable String disclaimer) { + this.disclaimer = disclaimer; + return this; + } + + /** + * Disclaimer + * + * @return disclaimer + */ + @jakarta.annotation.Nullable + public String getDisclaimer() { + return disclaimer; + } + + public void setDisclaimer(@jakarta.annotation.Nullable String disclaimer) { + this.disclaimer = disclaimer; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ComAnnouncementEnResponse comAnnouncementEnResponse = (ComAnnouncementEnResponse) o; + return Objects.equals(this.catalogId, comAnnouncementEnResponse.catalogId) + && Objects.equals(this.catalogName, comAnnouncementEnResponse.catalogName) + && Objects.equals(this.publishDate, comAnnouncementEnResponse.publishDate) + && Objects.equals(this.title, comAnnouncementEnResponse.title) + && Objects.equals(this.body, comAnnouncementEnResponse.body) + && Objects.equals(this.disclaimer, comAnnouncementEnResponse.disclaimer); + } + + @Override + public int hashCode() { + return Objects.hash(catalogId, catalogName, publishDate, title, body, disclaimer); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ComAnnouncementEnResponse {\n"); + sb.append(" catalogId: ").append(toIndentedString(catalogId)).append("\n"); + sb.append(" catalogName: ").append(toIndentedString(catalogName)).append("\n"); + sb.append(" publishDate: ").append(toIndentedString(publishDate)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" disclaimer: ").append(toIndentedString(disclaimer)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + Long catalogIdValue = getCatalogId(); + if (catalogIdValue != null) { + String catalogIdValueAsString = catalogIdValue.toString(); + valMap.put("catalogId", catalogIdValueAsString); + } + String catalogNameValue = getCatalogName(); + if (catalogNameValue != null) { + String catalogNameValueAsString = catalogNameValue.toString(); + valMap.put("catalogName", catalogNameValueAsString); + } + Long publishDateValue = getPublishDate(); + if (publishDateValue != null) { + String publishDateValueAsString = publishDateValue.toString(); + valMap.put("publishDate", publishDateValueAsString); + } + String titleValue = getTitle(); + if (titleValue != null) { + String titleValueAsString = titleValue.toString(); + valMap.put("title", titleValueAsString); + } + String bodyValue = getBody(); + if (bodyValue != null) { + String bodyValueAsString = bodyValue.toString(); + valMap.put("body", bodyValueAsString); + } + String disclaimerValue = getDisclaimer(); + if (disclaimerValue != null) { + String disclaimerValueAsString = disclaimerValue.toString(); + valMap.put("disclaimer", disclaimerValueAsString); + } + + 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 catalogIdValue = getCatalogId(); + if (catalogIdValue != null) { + valMap.put("catalogId", catalogIdValue); + } + Object catalogNameValue = getCatalogName(); + if (catalogNameValue != null) { + valMap.put("catalogName", catalogNameValue); + } + Object publishDateValue = getPublishDate(); + if (publishDateValue != null) { + valMap.put("publishDate", publishDateValue); + } + Object titleValue = getTitle(); + if (titleValue != null) { + valMap.put("title", titleValue); + } + Object bodyValue = getBody(); + if (bodyValue != null) { + valMap.put("body", bodyValue); + } + Object disclaimerValue = getDisclaimer(); + if (disclaimerValue != null) { + valMap.put("disclaimer", disclaimerValue); + } + + 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("catalogId"); + openapiFields.add("catalogName"); + openapiFields.add("publishDate"); + openapiFields.add("title"); + openapiFields.add("body"); + openapiFields.add("disclaimer"); + + // 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 ComAnnouncementEnResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ComAnnouncementEnResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ComAnnouncementEnResponse is not found" + + " in the empty JSON string", + ComAnnouncementEnResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ComAnnouncementEnResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `ComAnnouncementEnResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("catalogName") != null && !jsonObj.get("catalogName").isJsonNull()) + && !jsonObj.get("catalogName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `catalogName` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("catalogName").toString())); + } + if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) + && !jsonObj.get("title").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `title` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("title").toString())); + } + if ((jsonObj.get("body") != null && !jsonObj.get("body").isJsonNull()) + && !jsonObj.get("body").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `body` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("body").toString())); + } + if ((jsonObj.get("disclaimer") != null && !jsonObj.get("disclaimer").isJsonNull()) + && !jsonObj.get("disclaimer").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `disclaimer` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("disclaimer").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ComAnnouncementEnResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ComAnnouncementEnResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ComAnnouncementEnResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ComAnnouncementEnResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ComAnnouncementEnResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ComAnnouncementEnResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ComAnnouncementEnResponse + * @throws IOException if the JSON string is invalid with respect to ComAnnouncementEnResponse + */ + public static ComAnnouncementEnResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ComAnnouncementEnResponse.class); + } + + /** + * Convert an instance of ComAnnouncementEnResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/cms/src/test/java/com/binance/connector/client/cms/websocket/stream/api/DefaultApiTest.java b/clients/cms/src/test/java/com/binance/connector/client/cms/websocket/stream/api/DefaultApiTest.java new file mode 100644 index 000000000..b1122bbe4 --- /dev/null +++ b/clients/cms/src/test/java/com/binance/connector/client/cms/websocket/stream/api/DefaultApiTest.java @@ -0,0 +1,112 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 types of per-user business events in real time via the Binance SApi WebSocket channel, covering trading (market / limit), reward claim, fund transfer and market resolution, plus order book (bid/ask) quotes broadcast per topic. Business events are routed by exact `(topic, userId)` match; order book topics are broadcast to every subscriber. Delivery is at-most-once, ordering is not guaranteed, and offline messages are not cached — pull the latest state via the REST API after reconnecting and deduplicate on `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.cms.websocket.stream.api; + +import com.binance.connector.client.cms.websocket.stream.model.ComAnnouncementEnRequest; +import com.binance.connector.client.cms.websocket.stream.model.ComAnnouncementEnResponse; +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.adapter.stream.SignedStreamConnectionWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionWrapper; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.dtos.RequestWrapperDTO; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; + +import java.io.File; +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.Set; +import java.util.concurrent.CompletableFuture; +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; + +/** API tests for DefaultApi */ +public class DefaultApiTest { + + private DefaultApi api; + private SignedStreamConnectionWrapper connectionSpy; + private Session sessionMock; + + @BeforeEach + public void initApiClient() throws Exception { + URL resource = DefaultApi.class.getResource("/test-ed25519-prv-key.pem"); + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + File file = new File(resource.toURI()); + signatureConfiguration.setPrivateKey(file.getAbsolutePath()); + WebSocketClientConfiguration clientConfiguration = new WebSocketClientConfiguration(); + // @TODO: run tests for LOGON as well + 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); + SignedStreamConnectionWrapper connectionWrapper = + new SignedStreamConnectionWrapper(clientConfiguration, webSocketClient); + connectionSpy = Mockito.spy(connectionWrapper); + Mockito.doNothing().when(connectionSpy).setUserAgent(Mockito.anyString()); + Mockito.doReturn(1736393892000L).when(connectionSpy).getTimestamp(); + DefaultApi apiClient = new DefaultApi(connectionSpy); + api = Mockito.spy(apiClient); + Mockito.doReturn("eaf3292c-64b6-4c04-ad4f-4ca2608b42b4").when(api).getRequestID(); + } + + /** + * Receive push notifications hen Binance publishes announcements in English (language code: + * en). + * + * @throws ApiException if the Api call fails + */ + @Test + public void comAnnouncementEnTest() throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.comAnnouncementEn(); + ArgumentCaptor, ComAnnouncementEnResponse>> + 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, ComAnnouncementEnResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/com_announcement_en-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } +} diff --git a/clients/cms/src/test/resources/expected/stream/DefaultApi/com_announcement_en-test.json b/clients/cms/src/test/resources/expected/stream/DefaultApi/com_announcement_en-test.json new file mode 100644 index 000000000..bd6eb35e7 --- /dev/null +++ b/clients/cms/src/test/resources/expected/stream/DefaultApi/com_announcement_en-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "com_announcement_en" +} diff --git a/clients/cms/src/test/resources/test-ed25519-prv-key.pem b/clients/cms/src/test/resources/test-ed25519-prv-key.pem new file mode 100644 index 000000000..f6cbbe619 --- /dev/null +++ b/clients/cms/src/test/resources/test-ed25519-prv-key.pem @@ -0,0 +1,3 @@ +-----BEGIN PRIVATE KEY----- +MC4CAQAwBQYDK2VwBCIEILpXm6EtDzSzPJWHTbP904h5R3bzb0QsLjTf1tAt2OlB +-----END PRIVATE KEY----- diff --git a/clients/common/pom.xml b/clients/common/pom.xml index e6e2d5cd7..c0c59469b 100644 --- a/clients/common/pom.xml +++ b/clients/common/pom.xml @@ -10,6 +10,6 @@ binance-common common - 2.5.3 + 2.6.1 jar \ No newline at end of file diff --git a/clients/common/src/main/java/com/binance/connector/client/common/configuration/ClientConfiguration.java b/clients/common/src/main/java/com/binance/connector/client/common/configuration/ClientConfiguration.java index 56a111b7d..70397ffcb 100644 --- a/clients/common/src/main/java/com/binance/connector/client/common/configuration/ClientConfiguration.java +++ b/clients/common/src/main/java/com/binance/connector/client/common/configuration/ClientConfiguration.java @@ -15,6 +15,8 @@ public class ClientConfiguration { public static final int DEFAULT_CONNECT_TIMEOUT = 1000; public static final int DEFAULT_READ_TIMEOUT = 5000; public static final long DEFAULT_MAX_MESSAGE_SIZE = 65536L; + public static final long DEFAULT_PING_INTERVAL_TIME = 30000L; + public static final long DEFAULT_RECV_WINDOW = 30000L; /** Base URL */ protected String url = "https://api.binance.com"; diff --git a/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/ConnectionWrapper.java b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/ConnectionWrapper.java index c55cd76de..ccb783208 100644 --- a/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/ConnectionWrapper.java +++ b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/ConnectionWrapper.java @@ -13,13 +13,18 @@ import com.binance.connector.client.common.websocket.dtos.SessionResponse; 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.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializer; +import com.google.gson.*; +import org.bouncycastle.crypto.CryptoException; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.http.HttpField; +import org.eclipse.jetty.http.HttpHeader; +import org.eclipse.jetty.websocket.api.Session; +import org.eclipse.jetty.websocket.api.StatusCode; +import org.eclipse.jetty.websocket.api.WebSocketListener; +import org.eclipse.jetty.websocket.api.WriteCallback; +import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; +import org.eclipse.jetty.websocket.client.WebSocketClient; + import java.io.IOException; import java.lang.reflect.Type; import java.net.URI; @@ -28,73 +33,41 @@ import java.nio.channels.ClosedChannelException; import java.text.DecimalFormat; import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; -import java.util.UUID; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.LinkedBlockingDeque; -import java.util.concurrent.TimeUnit; +import java.util.*; +import java.util.concurrent.*; import java.util.function.Consumer; import java.util.logging.Level; import java.util.logging.Logger; -import org.bouncycastle.crypto.CryptoException; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.http.HttpField; -import org.eclipse.jetty.http.HttpHeader; -import org.eclipse.jetty.util.component.LifeCycle; -import org.eclipse.jetty.websocket.api.Session; -import org.eclipse.jetty.websocket.api.StatusCode; -import org.eclipse.jetty.websocket.api.WebSocketListener; -import org.eclipse.jetty.websocket.api.WriteCallback; -import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; -import org.eclipse.jetty.websocket.client.WebSocketClient; public class ConnectionWrapper implements WebSocketListener, ConnectionInterface { - private static final Logger log = Logger.getLogger(ConnectionWrapper.class.getName()); - public static final int WAIT_TIME = 5; + private static final Logger log = Logger.getLogger(ConnectionWrapper.class.getName()); private static final String QUERY_PARAM_TIME_UNIT = "timeUnit"; // -2015 for wrong API Keys, -1022 for wrong signature private static final List ERROR_CODE_WRONG_CREDENTIALS = Arrays.asList(-2015, -1022); - + private final WebSocketClient webSocketClient; + private final WebSocketClientConfiguration configuration; + private final SignatureGeneratorFactory signatureGeneratorFactory = + new SignatureGeneratorFactory(); protected Map pendingRequest = new HashMap<>(); protected Session session; protected Session oldSession; - protected List logonMethods = new ArrayList<>(); protected List logoutMethods = new ArrayList<>(); - + protected Timer timer; private String userAgent = String.format( "binance-connector-java/1.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); - private boolean isLoggedOn = false; private boolean isReady = false; private boolean canReconnect = true; - private final WebSocketClient webSocketClient; - private final WebSocketClientConfiguration configuration; - private final SignatureGeneratorFactory signatureGeneratorFactory = - new SignatureGeneratorFactory(); private Gson gson; private SignatureGenerator signatureGenerator; - private CountDownLatch countDownLatch; - private boolean pendingReconnect = false; - private List> streamQueues = new ArrayList<>(); - private Timer timer; - public ConnectionWrapper(WebSocketClientConfiguration configuration, Gson gson) { this(configuration, null, gson); } @@ -165,24 +138,24 @@ public ConnectionWrapper( Integer reconnectAfter = configuration.getReconnectIntervalTime(); this.timer = new Timer(); this.timer.scheduleAtFixedRate( - new TimerTask() { - @Override - public void run() { - try { - if (canReconnect()) { - connect(); - } else { - pendingReconnect = true; - } - - } catch (Exception e) { - System.out.println(e); - throw new RuntimeException(e); - } + new TimerTask() { + @Override + public void run() { + try { + if (canReconnect()) { + connect(); + } else { + pendingReconnect = true; } - }, - reconnectAfter, - reconnectAfter); + + } catch (Exception e) { + System.out.println(e); + throw new RuntimeException(e); + } + } + }, + reconnectAfter, + reconnectAfter); } public void connect() { @@ -203,8 +176,7 @@ public void connect(Consumer customCallback) Consumer callback = autoLogon ? getLogonConsumer() : null; // The server URI to connect to. - URI serverURI = null; - serverURI = getUri(configuration.getUrl()); + URI serverURI = getUri(configuration.getUrl()); if (configuration.getSignatureConfiguration() != null) { this.signatureGenerator = @@ -215,10 +187,13 @@ public void connect(Consumer customCallback) beforeConnect(); ClientUpgradeRequest clientUpgradeRequest = null; + clientUpgradeRequest = new ClientUpgradeRequest(); if (configuration.getCompression()) { - clientUpgradeRequest = new ClientUpgradeRequest(); clientUpgradeRequest.addExtensions("permessage-deflate"); } + if (configuration.getSignatureConfiguration() != null && configuration.getSignatureConfiguration().getApiKey() != null) { + clientUpgradeRequest.setHeader("X-MBX-APIKEY", configuration.getSignatureConfiguration().getApiKey()); + } // Connect the client EndPoint to the server. CompletableFuture clientSessionPromise = @@ -383,7 +358,9 @@ public void writeFailed(Throwable x) { @Override public void writeSuccess() { - ConnectionWrapper.this.pendingRequest.put(request.getId(), request); + if (request.getId() != null) { + ConnectionWrapper.this.pendingRequest.put(request.getId(), request); + } } }); } @@ -552,7 +529,7 @@ public URI getUri(String uri) throws URISyntaxException { // timeUnit not configured or already specified in query if (configuration.getTimeUnit() == null || (oldUri.getQuery() != null - && oldUri.getQuery().contains(QUERY_PARAM_TIME_UNIT + "="))) { + && oldUri.getQuery().contains(QUERY_PARAM_TIME_UNIT + "="))) { return oldUri; } @@ -588,4 +565,8 @@ public void stop() throws Exception { webSocketClient.stop(); } } + + public WebSocketClientConfiguration getConfiguration() { + return configuration; + } } diff --git a/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/SignedStreamConnectionPoolWrapper.java b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/SignedStreamConnectionPoolWrapper.java new file mode 100644 index 000000000..6fbf829cf --- /dev/null +++ b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/SignedStreamConnectionPoolWrapper.java @@ -0,0 +1,24 @@ +package com.binance.connector.client.common.websocket.adapter.stream; + +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.google.gson.Gson; + +public class SignedStreamConnectionPoolWrapper extends StreamConnectionPoolWrapper { + public SignedStreamConnectionPoolWrapper(WebSocketClientConfiguration clientConfiguration) { + super(clientConfiguration); + } + + public SignedStreamConnectionPoolWrapper(WebSocketClientConfiguration clientConfiguration, Gson gson) { + super(clientConfiguration, gson); + } + + @Override + protected void initConnectionPool(WebSocketClientConfiguration clientConfiguration, Gson gson) { + Integer poolSize = clientConfiguration.getPoolSize(); + for (int i = 0; i < poolSize; i++) { + SignedStreamConnectionWrapper connectionWrapper = + new SignedStreamConnectionWrapper(clientConfiguration, gson); + getConnectionList().add(connectionWrapper); + } + } +} diff --git a/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/SignedStreamConnectionWrapper.java b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/SignedStreamConnectionWrapper.java new file mode 100644 index 000000000..38a5d3efc --- /dev/null +++ b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/SignedStreamConnectionWrapper.java @@ -0,0 +1,241 @@ +package com.binance.connector.client.common.websocket.adapter.stream; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.JSON; +import com.binance.connector.client.common.auth.SignatureGeneratorFactory; +import com.binance.connector.client.common.sign.SignatureGenerator; +import com.binance.connector.client.common.websocket.adapter.ConnectionWrapper; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +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.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.apache.commons.codec.binary.Hex; +import org.apache.commons.lang3.StringUtils; +import org.bouncycastle.crypto.CryptoException; +import org.eclipse.jetty.websocket.api.Session; +import org.eclipse.jetty.websocket.api.WriteCallback; +import org.eclipse.jetty.websocket.client.WebSocketClient; + +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.SecureRandom; +import java.util.*; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.stream.Collectors; + +import static com.binance.connector.client.common.configuration.ClientConfiguration.DEFAULT_PING_INTERVAL_TIME; + +public class SignedStreamConnectionWrapper extends ConnectionWrapper + implements StreamConnectionInterface { + private final HashMap>> subscriptions = + new HashMap<>(); + private final TimerTask pingTask = new TimerTask() { + @Override + public void run() { + try { + session.getRemote().sendPing(null, WriteCallback.NOOP); + } catch (Exception e) { + System.err.println("ping failed:" + e.getMessage()); + } + } + }; + + public SignedStreamConnectionWrapper(WebSocketClientConfiguration configuration, Gson json) { + super(configuration, json); + } + + public SignedStreamConnectionWrapper(WebSocketClientConfiguration configuration) { + super(configuration); + } + + public SignedStreamConnectionWrapper( + WebSocketClientConfiguration configuration, WebSocketClient webSocketClient) { + super(configuration, webSocketClient); + } + + public static String getRandomString() { + SecureRandom random = new SecureRandom(); + byte[] bytes = new byte[16]; + random.nextBytes(bytes); + + return Hex.encodeHexString(bytes); + } + + public Map> subscribe( + RequestWrapperDTO, Object> requestWrapperDTO) { + HashMap> queueMap = new HashMap<>(); + List allSubscriptions = new ArrayList<>(); + String value = requestWrapperDTO.getValue(); + if (StringUtils.isNotBlank(value)) { + allSubscriptions.addAll(Arrays.asList(value.split("\\|"))); + } + if (requestWrapperDTO.getParams() != null) { + allSubscriptions.addAll(requestWrapperDTO.getParams()); + } + for (String subscription : allSubscriptions) { + List> blockingQueueList; + if (this.subscriptions.containsKey(subscription)) { + blockingQueueList = this.subscriptions.get(subscription); + } else { + blockingQueueList = new ArrayList<>(); + } + BlockingQueue blockingQueue = new LinkedBlockingDeque<>(); + + StreamBlockingQueue blockingQueueWrapper = + new StreamBlockingQueue(blockingQueue, subscription); + + blockingQueueList.add(blockingQueueWrapper); + this.subscriptions.put(subscription, blockingQueueList); + this.innerSend(requestWrapperDTO); + queueMap.put(subscription, blockingQueueWrapper); + } + + return queueMap; + } + + public void unsubscribe(StreamBlockingQueueWrapper blockingQueueWrapper) { + unsubscribe(blockingQueueWrapper.getInnerQueue()); + } + + public void unsubscribe(StreamBlockingQueue queue) { + String operationId = queue.getOperationId(); + List> blockingQueues = subscriptions.get(operationId); + blockingQueues.remove(queue); + + // unsubscribe from the stream if no more queue + if (blockingQueues.isEmpty()) { + RequestWrapperDTO unsubscribe = + new RequestWrapperDTO.Builder<>() + .command("UNSUBSCRIBE") + .value(operationId) + .build(); + + this.send(unsubscribe); + } + } + + @Override + public void onWebSocketText(String message) { + try { + JsonElement root = JsonParser.parseString(message); + JsonObject obj = root.getAsJsonObject(); + + if (handleShutdownMessage(obj)) { + return; + } + + // Response to subscribe + JsonElement id = obj.get("id"); + if (id != null && !id.isJsonNull()) { + JsonElement result = obj.get("result"); + RequestWrapperDTO requestWrapperDTO = pendingRequest.get(id.getAsString()); + Type responseType = requestWrapperDTO.getResponseType(); + Object fromJson = + result.isJsonNull() ? null : JSON.getGson().fromJson(result, responseType); + pendingRequest.remove(id.getAsString()); + requestWrapperDTO.getResponseCallback().complete(fromJson); + return; + } + + JsonElement stream = obj.get("stream"); + if (stream == null) { + stream = obj.get("topic"); + } + // no stream, we couldn't detect which queue to use. + if (stream == null) { + return; + } + List> blockingQueues = + subscriptions.get(stream.getAsString()); + if (blockingQueues == null || blockingQueues.isEmpty()) { + return; + } + for (StreamBlockingQueue queue : blockingQueues) { + JsonElement data = obj.get("data"); + + if (data == null || data.isJsonNull()) { + return; + } + + String dataJson = data.isJsonPrimitive() && data.getAsJsonPrimitive().isString() + ? data.getAsString() + : data.toString(); + + queue.offer(dataJson); + } + } catch (Exception e) { + throw new ApiException(e); + } + } + + protected void beforeConnect() { + super.beforeConnect(); + } + + protected void afterConnect(Session session) { + List subcriptionsListResult = subscriptions.entrySet().stream() + .filter(entry -> entry.getValue() != null && !entry.getValue().isEmpty()) + .map(Map.Entry::getKey) + .collect(Collectors.toList()); + + if (!subcriptionsListResult.isEmpty()) { + RequestWrapperDTO subscribe = + new RequestWrapperDTO.Builder<>() + .command("SUBSCRIBE") + .value(String.join("|", subcriptionsListResult)) + .build(); + + this.send(subscribe); + } + + Long pingIntervalTime = getConfiguration().getPingIntervalTime(); + if (pingIntervalTime == null) { + pingIntervalTime = DEFAULT_PING_INTERVAL_TIME; + } + + // it's the first connect + if (oldSession == null) { + this.timer.scheduleAtFixedRate( + pingTask, + pingIntervalTime, + pingIntervalTime + ); + } + + super.afterConnect(session); + } + + @Override + public URI getUri(String uri) throws URISyntaxException { + URI oldUri = new URI(uri); + SignatureGeneratorFactory signatureGeneratorFactory = new SignatureGeneratorFactory(); + SignatureGenerator signatureGenerator = + signatureGeneratorFactory.getSignatureGenerator(getConfiguration().getSignatureConfiguration()); + + String newQuery = + "random=" + + getRandomString() + + "&recvWindow=" + + getConfiguration().getRecvWindow() + + "×tamp=" + + getTimestamp(); + String signature = null; + try { + signature = signatureGenerator.signAsString(newQuery); + } catch (CryptoException e) { + throw new RuntimeException(e); + } + return new URI( + oldUri.getScheme(), + oldUri.getAuthority(), + oldUri.getPath(), + newQuery + "&signature=" + signature, + oldUri.getFragment()); + } +} \ No newline at end of file diff --git a/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/StreamConnectionInterface.java b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/StreamConnectionInterface.java index 797f6e671..a740cb977 100644 --- a/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/StreamConnectionInterface.java +++ b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/StreamConnectionInterface.java @@ -3,6 +3,7 @@ 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 java.util.Map; import java.util.Set; @@ -16,6 +17,10 @@ Map> subscribe( void connect(); + boolean canReconnect(); + + boolean isReady(); + void disconnect(); boolean isConnected(); diff --git a/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/StreamConnectionPoolWrapper.java b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/StreamConnectionPoolWrapper.java index 7e765bf51..393cf3c39 100644 --- a/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/StreamConnectionPoolWrapper.java +++ b/clients/common/src/main/java/com/binance/connector/client/common/websocket/adapter/stream/StreamConnectionPoolWrapper.java @@ -1,32 +1,24 @@ package com.binance.connector.client.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.configuration.WebSocketClientConfiguration; 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.google.gson.Gson; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.ListIterator; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -public class StreamConnectionPoolWrapper implements StreamConnectionInterface { +import java.util.*; - private final LinkedList connectionList = new LinkedList<>(); - private ListIterator pool; +public class StreamConnectionPoolWrapper implements StreamConnectionInterface { + private final LinkedList connectionList = new LinkedList<>(); + private final Map connectionStreamMap = new HashMap<>(); + private ListIterator pool; private Boolean isConnected = false; private String userAgent = String.format( "binance-connector-java/1.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); - private final Map connectionStreamMap = new HashMap<>(); - public StreamConnectionPoolWrapper(WebSocketClientConfiguration clientConfiguration) { this(clientConfiguration, null); } @@ -36,12 +28,7 @@ public StreamConnectionPoolWrapper( Integer poolSize = clientConfiguration.getPoolSize(); Integer batchSize = clientConfiguration.getReconnectBatchSize(); Integer reconnectAfter = clientConfiguration.getReconnectIntervalTime(); - for (int i = 0; i < poolSize; i++) { - StreamConnectionWrapper connectionWrapper = - new StreamConnectionWrapper(clientConfiguration, gson); - connectionList.add(connectionWrapper); - } - + initConnectionPool(clientConfiguration, gson); // Scheduler to reconnect by batch every 23h (configurable) new Timer() .scheduleAtFixedRate( @@ -57,7 +44,7 @@ public void run() { for (int j = 0; j < currentBatchSize; j++) { int connectionIndex = ((poolSize / batchSize) * i) + j; - ConnectionWrapper connectionWrapper = + StreamConnectionInterface connectionWrapper = connectionList.get(connectionIndex); if (connectionWrapper.canReconnect()) { connectionWrapper.connect(); @@ -77,7 +64,7 @@ public void run() { @Override public void connect() { - for (ConnectionWrapper connectionWrapper : connectionList) { + for (StreamConnectionInterface connectionWrapper : connectionList) { connectionWrapper.setUserAgent(userAgent); connectionWrapper.connect(); } @@ -86,7 +73,7 @@ public void connect() { @Override public void disconnect() { - for (ConnectionWrapper connectionWrapper : connectionList) { + for (StreamConnectionInterface connectionWrapper : connectionList) { connectionWrapper.disconnect(); } isConnected = false; @@ -97,7 +84,7 @@ public Map> subscribe( Set params = requestWrapperDTO.getParams(); Map> queueMap = new HashMap<>(); for (String identifier : params) { - StreamConnectionWrapper connection = getConnection(identifier); + StreamConnectionInterface connection = getConnection(identifier); queueMap.putAll(connection.subscribe(requestWrapperDTO)); } return queueMap; @@ -110,17 +97,17 @@ public void unsubscribe(StreamBlockingQueueWrapper queue) { @Override public void unsubscribe(StreamBlockingQueue queue) { - StreamConnectionWrapper connection = getConnection(queue.getOperationId()); + StreamConnectionInterface connection = getConnection(queue.getOperationId()); connection.unsubscribe(queue); connectionStreamMap.remove(queue.getOperationId()); } - public StreamConnectionWrapper getConnection(String identifier) { + public StreamConnectionInterface getConnection(String identifier) { if (connectionStreamMap.containsKey(identifier)) { return connectionStreamMap.get(identifier); } - StreamConnectionWrapper connection = getConnection(); + StreamConnectionInterface connection = getConnection(); connectionStreamMap.put(identifier, connection); return connection; @@ -129,11 +116,11 @@ public StreamConnectionWrapper getConnection(String identifier) { /** * @return the next connection from the pool, using round-robin */ - public StreamConnectionWrapper getConnection() { + public StreamConnectionInterface getConnection() { if (!pool.hasNext()) { pool = connectionList.listIterator(); } - StreamConnectionWrapper connection = pool.next(); + StreamConnectionInterface connection = pool.next(); while (!connection.isReady()) { if (!pool.hasNext()) { pool = connectionList.listIterator(); @@ -157,9 +144,42 @@ public boolean isConnected() { @Override public void stop() throws Exception { - for (ConnectionWrapper connectionWrapper : connectionList) { + for (StreamConnectionInterface connectionWrapper : connectionList) { connectionWrapper.stop(); } isConnected = false; } + + @Override + public boolean canReconnect() { + for (StreamConnectionInterface connectionWrapper : connectionList) { + if (!connectionWrapper.canReconnect()) { + return false; + } + } + return true; + } + + @Override + public boolean isReady() { + for (StreamConnectionInterface connectionWrapper : connectionList) { + if (!connectionWrapper.isReady()) { + return false; + } + } + return true; + } + + protected LinkedList getConnectionList() { + return connectionList; + } + + protected void initConnectionPool(WebSocketClientConfiguration clientConfiguration, Gson gson) { + Integer poolSize = clientConfiguration.getPoolSize(); + for (int i = 0; i < poolSize; i++) { + StreamConnectionWrapper connectionWrapper = + new StreamConnectionWrapper(clientConfiguration, gson); + connectionList.add(connectionWrapper); + } + } } diff --git a/clients/common/src/main/java/com/binance/connector/client/common/websocket/configuration/WebSocketClientConfiguration.java b/clients/common/src/main/java/com/binance/connector/client/common/websocket/configuration/WebSocketClientConfiguration.java index fdc722ce3..c28c3a780 100644 --- a/clients/common/src/main/java/com/binance/connector/client/common/websocket/configuration/WebSocketClientConfiguration.java +++ b/clients/common/src/main/java/com/binance/connector/client/common/websocket/configuration/WebSocketClientConfiguration.java @@ -32,6 +32,12 @@ public class WebSocketClientConfiguration extends ClientConfiguration implements /** messageMaxSize for WebSocket messages */ private Long messageMaxSize = DEFAULT_MAX_MESSAGE_SIZE; + /** Send ping every configured ms, disabled if null */ + private Long pingIntervalTime = null; + + /** Default recvWindow */ + private Long recvWindow = DEFAULT_RECV_WINDOW; + @Override public String getUrl() { return url; @@ -106,6 +112,22 @@ public void setMessageMaxSize(Long messageMaxSize) { this.messageMaxSize = messageMaxSize; } + public Long getPingIntervalTime() { + return pingIntervalTime; + } + + public void setPingIntervalTime(Long pingIntervalTime) { + this.pingIntervalTime = pingIntervalTime; + } + + public Long getRecvWindow() { + return recvWindow; + } + + public void setRecvWindow(Long recvWindow) { + this.recvWindow = recvWindow; + } + @Override public Object clone() { try { diff --git a/clients/common/src/main/java/com/binance/connector/client/common/websocket/dtos/RequestWrapperDTO.java b/clients/common/src/main/java/com/binance/connector/client/common/websocket/dtos/RequestWrapperDTO.java index 82113d014..8ec486b22 100644 --- a/clients/common/src/main/java/com/binance/connector/client/common/websocket/dtos/RequestWrapperDTO.java +++ b/clients/common/src/main/java/com/binance/connector/client/common/websocket/dtos/RequestWrapperDTO.java @@ -7,6 +7,8 @@ public class RequestWrapperDTO { protected String id; protected T params; protected String method; + protected String command; + protected String value; protected transient Type responseType; protected transient CompletableFuture responseCallback = new CompletableFuture<>(); @@ -34,6 +36,22 @@ public Type getResponseType() { return responseType; } + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + public void setResponseType(Type responseType) { this.responseType = responseType; } @@ -43,6 +61,8 @@ private RequestWrapperDTO(Builder builder) { params = builder.params; method = builder.method; responseType = builder.responseType; + command = builder.command; + value = builder.value; } public CompletableFuture getResponseCallback() { @@ -54,6 +74,8 @@ public static final class Builder { private T params; private String method; private Type responseType; + private String command; + private String value; public Builder() {} @@ -77,6 +99,16 @@ public Builder responseType(Type val) { return this; } + public Builder command(String val) { + command = val; + return this; + } + + public Builder value(String val) { + value = val; + return this; + } + public RequestWrapperDTO build() { return new RequestWrapperDTO<>(this); } diff --git a/clients/common/src/main/java/com/binance/connector/client/common/websocket/service/StreamBlockingQueueWrapper.java b/clients/common/src/main/java/com/binance/connector/client/common/websocket/service/StreamBlockingQueueWrapper.java index 80ba35840..d052179dc 100644 --- a/clients/common/src/main/java/com/binance/connector/client/common/websocket/service/StreamBlockingQueueWrapper.java +++ b/clients/common/src/main/java/com/binance/connector/client/common/websocket/service/StreamBlockingQueueWrapper.java @@ -28,4 +28,12 @@ public T take() throws InterruptedException { String take = innerQueue.take(); return gson.fromJson(take, convertType); } + + public T poll() { + String take = innerQueue.poll(); + if (take == null) { + return null; + } + return gson.fromJson(take, convertType); + } } diff --git a/clients/pom.xml b/clients/pom.xml index cde6238bb..e4d418d43 100644 --- a/clients/pom.xml +++ b/clients/pom.xml @@ -19,6 +19,7 @@ algo alpha c2c + cms convert common copy-trading @@ -81,7 +82,7 @@ org.sonatype.central central-publishing-maven-plugin - 0.8.0 + 0.11.0 true central diff --git a/clients/w3w-prediction/CHANGELOG.md b/clients/w3w-prediction/CHANGELOG.md index 0a704b87e..f283527a2 100644 --- a/clients/w3w-prediction/CHANGELOG.md +++ b/clients/w3w-prediction/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 2.1.3 - 2026-10-09 + +### Changed (2) + +- Modified response for `getMarketDetail()` (`GET /sapi/v1/w3w/wallet/prediction/market/detail`): + - `markets`.items.`outcomes`.items: property `winner` added + - `markets`.items.`outcomes`.items: item property `winner` added + - `markets`.items.`outcomes`.items: property `winner` added + - `markets`.items.`outcomes`.items: item property `winner` added + +- Modified response field `markets`: + - items.`outcomes`.items: property `winner` added + - items.`outcomes`.items: item property `winner` added + - items.`outcomes`.items: property `winner` added + - items.`outcomes`.items: item property `winner` added + - affected events: + - `getMarketDetailResponse` + ## 2.1.2 - 2026-10-01 - Update parent pom to 1.1.4 diff --git a/clients/w3w-prediction/docs/BatchClaimPartiallySucceededResponse.md b/clients/w3w-prediction/docs/BatchClaimPartiallySucceededResponse.md new file mode 100644 index 000000000..616ff45f4 --- /dev/null +++ b/clients/w3w-prediction/docs/BatchClaimPartiallySucceededResponse.md @@ -0,0 +1,13 @@ + + +# BatchClaimPartiallySucceededResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/DefaultApi.md b/clients/w3w-prediction/docs/DefaultApi.md new file mode 100644 index 000000000..e32b9bb2c --- /dev/null +++ b/clients/w3w-prediction/docs/DefaultApi.md @@ -0,0 +1,897 @@ +# DefaultApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**batchClaimPartiallySucceeded**](DefaultApi.md#batchClaimPartiallySucceeded) | **POST** /web3_prediction_pm_claim_partial_success | Batch claim partially succeeded | +| [**fundTransferFailed**](DefaultApi.md#fundTransferFailed) | **POST** /web3_prediction_pm_transfer_fail | Fund transfer failed | +| [**fundTransferSucceeded**](DefaultApi.md#fundTransferSucceeded) | **POST** /web3_prediction_pm_transfer_success | Fund transfer succeeded | +| [**limitOrderFullyFilled**](DefaultApi.md#limitOrderFullyFilled) | **POST** /web3_prediction_pm_limit_order_filled | Limit order fully filled | +| [**limitOrderPartiallyFilled**](DefaultApi.md#limitOrderPartiallyFilled) | **POST** /web3_prediction_pm_limit_order_partial_fill | Limit order partially filled | +| [**limitOrderSubmissionFailed**](DefaultApi.md#limitOrderSubmissionFailed) | **POST** /web3_prediction_pm_limit_submit_fail | Limit order submission failed | +| [**limitOrderSubmittedSuccessfully**](DefaultApi.md#limitOrderSubmittedSuccessfully) | **POST** /web3_prediction_pm_limit_submit_success | Limit order submitted successfully | +| [**marketBuyOrderFailed**](DefaultApi.md#marketBuyOrderFailed) | **POST** /web3_prediction_pm_market_buy_fail | Market buy order failed / expired | +| [**marketBuyOrderFullyFilled**](DefaultApi.md#marketBuyOrderFullyFilled) | **POST** /web3_prediction_pm_market_buy_success | Market buy order fully filled | +| [**marketResolutionNotification**](DefaultApi.md#marketResolutionNotification) | **POST** /web3_prediction_pm_market_close | Market resolution notification | +| [**marketSellOrderFailedExpired**](DefaultApi.md#marketSellOrderFailedExpired) | **POST** /web3_prediction_pm_market_sell_fail | Market sell order failed / expired | +| [**marketSellOrderFullyFilled**](DefaultApi.md#marketSellOrderFullyFilled) | **POST** /web3_prediction_pm_market_sell_success | Market sell order fully filled | +| [**predictionOrderBookByMarketId**](DefaultApi.md#predictionOrderBookByMarketId) | **POST** /web3_prediction_orderbook_<marketId> | Prediction Order Book by marketId | +| [**rewardClaimFailed**](DefaultApi.md#rewardClaimFailed) | **POST** /web3_prediction_pm_claim_fail | Reward claim failed | +| [**rewardClaimSucceeded**](DefaultApi.md#rewardClaimSucceeded) | **POST** /web3_prediction_pm_claim_success | Reward claim succeeded | + + + +# **batchClaimPartiallySucceeded** +> BatchClaimPartiallySucceededResponse batchClaimPartiallySucceeded() + +Batch claim partially succeeded + +Pushed when only part of a batch claim succeeds. Only `pushId` is included — call the REST API for details. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + BatchClaimPartiallySucceededResponse result = apiInstance.batchClaimPartiallySucceeded(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#batchClaimPartiallySucceeded"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**BatchClaimPartiallySucceededResponse**](BatchClaimPartiallySucceededResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **fundTransferFailed** +> FundTransferFailedResponse fundTransferFailed() + +Fund transfer failed + +Pushed when a fund transfer fails. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + FundTransferFailedResponse result = apiInstance.fundTransferFailed(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#fundTransferFailed"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**FundTransferFailedResponse**](FundTransferFailedResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **fundTransferSucceeded** +> FundTransferSucceededResponse fundTransferSucceeded() + +Fund transfer succeeded + +Pushed when a fund transfer into or out of the prediction wallet succeeds. The direction and the token are not included (currently USDT only). Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + FundTransferSucceededResponse result = apiInstance.fundTransferSucceeded(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#fundTransferSucceeded"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**FundTransferSucceededResponse**](FundTransferSucceededResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **limitOrderFullyFilled** +> LimitOrderFullyFilledResponse limitOrderFullyFilled() + +Limit order fully filled + +Pushed when a **limit order** is fully filled. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + LimitOrderFullyFilledResponse result = apiInstance.limitOrderFullyFilled(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#limitOrderFullyFilled"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**LimitOrderFullyFilledResponse**](LimitOrderFullyFilledResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **limitOrderPartiallyFilled** +> LimitOrderPartiallyFilledResponse limitOrderPartiallyFilled() + +Limit order partially filled + +Pushed on each new partial fill of a **limit order**. One order can be pushed several times, so always remove duplicates by `pushId`. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + LimitOrderPartiallyFilledResponse result = apiInstance.limitOrderPartiallyFilled(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#limitOrderPartiallyFilled"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**LimitOrderPartiallyFilledResponse**](LimitOrderPartiallyFilledResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **limitOrderSubmissionFailed** +> LimitOrderSubmissionFailedResponse limitOrderSubmissionFailed() + +Limit order submission failed + +Pushed when a **limit order** is rejected when placed. No `amount` is included. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + LimitOrderSubmissionFailedResponse result = apiInstance.limitOrderSubmissionFailed(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#limitOrderSubmissionFailed"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**LimitOrderSubmissionFailedResponse**](LimitOrderSubmissionFailedResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **limitOrderSubmittedSuccessfully** +> LimitOrderSubmittedSuccessfullyResponse limitOrderSubmittedSuccessfully() + +Limit order submitted successfully + +Pushed when the user's **limit order** is successfully placed on the order book. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + LimitOrderSubmittedSuccessfullyResponse result = apiInstance.limitOrderSubmittedSuccessfully(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#limitOrderSubmittedSuccessfully"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**LimitOrderSubmittedSuccessfullyResponse**](LimitOrderSubmittedSuccessfullyResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **marketBuyOrderFailed** +> MarketBuyOrderFailedResponse marketBuyOrderFailed() + +Market buy order failed / expired + +Pushed when the user's **market buy order** fails or expires. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + MarketBuyOrderFailedResponse result = apiInstance.marketBuyOrderFailed(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#marketBuyOrderFailed"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**MarketBuyOrderFailedResponse**](MarketBuyOrderFailedResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **marketBuyOrderFullyFilled** +> MarketBuyOrderFullyFilledResponse marketBuyOrderFullyFilled() + +Market buy order fully filled + +Pushed when the user's **market buy order** is fully filled. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + MarketBuyOrderFullyFilledResponse result = apiInstance.marketBuyOrderFullyFilled(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#marketBuyOrderFullyFilled"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**MarketBuyOrderFullyFilledResponse**](MarketBuyOrderFullyFilledResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **marketResolutionNotification** +> MarketResolutionNotificationResponse marketResolutionNotification() + +Market resolution notification + +Pushed when a market is resolved, to every user holding a position in it, win or lose. No amount or outcome is included — call the REST API for the user's profit and loss. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + MarketResolutionNotificationResponse result = apiInstance.marketResolutionNotification(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#marketResolutionNotification"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**MarketResolutionNotificationResponse**](MarketResolutionNotificationResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **marketSellOrderFailedExpired** +> MarketSellOrderFailedExpiredResponse marketSellOrderFailedExpired() + +Market sell order failed / expired + +Pushed when the user's **market sell order** fails or expires. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + MarketSellOrderFailedExpiredResponse result = apiInstance.marketSellOrderFailedExpired(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#marketSellOrderFailedExpired"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**MarketSellOrderFailedExpiredResponse**](MarketSellOrderFailedExpiredResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **marketSellOrderFullyFilled** +> MarketSellOrderFullyFilledResponse marketSellOrderFullyFilled() + +Market sell order fully filled + +Pushed when the user's **market sell order** is fully filled. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + MarketSellOrderFullyFilledResponse result = apiInstance.marketSellOrderFullyFilled(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#marketSellOrderFullyFilled"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**MarketSellOrderFullyFilledResponse**](MarketSellOrderFullyFilledResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **predictionOrderBookByMarketId** +> PredictionOrderBookByMarketIdResponse predictionOrderBookByMarketId(predictionOrderBookByMarketIdRequest) + +Prediction Order Book by marketId + +Order book (bid/ask) updates for one market. Only active markets are pushed. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + PredictionOrderBookByMarketIdRequest predictionOrderBookByMarketIdRequest = new PredictionOrderBookByMarketIdRequest(); // PredictionOrderBookByMarketIdRequest | + try { + PredictionOrderBookByMarketIdResponse result = apiInstance.predictionOrderBookByMarketId(predictionOrderBookByMarketIdRequest); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#predictionOrderBookByMarketId"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **predictionOrderBookByMarketIdRequest** | [**PredictionOrderBookByMarketIdRequest**](PredictionOrderBookByMarketIdRequest.md)| | | + +### Return type + +[**PredictionOrderBookByMarketIdResponse**](PredictionOrderBookByMarketIdResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **rewardClaimFailed** +> RewardClaimFailedResponse rewardClaimFailed() + +Reward claim failed + +Pushed when a claim fails completely — a single claim, or every item of a batch. For a batch, only the first failed item's amount and outcome are included. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + RewardClaimFailedResponse result = apiInstance.rewardClaimFailed(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#rewardClaimFailed"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**RewardClaimFailedResponse**](RewardClaimFailedResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + + +# **rewardClaimSucceeded** +> RewardClaimSucceededResponse rewardClaimSucceeded() + +Reward claim succeeded + +Pushed when a claim fully succeeds — a single claim, or every item of a batch. Only the total is reported; no market title or outcome is included. Update Speed: Real-time + +### Example +```java +// Import classes: +import com.binance.connector.client.w3w_prediction.ApiClient; +import com.binance.connector.client.w3w_prediction.ApiException; +import com.binance.connector.client.w3w_prediction.Configuration; +import com.binance.connector.client.w3w_prediction.models.*; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + RewardClaimSucceededResponse result = apiInstance.rewardClaimSucceeded(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#rewardClaimSucceeded"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**RewardClaimSucceededResponse**](RewardClaimSucceededResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Prediction Stream response | - | + diff --git a/clients/w3w-prediction/docs/FundTransferFailedResponse.md b/clients/w3w-prediction/docs/FundTransferFailedResponse.md new file mode 100644 index 000000000..d22ba436c --- /dev/null +++ b/clients/w3w-prediction/docs/FundTransferFailedResponse.md @@ -0,0 +1,14 @@ + + +# FundTransferFailedResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | Amount of the attempted transfer. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/FundTransferSucceededResponse.md b/clients/w3w-prediction/docs/FundTransferSucceededResponse.md new file mode 100644 index 000000000..d8dab7e3c --- /dev/null +++ b/clients/w3w-prediction/docs/FundTransferSucceededResponse.md @@ -0,0 +1,14 @@ + + +# FundTransferSucceededResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | Amount transferred. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/GetMarketDetailResponseMarketsInner.md b/clients/w3w-prediction/docs/GetMarketDetailResponseMarketsInner.md index 46918fc0e..476ef7199 100644 --- a/clients/w3w-prediction/docs/GetMarketDetailResponseMarketsInner.md +++ b/clients/w3w-prediction/docs/GetMarketDetailResponseMarketsInner.md @@ -17,7 +17,7 @@ |**tradingStatus** | **String** | | [optional] | |**tradeVolume** | **String** | | [optional] | |**liquidity** | **String** | | [optional] | -|**decimalPrecision** | **Integer** | | [optional] | +|**decimalPrecision** | **Integer** | Price precision of the market, in decimal places. The price tick is 10 to the power of minus `decimalPrecision`, for example `2` means a tick of 0.01. A limit price that is not on the tick is truncated down | [optional] | |**outcomes** | [**List<GetMarketDetailResponseMarketsInnerOutcomesInner>**](GetMarketDetailResponseMarketsInnerOutcomesInner.md) | | [optional] | diff --git a/clients/w3w-prediction/docs/GetMarketDetailResponseMarketsInnerOutcomesInner.md b/clients/w3w-prediction/docs/GetMarketDetailResponseMarketsInnerOutcomesInner.md index a64989a37..d453cb08b 100644 --- a/clients/w3w-prediction/docs/GetMarketDetailResponseMarketsInnerOutcomesInner.md +++ b/clients/w3w-prediction/docs/GetMarketDetailResponseMarketsInnerOutcomesInner.md @@ -12,6 +12,7 @@ |**chance** | **String** | | [optional] | |**index** | **Integer** | | [optional] | |**tokenId** | **String** | | [optional] | +|**winner** | **Boolean** | Whether this outcome won. Returned only after the market is resolved. More than one outcome can be `true` when the payout is split | [optional] | diff --git a/clients/w3w-prediction/docs/GetQuoteRequest.md b/clients/w3w-prediction/docs/GetQuoteRequest.md index 167f26cab..0dda83396 100644 --- a/clients/w3w-prediction/docs/GetQuoteRequest.md +++ b/clients/w3w-prediction/docs/GetQuoteRequest.md @@ -10,10 +10,10 @@ |**walletAddress** | **String** | User's prediction wallet address | | |**tokenId** | **String** | Prediction outcome token ID | | |**side** | **Side** | | | -|**amountIn** | **String** | Input amount in wei (18 decimals). Must be > 0. For `MARKET` orders, minimum is approximately 1.5 USDT (varies by market depth). Example: `1000000000000000000` = 1 USDT | | +|**amountIn** | **String** | Input amount in wei (18 decimals). Must be > 0. The minimum is set by the server and may change, see the response notes. Example: `1000000000000000000` = 1 USDT | | |**orderType** | **OrderType** | | | |**slippageBps** | **Integer** | Slippage tolerance in basis points. Range 1–10000 | | -|**priceLimit** | **String** | Limit price. Required when `orderType=LIMIT`. Must be > 0 | [optional] | +|**priceLimit** | **String** | Limit price. Required when `orderType=LIMIT`. Must be > 0. A price that is not on the price tick of the market (see `decimalPrecision` in Get Market Detail) is truncated down instead of being rejected, unless the result is 0 | [optional] | |**chainId** | **String** | Chain ID. Default `56` (BSC) | [optional] | |**feeRateBps** | **Integer** | Fee rate in basis points. Default `200`, range 1–10000 | [optional] | |**fundingSource** | **FundingSource** | | [optional] | diff --git a/clients/w3w-prediction/docs/LimitOrderFullyFilledResponse.md b/clients/w3w-prediction/docs/LimitOrderFullyFilledResponse.md new file mode 100644 index 000000000..dcf47ec15 --- /dev/null +++ b/clients/w3w-prediction/docs/LimitOrderFullyFilledResponse.md @@ -0,0 +1,15 @@ + + +# LimitOrderFullyFilledResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | Filled amount in USDT — paid for a buy, received after fees for a sell. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/LimitOrderPartiallyFilledResponse.md b/clients/w3w-prediction/docs/LimitOrderPartiallyFilledResponse.md new file mode 100644 index 000000000..0dbe7b7d8 --- /dev/null +++ b/clients/w3w-prediction/docs/LimitOrderPartiallyFilledResponse.md @@ -0,0 +1,15 @@ + + +# LimitOrderPartiallyFilledResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | **Total** filled so far in USDT, not just this fill — paid for a buy, received after fees for a sell. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/LimitOrderSubmissionFailedResponse.md b/clients/w3w-prediction/docs/LimitOrderSubmissionFailedResponse.md new file mode 100644 index 000000000..65e9f10bc --- /dev/null +++ b/clients/w3w-prediction/docs/LimitOrderSubmissionFailedResponse.md @@ -0,0 +1,14 @@ + + +# LimitOrderSubmissionFailedResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/LimitOrderSubmittedSuccessfullyResponse.md b/clients/w3w-prediction/docs/LimitOrderSubmittedSuccessfullyResponse.md new file mode 100644 index 000000000..85f3cb853 --- /dev/null +++ b/clients/w3w-prediction/docs/LimitOrderSubmittedSuccessfullyResponse.md @@ -0,0 +1,15 @@ + + +# LimitOrderSubmittedSuccessfullyResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | Total order amount in USDT, before fees. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/MarketBuyOrderFailedResponse.md b/clients/w3w-prediction/docs/MarketBuyOrderFailedResponse.md new file mode 100644 index 000000000..0adc681cb --- /dev/null +++ b/clients/w3w-prediction/docs/MarketBuyOrderFailedResponse.md @@ -0,0 +1,15 @@ + + +# MarketBuyOrderFailedResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | Original order amount in USDT — **not** actually charged. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/MarketBuyOrderFullyFilledResponse.md b/clients/w3w-prediction/docs/MarketBuyOrderFullyFilledResponse.md new file mode 100644 index 000000000..51a8bebb5 --- /dev/null +++ b/clients/w3w-prediction/docs/MarketBuyOrderFullyFilledResponse.md @@ -0,0 +1,15 @@ + + +# MarketBuyOrderFullyFilledResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | USDT the user paid. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/MarketDataApi.md b/clients/w3w-prediction/docs/MarketDataApi.md index 6f120a7fd..d1b3439f3 100644 --- a/clients/w3w-prediction/docs/MarketDataApi.md +++ b/clients/w3w-prediction/docs/MarketDataApi.md @@ -18,7 +18,7 @@ All URIs are relative to *https://api.binance.com* Get Market Detail -Get full details for a specific prediction market topic, including variant data and timeline. Weight(IP): 1 +Get full details for a specific prediction market topic, including variant data and timeline. Weight(IP): 1 Response Notes: - `status` is a case-sensitive string. `REGISTERED`: registered and not yet resolved, this value alone does not guarantee that trading is available. `RESOLVED`: the outcome has been determined, it does not mean that the user has already claimed the payout. `PAUSED`: trading is temporarily suspended and may resume. `CLOSED`: closed for display, for example the end time has passed or the market was removed, it does not guarantee that trading is closed. - `markets[].tradingStatus` shows whether new orders may be attempted. `OPEN`: new orders may be attempted, this is the only value that allows new orders. `MATCHING_NOT_ENABLED`: order matching is not enabled. `CANCEL_ONLY`: only cancellation is allowed. `CLOSED`: trading has stopped. Use `markets[].tradingStatus`, not `status`, to decide whether to place an order, because a market whose `status` is `CLOSED` can still have `tradingStatus` `OPEN`. A topic can contain several markets and an order is placed on one market, so only the `tradingStatus` of that market matters. A successful quote does not guarantee that an order is accepted or filled. - `outcomes[].winner` is returned only after the market is resolved. There is no separate cancelled, invalid or refunded status. A resolved market can pay more than one outcome, in that case several outcomes have `winner` set to `true` and `price` is the settled value per share, for example `0.5` for each of two outcomes. ### Example ```java @@ -138,7 +138,7 @@ No authorization required List Prediction Markets -Get a paginated list of prediction market topics, with optional category and sort filters. Weight(IP): 1 +Get a paginated list of prediction market topics, with optional category and sort filters. Weight(IP): 1 Response Notes: - For the values of `status` and `markets[].tradingStatus`, see Get Market Detail. ### Example ```java diff --git a/clients/w3w-prediction/docs/MarketResolutionNotificationResponse.md b/clients/w3w-prediction/docs/MarketResolutionNotificationResponse.md new file mode 100644 index 000000000..0a6000967 --- /dev/null +++ b/clients/w3w-prediction/docs/MarketResolutionNotificationResponse.md @@ -0,0 +1,14 @@ + + +# MarketResolutionNotificationResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/MarketSellOrderFailedExpiredResponse.md b/clients/w3w-prediction/docs/MarketSellOrderFailedExpiredResponse.md new file mode 100644 index 000000000..dcc0e561f --- /dev/null +++ b/clients/w3w-prediction/docs/MarketSellOrderFailedExpiredResponse.md @@ -0,0 +1,15 @@ + + +# MarketSellOrderFailedExpiredResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | USDT the user would have received after fees — **not** credited. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/MarketSellOrderFullyFilledResponse.md b/clients/w3w-prediction/docs/MarketSellOrderFullyFilledResponse.md new file mode 100644 index 000000000..3760f58ea --- /dev/null +++ b/clients/w3w-prediction/docs/MarketSellOrderFullyFilledResponse.md @@ -0,0 +1,15 @@ + + +# MarketSellOrderFullyFilledResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | USDT the user received, **after fees**. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | +|**topic** | **String** | Market title, cut to 12 characters with `..` added when longer; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/PositionApi.md b/clients/w3w-prediction/docs/PositionApi.md index b27944c0f..1c5235ef5 100644 --- a/clients/w3w-prediction/docs/PositionApi.md +++ b/clients/w3w-prediction/docs/PositionApi.md @@ -291,7 +291,7 @@ No authorization required Query Settled Position History (PREDICTION_TRADE) -Get the authenticated user's settled (resolved) prediction position history with optional filters. Weight(IP): 1 Security Type: PREDICTION_TRADE +Get the authenticated user's settled (resolved) prediction position history with optional filters. Weight(IP): 1 Security Type: PREDICTION_TRADE Response Notes: - There is no separate cancelled, invalid or refunded status. A resolved market pays each outcome by its payout ratio, which can be fractional, for example `0.5` for each of two outcomes. This is not a refund of the purchase cost. Use `finalOutcome`, `isWinner`, `claimAmount` and `redeemStatus` together with your own claim records, and Get Market Detail for `outcomes[].winner`. ### Example ```java diff --git a/clients/w3w-prediction/docs/PredictionOrderBookByMarketIdRequest.md b/clients/w3w-prediction/docs/PredictionOrderBookByMarketIdRequest.md new file mode 100644 index 000000000..2e7197579 --- /dev/null +++ b/clients/w3w-prediction/docs/PredictionOrderBookByMarketIdRequest.md @@ -0,0 +1,13 @@ + + +# PredictionOrderBookByMarketIdRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**marketId** | **String** | Market ID to subscribe to — the `marketId` inside `markets[]` returned by `market/list` or `market/detail`. It is **not** `marketTopicId` and **not** `externalId`. A wrong id is never rejected: subscribing with `marketTopicId`, `externalId`, or with a closed or resolved market returns the same successful `COMMAND` reply as a correct id and then pushes nothing at all, so a stream that stays silent is far more likely a wrong id than a broken connection. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/PredictionOrderBookByMarketIdResponse.md b/clients/w3w-prediction/docs/PredictionOrderBookByMarketIdResponse.md new file mode 100644 index 000000000..8eb063ecb --- /dev/null +++ b/clients/w3w-prediction/docs/PredictionOrderBookByMarketIdResponse.md @@ -0,0 +1,17 @@ + + +# PredictionOrderBookByMarketIdResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**msgType** | **String** | Message type, always `orderbook`. | [optional] | +|**marketId** | **Long** | Market ID of this order book, the same `markets[].marketId` used by the REST API. | [optional] | +|**updateTimestampMs** | **Long** | Quote update time in milliseconds (UTC). Messages for the same market may arrive out of order, so discard anything older than the snapshot you already have. | [optional] | +|**asks** | **List<List<BigDecimal>>** | Ask levels sorted by price **ascending**, usually the top 50 or fewer; an empty array means no asks. Values may carry floating-point noise (e.g. `6865.999999999999`), so round them before display. | [optional] | +|**bids** | **List<List<BigDecimal>>** | Bid levels sorted by price **descending**, usually the top 50 or fewer; an empty array means no bids. Values may carry floating-point noise (e.g. `6865.999999999999`), so round them before display. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/RewardClaimFailedResponse.md b/clients/w3w-prediction/docs/RewardClaimFailedResponse.md new file mode 100644 index 000000000..3aa4da36e --- /dev/null +++ b/clients/w3w-prediction/docs/RewardClaimFailedResponse.md @@ -0,0 +1,15 @@ + + +# RewardClaimFailedResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | Amount of the **first failed claim**. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | +|**outcome** | **String** | Outcome name of the **first failed claim**, such as `Yes` or `No`; empty if unavailable. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/RewardClaimSucceededResponse.md b/clients/w3w-prediction/docs/RewardClaimSucceededResponse.md new file mode 100644 index 000000000..0a3617d52 --- /dev/null +++ b/clients/w3w-prediction/docs/RewardClaimSucceededResponse.md @@ -0,0 +1,14 @@ + + +# RewardClaimSucceededResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pushId** | **String** | Unique ID of this push. Use it to remove duplicates. | [optional] | +|**amount** | **String** | Total USDT claimed. Rounded down to 2 decimals; shown as `<0.01` if smaller. | [optional] | + + + diff --git a/clients/w3w-prediction/docs/TradeApi.md b/clients/w3w-prediction/docs/TradeApi.md index 37ce30a82..9dcc12a23 100644 --- a/clients/w3w-prediction/docs/TradeApi.md +++ b/clients/w3w-prediction/docs/TradeApi.md @@ -79,7 +79,7 @@ No authorization required Get Quote (PREDICTION_TRADE) -Get a price quote for a prediction order. The returned `quoteId` must be used in the subsequent Place Order request. Weight(IP): 1 Security Type: PREDICTION_TRADE Response Notes: - `feeAmount` is a string because it is denominated in wei (18 decimals) and may exceed JavaScript's safe integer range. `feeDiscountBps` is also a string to allow fractional basis-point values in the future. `feeRateBps` and `slippageBps` are integers and will never exceed safe integer bounds. - **MARKET order minimum amount:** For `MARKET` orders, `amountIn` must be at least approximately **1.5 USDT** (in wei: `1500000000000000000`). The exact minimum varies by market liquidity. If the amount is too small, the server returns `-9000 Your order amount is too small`. This limit does **not** apply to `LIMIT` orders. +Get a price quote for a prediction order. The returned `quoteId` must be used in the subsequent Place Order request. Weight(IP): 1 Security Type: PREDICTION_TRADE Response Notes: - `feeAmount` is a string because it is denominated in wei (18 decimals) and may exceed JavaScript's safe integer range. `feeDiscountBps` is also a string to allow fractional basis-point values in the future. `feeRateBps` and `slippageBps` are integers and will never exceed safe integer bounds. - **Minimum order amount:** The minimum order amount is set by the server and the upstream market rules and may change, so no fixed value is documented. `BUY` orders are checked by amount (`amountIn`) and `SELL` orders by share quantity, for both `MARKET` and `LIMIT` orders. If the `amountIn` of a `BUY` order is below the minimum, the server returns `-9000` with the message `Your order amount is too small`. A successful quote does not guarantee that the order is accepted or filled, so check the error message and the final order status. ### Example ```java diff --git a/clients/w3w-prediction/example_rest.md b/clients/w3w-prediction/example_rest.md index 1ee7ef700..26bcf7984 100644 --- a/clients/w3w-prediction/example_rest.md +++ b/clients/w3w-prediction/example_rest.md @@ -1,10 +1,10 @@ ## MarketData -[GET /sapi/v1/w3w/wallet/prediction/market/detail](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#get-market-detail) - getMarketDetail - [GetMarketDetailExample.java:37](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/GetMarketDetailExample.java#L37) +[GET /sapi/v1/w3w/wallet/prediction/market/detail](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#get-market-detail) - getMarketDetail - [GetMarketDetailExample.java:56](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/GetMarketDetailExample.java#L56) [GET /sapi/v1/w3w/wallet/prediction/category/list](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#list-prediction-categories) - listPredictionCategories - [ListPredictionCategoriesExample.java:36](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/ListPredictionCategoriesExample.java#L36) -[GET /sapi/v1/w3w/wallet/prediction/market/list](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#list-prediction-markets) - listPredictionMarkets - [ListPredictionMarketsExample.java:39](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/ListPredictionMarketsExample.java#L39) +[GET /sapi/v1/w3w/wallet/prediction/market/list](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#list-prediction-markets) - listPredictionMarkets - [ListPredictionMarketsExample.java:40](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/ListPredictionMarketsExample.java#L40) [GET /sapi/v1/w3w/wallet/prediction/market/search](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/market-data#market-search) - marketSearch - [MarketSearchExample.java:36](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/MarketSearchExample.java#L36) @@ -40,7 +40,7 @@ [GET /sapi/v1/w3w/wallet/prediction/position/filter](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/position#query-positions-by-filter) - queryPositionsByFilter - [QueryPositionsByFilterExample.java:37](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/position/QueryPositionsByFilterExample.java#L37) -[GET /sapi/v1/w3w/wallet/prediction/position/settled-history](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/position#query-settled-position-history) - querySettledPositionHistory - [QuerySettledPositionHistoryExample.java:37](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/position/QuerySettledPositionHistoryExample.java#L37) +[GET /sapi/v1/w3w/wallet/prediction/position/settled-history](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/position#query-settled-position-history) - querySettledPositionHistory - [QuerySettledPositionHistoryExample.java:42](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/position/QuerySettledPositionHistoryExample.java#L42) ## Redeem @@ -52,7 +52,7 @@ [POST /sapi/v1/w3w/wallet/prediction/trade/batch-cancel](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#batch-cancel-orders) - batchCancelOrders - [BatchCancelOrdersExample.java:53](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/trade/BatchCancelOrdersExample.java#L53) -[POST /sapi/v1/w3w/wallet/prediction/trade/get-quote](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#get-quote) - getQuote - [GetQuoteExample.java:48](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/trade/GetQuoteExample.java#L48) +[POST /sapi/v1/w3w/wallet/prediction/trade/get-quote](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#get-quote) - getQuote - [GetQuoteExample.java:51](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/trade/GetQuoteExample.java#L51) [POST /sapi/v1/w3w/wallet/prediction/trade/place-order-bundle](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/rest-api/trade#place-order) - placeOrder - [PlaceOrderExample.java:43](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/trade/PlaceOrderExample.java#L43) diff --git a/clients/w3w-prediction/example_websocket_stream.md b/clients/w3w-prediction/example_websocket_stream.md new file mode 100644 index 000000000..a87bb2a82 --- /dev/null +++ b/clients/w3w-prediction/example_websocket_stream.md @@ -0,0 +1,32 @@ +## Default + +[web3_prediction_pm_claim_partial_success](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#batch-claim-partially-succeeded) - batchClaimPartiallySucceeded - [BatchClaimPartiallySucceededExample.java:36](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/BatchClaimPartiallySucceededExample.java#L36) + +[web3_prediction_pm_transfer_fail](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#fund-transfer-failed) - fundTransferFailed - [FundTransferFailedExample.java:35](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferFailedExample.java#L35) + +[web3_prediction_pm_transfer_success](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#fund-transfer-succeeded) - fundTransferSucceeded - [FundTransferSucceededExample.java:36](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferSucceededExample.java#L36) + +[web3_prediction_pm_limit_order_filled](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#limit-order-fully-filled) - limitOrderFullyFilled - [LimitOrderFullyFilledExample.java:35](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderFullyFilledExample.java#L35) + +[web3_prediction_pm_limit_order_partial_fill](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#limit-order-partially-filled) - limitOrderPartiallyFilled - [LimitOrderPartiallyFilledExample.java:36](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderPartiallyFilledExample.java#L36) + +[web3_prediction_pm_limit_submit_fail](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#limit-order-submission-failed) - limitOrderSubmissionFailed - [LimitOrderSubmissionFailedExample.java:36](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmissionFailedExample.java#L36) + +[web3_prediction_pm_limit_submit_success](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#limit-order-submitted-successfully) - limitOrderSubmittedSuccessfully - [LimitOrderSubmittedSuccessfullyExample.java:36](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmittedSuccessfullyExample.java#L36) + +[web3_prediction_pm_market_buy_fail](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#market-buy-order-failed) - marketBuyOrderFailed - [MarketBuyOrderFailedExample.java:35](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFailedExample.java#L35) + +[web3_prediction_pm_market_buy_success](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#market-buy-order-fully-filled) - marketBuyOrderFullyFilled - [MarketBuyOrderFullyFilledExample.java:35](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFullyFilledExample.java#L35) + +[web3_prediction_pm_market_close](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#market-resolution-notification) - marketResolutionNotification - [MarketResolutionNotificationExample.java:37](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketResolutionNotificationExample.java#L37) + +[web3_prediction_pm_market_sell_fail](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#market-sell-order-failed-expired) - marketSellOrderFailedExpired - [MarketSellOrderFailedExpiredExample.java:35](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFailedExpiredExample.java#L35) + +[web3_prediction_pm_market_sell_success](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#market-sell-order-fully-filled) - marketSellOrderFullyFilled - [MarketSellOrderFullyFilledExample.java:35](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFullyFilledExample.java#L35) + +[web3_prediction_orderbook_](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#prediction-order-book-by-market-id) - predictionOrderBookByMarketId - [PredictionOrderBookByMarketIdExample.java:37](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/PredictionOrderBookByMarketIdExample.java#L37) + +[web3_prediction_pm_claim_fail](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#reward-claim-failed) - rewardClaimFailed - [RewardClaimFailedExample.java:37](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimFailedExample.java#L37) + +[web3_prediction_pm_claim_success](https://developers.binance.com/en/docs/catalog/web3-wallet-prediction-trading/api/ws-streams/~#reward-claim-succeeded) - rewardClaimSucceeded - [RewardClaimSucceededExample.java:36](/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimSucceededExample.java#L36) + diff --git a/clients/w3w-prediction/pom.xml b/clients/w3w-prediction/pom.xml index 3f332723b..0530ba7a9 100644 --- a/clients/w3w-prediction/pom.xml +++ b/clients/w3w-prediction/pom.xml @@ -5,7 +5,7 @@ 4.0.0 binance-w3w-prediction w3w-prediction - 2.1.2 + 2.2.0 jar @@ -31,7 +31,7 @@ io.github.binance binance-common - 2.5.3 + 2.6.0 \ No newline at end of file diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/MarketDataApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/MarketDataApi.java index 436904aff..e2fc05328 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/MarketDataApi.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/MarketDataApi.java @@ -49,7 +49,7 @@ public class MarketDataApi { private static final String USER_AGENT = String.format( - "binance-w3w-prediction/2.1.2 (Java/%s; %s; %s)", + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; @@ -195,7 +195,26 @@ private okhttp3.Call getMarketDetailValidateBeforeCall(Long marketTopicId) throw /** * Get Market Detail Get full details for a specific prediction market topic, including variant - * data and timeline. Weight(IP): 1 + * data and timeline. Weight(IP): 1 Response Notes: - `status` is a case-sensitive + * string. `REGISTERED`: registered and not yet resolved, this value alone does not + * guarantee that trading is available. `RESOLVED`: the outcome has been determined, + * it does not mean that the user has already claimed the payout. `PAUSED`: trading is + * temporarily suspended and may resume. `CLOSED`: closed for display, for example the + * end time has passed or the market was removed, it does not guarantee that trading is closed. + * - `markets[].tradingStatus` shows whether new orders may be attempted. + * `OPEN`: new orders may be attempted, this is the only value that allows new orders. + * `MATCHING_NOT_ENABLED`: order matching is not enabled. `CANCEL_ONLY`: + * only cancellation is allowed. `CLOSED`: trading has stopped. Use + * `markets[].tradingStatus`, not `status`, to decide whether to place an + * order, because a market whose `status` is `CLOSED` can still have + * `tradingStatus` `OPEN`. A topic can contain several markets and an order + * is placed on one market, so only the `tradingStatus` of that market matters. A + * successful quote does not guarantee that an order is accepted or filled. - + * `outcomes[].winner` is returned only after the market is resolved. There is no + * separate cancelled, invalid or refunded status. A resolved market can pay more than one + * outcome, in that case several outcomes have `winner` set to `true` and + * `price` is the settled value per share, for example `0.5` for each of two + * outcomes. * * @param marketTopicId Market topic ID. Must be > 0 (required) * @return ApiResponse<GetMarketDetailResponse> @@ -505,7 +524,8 @@ private okhttp3.Call listPredictionMarketsValidateBeforeCall( /** * List Prediction Markets Get a paginated list of prediction market topics, with optional - * category and sort filters. Weight(IP): 1 + * category and sort filters. Weight(IP): 1 Response Notes: - For the values of + * `status` and `markets[].tradingStatus`, see Get Market Detail. * * @param l1Category Level-1 category filter (optional) * @param l2Category Level-2 category filter (optional) diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/OtcApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/OtcApi.java index d6b47b0b4..dc95b5b08 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/OtcApi.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/OtcApi.java @@ -59,7 +59,7 @@ public class OtcApi { private static final String USER_AGENT = String.format( - "binance-w3w-prediction/2.1.2 (Java/%s; %s; %s)", + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/PositionApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/PositionApi.java index fe8553c10..deff1d0c5 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/PositionApi.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/PositionApi.java @@ -46,7 +46,7 @@ public class PositionApi { private static final String USER_AGENT = String.format( - "binance-w3w-prediction/2.1.2 (Java/%s; %s; %s)", + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; @@ -956,7 +956,12 @@ private okhttp3.Call querySettledPositionHistoryValidateBeforeCall( /** * Query Settled Position History (PREDICTION_TRADE) Get the authenticated user's settled * (resolved) prediction position history with optional filters. Weight(IP): 1 Security Type: - * PREDICTION_TRADE + * PREDICTION_TRADE Response Notes: - There is no separate cancelled, invalid or refunded + * status. A resolved market pays each outcome by its payout ratio, which can be fractional, for + * example `0.5` for each of two outcomes. This is not a refund of the purchase cost. + * Use `finalOutcome`, `isWinner`, `claimAmount` and + * `redeemStatus` together with your own claim records, and Get Market Detail for + * `outcomes[].winner`. * * @param walletAddress User's prediction wallet address (required) * @param l1Category Filter by level-1 category (optional) diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/RedeemApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/RedeemApi.java index 7b987b564..ba1696047 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/RedeemApi.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/RedeemApi.java @@ -46,7 +46,7 @@ public class RedeemApi { private static final String USER_AGENT = String.format( - "binance-w3w-prediction/2.1.2 (Java/%s; %s; %s)", + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/TradeApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/TradeApi.java index bf2d46eb6..54d216c87 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/TradeApi.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/TradeApi.java @@ -53,7 +53,7 @@ public class TradeApi { private static final String USER_AGENT = String.format( - "binance-w3w-prediction/2.1.2 (Java/%s; %s; %s)", + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; @@ -405,11 +405,14 @@ private okhttp3.Call getQuoteValidateBeforeCall(GetQuoteRequest getQuoteRequest) * it is denominated in wei (18 decimals) and may exceed JavaScript's safe integer range. * `feeDiscountBps` is also a string to allow fractional basis-point values in the * future. `feeRateBps` and `slippageBps` are integers and will never exceed - * safe integer bounds. - **MARKET order minimum amount:** For `MARKET` orders, - * `amountIn` must be at least approximately **1.5 USDT** (in wei: - * `1500000000000000000`). The exact minimum varies by market liquidity. If the amount - * is too small, the server returns `-9000 Your order amount is too small`. This limit - * does **not** apply to `LIMIT` orders. + * safe integer bounds. - **Minimum order amount:** The minimum order amount is set by the + * server and the upstream market rules and may change, so no fixed value is documented. + * `BUY` orders are checked by amount (`amountIn`) and `SELL` + * orders by share quantity, for both `MARKET` and `LIMIT` orders. If the + * `amountIn` of a `BUY` order is below the minimum, the server returns + * `-9000` with the message `Your order amount is too small`. A successful + * quote does not guarantee that the order is accepted or filled, so check the error message and + * the final order status. * * @param getQuoteRequest (required) * @return ApiResponse<GetQuoteResponse> diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/TransferApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/TransferApi.java index 1481b389f..ecf6bb332 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/TransferApi.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/TransferApi.java @@ -53,7 +53,7 @@ public class TransferApi { private static final String USER_AGENT = String.format( - "binance-w3w-prediction/2.1.2 (Java/%s; %s; %s)", + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/W3WPredictionRestApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/W3WPredictionRestApi.java index 543937de9..3a29ac1cd 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/W3WPredictionRestApi.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/W3WPredictionRestApi.java @@ -89,7 +89,26 @@ public W3WPredictionRestApi(ApiClient apiClient) { /** * Get Market Detail Get full details for a specific prediction market topic, including variant - * data and timeline. Weight(IP): 1 + * data and timeline. Weight(IP): 1 Response Notes: - `status` is a case-sensitive + * string. `REGISTERED`: registered and not yet resolved, this value alone does not + * guarantee that trading is available. `RESOLVED`: the outcome has been determined, + * it does not mean that the user has already claimed the payout. `PAUSED`: trading is + * temporarily suspended and may resume. `CLOSED`: closed for display, for example the + * end time has passed or the market was removed, it does not guarantee that trading is closed. + * - `markets[].tradingStatus` shows whether new orders may be attempted. + * `OPEN`: new orders may be attempted, this is the only value that allows new orders. + * `MATCHING_NOT_ENABLED`: order matching is not enabled. `CANCEL_ONLY`: + * only cancellation is allowed. `CLOSED`: trading has stopped. Use + * `markets[].tradingStatus`, not `status`, to decide whether to place an + * order, because a market whose `status` is `CLOSED` can still have + * `tradingStatus` `OPEN`. A topic can contain several markets and an order + * is placed on one market, so only the `tradingStatus` of that market matters. A + * successful quote does not guarantee that an order is accepted or filled. - + * `outcomes[].winner` is returned only after the market is resolved. There is no + * separate cancelled, invalid or refunded status. A resolved market can pay more than one + * outcome, in that case several outcomes have `winner` set to `true` and + * `price` is the settled value per share, for example `0.5` for each of two + * outcomes. * * @param marketTopicId Market topic ID. Must be > 0 (required) * @return ApiResponse<GetMarketDetailResponse> @@ -136,7 +155,8 @@ public ApiResponse listPredictionCategories() /** * List Prediction Markets Get a paginated list of prediction market topics, with optional - * category and sort filters. Weight(IP): 1 + * category and sort filters. Weight(IP): 1 Response Notes: - For the values of + * `status` and `markets[].tradingStatus`, see Get Market Detail. * * @param l1Category Level-1 category filter (optional) * @param l2Category Level-2 category filter (optional) @@ -603,7 +623,12 @@ public ApiResponse queryPositionsByFilter( /** * Query Settled Position History (PREDICTION_TRADE) Get the authenticated user's settled * (resolved) prediction position history with optional filters. Weight(IP): 1 Security Type: - * PREDICTION_TRADE + * PREDICTION_TRADE Response Notes: - There is no separate cancelled, invalid or refunded + * status. A resolved market pays each outcome by its payout ratio, which can be fractional, for + * example `0.5` for each of two outcomes. This is not a refund of the purchase cost. + * Use `finalOutcome`, `isWinner`, `claimAmount` and + * `redeemStatus` together with your own claim records, and Get Market Detail for + * `outcomes[].winner`. * * @param walletAddress User's prediction wallet address (required) * @param l1Category Filter by level-1 category (optional) @@ -745,11 +770,14 @@ public ApiResponse batchCancelOrders( * it is denominated in wei (18 decimals) and may exceed JavaScript's safe integer range. * `feeDiscountBps` is also a string to allow fractional basis-point values in the * future. `feeRateBps` and `slippageBps` are integers and will never exceed - * safe integer bounds. - **MARKET order minimum amount:** For `MARKET` orders, - * `amountIn` must be at least approximately **1.5 USDT** (in wei: - * `1500000000000000000`). The exact minimum varies by market liquidity. If the amount - * is too small, the server returns `-9000 Your order amount is too small`. This limit - * does **not** apply to `LIMIT` orders. + * safe integer bounds. - **Minimum order amount:** The minimum order amount is set by the + * server and the upstream market rules and may change, so no fixed value is documented. + * `BUY` orders are checked by amount (`amountIn`) and `SELL` + * orders by share quantity, for both `MARKET` and `LIMIT` orders. If the + * `amountIn` of a `BUY` order is below the minimum, the server returns + * `-9000` with the message `Your order amount is too small`. A successful + * quote does not guarantee that the order is accepted or filled, so check the error message and + * the final order status. * * @param getQuoteRequest (required) * @return ApiResponse<GetQuoteResponse> diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/WalletApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/WalletApi.java index 554f74cde..1cca0da4e 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/WalletApi.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/api/WalletApi.java @@ -45,7 +45,7 @@ public class WalletApi { private static final String USER_AGENT = String.format( - "binance-w3w-prediction/2.1.2 (Java/%s; %s; %s)", + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetMarketDetailResponseMarketsInner.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetMarketDetailResponseMarketsInner.java index 38dddc7fe..3e67851c7 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetMarketDetailResponseMarketsInner.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetMarketDetailResponseMarketsInner.java @@ -321,7 +321,9 @@ public GetMarketDetailResponseMarketsInner decimalPrecision( } /** - * Get decimalPrecision + * Price precision of the market, in decimal places. The price tick is 10 to the power of minus + * `decimalPrecision`, for example `2` means a tick of 0.01. A limit price + * that is not on the tick is truncated down * * @return decimalPrecision */ diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetMarketDetailResponseMarketsInnerOutcomesInner.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetMarketDetailResponseMarketsInnerOutcomesInner.java index 33cfef681..d7ad6955a 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetMarketDetailResponseMarketsInnerOutcomesInner.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetMarketDetailResponseMarketsInnerOutcomesInner.java @@ -66,6 +66,12 @@ public class GetMarketDetailResponseMarketsInnerOutcomesInner { @jakarta.annotation.Nullable private String tokenId; + public static final String SERIALIZED_NAME_WINNER = "winner"; + + @SerializedName(SERIALIZED_NAME_WINNER) + @jakarta.annotation.Nullable + private Boolean winner; + public GetMarketDetailResponseMarketsInnerOutcomesInner() {} public GetMarketDetailResponseMarketsInnerOutcomesInner name( @@ -168,6 +174,27 @@ public void setTokenId(@jakarta.annotation.Nullable String tokenId) { this.tokenId = tokenId; } + public GetMarketDetailResponseMarketsInnerOutcomesInner winner( + @jakarta.annotation.Nullable Boolean winner) { + this.winner = winner; + return this; + } + + /** + * Whether this outcome won. Returned only after the market is resolved. More than one outcome + * can be `true` when the payout is split + * + * @return winner + */ + @jakarta.annotation.Nullable + public Boolean getWinner() { + return winner; + } + + public void setWinner(@jakarta.annotation.Nullable Boolean winner) { + this.winner = winner; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -187,12 +214,14 @@ public boolean equals(Object o) { && Objects.equals( this.index, getMarketDetailResponseMarketsInnerOutcomesInner.index) && Objects.equals( - this.tokenId, getMarketDetailResponseMarketsInnerOutcomesInner.tokenId); + this.tokenId, getMarketDetailResponseMarketsInnerOutcomesInner.tokenId) + && Objects.equals( + this.winner, getMarketDetailResponseMarketsInnerOutcomesInner.winner); } @Override public int hashCode() { - return Objects.hash(name, price, chance, index, tokenId); + return Objects.hash(name, price, chance, index, tokenId, winner); } @Override @@ -204,6 +233,7 @@ public String toString() { sb.append(" chance: ").append(toIndentedString(chance)).append("\n"); sb.append(" index: ").append(toIndentedString(index)).append("\n"); sb.append(" tokenId: ").append(toIndentedString(tokenId)).append("\n"); + sb.append(" winner: ").append(toIndentedString(winner)).append("\n"); sb.append("}"); return sb.toString(); } @@ -231,6 +261,10 @@ public String toUrlQueryString() { String tokenIdValueAsString = ""; tokenIdValueAsString = tokenIdValue.toString(); sb.append("tokenId=").append(urlEncode(tokenIdValueAsString)).append(""); + Object winnerValue = getWinner(); + String winnerValueAsString = ""; + winnerValueAsString = winnerValue.toString(); + sb.append("winner=").append(urlEncode(winnerValueAsString)).append(""); return sb.toString(); } @@ -264,6 +298,7 @@ private String toIndentedString(Object o) { openapiFields.add("chance"); openapiFields.add("index"); openapiFields.add("tokenId"); + openapiFields.add("winner"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetQuoteRequest.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetQuoteRequest.java index 9c60f7bab..a791d9306 100644 --- a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetQuoteRequest.java +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/model/GetQuoteRequest.java @@ -172,9 +172,8 @@ public GetQuoteRequest amountIn(@jakarta.annotation.Nonnull String amountIn) { } /** - * Input amount in wei (18 decimals). Must be > 0. For `MARKET` orders, minimum is - * approximately 1.5 USDT (varies by market depth). Example: `1000000000000000000` - * = 1 USDT + * Input amount in wei (18 decimals). Must be > 0. The minimum is set by the server and may + * change, see the response notes. Example: `1000000000000000000` = 1 USDT * * @return amountIn */ @@ -237,7 +236,9 @@ public GetQuoteRequest priceLimit(@jakarta.annotation.Nullable String priceLimit } /** - * Limit price. Required when `orderType=LIMIT`. Must be > 0 + * Limit price. Required when `orderType=LIMIT`. Must be > 0. A price that is + * not on the price tick of the market (see `decimalPrecision` in Get Market Detail) + * is truncated down instead of being rejected, unless the result is 0 * * @return priceLimit */ diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/JSON.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/JSON.java new file mode 100644 index 000000000..fb9f73e62 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/JSON.java @@ -0,0 +1,458 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.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.w3w_prediction.websocket.stream.model + .BatchClaimPartiallySucceededResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .FundTransferFailedResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .FundTransferSucceededResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .LimitOrderFullyFilledResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .LimitOrderPartiallyFilledResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .LimitOrderSubmissionFailedResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .LimitOrderSubmittedSuccessfullyResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .MarketBuyOrderFailedResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .MarketBuyOrderFullyFilledResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .MarketResolutionNotificationResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .MarketSellOrderFailedExpiredResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .MarketSellOrderFullyFilledResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .PredictionOrderBookByMarketIdRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .PredictionOrderBookByMarketIdResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .RewardClaimFailedResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new com.binance.connector.client.w3w_prediction.websocket.stream.model + .RewardClaimSucceededResponse.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/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/W3WPredictionWebSocketStreamsUtil.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/W3WPredictionWebSocketStreamsUtil.java new file mode 100644 index 000000000..7f146a122 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/W3WPredictionWebSocketStreamsUtil.java @@ -0,0 +1,35 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream; + +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; + +public class W3WPredictionWebSocketStreamsUtil { + private static final String BASE_URL = "wss://api.binance.com/sapi/wss"; + private static final boolean HAS_TIME_UNIT = false; + + public static WebSocketClientConfiguration getClientConfiguration() { + return getClientConfiguration(""); + } + + public static WebSocketClientConfiguration getClientConfiguration(String path) { + WebSocketClientConfiguration clientConfiguration = new WebSocketClientConfiguration(); + if (!HAS_TIME_UNIT) { + clientConfiguration.setTimeUnit(null); + } + clientConfiguration.setAutoLogon(false); + return clientConfiguration; + } + + public static WebSocketClientConfiguration getClientConfiguration( + SignatureConfiguration signatureConfiguration) { + WebSocketClientConfiguration clientConfiguration = getClientConfiguration(); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + clientConfiguration.setUrl(getBaseUrl()); + clientConfiguration.setPingIntervalTime(30000L); + return clientConfiguration; + } + + public static String getBaseUrl() { + return BASE_URL; + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/DefaultApi.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/DefaultApi.java new file mode 100644 index 000000000..89cfaab02 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/DefaultApi.java @@ -0,0 +1,859 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.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.SignedStreamConnectionPoolWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.SignedStreamConnectionWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionInterface; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +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.w3w_prediction.websocket.stream.JSON; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.BatchClaimPartiallySucceededResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.FundTransferFailedResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.FundTransferSucceededResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderFullyFilledResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderPartiallyFilledResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderSubmissionFailedResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderSubmittedSuccessfullyResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketBuyOrderFailedResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketBuyOrderFullyFilledResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketResolutionNotificationResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketSellOrderFailedExpiredResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketSellOrderFullyFilledResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.PredictionOrderBookByMarketIdRequest; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.PredictionOrderBookByMarketIdResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.RewardClaimFailedResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.RewardClaimSucceededResponse; +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.Map; +import java.util.Set; +import java.util.UUID; +import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator; + +public class DefaultApi { + private static final String USER_AGENT = + String.format( + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", + SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); + + private StreamConnectionInterface connection; + + public DefaultApi() {} + + public DefaultApi(WebSocketClientConfiguration configuration) { + this( + configuration.getUsePool() + ? new SignedStreamConnectionPoolWrapper(configuration, JSON.getGson()) + : new SignedStreamConnectionWrapper(configuration, JSON.getGson())); + } + + public DefaultApi(StreamConnectionInterface connection) { + connection.setUserAgent(USER_AGENT); + if (!connection.isConnected()) { + connection.connect(); + } + this.connection = connection; + } + + public StreamConnectionInterface getConnection() { + return connection; + } + + /** + * Batch claim partially succeeded Pushed when only part of a batch claim succeeds. Only + * `pushId` is included — call the REST API for details. Update Speed: Real-time + * + * @return BatchClaimPartiallySucceededResponse + * @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 Prediction Stream response -
+ * + * @see Batch + * claim partially succeeded Documentation + */ + public StreamBlockingQueueWrapper + batchClaimPartiallySucceeded() throws ApiException { + StreamBlockingQueue queue = batchClaimPartiallySucceededRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue batchClaimPartiallySucceededRaw() throws ApiException { + batchClaimPartiallySucceededValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_claim_partial_success".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void batchClaimPartiallySucceededValidateBeforeCall() throws ApiException {} + + /** + * Fund transfer failed Pushed when a fund transfer fails. Update Speed: Real-time + * + * @return FundTransferFailedResponse + * @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 Prediction Stream response -
+ * + * @see Fund + * transfer failed Documentation + */ + public StreamBlockingQueueWrapper fundTransferFailed() + throws ApiException { + StreamBlockingQueue queue = fundTransferFailedRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue fundTransferFailedRaw() throws ApiException { + fundTransferFailedValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_transfer_fail".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void fundTransferFailedValidateBeforeCall() throws ApiException {} + + /** + * Fund transfer succeeded Pushed when a fund transfer into or out of the prediction wallet + * succeeds. The direction and the token are not included (currently USDT only). Update Speed: + * Real-time + * + * @return FundTransferSucceededResponse + * @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 Prediction Stream response -
+ * + * @see Fund + * transfer succeeded Documentation + */ + public StreamBlockingQueueWrapper fundTransferSucceeded() + throws ApiException { + StreamBlockingQueue queue = fundTransferSucceededRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue fundTransferSucceededRaw() throws ApiException { + fundTransferSucceededValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_transfer_success".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void fundTransferSucceededValidateBeforeCall() throws ApiException {} + + /** + * Limit order fully filled Pushed when a **limit order** is fully filled. Update Speed: + * Real-time + * + * @return LimitOrderFullyFilledResponse + * @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 Prediction Stream response -
+ * + * @see Limit + * order fully filled Documentation + */ + public StreamBlockingQueueWrapper limitOrderFullyFilled() + throws ApiException { + StreamBlockingQueue queue = limitOrderFullyFilledRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue limitOrderFullyFilledRaw() throws ApiException { + limitOrderFullyFilledValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_limit_order_filled".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void limitOrderFullyFilledValidateBeforeCall() throws ApiException {} + + /** + * Limit order partially filled Pushed on each new partial fill of a **limit order**. One order + * can be pushed several times, so always remove duplicates by `pushId`. Update Speed: + * Real-time + * + * @return LimitOrderPartiallyFilledResponse + * @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 Prediction Stream response -
+ * + * @see Limit + * order partially filled Documentation + */ + public StreamBlockingQueueWrapper limitOrderPartiallyFilled() + throws ApiException { + StreamBlockingQueue queue = limitOrderPartiallyFilledRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue limitOrderPartiallyFilledRaw() throws ApiException { + limitOrderPartiallyFilledValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_limit_order_partial_fill".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void limitOrderPartiallyFilledValidateBeforeCall() throws ApiException {} + + /** + * Limit order submission failed Pushed when a **limit order** is rejected when placed. No + * `amount` is included. Update Speed: Real-time + * + * @return LimitOrderSubmissionFailedResponse + * @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 Prediction Stream response -
+ * + * @see Limit + * order submission failed Documentation + */ + public StreamBlockingQueueWrapper + limitOrderSubmissionFailed() throws ApiException { + StreamBlockingQueue queue = limitOrderSubmissionFailedRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue limitOrderSubmissionFailedRaw() throws ApiException { + limitOrderSubmissionFailedValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_limit_submit_fail".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void limitOrderSubmissionFailedValidateBeforeCall() throws ApiException {} + + /** + * Limit order submitted successfully Pushed when the user's **limit order** is successfully + * placed on the order book. Update Speed: Real-time + * + * @return LimitOrderSubmittedSuccessfullyResponse + * @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 Prediction Stream response -
+ * + * @see Limit + * order submitted successfully Documentation + */ + public StreamBlockingQueueWrapper + limitOrderSubmittedSuccessfully() throws ApiException { + StreamBlockingQueue queue = limitOrderSubmittedSuccessfullyRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue limitOrderSubmittedSuccessfullyRaw() throws ApiException { + limitOrderSubmittedSuccessfullyValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_limit_submit_success".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void limitOrderSubmittedSuccessfullyValidateBeforeCall() throws ApiException {} + + /** + * Market buy order failed / expired Pushed when the user's **market buy order** fails or + * expires. Update Speed: Real-time + * + * @return MarketBuyOrderFailedResponse + * @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 Prediction Stream response -
+ * + * @see Market + * buy order failed / expired Documentation + */ + public StreamBlockingQueueWrapper marketBuyOrderFailed() + throws ApiException { + StreamBlockingQueue queue = marketBuyOrderFailedRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue marketBuyOrderFailedRaw() throws ApiException { + marketBuyOrderFailedValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_market_buy_fail".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void marketBuyOrderFailedValidateBeforeCall() throws ApiException {} + + /** + * Market buy order fully filled Pushed when the user's **market buy order** is fully + * filled. Update Speed: Real-time + * + * @return MarketBuyOrderFullyFilledResponse + * @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 Prediction Stream response -
+ * + * @see Market + * buy order fully filled Documentation + */ + public StreamBlockingQueueWrapper marketBuyOrderFullyFilled() + throws ApiException { + StreamBlockingQueue queue = marketBuyOrderFullyFilledRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue marketBuyOrderFullyFilledRaw() throws ApiException { + marketBuyOrderFullyFilledValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_market_buy_success".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void marketBuyOrderFullyFilledValidateBeforeCall() throws ApiException {} + + /** + * Market resolution notification Pushed when a market is resolved, to every user holding a + * position in it, win or lose. No amount or outcome is included — call the REST API for the + * user's profit and loss. Update Speed: Real-time + * + * @return MarketResolutionNotificationResponse + * @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 Prediction Stream response -
+ * + * @see Market + * resolution notification Documentation + */ + public StreamBlockingQueueWrapper + marketResolutionNotification() throws ApiException { + StreamBlockingQueue queue = marketResolutionNotificationRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue marketResolutionNotificationRaw() throws ApiException { + marketResolutionNotificationValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_market_close".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void marketResolutionNotificationValidateBeforeCall() throws ApiException {} + + /** + * Market sell order failed / expired Pushed when the user's **market sell order** fails or + * expires. Update Speed: Real-time + * + * @return MarketSellOrderFailedExpiredResponse + * @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 Prediction Stream response -
+ * + * @see Market + * sell order failed / expired Documentation + */ + public StreamBlockingQueueWrapper + marketSellOrderFailedExpired() throws ApiException { + StreamBlockingQueue queue = marketSellOrderFailedExpiredRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue marketSellOrderFailedExpiredRaw() throws ApiException { + marketSellOrderFailedExpiredValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_market_sell_fail".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void marketSellOrderFailedExpiredValidateBeforeCall() throws ApiException {} + + /** + * Market sell order fully filled Pushed when the user's **market sell order** is fully + * filled. Update Speed: Real-time + * + * @return MarketSellOrderFullyFilledResponse + * @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 Prediction Stream response -
+ * + * @see Market + * sell order fully filled Documentation + */ + public StreamBlockingQueueWrapper + marketSellOrderFullyFilled() throws ApiException { + StreamBlockingQueue queue = marketSellOrderFullyFilledRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue marketSellOrderFullyFilledRaw() throws ApiException { + marketSellOrderFullyFilledValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_market_sell_success".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void marketSellOrderFullyFilledValidateBeforeCall() throws ApiException {} + + /** + * Prediction Order Book by marketId Order book (bid/ask) updates for one market. Only active + * markets are pushed. Update Speed: Real-time + * + * @param predictionOrderBookByMarketIdRequest (required) + * @return PredictionOrderBookByMarketIdResponse + * @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 Prediction Stream response -
+ * + * @see Prediction + * Order Book by marketId Documentation + */ + public StreamBlockingQueueWrapper + predictionOrderBookByMarketId( + PredictionOrderBookByMarketIdRequest predictionOrderBookByMarketIdRequest) + throws ApiException { + StreamBlockingQueue queue = + predictionOrderBookByMarketIdRaw(predictionOrderBookByMarketIdRequest); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue predictionOrderBookByMarketIdRaw( + PredictionOrderBookByMarketIdRequest predictionOrderBookByMarketIdRequest) + throws ApiException { + predictionOrderBookByMarketIdValidateBeforeCall(predictionOrderBookByMarketIdRequest); + + String methodName = + "/web3_prediction_orderbook_" + .substring(1) + .replace( + "", + predictionOrderBookByMarketIdRequest.getMarketId() != null + ? predictionOrderBookByMarketIdRequest + .getMarketId() + .toString() + : ""); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void predictionOrderBookByMarketIdValidateBeforeCall( + PredictionOrderBookByMarketIdRequest predictionOrderBookByMarketIdRequest) + throws ApiException { + try { + Validator validator = + Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory() + .getValidator(); + + Set> violations = + validator.validate(predictionOrderBookByMarketIdRequest); + + if (!violations.isEmpty()) { + throw new ConstraintViolationException(violations); + } + } catch (SecurityException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } + } + + /** + * Reward claim failed Pushed when a claim fails completely — a single claim, or every item of a + * batch. For a batch, only the first failed item's amount and outcome are included. Update + * Speed: Real-time + * + * @return RewardClaimFailedResponse + * @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 Prediction Stream response -
+ * + * @see Reward + * claim failed Documentation + */ + public StreamBlockingQueueWrapper rewardClaimFailed() + throws ApiException { + StreamBlockingQueue queue = rewardClaimFailedRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue rewardClaimFailedRaw() throws ApiException { + rewardClaimFailedValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_claim_fail".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void rewardClaimFailedValidateBeforeCall() throws ApiException {} + + /** + * Reward claim succeeded Pushed when a claim fully succeeds — a single claim, or every item of + * a batch. Only the total is reported; no market title or outcome is included. Update Speed: + * Real-time + * + * @return RewardClaimSucceededResponse + * @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 Prediction Stream response -
+ * + * @see Reward + * claim succeeded Documentation + */ + public StreamBlockingQueueWrapper rewardClaimSucceeded() + throws ApiException { + StreamBlockingQueue queue = rewardClaimSucceededRaw(); + + TypeToken typeToken = + new TypeToken() {}; + + return new StreamBlockingQueueWrapper<>(queue, typeToken); + } + + public StreamBlockingQueue rewardClaimSucceededRaw() throws ApiException { + rewardClaimSucceededValidateBeforeCall(); + + String methodName = "/web3_prediction_pm_claim_success".substring(1); + if ("@".equals(methodName.substring(methodName.length() - 1))) { + methodName = methodName.substring(0, methodName.length() - 1); + } + + RequestWrapperDTO, Object> requestWrapperDTO = + new RequestWrapperDTO.Builder, Object>() + .command("SUBSCRIBE") + .value(methodName) + .build(); + Map> queuesMap = + connection.subscribe(requestWrapperDTO); + return queuesMap.get(methodName); + } + + @SuppressWarnings("rawtypes") + private void rewardClaimSucceededValidateBeforeCall() throws ApiException {} + + public String getRequestID() { + return UUID.randomUUID().toString(); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/W3WPredictionWebSocketStreams.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/W3WPredictionWebSocketStreams.java new file mode 100644 index 000000000..885539110 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/W3WPredictionWebSocketStreams.java @@ -0,0 +1,142 @@ +package com.binance.connector.client.w3w_prediction.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.SignedStreamConnectionPoolWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.SignedStreamConnectionWrapper; +import com.binance.connector.client.common.websocket.adapter.stream.StreamConnectionInterface; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.JSON; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.BatchClaimPartiallySucceededResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.FundTransferFailedResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.FundTransferSucceededResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderFullyFilledResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderPartiallyFilledResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderSubmissionFailedResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderSubmittedSuccessfullyResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketBuyOrderFailedResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketBuyOrderFullyFilledResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketResolutionNotificationResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketSellOrderFailedExpiredResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketSellOrderFullyFilledResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.PredictionOrderBookByMarketIdRequest; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.PredictionOrderBookByMarketIdResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.RewardClaimFailedResponse; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.RewardClaimSucceededResponse; +import java.util.UUID; + +public class W3WPredictionWebSocketStreams { + private static final String USER_AGENT = + String.format( + "binance-w3w-prediction/2.2.0 (Java/%s; %s; %s)", + SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); + + private final StreamConnectionInterface connection; + + private DefaultApi defaultApi; + + public W3WPredictionWebSocketStreams(WebSocketClientConfiguration configuration) { + this( + configuration.getUsePool() + ? new SignedStreamConnectionPoolWrapper(configuration, JSON.getGson()) + : new SignedStreamConnectionWrapper(configuration, JSON.getGson())); + } + + public W3WPredictionWebSocketStreams(StreamConnectionInterface connection) { + connection.setUserAgent(USER_AGENT); + if (!connection.isConnected()) { + connection.connect(); + } + this.connection = connection; + + this.defaultApi = new DefaultApi(connection); + } + + public void stop() throws Exception { + if (connection != null && connection.isConnected()) { + connection.stop(); + } + } + + public StreamBlockingQueueWrapper + batchClaimPartiallySucceeded() throws ApiException { + return defaultApi.batchClaimPartiallySucceeded(); + } + + public StreamBlockingQueueWrapper fundTransferFailed() + throws ApiException { + return defaultApi.fundTransferFailed(); + } + + public StreamBlockingQueueWrapper fundTransferSucceeded() + throws ApiException { + return defaultApi.fundTransferSucceeded(); + } + + public StreamBlockingQueueWrapper limitOrderFullyFilled() + throws ApiException { + return defaultApi.limitOrderFullyFilled(); + } + + public StreamBlockingQueueWrapper limitOrderPartiallyFilled() + throws ApiException { + return defaultApi.limitOrderPartiallyFilled(); + } + + public StreamBlockingQueueWrapper + limitOrderSubmissionFailed() throws ApiException { + return defaultApi.limitOrderSubmissionFailed(); + } + + public StreamBlockingQueueWrapper + limitOrderSubmittedSuccessfully() throws ApiException { + return defaultApi.limitOrderSubmittedSuccessfully(); + } + + public StreamBlockingQueueWrapper marketBuyOrderFailed() + throws ApiException { + return defaultApi.marketBuyOrderFailed(); + } + + public StreamBlockingQueueWrapper marketBuyOrderFullyFilled() + throws ApiException { + return defaultApi.marketBuyOrderFullyFilled(); + } + + public StreamBlockingQueueWrapper + marketResolutionNotification() throws ApiException { + return defaultApi.marketResolutionNotification(); + } + + public StreamBlockingQueueWrapper + marketSellOrderFailedExpired() throws ApiException { + return defaultApi.marketSellOrderFailedExpired(); + } + + public StreamBlockingQueueWrapper + marketSellOrderFullyFilled() throws ApiException { + return defaultApi.marketSellOrderFullyFilled(); + } + + public StreamBlockingQueueWrapper + predictionOrderBookByMarketId( + PredictionOrderBookByMarketIdRequest predictionOrderBookByMarketIdRequest) + throws ApiException { + return defaultApi.predictionOrderBookByMarketId(predictionOrderBookByMarketIdRequest); + } + + public StreamBlockingQueueWrapper rewardClaimFailed() + throws ApiException { + return defaultApi.rewardClaimFailed(); + } + + public StreamBlockingQueueWrapper rewardClaimSucceeded() + throws ApiException { + return defaultApi.rewardClaimSucceeded(); + } + + public String getRequestID() { + return UUID.randomUUID().toString(); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/AbstractOpenApiSchema.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/AbstractOpenApiSchema.java new file mode 100644 index 000000000..3a0ea6c7d --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/AbstractOpenApiSchema.java @@ -0,0 +1,145 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.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/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/BatchClaimPartiallySucceededResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/BatchClaimPartiallySucceededResponse.java new file mode 100644 index 000000000..ee65e273d --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/BatchClaimPartiallySucceededResponse.java @@ -0,0 +1,250 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** BatchClaimPartiallySucceededResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class BatchClaimPartiallySucceededResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public BatchClaimPartiallySucceededResponse() {} + + public BatchClaimPartiallySucceededResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchClaimPartiallySucceededResponse batchClaimPartiallySucceededResponse = + (BatchClaimPartiallySucceededResponse) o; + return Objects.equals(this.pushId, batchClaimPartiallySucceededResponse.pushId); + } + + @Override + public int hashCode() { + return Objects.hash(pushId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchClaimPartiallySucceededResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + + 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("pushId"); + + // 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 + * BatchClaimPartiallySucceededResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!BatchClaimPartiallySucceededResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in BatchClaimPartiallySucceededResponse" + + " is not found in the empty JSON string", + BatchClaimPartiallySucceededResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!BatchClaimPartiallySucceededResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `BatchClaimPartiallySucceededResponse` properties. JSON:" + + " %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!BatchClaimPartiallySucceededResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BatchClaimPartiallySucceededResponse' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(BatchClaimPartiallySucceededResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, BatchClaimPartiallySucceededResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public BatchClaimPartiallySucceededResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of BatchClaimPartiallySucceededResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of BatchClaimPartiallySucceededResponse + * @throws IOException if the JSON string is invalid with respect to + * BatchClaimPartiallySucceededResponse + */ + public static BatchClaimPartiallySucceededResponse fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, BatchClaimPartiallySucceededResponse.class); + } + + /** + * Convert an instance of BatchClaimPartiallySucceededResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/FundTransferFailedResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/FundTransferFailedResponse.java new file mode 100644 index 000000000..1fa51f289 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/FundTransferFailedResponse.java @@ -0,0 +1,287 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** FundTransferFailedResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class FundTransferFailedResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public FundTransferFailedResponse() {} + + public FundTransferFailedResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public FundTransferFailedResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * Amount of the attempted transfer. Rounded down to 2 decimals; shown as `<0.01` + * if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FundTransferFailedResponse fundTransferFailedResponse = (FundTransferFailedResponse) o; + return Objects.equals(this.pushId, fundTransferFailedResponse.pushId) + && Objects.equals(this.amount, fundTransferFailedResponse.amount); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FundTransferFailedResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + + 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("pushId"); + openapiFields.add("amount"); + + // 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 FundTransferFailedResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FundTransferFailedResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in FundTransferFailedResponse is not" + + " found in the empty JSON string", + FundTransferFailedResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!FundTransferFailedResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `FundTransferFailedResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FundTransferFailedResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FundTransferFailedResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(FundTransferFailedResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, FundTransferFailedResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FundTransferFailedResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of FundTransferFailedResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of FundTransferFailedResponse + * @throws IOException if the JSON string is invalid with respect to FundTransferFailedResponse + */ + public static FundTransferFailedResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FundTransferFailedResponse.class); + } + + /** + * Convert an instance of FundTransferFailedResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/FundTransferSucceededResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/FundTransferSucceededResponse.java new file mode 100644 index 000000000..e1175d9e8 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/FundTransferSucceededResponse.java @@ -0,0 +1,291 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** FundTransferSucceededResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class FundTransferSucceededResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public FundTransferSucceededResponse() {} + + public FundTransferSucceededResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public FundTransferSucceededResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * Amount transferred. Rounded down to 2 decimals; shown as `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FundTransferSucceededResponse fundTransferSucceededResponse = + (FundTransferSucceededResponse) o; + return Objects.equals(this.pushId, fundTransferSucceededResponse.pushId) + && Objects.equals(this.amount, fundTransferSucceededResponse.amount); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FundTransferSucceededResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + + 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("pushId"); + openapiFields.add("amount"); + + // 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 + * FundTransferSucceededResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FundTransferSucceededResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in FundTransferSucceededResponse is not" + + " found in the empty JSON string", + FundTransferSucceededResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!FundTransferSucceededResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `FundTransferSucceededResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FundTransferSucceededResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FundTransferSucceededResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(FundTransferSucceededResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, FundTransferSucceededResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FundTransferSucceededResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of FundTransferSucceededResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of FundTransferSucceededResponse + * @throws IOException if the JSON string is invalid with respect to + * FundTransferSucceededResponse + */ + public static FundTransferSucceededResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FundTransferSucceededResponse.class); + } + + /** + * Convert an instance of FundTransferSucceededResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderFullyFilledResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderFullyFilledResponse.java new file mode 100644 index 000000000..b870afacc --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderFullyFilledResponse.java @@ -0,0 +1,338 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** LimitOrderFullyFilledResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class LimitOrderFullyFilledResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public LimitOrderFullyFilledResponse() {} + + public LimitOrderFullyFilledResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public LimitOrderFullyFilledResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * Filled amount in USDT — paid for a buy, received after fees for a sell. Rounded down to 2 + * decimals; shown as `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + public LimitOrderFullyFilledResponse topic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LimitOrderFullyFilledResponse limitOrderFullyFilledResponse = + (LimitOrderFullyFilledResponse) o; + return Objects.equals(this.pushId, limitOrderFullyFilledResponse.pushId) + && Objects.equals(this.amount, limitOrderFullyFilledResponse.amount) + && Objects.equals(this.topic, limitOrderFullyFilledResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LimitOrderFullyFilledResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("amount"); + openapiFields.add("topic"); + + // 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 + * LimitOrderFullyFilledResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LimitOrderFullyFilledResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LimitOrderFullyFilledResponse is not" + + " found in the empty JSON string", + LimitOrderFullyFilledResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LimitOrderFullyFilledResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `LimitOrderFullyFilledResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LimitOrderFullyFilledResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LimitOrderFullyFilledResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(LimitOrderFullyFilledResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LimitOrderFullyFilledResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LimitOrderFullyFilledResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LimitOrderFullyFilledResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of LimitOrderFullyFilledResponse + * @throws IOException if the JSON string is invalid with respect to + * LimitOrderFullyFilledResponse + */ + public static LimitOrderFullyFilledResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LimitOrderFullyFilledResponse.class); + } + + /** + * Convert an instance of LimitOrderFullyFilledResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderPartiallyFilledResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderPartiallyFilledResponse.java new file mode 100644 index 000000000..a8fd1e706 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderPartiallyFilledResponse.java @@ -0,0 +1,339 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** LimitOrderPartiallyFilledResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class LimitOrderPartiallyFilledResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public LimitOrderPartiallyFilledResponse() {} + + public LimitOrderPartiallyFilledResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public LimitOrderPartiallyFilledResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * **Total** filled so far in USDT, not just this fill — paid for a buy, received after fees for + * a sell. Rounded down to 2 decimals; shown as `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + public LimitOrderPartiallyFilledResponse topic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LimitOrderPartiallyFilledResponse limitOrderPartiallyFilledResponse = + (LimitOrderPartiallyFilledResponse) o; + return Objects.equals(this.pushId, limitOrderPartiallyFilledResponse.pushId) + && Objects.equals(this.amount, limitOrderPartiallyFilledResponse.amount) + && Objects.equals(this.topic, limitOrderPartiallyFilledResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LimitOrderPartiallyFilledResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("amount"); + openapiFields.add("topic"); + + // 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 + * LimitOrderPartiallyFilledResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LimitOrderPartiallyFilledResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LimitOrderPartiallyFilledResponse is" + + " not found in the empty JSON string", + LimitOrderPartiallyFilledResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LimitOrderPartiallyFilledResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `LimitOrderPartiallyFilledResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LimitOrderPartiallyFilledResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LimitOrderPartiallyFilledResponse' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(LimitOrderPartiallyFilledResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LimitOrderPartiallyFilledResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LimitOrderPartiallyFilledResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LimitOrderPartiallyFilledResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of LimitOrderPartiallyFilledResponse + * @throws IOException if the JSON string is invalid with respect to + * LimitOrderPartiallyFilledResponse + */ + public static LimitOrderPartiallyFilledResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LimitOrderPartiallyFilledResponse.class); + } + + /** + * Convert an instance of LimitOrderPartiallyFilledResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderSubmissionFailedResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderSubmissionFailedResponse.java new file mode 100644 index 000000000..adf566ec0 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderSubmissionFailedResponse.java @@ -0,0 +1,294 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** LimitOrderSubmissionFailedResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class LimitOrderSubmissionFailedResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public LimitOrderSubmissionFailedResponse() {} + + public LimitOrderSubmissionFailedResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public LimitOrderSubmissionFailedResponse topic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LimitOrderSubmissionFailedResponse limitOrderSubmissionFailedResponse = + (LimitOrderSubmissionFailedResponse) o; + return Objects.equals(this.pushId, limitOrderSubmissionFailedResponse.pushId) + && Objects.equals(this.topic, limitOrderSubmissionFailedResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LimitOrderSubmissionFailedResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("topic"); + + // 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 + * LimitOrderSubmissionFailedResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LimitOrderSubmissionFailedResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LimitOrderSubmissionFailedResponse is" + + " not found in the empty JSON string", + LimitOrderSubmissionFailedResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LimitOrderSubmissionFailedResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `LimitOrderSubmissionFailedResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LimitOrderSubmissionFailedResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LimitOrderSubmissionFailedResponse' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(LimitOrderSubmissionFailedResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LimitOrderSubmissionFailedResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LimitOrderSubmissionFailedResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LimitOrderSubmissionFailedResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of LimitOrderSubmissionFailedResponse + * @throws IOException if the JSON string is invalid with respect to + * LimitOrderSubmissionFailedResponse + */ + public static LimitOrderSubmissionFailedResponse fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, LimitOrderSubmissionFailedResponse.class); + } + + /** + * Convert an instance of LimitOrderSubmissionFailedResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderSubmittedSuccessfullyResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderSubmittedSuccessfullyResponse.java new file mode 100644 index 000000000..70e1c213b --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/LimitOrderSubmittedSuccessfullyResponse.java @@ -0,0 +1,347 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** LimitOrderSubmittedSuccessfullyResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class LimitOrderSubmittedSuccessfullyResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public LimitOrderSubmittedSuccessfullyResponse() {} + + public LimitOrderSubmittedSuccessfullyResponse pushId( + @jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public LimitOrderSubmittedSuccessfullyResponse amount( + @jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * Total order amount in USDT, before fees. Rounded down to 2 decimals; shown as + * `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + public LimitOrderSubmittedSuccessfullyResponse topic( + @jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LimitOrderSubmittedSuccessfullyResponse limitOrderSubmittedSuccessfullyResponse = + (LimitOrderSubmittedSuccessfullyResponse) o; + return Objects.equals(this.pushId, limitOrderSubmittedSuccessfullyResponse.pushId) + && Objects.equals(this.amount, limitOrderSubmittedSuccessfullyResponse.amount) + && Objects.equals(this.topic, limitOrderSubmittedSuccessfullyResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LimitOrderSubmittedSuccessfullyResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("amount"); + openapiFields.add("topic"); + + // 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 + * LimitOrderSubmittedSuccessfullyResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LimitOrderSubmittedSuccessfullyResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in" + + " LimitOrderSubmittedSuccessfullyResponse is not found in the" + + " empty JSON string", + LimitOrderSubmittedSuccessfullyResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LimitOrderSubmittedSuccessfullyResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `LimitOrderSubmittedSuccessfullyResponse` properties. JSON:" + + " %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LimitOrderSubmittedSuccessfullyResponse.class.isAssignableFrom( + type.getRawType())) { + return null; // this class only serializes 'LimitOrderSubmittedSuccessfullyResponse' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(LimitOrderSubmittedSuccessfullyResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, LimitOrderSubmittedSuccessfullyResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LimitOrderSubmittedSuccessfullyResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LimitOrderSubmittedSuccessfullyResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of LimitOrderSubmittedSuccessfullyResponse + * @throws IOException if the JSON string is invalid with respect to + * LimitOrderSubmittedSuccessfullyResponse + */ + public static LimitOrderSubmittedSuccessfullyResponse fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, LimitOrderSubmittedSuccessfullyResponse.class); + } + + /** + * Convert an instance of LimitOrderSubmittedSuccessfullyResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketBuyOrderFailedResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketBuyOrderFailedResponse.java new file mode 100644 index 000000000..c65080caf --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketBuyOrderFailedResponse.java @@ -0,0 +1,337 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** MarketBuyOrderFailedResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class MarketBuyOrderFailedResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public MarketBuyOrderFailedResponse() {} + + public MarketBuyOrderFailedResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public MarketBuyOrderFailedResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * Original order amount in USDT — **not** actually charged. Rounded down to 2 decimals; shown + * as `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + public MarketBuyOrderFailedResponse topic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MarketBuyOrderFailedResponse marketBuyOrderFailedResponse = + (MarketBuyOrderFailedResponse) o; + return Objects.equals(this.pushId, marketBuyOrderFailedResponse.pushId) + && Objects.equals(this.amount, marketBuyOrderFailedResponse.amount) + && Objects.equals(this.topic, marketBuyOrderFailedResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MarketBuyOrderFailedResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("amount"); + openapiFields.add("topic"); + + // 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 + * MarketBuyOrderFailedResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MarketBuyOrderFailedResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in MarketBuyOrderFailedResponse is not" + + " found in the empty JSON string", + MarketBuyOrderFailedResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MarketBuyOrderFailedResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `MarketBuyOrderFailedResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MarketBuyOrderFailedResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MarketBuyOrderFailedResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(MarketBuyOrderFailedResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, MarketBuyOrderFailedResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MarketBuyOrderFailedResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of MarketBuyOrderFailedResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of MarketBuyOrderFailedResponse + * @throws IOException if the JSON string is invalid with respect to + * MarketBuyOrderFailedResponse + */ + public static MarketBuyOrderFailedResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MarketBuyOrderFailedResponse.class); + } + + /** + * Convert an instance of MarketBuyOrderFailedResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketBuyOrderFullyFilledResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketBuyOrderFullyFilledResponse.java new file mode 100644 index 000000000..96fee6bbb --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketBuyOrderFullyFilledResponse.java @@ -0,0 +1,338 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** MarketBuyOrderFullyFilledResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class MarketBuyOrderFullyFilledResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public MarketBuyOrderFullyFilledResponse() {} + + public MarketBuyOrderFullyFilledResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public MarketBuyOrderFullyFilledResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * USDT the user paid. Rounded down to 2 decimals; shown as `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + public MarketBuyOrderFullyFilledResponse topic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MarketBuyOrderFullyFilledResponse marketBuyOrderFullyFilledResponse = + (MarketBuyOrderFullyFilledResponse) o; + return Objects.equals(this.pushId, marketBuyOrderFullyFilledResponse.pushId) + && Objects.equals(this.amount, marketBuyOrderFullyFilledResponse.amount) + && Objects.equals(this.topic, marketBuyOrderFullyFilledResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MarketBuyOrderFullyFilledResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("amount"); + openapiFields.add("topic"); + + // 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 + * MarketBuyOrderFullyFilledResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MarketBuyOrderFullyFilledResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in MarketBuyOrderFullyFilledResponse is" + + " not found in the empty JSON string", + MarketBuyOrderFullyFilledResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MarketBuyOrderFullyFilledResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `MarketBuyOrderFullyFilledResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MarketBuyOrderFullyFilledResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MarketBuyOrderFullyFilledResponse' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(MarketBuyOrderFullyFilledResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, MarketBuyOrderFullyFilledResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MarketBuyOrderFullyFilledResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of MarketBuyOrderFullyFilledResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of MarketBuyOrderFullyFilledResponse + * @throws IOException if the JSON string is invalid with respect to + * MarketBuyOrderFullyFilledResponse + */ + public static MarketBuyOrderFullyFilledResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MarketBuyOrderFullyFilledResponse.class); + } + + /** + * Convert an instance of MarketBuyOrderFullyFilledResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketResolutionNotificationResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketResolutionNotificationResponse.java new file mode 100644 index 000000000..05a57c8e5 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketResolutionNotificationResponse.java @@ -0,0 +1,296 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** MarketResolutionNotificationResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class MarketResolutionNotificationResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public MarketResolutionNotificationResponse() {} + + public MarketResolutionNotificationResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public MarketResolutionNotificationResponse topic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MarketResolutionNotificationResponse marketResolutionNotificationResponse = + (MarketResolutionNotificationResponse) o; + return Objects.equals(this.pushId, marketResolutionNotificationResponse.pushId) + && Objects.equals(this.topic, marketResolutionNotificationResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MarketResolutionNotificationResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("topic"); + + // 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 + * MarketResolutionNotificationResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MarketResolutionNotificationResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in MarketResolutionNotificationResponse" + + " is not found in the empty JSON string", + MarketResolutionNotificationResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MarketResolutionNotificationResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `MarketResolutionNotificationResponse` properties. JSON:" + + " %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MarketResolutionNotificationResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MarketResolutionNotificationResponse' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(MarketResolutionNotificationResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, MarketResolutionNotificationResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MarketResolutionNotificationResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of MarketResolutionNotificationResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of MarketResolutionNotificationResponse + * @throws IOException if the JSON string is invalid with respect to + * MarketResolutionNotificationResponse + */ + public static MarketResolutionNotificationResponse fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, MarketResolutionNotificationResponse.class); + } + + /** + * Convert an instance of MarketResolutionNotificationResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketSellOrderFailedExpiredResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketSellOrderFailedExpiredResponse.java new file mode 100644 index 000000000..ec10ab80d --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketSellOrderFailedExpiredResponse.java @@ -0,0 +1,342 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** MarketSellOrderFailedExpiredResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class MarketSellOrderFailedExpiredResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public MarketSellOrderFailedExpiredResponse() {} + + public MarketSellOrderFailedExpiredResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public MarketSellOrderFailedExpiredResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * USDT the user would have received after fees — **not** credited. Rounded down to 2 decimals; + * shown as `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + public MarketSellOrderFailedExpiredResponse topic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MarketSellOrderFailedExpiredResponse marketSellOrderFailedExpiredResponse = + (MarketSellOrderFailedExpiredResponse) o; + return Objects.equals(this.pushId, marketSellOrderFailedExpiredResponse.pushId) + && Objects.equals(this.amount, marketSellOrderFailedExpiredResponse.amount) + && Objects.equals(this.topic, marketSellOrderFailedExpiredResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MarketSellOrderFailedExpiredResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("amount"); + openapiFields.add("topic"); + + // 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 + * MarketSellOrderFailedExpiredResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MarketSellOrderFailedExpiredResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in MarketSellOrderFailedExpiredResponse" + + " is not found in the empty JSON string", + MarketSellOrderFailedExpiredResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MarketSellOrderFailedExpiredResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `MarketSellOrderFailedExpiredResponse` properties. JSON:" + + " %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MarketSellOrderFailedExpiredResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MarketSellOrderFailedExpiredResponse' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(MarketSellOrderFailedExpiredResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, MarketSellOrderFailedExpiredResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MarketSellOrderFailedExpiredResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of MarketSellOrderFailedExpiredResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of MarketSellOrderFailedExpiredResponse + * @throws IOException if the JSON string is invalid with respect to + * MarketSellOrderFailedExpiredResponse + */ + public static MarketSellOrderFailedExpiredResponse fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, MarketSellOrderFailedExpiredResponse.class); + } + + /** + * Convert an instance of MarketSellOrderFailedExpiredResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketSellOrderFullyFilledResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketSellOrderFullyFilledResponse.java new file mode 100644 index 000000000..f54f20648 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/MarketSellOrderFullyFilledResponse.java @@ -0,0 +1,340 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** MarketSellOrderFullyFilledResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class MarketSellOrderFullyFilledResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public static final String SERIALIZED_NAME_TOPIC = "topic"; + + @SerializedName(SERIALIZED_NAME_TOPIC) + @jakarta.annotation.Nullable + private String topic; + + public MarketSellOrderFullyFilledResponse() {} + + public MarketSellOrderFullyFilledResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public MarketSellOrderFullyFilledResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * USDT the user received, **after fees**. Rounded down to 2 decimals; shown as + * `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + public MarketSellOrderFullyFilledResponse topic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + return this; + } + + /** + * Market title, cut to 12 characters with `..` added when longer; empty if + * unavailable. + * + * @return topic + */ + @jakarta.annotation.Nullable + public String getTopic() { + return topic; + } + + public void setTopic(@jakarta.annotation.Nullable String topic) { + this.topic = topic; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MarketSellOrderFullyFilledResponse marketSellOrderFullyFilledResponse = + (MarketSellOrderFullyFilledResponse) o; + return Objects.equals(this.pushId, marketSellOrderFullyFilledResponse.pushId) + && Objects.equals(this.amount, marketSellOrderFullyFilledResponse.amount) + && Objects.equals(this.topic, marketSellOrderFullyFilledResponse.topic); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount, topic); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MarketSellOrderFullyFilledResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" topic: ").append(toIndentedString(topic)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + String topicValue = getTopic(); + if (topicValue != null) { + String topicValueAsString = topicValue.toString(); + valMap.put("topic", topicValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + Object topicValue = getTopic(); + if (topicValue != null) { + valMap.put("topic", topicValue); + } + + 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("pushId"); + openapiFields.add("amount"); + openapiFields.add("topic"); + + // 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 + * MarketSellOrderFullyFilledResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MarketSellOrderFullyFilledResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in MarketSellOrderFullyFilledResponse is" + + " not found in the empty JSON string", + MarketSellOrderFullyFilledResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!MarketSellOrderFullyFilledResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `MarketSellOrderFullyFilledResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + if ((jsonObj.get("topic") != null && !jsonObj.get("topic").isJsonNull()) + && !jsonObj.get("topic").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `topic` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("topic").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MarketSellOrderFullyFilledResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MarketSellOrderFullyFilledResponse' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(MarketSellOrderFullyFilledResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, MarketSellOrderFullyFilledResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public MarketSellOrderFullyFilledResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of MarketSellOrderFullyFilledResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of MarketSellOrderFullyFilledResponse + * @throws IOException if the JSON string is invalid with respect to + * MarketSellOrderFullyFilledResponse + */ + public static MarketSellOrderFullyFilledResponse fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, MarketSellOrderFullyFilledResponse.class); + } + + /** + * Convert an instance of MarketSellOrderFullyFilledResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/PredictionOrderBookByMarketIdRequest.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/PredictionOrderBookByMarketIdRequest.java new file mode 100644 index 000000000..a5fed91ee --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/PredictionOrderBookByMarketIdRequest.java @@ -0,0 +1,256 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** PredictionOrderBookByMarketIdRequest */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class PredictionOrderBookByMarketIdRequest extends BaseDTO { + public static final String SERIALIZED_NAME_MARKET_ID = "marketId"; + + @SerializedName(SERIALIZED_NAME_MARKET_ID) + @jakarta.annotation.Nullable + private String marketId; + + public PredictionOrderBookByMarketIdRequest() {} + + public PredictionOrderBookByMarketIdRequest marketId( + @jakarta.annotation.Nullable String marketId) { + this.marketId = marketId; + return this; + } + + /** + * Market ID to subscribe to — the `marketId` inside `markets[]` returned by + * `market/list` or `market/detail`. It is **not** `marketTopicId` + * and **not** `externalId`. A wrong id is never rejected: subscribing with + * `marketTopicId`, `externalId`, or with a closed or resolved market + * returns the same successful `COMMAND` reply as a correct id and then pushes nothing + * at all, so a stream that stays silent is far more likely a wrong id than a broken connection. + * + * @return marketId + */ + @jakarta.annotation.Nullable + public String getMarketId() { + return marketId; + } + + public void setMarketId(@jakarta.annotation.Nullable String marketId) { + this.marketId = marketId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PredictionOrderBookByMarketIdRequest predictionOrderBookByMarketIdRequest = + (PredictionOrderBookByMarketIdRequest) o; + return Objects.equals(this.marketId, predictionOrderBookByMarketIdRequest.marketId); + } + + @Override + public int hashCode() { + return Objects.hash(marketId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PredictionOrderBookByMarketIdRequest {\n"); + sb.append(" marketId: ").append(toIndentedString(marketId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String marketIdValue = getMarketId(); + if (marketIdValue != null) { + String marketIdValueAsString = marketIdValue.toString(); + valMap.put("marketId", marketIdValueAsString); + } + + 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 marketIdValue = getMarketId(); + if (marketIdValue != null) { + valMap.put("marketId", marketIdValue); + } + + 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("marketId"); + + // 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 + * PredictionOrderBookByMarketIdRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PredictionOrderBookByMarketIdRequest.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in PredictionOrderBookByMarketIdRequest" + + " is not found in the empty JSON string", + PredictionOrderBookByMarketIdRequest.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PredictionOrderBookByMarketIdRequest.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `PredictionOrderBookByMarketIdRequest` properties. JSON:" + + " %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("marketId") != null && !jsonObj.get("marketId").isJsonNull()) + && !jsonObj.get("marketId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `marketId` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("marketId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PredictionOrderBookByMarketIdRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PredictionOrderBookByMarketIdRequest' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(PredictionOrderBookByMarketIdRequest.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, PredictionOrderBookByMarketIdRequest value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PredictionOrderBookByMarketIdRequest read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of PredictionOrderBookByMarketIdRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of PredictionOrderBookByMarketIdRequest + * @throws IOException if the JSON string is invalid with respect to + * PredictionOrderBookByMarketIdRequest + */ + public static PredictionOrderBookByMarketIdRequest fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, PredictionOrderBookByMarketIdRequest.class); + } + + /** + * Convert an instance of PredictionOrderBookByMarketIdRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/PredictionOrderBookByMarketIdResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/PredictionOrderBookByMarketIdResponse.java new file mode 100644 index 000000000..32398c60f --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/PredictionOrderBookByMarketIdResponse.java @@ -0,0 +1,452 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.Valid; +import jakarta.validation.constraints.*; +import java.io.IOException; +import java.math.BigDecimal; +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.*; + +/** PredictionOrderBookByMarketIdResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class PredictionOrderBookByMarketIdResponse extends BaseDTO { + public static final String SERIALIZED_NAME_MSG_TYPE = "msgType"; + + @SerializedName(SERIALIZED_NAME_MSG_TYPE) + @jakarta.annotation.Nullable + private String msgType; + + public static final String SERIALIZED_NAME_MARKET_ID = "marketId"; + + @SerializedName(SERIALIZED_NAME_MARKET_ID) + @jakarta.annotation.Nullable + private Long marketId; + + public static final String SERIALIZED_NAME_UPDATE_TIMESTAMP_MS = "updateTimestampMs"; + + @SerializedName(SERIALIZED_NAME_UPDATE_TIMESTAMP_MS) + @jakarta.annotation.Nullable + private Long updateTimestampMs; + + public static final String SERIALIZED_NAME_ASKS = "asks"; + + @SerializedName(SERIALIZED_NAME_ASKS) + @jakarta.annotation.Nullable + private List> asks; + + public static final String SERIALIZED_NAME_BIDS = "bids"; + + @SerializedName(SERIALIZED_NAME_BIDS) + @jakarta.annotation.Nullable + private List> bids; + + public PredictionOrderBookByMarketIdResponse() {} + + public PredictionOrderBookByMarketIdResponse msgType( + @jakarta.annotation.Nullable String msgType) { + this.msgType = msgType; + return this; + } + + /** + * Message type, always `orderbook`. + * + * @return msgType + */ + @jakarta.annotation.Nullable + public String getMsgType() { + return msgType; + } + + public void setMsgType(@jakarta.annotation.Nullable String msgType) { + this.msgType = msgType; + } + + public PredictionOrderBookByMarketIdResponse marketId( + @jakarta.annotation.Nullable Long marketId) { + this.marketId = marketId; + return this; + } + + /** + * Market ID of this order book, the same `markets[].marketId` used by the REST API. + * + * @return marketId + */ + @jakarta.annotation.Nullable + public Long getMarketId() { + return marketId; + } + + public void setMarketId(@jakarta.annotation.Nullable Long marketId) { + this.marketId = marketId; + } + + public PredictionOrderBookByMarketIdResponse updateTimestampMs( + @jakarta.annotation.Nullable Long updateTimestampMs) { + this.updateTimestampMs = updateTimestampMs; + return this; + } + + /** + * Quote update time in milliseconds (UTC). Messages for the same market may arrive out of + * order, so discard anything older than the snapshot you already have. + * + * @return updateTimestampMs + */ + @jakarta.annotation.Nullable + public Long getUpdateTimestampMs() { + return updateTimestampMs; + } + + public void setUpdateTimestampMs(@jakarta.annotation.Nullable Long updateTimestampMs) { + this.updateTimestampMs = updateTimestampMs; + } + + public PredictionOrderBookByMarketIdResponse asks( + @jakarta.annotation.Nullable List> asks) { + this.asks = asks; + return this; + } + + public PredictionOrderBookByMarketIdResponse addAsksItem(List asksItem) { + if (this.asks == null) { + this.asks = new ArrayList<>(); + } + this.asks.add(asksItem); + return this; + } + + /** + * Ask levels sorted by price **ascending**, usually the top 50 or fewer; an empty array means + * no asks. Values may carry floating-point noise (e.g. `6865.999999999999`), so round + * them before display. + * + * @return asks + */ + @jakarta.annotation.Nullable + @Valid + public List> getAsks() { + return asks; + } + + public void setAsks(@jakarta.annotation.Nullable List> asks) { + this.asks = asks; + } + + public PredictionOrderBookByMarketIdResponse bids( + @jakarta.annotation.Nullable List> bids) { + this.bids = bids; + return this; + } + + public PredictionOrderBookByMarketIdResponse addBidsItem(List bidsItem) { + if (this.bids == null) { + this.bids = new ArrayList<>(); + } + this.bids.add(bidsItem); + return this; + } + + /** + * Bid levels sorted by price **descending**, usually the top 50 or fewer; an empty array means + * no bids. Values may carry floating-point noise (e.g. `6865.999999999999`), so round + * them before display. + * + * @return bids + */ + @jakarta.annotation.Nullable + @Valid + public List> getBids() { + return bids; + } + + public void setBids(@jakarta.annotation.Nullable List> bids) { + this.bids = bids; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PredictionOrderBookByMarketIdResponse predictionOrderBookByMarketIdResponse = + (PredictionOrderBookByMarketIdResponse) o; + return Objects.equals(this.msgType, predictionOrderBookByMarketIdResponse.msgType) + && Objects.equals(this.marketId, predictionOrderBookByMarketIdResponse.marketId) + && Objects.equals( + this.updateTimestampMs, + predictionOrderBookByMarketIdResponse.updateTimestampMs) + && Objects.equals(this.asks, predictionOrderBookByMarketIdResponse.asks) + && Objects.equals(this.bids, predictionOrderBookByMarketIdResponse.bids); + } + + @Override + public int hashCode() { + return Objects.hash(msgType, marketId, updateTimestampMs, asks, bids); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PredictionOrderBookByMarketIdResponse {\n"); + sb.append(" msgType: ").append(toIndentedString(msgType)).append("\n"); + sb.append(" marketId: ").append(toIndentedString(marketId)).append("\n"); + sb.append(" updateTimestampMs: ").append(toIndentedString(updateTimestampMs)).append("\n"); + sb.append(" asks: ").append(toIndentedString(asks)).append("\n"); + sb.append(" bids: ").append(toIndentedString(bids)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String msgTypeValue = getMsgType(); + if (msgTypeValue != null) { + String msgTypeValueAsString = msgTypeValue.toString(); + valMap.put("msgType", msgTypeValueAsString); + } + Long marketIdValue = getMarketId(); + if (marketIdValue != null) { + String marketIdValueAsString = marketIdValue.toString(); + valMap.put("marketId", marketIdValueAsString); + } + Long updateTimestampMsValue = getUpdateTimestampMs(); + if (updateTimestampMsValue != null) { + String updateTimestampMsValueAsString = updateTimestampMsValue.toString(); + valMap.put("updateTimestampMs", updateTimestampMsValueAsString); + } + List> asksValue = getAsks(); + if (asksValue != null) { + String asksValueAsString = JSON.getGson().toJson(asksValue); + valMap.put("asks", asksValueAsString); + } + List> bidsValue = getBids(); + if (bidsValue != null) { + String bidsValueAsString = JSON.getGson().toJson(bidsValue); + valMap.put("bids", bidsValueAsString); + } + + 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 msgTypeValue = getMsgType(); + if (msgTypeValue != null) { + valMap.put("msgType", msgTypeValue); + } + Object marketIdValue = getMarketId(); + if (marketIdValue != null) { + valMap.put("marketId", marketIdValue); + } + Object updateTimestampMsValue = getUpdateTimestampMs(); + if (updateTimestampMsValue != null) { + valMap.put("updateTimestampMs", updateTimestampMsValue); + } + Object asksValue = getAsks(); + if (asksValue != null) { + valMap.put("asks", asksValue); + } + Object bidsValue = getBids(); + if (bidsValue != null) { + valMap.put("bids", bidsValue); + } + + 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("msgType"); + openapiFields.add("marketId"); + openapiFields.add("updateTimestampMs"); + openapiFields.add("asks"); + openapiFields.add("bids"); + + // 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 + * PredictionOrderBookByMarketIdResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PredictionOrderBookByMarketIdResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in PredictionOrderBookByMarketIdResponse" + + " is not found in the empty JSON string", + PredictionOrderBookByMarketIdResponse.openapiRequiredFields + .toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PredictionOrderBookByMarketIdResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `PredictionOrderBookByMarketIdResponse` properties. JSON:" + + " %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("msgType") != null && !jsonObj.get("msgType").isJsonNull()) + && !jsonObj.get("msgType").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `msgType` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("msgType").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("asks") != null + && !jsonObj.get("asks").isJsonNull() + && !jsonObj.get("asks").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `asks` to be an array in the JSON string but got" + + " `%s`", + jsonObj.get("asks").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("bids") != null + && !jsonObj.get("bids").isJsonNull() + && !jsonObj.get("bids").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `bids` to be an array in the JSON string but got" + + " `%s`", + jsonObj.get("bids").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PredictionOrderBookByMarketIdResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PredictionOrderBookByMarketIdResponse' + // and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(PredictionOrderBookByMarketIdResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write( + JsonWriter out, PredictionOrderBookByMarketIdResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PredictionOrderBookByMarketIdResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of PredictionOrderBookByMarketIdResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of PredictionOrderBookByMarketIdResponse + * @throws IOException if the JSON string is invalid with respect to + * PredictionOrderBookByMarketIdResponse + */ + public static PredictionOrderBookByMarketIdResponse fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, PredictionOrderBookByMarketIdResponse.class); + } + + /** + * Convert an instance of PredictionOrderBookByMarketIdResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/RewardClaimFailedResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/RewardClaimFailedResponse.java new file mode 100644 index 000000000..c9158d00c --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/RewardClaimFailedResponse.java @@ -0,0 +1,333 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** RewardClaimFailedResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class RewardClaimFailedResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public static final String SERIALIZED_NAME_OUTCOME = "outcome"; + + @SerializedName(SERIALIZED_NAME_OUTCOME) + @jakarta.annotation.Nullable + private String outcome; + + public RewardClaimFailedResponse() {} + + public RewardClaimFailedResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public RewardClaimFailedResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * Amount of the **first failed claim**. Rounded down to 2 decimals; shown as + * `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + public RewardClaimFailedResponse outcome(@jakarta.annotation.Nullable String outcome) { + this.outcome = outcome; + return this; + } + + /** + * Outcome name of the **first failed claim**, such as `Yes` or `No`; empty + * if unavailable. + * + * @return outcome + */ + @jakarta.annotation.Nullable + public String getOutcome() { + return outcome; + } + + public void setOutcome(@jakarta.annotation.Nullable String outcome) { + this.outcome = outcome; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RewardClaimFailedResponse rewardClaimFailedResponse = (RewardClaimFailedResponse) o; + return Objects.equals(this.pushId, rewardClaimFailedResponse.pushId) + && Objects.equals(this.amount, rewardClaimFailedResponse.amount) + && Objects.equals(this.outcome, rewardClaimFailedResponse.outcome); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount, outcome); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RewardClaimFailedResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" outcome: ").append(toIndentedString(outcome)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + String outcomeValue = getOutcome(); + if (outcomeValue != null) { + String outcomeValueAsString = outcomeValue.toString(); + valMap.put("outcome", outcomeValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + Object outcomeValue = getOutcome(); + if (outcomeValue != null) { + valMap.put("outcome", outcomeValue); + } + + 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("pushId"); + openapiFields.add("amount"); + openapiFields.add("outcome"); + + // 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 RewardClaimFailedResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RewardClaimFailedResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in RewardClaimFailedResponse is not found" + + " in the empty JSON string", + RewardClaimFailedResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RewardClaimFailedResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `RewardClaimFailedResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + if ((jsonObj.get("outcome") != null && !jsonObj.get("outcome").isJsonNull()) + && !jsonObj.get("outcome").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `outcome` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("outcome").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RewardClaimFailedResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RewardClaimFailedResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(RewardClaimFailedResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, RewardClaimFailedResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RewardClaimFailedResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of RewardClaimFailedResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of RewardClaimFailedResponse + * @throws IOException if the JSON string is invalid with respect to RewardClaimFailedResponse + */ + public static RewardClaimFailedResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RewardClaimFailedResponse.class); + } + + /** + * Convert an instance of RewardClaimFailedResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/RewardClaimSucceededResponse.java b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/RewardClaimSucceededResponse.java new file mode 100644 index 000000000..c727e67c5 --- /dev/null +++ b/clients/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/model/RewardClaimSucceededResponse.java @@ -0,0 +1,290 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 kinds of real-time events over the Binance SApi WebSocket channel, covering market and limit trading, reward claims, fund transfers and market resolution, plus order book (bid/ask) quotes per market. Trading events go only to the user they belong to; order book quotes go to everyone subscribed. A message may occasionally be missed, order is not guaranteed, and nothing is stored while you are offline — after reconnecting, fetch the latest state from the REST API and drop duplicates using `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.model; + +import com.binance.connector.client.common.websocket.dtos.BaseDTO; +import com.binance.connector.client.w3w_prediction.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.*; + +/** RewardClaimSucceededResponse */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.22.0") +public class RewardClaimSucceededResponse extends BaseDTO { + public static final String SERIALIZED_NAME_PUSH_ID = "pushId"; + + @SerializedName(SERIALIZED_NAME_PUSH_ID) + @jakarta.annotation.Nullable + private String pushId; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + + @SerializedName(SERIALIZED_NAME_AMOUNT) + @jakarta.annotation.Nullable + private String amount; + + public RewardClaimSucceededResponse() {} + + public RewardClaimSucceededResponse pushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + return this; + } + + /** + * Unique ID of this push. Use it to remove duplicates. + * + * @return pushId + */ + @jakarta.annotation.Nullable + public String getPushId() { + return pushId; + } + + public void setPushId(@jakarta.annotation.Nullable String pushId) { + this.pushId = pushId; + } + + public RewardClaimSucceededResponse amount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + return this; + } + + /** + * Total USDT claimed. Rounded down to 2 decimals; shown as `<0.01` if smaller. + * + * @return amount + */ + @jakarta.annotation.Nullable + public String getAmount() { + return amount; + } + + public void setAmount(@jakarta.annotation.Nullable String amount) { + this.amount = amount; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RewardClaimSucceededResponse rewardClaimSucceededResponse = + (RewardClaimSucceededResponse) o; + return Objects.equals(this.pushId, rewardClaimSucceededResponse.pushId) + && Objects.equals(this.amount, rewardClaimSucceededResponse.amount); + } + + @Override + public int hashCode() { + return Objects.hash(pushId, amount); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RewardClaimSucceededResponse {\n"); + sb.append(" pushId: ").append(toIndentedString(pushId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public String toUrlQueryString() { + StringBuilder sb = new StringBuilder(); + Map valMap = new TreeMap(); + valMap.put("apiKey", getApiKey()); + String pushIdValue = getPushId(); + if (pushIdValue != null) { + String pushIdValueAsString = pushIdValue.toString(); + valMap.put("pushId", pushIdValueAsString); + } + String amountValue = getAmount(); + if (amountValue != null) { + String amountValueAsString = amountValue.toString(); + valMap.put("amount", amountValueAsString); + } + + 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 pushIdValue = getPushId(); + if (pushIdValue != null) { + valMap.put("pushId", pushIdValue); + } + Object amountValue = getAmount(); + if (amountValue != null) { + valMap.put("amount", amountValue); + } + + 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("pushId"); + openapiFields.add("amount"); + + // 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 + * RewardClaimSucceededResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RewardClaimSucceededResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in RewardClaimSucceededResponse is not" + + " found in the empty JSON string", + RewardClaimSucceededResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!RewardClaimSucceededResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the" + + " `RewardClaimSucceededResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("pushId") != null && !jsonObj.get("pushId").isJsonNull()) + && !jsonObj.get("pushId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushId` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("pushId").toString())); + } + if ((jsonObj.get("amount") != null && !jsonObj.get("amount").isJsonNull()) + && !jsonObj.get("amount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `amount` to be a primitive type in the JSON string" + + " but got `%s`", + jsonObj.get("amount").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RewardClaimSucceededResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RewardClaimSucceededResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(RewardClaimSucceededResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, RewardClaimSucceededResponse value) + throws IOException { + JsonElement obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public RewardClaimSucceededResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + // validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of RewardClaimSucceededResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of RewardClaimSucceededResponse + * @throws IOException if the JSON string is invalid with respect to + * RewardClaimSucceededResponse + */ + public static RewardClaimSucceededResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RewardClaimSucceededResponse.class); + } + + /** + * Convert an instance of RewardClaimSucceededResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/clients/w3w-prediction/src/test/java/com/binance/connector/client/w3w_prediction/rest/api/OtcApiTest.java b/clients/w3w-prediction/src/test/java/com/binance/connector/client/w3w_prediction/rest/api/OtcApiTest.java new file mode 100644 index 000000000..b340a2c2e --- /dev/null +++ b/clients/w3w-prediction/src/test/java/com/binance/connector/client/w3w_prediction/rest/api/OtcApiTest.java @@ -0,0 +1,404 @@ +/* + * Prediction Trading REST API + * Place and manage prediction market orders, query positions, and transfer funds via the Prediction Trading REST API. + * + * 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.w3w_prediction.rest.api; + +import static org.junit.Assert.assertEquals; + +import com.binance.connector.client.common.ApiClient; +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.ApiResponse; +import com.binance.connector.client.common.auth.BinanceAuthenticationFactory; +import com.binance.connector.client.common.auth.SignatureAuthentication; +import com.binance.connector.client.common.configuration.ClientConfiguration; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.sign.HmacSignatureGenerator; +import com.binance.connector.client.common.sign.SignatureGenerator; +import com.binance.connector.client.w3w_prediction.rest.model.Assets; +import com.binance.connector.client.w3w_prediction.rest.model.CreateOtcBlocktradeRequest; +import com.binance.connector.client.w3w_prediction.rest.model.CreateOtcBlocktradeResponse; +import com.binance.connector.client.w3w_prediction.rest.model.FulfilOtcBlocktradeRequest; +import com.binance.connector.client.w3w_prediction.rest.model.FulfilOtcBlocktradeResponse; +import com.binance.connector.client.w3w_prediction.rest.model.GetOtcBlocktradeDetailRequest; +import com.binance.connector.client.w3w_prediction.rest.model.GetOtcBlocktradeDetailResponse; +import com.binance.connector.client.w3w_prediction.rest.model.GetOtcBlocktradeEventsRequest; +import com.binance.connector.client.w3w_prediction.rest.model.GetOtcBlocktradeEventsResponse; +import com.binance.connector.client.w3w_prediction.rest.model.GetOtcReservedBalancesRequest; +import com.binance.connector.client.w3w_prediction.rest.model.GetOtcReservedBalancesResponse; +import com.binance.connector.client.w3w_prediction.rest.model.ListOtcBlocktradesRequest; +import com.binance.connector.client.w3w_prediction.rest.model.ListOtcBlocktradesResponse; +import com.binance.connector.client.w3w_prediction.rest.model.OrderIds; +import com.binance.connector.client.w3w_prediction.rest.model.PreviewOtcBlocktradeRequest; +import com.binance.connector.client.w3w_prediction.rest.model.PreviewOtcBlocktradeResponse; +import com.binance.connector.client.w3w_prediction.rest.model.RemoveOtcBlocktradesRequest; +import com.binance.connector.client.w3w_prediction.rest.model.RemoveOtcBlocktradesResponse; +import com.binance.connector.client.w3w_prediction.rest.model.Side; +import jakarta.validation.constraints.*; +import java.io.IOException; +import okhttp3.Call; +import okhttp3.Request; +import org.bouncycastle.crypto.CryptoException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; + +/** API tests for OtcApi */ +public class OtcApiTest { + + private OtcApi api; + private ApiClient apiClientSpy; + private SignatureGenerator signatureGeneratorSpy; + + @BeforeEach + public void initApiClient() throws ApiException { + ClientConfiguration clientConfiguration = new ClientConfiguration(); + clientConfiguration.setUrl("http://localhost:8080"); + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setSecretKey("secretKey"); + clientConfiguration.setSignatureConfiguration(signatureConfiguration); + + HmacSignatureGenerator signatureGenerator = + new HmacSignatureGenerator(signatureConfiguration.getSecretKey()); + signatureGeneratorSpy = Mockito.spy(signatureGenerator); + SignatureAuthentication signatureAuthentication = + new SignatureAuthentication( + signatureConfiguration.getApiKey(), signatureGeneratorSpy); + SignatureAuthentication authenticationSpy = Mockito.spy(signatureAuthentication); + Mockito.doReturn("1736393892000").when(authenticationSpy).buildTimestamp(); + + BinanceAuthenticationFactory factoryMock = Mockito.mock(BinanceAuthenticationFactory.class); + Mockito.doReturn(authenticationSpy) + .when(factoryMock) + .getAuthentication(signatureConfiguration); + + ApiClient apiClient = new ApiClient(clientConfiguration, factoryMock); + + apiClientSpy = Mockito.spy(apiClient); + Mockito.doReturn(new ApiResponse<>(200, null)) + .when(apiClientSpy) + .execute(Mockito.any(), Mockito.any(java.lang.reflect.Type.class)); + Mockito.doReturn(new ApiResponse<>(200, null)).when(apiClientSpy).execute(Mockito.any()); + Mockito.doReturn("1736393892000").when(apiClientSpy).buildTimestamp(); + + api = new OtcApi(apiClientSpy); + } + + /** + * Create OTC Blocktrade (PREDICTION_TRADE) + * + *

Create an OTC blocktrade as the maker (BID to buy outcome shares with USDT, or ASK to sell + * outcome shares for USDT). The maker wallet is resolved server-side by `userId`; + * signing is done server-side via SAS `typedDataSign`. Returns `orderId` + * and a one-time `secretToken` to share out-of-band with the intended taker. + * Weight(IP): 200 Security Type: PREDICTION_TRADE Notes: - Restricted to authorized market + * makers. Requests from unauthorized accounts are rejected — contact BD to request access. - + * Side & Amount Rules: | side | makerAmount | takerAmount | | ------ | ------------- | + * ------------- | | `BUY` | USDT (wei) | shares (wei) | | `SELL` | shares + * (wei) | USDT (wei) | - \"Note on `side` encoding: this request uses a string + * enum (`BUY`/`SELL`). Responses from Get Blocktrade Detail / Preview / + * List return `side` as an integer and also include a `quoteType` string — + * both encode the same concept.\" | Request `side` | Response `side` + * (Integer) | Response `quoteType` | | --------------- | -------------------------- | + * ---------------------- | | `BUY` | `0` | `\"Bid\"` | + * | `SELL` | `1` | `\"Ask\"` | + * + * @throws ApiException if the Api call fails + */ + @Test + public void createOtcBlocktradeTest() throws ApiException, CryptoException, IOException { + CreateOtcBlocktradeRequest createOtcBlocktradeRequest = new CreateOtcBlocktradeRequest(); + createOtcBlocktradeRequest.marketId("123"); + createOtcBlocktradeRequest.tokenId( + "71321045679252212594626385532706912750332728571942532289631379312455583992563"); + createOtcBlocktradeRequest.side(Side.BUY); + createOtcBlocktradeRequest.makerAmount("600000000000000000000"); + createOtcBlocktradeRequest.takerAmount("1000000000000000000000"); + createOtcBlocktradeRequest.pricePerShare("0.65"); + createOtcBlocktradeRequest.expiration(1790000000L); + + ApiResponse response = + api.createOtcBlocktrade(createOtcBlocktradeRequest); + + ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); + Mockito.verify(apiClientSpy) + .execute(callArgumentCaptor.capture(), Mockito.any(java.lang.reflect.Type.class)); + + ArgumentCaptor signInputCaptor = ArgumentCaptor.forClass(String.class); + Mockito.verify(signatureGeneratorSpy).signAsString(signInputCaptor.capture()); + + Call captorValue = callArgumentCaptor.getValue(); + Request actualRequest = captorValue.request(); + + assertEquals("timestamp=1736393892000side=BUY&tokenId=71321045679252212594626385532706912750332728571942532289631379312455583992563&makerAmount=600000000000000000000&takerAmount=1000000000000000000000&expiration=1790000000&pricePerShare=0.65&marketId=123", signInputCaptor.getValue()); + assertEquals( + "3a9caa2f306723db3768a8ed7552f344309df9470fc215a5f3babd8fac13d446", actualRequest.url().queryParameter("signature")); + assertEquals("/sapi/v1/w3w/wallet/prediction/otc/blocktrade/create", actualRequest.url().encodedPath()); + } + + /** + * Fulfil OTC Blocktrade (PREDICTION_TRADE) + * + *

Fulfil an open maker blocktrade as the taker, using the `secretToken` the maker + * shared out-of-band. All-or-nothing fill (no partial fill); the taker order is the + * server-derived symmetric inverse of the maker order. Weight(IP): 200 Security Type: + * PREDICTION_TRADE Notes: - Restricted to authorized market makers. Requests from unauthorized + * accounts are rejected — contact BD to request access. + * + * @throws ApiException if the Api call fails + */ + @Test + public void fulfilOtcBlocktradeTest() throws ApiException, CryptoException, IOException { + FulfilOtcBlocktradeRequest fulfilOtcBlocktradeRequest = new FulfilOtcBlocktradeRequest(); + fulfilOtcBlocktradeRequest.orderId("26080500000001234567"); + fulfilOtcBlocktradeRequest.secretToken("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); + + ApiResponse response = + api.fulfilOtcBlocktrade(fulfilOtcBlocktradeRequest); + + ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); + Mockito.verify(apiClientSpy) + .execute(callArgumentCaptor.capture(), Mockito.any(java.lang.reflect.Type.class)); + + ArgumentCaptor signInputCaptor = ArgumentCaptor.forClass(String.class); + Mockito.verify(signatureGeneratorSpy).signAsString(signInputCaptor.capture()); + + Call captorValue = callArgumentCaptor.getValue(); + Request actualRequest = captorValue.request(); + + assertEquals("timestamp=1736393892000orderId=26080500000001234567&secretToken=a1b2c3d4-e5f6-7890-abcd-ef1234567890", signInputCaptor.getValue()); + assertEquals( + "10449b3f7d0aa23528ed45d83a5d546bbf6af2c1699c78e4505060c003c4d1a8", actualRequest.url().queryParameter("signature")); + assertEquals("/sapi/v1/w3w/wallet/prediction/otc/blocktrade/fulfil", actualRequest.url().encodedPath()); + } + + /** + * Get OTC Blocktrade Detail (PREDICTION_TRADE) + * + *

Query the maker's own blocktrade by `orderId`. Returns full order data + * including status and `secretToken`. Weight(IP): 200 Security Type: PREDICTION_TRADE + * Notes: - Restricted to authorized market makers. Requests from unauthorized accounts are + * rejected — contact BD to request access. + * + * @throws ApiException if the Api call fails + */ + @Test + public void getOtcBlocktradeDetailTest() throws ApiException, CryptoException, IOException { + GetOtcBlocktradeDetailRequest getOtcBlocktradeDetailRequest = + new GetOtcBlocktradeDetailRequest(); + getOtcBlocktradeDetailRequest.orderId("26080500000001234567"); + + ApiResponse response = + api.getOtcBlocktradeDetail(getOtcBlocktradeDetailRequest); + + ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); + Mockito.verify(apiClientSpy) + .execute(callArgumentCaptor.capture(), Mockito.any(java.lang.reflect.Type.class)); + + ArgumentCaptor signInputCaptor = ArgumentCaptor.forClass(String.class); + Mockito.verify(signatureGeneratorSpy).signAsString(signInputCaptor.capture()); + + Call captorValue = callArgumentCaptor.getValue(); + Request actualRequest = captorValue.request(); + + assertEquals("timestamp=1736393892000orderId=26080500000001234567", signInputCaptor.getValue()); + assertEquals( + "52743a81e25f2b413ec493a5ac5c99afa26a9cf3cb16f29a6ebb56c031a19e56", + actualRequest.url().queryParameter("signature")); + assertEquals("/sapi/v1/w3w/wallet/prediction/otc/blocktrade/detail", actualRequest.url().encodedPath()); + } + + /** + * Get OTC Blocktrade Events (PREDICTION_TRADE) + * + *

Paginated feed of blocktrade lifecycle and settlement events (CREATE, FULFIL, + * MATCH_SUBMIT, MATCH_SUCCESS, EXPIRE, FAILED, etc.). Weight(IP): 200 Security Type: + * PREDICTION_TRADE Notes: - Restricted to authorized market makers. Requests from unauthorized + * accounts are rejected — contact BD to request access. + * + * @throws ApiException if the Api call fails + */ + @Test + public void getOtcBlocktradeEventsTest() throws ApiException, CryptoException, IOException { + GetOtcBlocktradeEventsRequest getOtcBlocktradeEventsRequest = + new GetOtcBlocktradeEventsRequest(); + + ApiResponse response = + api.getOtcBlocktradeEvents(getOtcBlocktradeEventsRequest); + + ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); + Mockito.verify(apiClientSpy) + .execute(callArgumentCaptor.capture(), Mockito.any(java.lang.reflect.Type.class)); + + ArgumentCaptor signInputCaptor = ArgumentCaptor.forClass(String.class); + Mockito.verify(signatureGeneratorSpy).signAsString(signInputCaptor.capture()); + + Call captorValue = callArgumentCaptor.getValue(); + Request actualRequest = captorValue.request(); + + assertEquals("timestamp=1736393892000", signInputCaptor.getValue()); + assertEquals( + "53668e00dc92eb93de0b253c301e9fc0c20042b13db384a0ad94b38688a5a84c", + actualRequest.url().queryParameter("signature")); + assertEquals("/sapi/v1/w3w/wallet/prediction/otc/blocktrade/events", actualRequest.url().encodedPath()); + } + + /** + * Get OTC Reserved Balances (PREDICTION_TRADE) + * + *

Query PredictFun reserved balances for the caller's bound wallet — these are funds + * locked by the caller's open OTC blocktrade orders (maker BID locks USDT, maker ASK locks + * shares). Not tied to a specific blocktrade id; the path nesting under + * `otc/blocktrade` reflects the cause of the lock, not a per-order query. Returns one + * entry per requested asset, aligned with the request order. Pass + * `{type:\"USDT\"}` for reserved USDT, or `{type:\"SHARE\", + * tokenId:\"...\"}` for a specific outcome token's reserved shares. + * Weight(IP): 200 Security Type: PREDICTION_TRADE Notes: - Restricted to authorized market + * makers. Requests from unauthorized accounts are rejected — contact BD to request access. - + * AssetQuery: | Name | Type | Mandatory | Description | | ------- | ------ | --------- | + * ----------- | | type | STRING | YES | Asset type. Enum: `USDT`, `SHARE` | + * | tokenId | STRING | NO | Outcome token id (present for `SHARE` entries only) | + * + * @throws ApiException if the Api call fails + */ + @Test + public void getOtcReservedBalancesTest() throws ApiException, CryptoException, IOException { + GetOtcReservedBalancesRequest getOtcReservedBalancesRequest = + new GetOtcReservedBalancesRequest(); + getOtcReservedBalancesRequest.assets(new Assets()); + + ApiResponse response = + api.getOtcReservedBalances(getOtcReservedBalancesRequest); + + ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); + Mockito.verify(apiClientSpy) + .execute(callArgumentCaptor.capture(), Mockito.any(java.lang.reflect.Type.class)); + + ArgumentCaptor signInputCaptor = ArgumentCaptor.forClass(String.class); + Mockito.verify(signatureGeneratorSpy).signAsString(signInputCaptor.capture()); + + Call captorValue = callArgumentCaptor.getValue(); + Request actualRequest = captorValue.request(); + + assertEquals("timestamp=1736393892000assets=%5B%5D", signInputCaptor.getValue()); + assertEquals( + "b12af74f0cdddb750ae86732c219cc3b4db5118eebaf08f819fa1cf9184d47b7", + actualRequest.url().queryParameter("signature")); + assertEquals("/sapi/v1/w3w/wallet/prediction/otc/blocktrade/reserved-balances", actualRequest.url().encodedPath()); + } + + /** + * List OTC Blocktrades (PREDICTION_TRADE) + * + *

List the maker's own blocktrades with optional status filter and cursor pagination. + * Weight(IP): 200 Security Type: PREDICTION_TRADE Notes: - Restricted to authorized market + * makers. Requests from unauthorized accounts are rejected — contact BD to request access. + * + * @throws ApiException if the Api call fails + */ + @Test + public void listOtcBlocktradesTest() throws ApiException, CryptoException, IOException { + ListOtcBlocktradesRequest listOtcBlocktradesRequest = new ListOtcBlocktradesRequest(); + + ApiResponse response = + api.listOtcBlocktrades(listOtcBlocktradesRequest); + + ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); + Mockito.verify(apiClientSpy) + .execute(callArgumentCaptor.capture(), Mockito.any(java.lang.reflect.Type.class)); + + ArgumentCaptor signInputCaptor = ArgumentCaptor.forClass(String.class); + Mockito.verify(signatureGeneratorSpy).signAsString(signInputCaptor.capture()); + + Call captorValue = callArgumentCaptor.getValue(); + Request actualRequest = captorValue.request(); + + assertEquals("timestamp=1736393892000", signInputCaptor.getValue()); + assertEquals( + "53668e00dc92eb93de0b253c301e9fc0c20042b13db384a0ad94b38688a5a84c", actualRequest.url().queryParameter("signature")); + assertEquals("/sapi/v1/w3w/wallet/prediction/otc/blocktrade/list", actualRequest.url().encodedPath()); + } + + /** + * Preview OTC Blocktrade (PREDICTION_TRADE) + * + *

Inspect an open blocktrade by `secretToken` (no `orderId` needed). + * Taker uses this to preview the maker order before fulfilling. Returns the same shape as + * `Get Blocktrade Detail`, but `orderId` is `null` and + * `secretToken` is never returned from this endpoint. Weight(IP): 200 Security Type: + * PREDICTION_TRADE Notes: - Restricted to authorized market makers. Requests from unauthorized + * accounts are rejected — contact BD to request access. + * + * @throws ApiException if the Api call fails + */ + @Test + public void previewOtcBlocktradeTest() throws ApiException, CryptoException, IOException { + PreviewOtcBlocktradeRequest previewOtcBlocktradeRequest = new PreviewOtcBlocktradeRequest(); + previewOtcBlocktradeRequest.secretToken("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); + + ApiResponse response = + api.previewOtcBlocktrade(previewOtcBlocktradeRequest); + + ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); + Mockito.verify(apiClientSpy) + .execute(callArgumentCaptor.capture(), Mockito.any(java.lang.reflect.Type.class)); + + ArgumentCaptor signInputCaptor = ArgumentCaptor.forClass(String.class); + Mockito.verify(signatureGeneratorSpy).signAsString(signInputCaptor.capture()); + + Call captorValue = callArgumentCaptor.getValue(); + Request actualRequest = captorValue.request(); + + assertEquals("timestamp=1736393892000secretToken=a1b2c3d4-e5f6-7890-abcd-ef1234567890", signInputCaptor.getValue()); + assertEquals( + "600959da09e7d2060ed7271350a04eecc2e559db5038d937adb457951255abaf", + actualRequest.url().queryParameter("signature")); + assertEquals("/sapi/v1/w3w/wallet/prediction/otc/blocktrade/preview", actualRequest.url().encodedPath()); + } + + /** + * Remove OTC Blocktrades (PREDICTION_TRADE) + * + *

Cancel open or fulfilled-but-unsettled blocktrades. Terminal orders (already + * `MATCHED`/`CANCELLED`/`EXPIRED`/`FAILED`) are + * returned in `noop` instead of `removed`. Weight(IP): 200 Security Type: + * PREDICTION_TRADE Notes: - Restricted to authorized market makers. Requests from unauthorized + * accounts are rejected — contact BD to request access. + * + * @throws ApiException if the Api call fails + */ + @Test + public void removeOtcBlocktradesTest() throws ApiException, CryptoException, IOException { + RemoveOtcBlocktradesRequest removeOtcBlocktradesRequest = new RemoveOtcBlocktradesRequest(); + removeOtcBlocktradesRequest.orderIds(new OrderIds()); + + ApiResponse response = + api.removeOtcBlocktrades(removeOtcBlocktradesRequest); + + ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); + Mockito.verify(apiClientSpy) + .execute(callArgumentCaptor.capture(), Mockito.any(java.lang.reflect.Type.class)); + + ArgumentCaptor signInputCaptor = ArgumentCaptor.forClass(String.class); + Mockito.verify(signatureGeneratorSpy).signAsString(signInputCaptor.capture()); + + Call captorValue = callArgumentCaptor.getValue(); + Request actualRequest = captorValue.request(); + + assertEquals("timestamp=1736393892000orderIds=%5B%5D", signInputCaptor.getValue()); + assertEquals( + "3f4e97de0c280ad415959df59e999c3718b3bbe1e8eda987c5897f0ab1254dfe", + actualRequest.url().queryParameter("signature")); + assertEquals("/sapi/v1/w3w/wallet/prediction/otc/blocktrade/remove", actualRequest.url().encodedPath()); + } +} diff --git a/clients/w3w-prediction/src/test/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/DefaultApiTest.java b/clients/w3w-prediction/src/test/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/DefaultApiTest.java new file mode 100644 index 000000000..bc6c5b4c6 --- /dev/null +++ b/clients/w3w-prediction/src/test/java/com/binance/connector/client/w3w_prediction/websocket/stream/api/DefaultApiTest.java @@ -0,0 +1,591 @@ +/* + * Prediction Trading Streams + * Binance Web3 Prediction pushes 14 types of per-user business events in real time via the Binance SApi WebSocket channel, covering trading (market / limit), reward claim, fund transfer and market resolution, plus order book (bid/ask) quotes broadcast per topic. Business events are routed by exact `(topic, userId)` match; order book topics are broadcast to every subscriber. Delivery is at-most-once, ordering is not guaranteed, and offline messages are not cached — pull the latest state via the REST API after reconnecting and deduplicate on `pushId` (business events) or `marketId` + `updateTimestampMs` (order book). + * + * 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.w3w_prediction.websocket.stream.api; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.adapter.stream.SignedStreamConnectionWrapper; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.dtos.RequestWrapperDTO; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.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.File; +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.Set; +import java.util.concurrent.CompletableFuture; + +/** API tests for DefaultApi */ +public class DefaultApiTest { + + private DefaultApi api; + private SignedStreamConnectionWrapper connectionSpy; + private Session sessionMock; + + @BeforeEach + public void initApiClient() throws Exception { + URL resource = DefaultApi.class.getResource("/test-ed25519-prv-key.pem"); + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + File file = new File(resource.toURI()); + signatureConfiguration.setPrivateKey(file.getAbsolutePath()); + WebSocketClientConfiguration clientConfiguration = new WebSocketClientConfiguration(); + // @TODO: run tests for LOGON as well + 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); + SignedStreamConnectionWrapper connectionWrapper = + new SignedStreamConnectionWrapper(clientConfiguration, webSocketClient); + connectionSpy = Mockito.spy(connectionWrapper); + Mockito.doNothing().when(connectionSpy).setUserAgent(Mockito.anyString()); + Mockito.doReturn(1736393892000L).when(connectionSpy).getTimestamp(); + DefaultApi apiClient = new DefaultApi(connectionSpy); + api = Mockito.spy(apiClient); + Mockito.doReturn("eaf3292c-64b6-4c04-ad4f-4ca2608b42b4").when(api).getRequestID(); + } + + /** + * Batch claim partially succeeded + * + *

Pushed when a batch claim is **partially successful** (some items succeed, some fail). The + * `refId` inside `pushId` is the claim `batchId`. This scenario + * contains **only** `pushId` — query the REST API for details. Update Speed: + * Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void batchClaimPartiallySucceededTest() + throws ApiException, URISyntaxException, IOException { + + StreamBlockingQueueWrapper response = + api.batchClaimPartiallySucceeded(); + ArgumentCaptor, BatchClaimPartiallySucceededResponse>> + 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, BatchClaimPartiallySucceededResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_claim_partial_success-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Fund transfer failed + * + *

Pushed when a fund transfer fails. The `refId` inside `pushId` is the + * `transferId`. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void fundTransferFailedTest() throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.fundTransferFailed(); + ArgumentCaptor, FundTransferFailedResponse>> + 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, FundTransferFailedResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_transfer_fail-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Fund transfer succeeded + * + *

Pushed when a fund transfer succeeds (deposit into the prediction wallet, or withdrawal + * out of it). The `refId` inside `pushId` is + * `FundTransferOrder.transferId`. The direction is not distinguished and the token + * type is not carried (currently USDT only). Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void fundTransferSucceededTest() throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.fundTransferSucceeded(); + ArgumentCaptor, FundTransferSucceededResponse>> + 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, FundTransferSucceededResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_transfer_success-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Limit order fully filled + * + *

Pushed when a previously placed **limit order** is fully filled. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void limitOrderFullyFilledTest() throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.limitOrderFullyFilled(); + ArgumentCaptor, LimitOrderFullyFilledResponse>> + 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, LimitOrderFullyFilledResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_limit_order_filled-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Limit order partially filled + * + *

Pushed on every new partial fill of a **limit order** (`PARTIALLY_FILLED`). A + * single order may trigger multiple pushes, so clients **must** deduplicate on + * `pushId`. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void limitOrderPartiallyFilledTest() + throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.limitOrderPartiallyFilled(); + ArgumentCaptor, LimitOrderPartiallyFilledResponse>> + 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, LimitOrderPartiallyFilledResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_limit_order_partial_fill-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Limit order submission failed + * + *

Pushed when a **limit order** is rejected at submission time. This scenario does **not** + * carry the `amount` field. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void limitOrderSubmissionFailedTest() + throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.limitOrderSubmissionFailed(); + ArgumentCaptor, LimitOrderSubmissionFailedResponse>> + 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, LimitOrderSubmissionFailedResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_fail-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Limit order submitted successfully + * + *

Pushed when the user's **limit order** is successfully placed on the order book. + * Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void limitOrderSubmittedSuccessfullyTest() + throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.limitOrderSubmittedSuccessfully(); + ArgumentCaptor, LimitOrderSubmittedSuccessfullyResponse>> + 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, LimitOrderSubmittedSuccessfullyResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_success-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Market buy order failed / expired + * + *

Pushed when the user's **market buy order** transitions to `FAILED` or + * `EXPIRED`. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void marketBuyOrderFailedTest() throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.marketBuyOrderFailed(); + ArgumentCaptor, MarketBuyOrderFailedResponse>> + 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, MarketBuyOrderFailedResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_market_buy_fail-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Market buy order fully filled + * + *

Pushed when the user's **market buy order** is fully filled (`OrderStatus = + * FILLED`). Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void marketBuyOrderFullyFilledTest() + throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.marketBuyOrderFullyFilled(); + ArgumentCaptor, MarketBuyOrderFullyFilledResponse>> + 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, MarketBuyOrderFullyFilledResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_market_buy_success-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Market resolution notification + * + *

Pushed after a market is resolved (`Market.status = RESOLVED`) to every + * user holding any outcome position in that market, regardless of win or loss. The + * `refId` inside `pushId` is the `marketId` (not the + * `outcomeId`). This scenario carries no `amount` / `outcome` / + * `isWinner` field — query the REST API after receiving the push to display user PnL. + * Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void marketResolutionNotificationTest() + throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.marketResolutionNotification(); + ArgumentCaptor, MarketResolutionNotificationResponse>> + 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, MarketResolutionNotificationResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_market_close-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Market sell order failed / expired + * + *

Pushed when the user's **market sell order** transitions to `FAILED` or + * `EXPIRED`. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void marketSellOrderFailedExpiredTest() + throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.marketSellOrderFailedExpired(); + ArgumentCaptor, MarketSellOrderFailedExpiredResponse>> + 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, MarketSellOrderFailedExpiredResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_market_sell_fail-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Market sell order fully filled + * + *

Pushed when the user's **market sell order** is fully filled (`OrderStatus = + * FILLED`). Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void marketSellOrderFullyFilledTest() + throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.marketSellOrderFullyFilled(); + ArgumentCaptor, MarketSellOrderFullyFilledResponse>> + 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, MarketSellOrderFullyFilledResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_market_sell_success-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Prediction Order Book by marketId + * + *

Subscribe to the order book (bid/ask) updates of a single market. Only continuously + * updating active markets are pushed — resolved or closed markets are not. Quotes come from the + * upstream market maker, so the channel pauses rather than pushing empty data when upstream + * disconnects. Subscribing to this topic **and** the aggregated + * `web3_prediction_orderbook_data` topic delivers each quote twice — deduplicate on + * `marketId` + `updateTimestampMs`. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void predictionOrderBookByMarketIdTest() + throws ApiException, URISyntaxException, IOException { + PredictionOrderBookByMarketIdRequest predictionOrderBookByMarketIdRequest = + new PredictionOrderBookByMarketIdRequest(); + + predictionOrderBookByMarketIdRequest.setMarketId("777"); + + StreamBlockingQueueWrapper response = + api.predictionOrderBookByMarketId(predictionOrderBookByMarketIdRequest); + ArgumentCaptor, PredictionOrderBookByMarketIdResponse>> + 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, PredictionOrderBookByMarketIdResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_orderbook_marketId-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Reward claim failed + * + *

Pushed when a claim **entirely fails** (a single claim, or every item of a batch). The + * `refId` inside `pushId` is the claim `batchId`. Even when + * several items of a batch fail, only the **first** item's `amount` / + * `outcome` is carried. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void rewardClaimFailedTest() throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.rewardClaimFailed(); + ArgumentCaptor, RewardClaimFailedResponse>> + 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, RewardClaimFailedResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_claim_fail-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } + + /** + * Reward claim succeeded + * + *

Pushed when a claim **fully succeeds** (a single claim, or every item of a batch). The + * `refId` inside `pushId` is the claim `batchId`. This scenario + * carries no `topic` / `outcome` field — even a single claim reports only + * the total. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + @Test + public void rewardClaimSucceededTest() throws ApiException, URISyntaxException, IOException { + StreamBlockingQueueWrapper response = + api.rewardClaimSucceeded(); + ArgumentCaptor, RewardClaimSucceededResponse>> + 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, RewardClaimSucceededResponse> requestWrapperDTO = + callArgumentCaptor.getValue(); + Set params = requestWrapperDTO.getParams(); + // TODO: test validations + String sentPayload = sendArgumentCaptor.getValue(); + + URL resource = + DefaultApiTest.class.getResource( + "/expected/stream/DefaultApi/web3_prediction_pm_claim_success-test.json"); + + String expectedJson = Files.readString(Paths.get(resource.toURI())); + JSONAssert.assertEquals(expectedJson, sentPayload, true); + } +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_orderbook_data-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_orderbook_data-test.json new file mode 100644 index 000000000..b739399c6 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_orderbook_data-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_orderbook_data" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_orderbook_marketId-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_orderbook_marketId-test.json new file mode 100644 index 000000000..99790a1e7 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_orderbook_marketId-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_orderbook_777" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_fail-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_fail-test.json new file mode 100644 index 000000000..b7b400a32 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_fail-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_claim_fail" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_partial_success-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_partial_success-test.json new file mode 100644 index 000000000..3e4976afc --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_partial_success-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_claim_partial_success" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_success-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_success-test.json new file mode 100644 index 000000000..ac343aa36 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_claim_success-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_claim_success" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_order_filled-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_order_filled-test.json new file mode 100644 index 000000000..b8aef63df --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_order_filled-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_limit_order_filled" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_order_partial_fill-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_order_partial_fill-test.json new file mode 100644 index 000000000..62855e11c --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_order_partial_fill-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_limit_order_partial_fill" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_fail-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_fail-test.json new file mode 100644 index 000000000..3a5016497 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_fail-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_limit_submit_fail" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_success-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_success-test.json new file mode 100644 index 000000000..b9a1b54e0 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_limit_submit_success-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_limit_submit_success" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_buy_fail-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_buy_fail-test.json new file mode 100644 index 000000000..6454f63f4 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_buy_fail-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_market_buy_fail" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_buy_success-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_buy_success-test.json new file mode 100644 index 000000000..04ddf77ea --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_buy_success-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_market_buy_success" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_close-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_close-test.json new file mode 100644 index 000000000..783d4a5e8 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_close-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_market_close" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_sell_fail-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_sell_fail-test.json new file mode 100644 index 000000000..fe55301bb --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_sell_fail-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_market_sell_fail" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_sell_success-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_sell_success-test.json new file mode 100644 index 000000000..13685b594 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_market_sell_success-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_market_sell_success" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_transfer_fail-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_transfer_fail-test.json new file mode 100644 index 000000000..a323322b6 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_transfer_fail-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_transfer_fail" +} diff --git a/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_transfer_success-test.json b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_transfer_success-test.json new file mode 100644 index 000000000..9d309da06 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/expected/stream/DefaultApi/web3_prediction_pm_transfer_success-test.json @@ -0,0 +1,4 @@ +{ + "command": "SUBSCRIBE", + "value": "web3_prediction_pm_transfer_success" +} diff --git a/clients/w3w-prediction/src/test/resources/test-ed25519-prv-key.pem b/clients/w3w-prediction/src/test/resources/test-ed25519-prv-key.pem new file mode 100644 index 000000000..f6cbbe619 --- /dev/null +++ b/clients/w3w-prediction/src/test/resources/test-ed25519-prv-key.pem @@ -0,0 +1,3 @@ +-----BEGIN PRIVATE KEY----- +MC4CAQAwBQYDK2VwBCIEILpXm6EtDzSzPJWHTbP904h5R3bzb0QsLjTf1tAt2OlB +-----END PRIVATE KEY----- diff --git a/examples/cms/pom.xml b/examples/cms/pom.xml new file mode 100644 index 000000000..cec69064c --- /dev/null +++ b/examples/cms/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + binance-cms-examples + cms + 1.0.0 + jar + + + io.github.binance + binance-connector-java-examples + 1.0.0 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + -parameters + + + + + + + + io.github.binance + binance-cms + 1.0.0 + + + \ No newline at end of file diff --git a/examples/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/defaultpkg/ComAnnouncementEnExample.java b/examples/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/defaultpkg/ComAnnouncementEnExample.java new file mode 100644 index 000000000..2374b87fd --- /dev/null +++ b/examples/cms/src/main/java/com/binance/connector/client/cms/websocket/stream/defaultpkg/ComAnnouncementEnExample.java @@ -0,0 +1,40 @@ +package com.binance.connector.client.cms.websocket.stream.defaultpkg; + +import com.binance.connector.client.cms.websocket.stream.CmsWebSocketStreamsUtil; +import com.binance.connector.client.cms.websocket.stream.api.CmsWebSocketStreams; +import com.binance.connector.client.cms.websocket.stream.model.ComAnnouncementEnResponse; +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; + +/** API examples for DefaultApi */ +public class ComAnnouncementEnExample { + private CmsWebSocketStreams api; + + public CmsWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + CmsWebSocketStreamsUtil.getClientConfiguration(signatureConfiguration); + api = new CmsWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Receive push notifications hen Binance publishes announcements in English (language code: + * en). + * + * @throws ApiException if the Api call fails + */ + public void comAnnouncementEnExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().comAnnouncementEn(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/pom.xml b/examples/pom.xml index 43665a826..2e784cd55 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,6 +18,7 @@ algo alpha c2c + cms convert copy-trading crypto-loan diff --git a/examples/w3w-prediction/pom.xml b/examples/w3w-prediction/pom.xml index 8a6581f92..0ab22c0d6 100644 --- a/examples/w3w-prediction/pom.xml +++ b/examples/w3w-prediction/pom.xml @@ -31,7 +31,7 @@ io.github.binance binance-w3w-prediction - 2.1.2 + 2.2.0 \ No newline at end of file diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/GetMarketDetailExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/GetMarketDetailExample.java index 8ba6ca222..f42c811da 100644 --- a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/GetMarketDetailExample.java +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/GetMarketDetailExample.java @@ -30,7 +30,26 @@ public W3WPredictionRestApi getApi() { * Get Market Detail * *

Get full details for a specific prediction market topic, including variant data and - * timeline. Weight(IP): 1 + * timeline. Weight(IP): 1 Response Notes: - `status` is a case-sensitive string. + * `REGISTERED`: registered and not yet resolved, this value alone does not guarantee + * that trading is available. `RESOLVED`: the outcome has been determined, it does not + * mean that the user has already claimed the payout. `PAUSED`: trading is temporarily + * suspended and may resume. `CLOSED`: closed for display, for example the end time + * has passed or the market was removed, it does not guarantee that trading is closed. - + * `markets[].tradingStatus` shows whether new orders may be attempted. + * `OPEN`: new orders may be attempted, this is the only value that allows new orders. + * `MATCHING_NOT_ENABLED`: order matching is not enabled. `CANCEL_ONLY`: + * only cancellation is allowed. `CLOSED`: trading has stopped. Use + * `markets[].tradingStatus`, not `status`, to decide whether to place an + * order, because a market whose `status` is `CLOSED` can still have + * `tradingStatus` `OPEN`. A topic can contain several markets and an order + * is placed on one market, so only the `tradingStatus` of that market matters. A + * successful quote does not guarantee that an order is accepted or filled. - + * `outcomes[].winner` is returned only after the market is resolved. There is no + * separate cancelled, invalid or refunded status. A resolved market can pay more than one + * outcome, in that case several outcomes have `winner` set to `true` and + * `price` is the settled value per share, for example `0.5` for each of two + * outcomes. * * @throws ApiException if the Api call fails */ diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/ListPredictionMarketsExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/ListPredictionMarketsExample.java index ecf62ead1..c531d55f2 100644 --- a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/ListPredictionMarketsExample.java +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/marketdata/ListPredictionMarketsExample.java @@ -32,7 +32,8 @@ public W3WPredictionRestApi getApi() { * List Prediction Markets * *

Get a paginated list of prediction market topics, with optional category and sort filters. - * Weight(IP): 1 + * Weight(IP): 1 Response Notes: - For the values of `status` and + * `markets[].tradingStatus`, see Get Market Detail. * * @throws ApiException if the Api call fails */ diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/position/QuerySettledPositionHistoryExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/position/QuerySettledPositionHistoryExample.java index 823182567..0db236eaa 100644 --- a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/position/QuerySettledPositionHistoryExample.java +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/position/QuerySettledPositionHistoryExample.java @@ -30,7 +30,12 @@ public W3WPredictionRestApi getApi() { * Query Settled Position History (PREDICTION_TRADE) * *

Get the authenticated user's settled (resolved) prediction position history with - * optional filters. Weight(IP): 1 Security Type: PREDICTION_TRADE + * optional filters. Weight(IP): 1 Security Type: PREDICTION_TRADE Response Notes: - There is no + * separate cancelled, invalid or refunded status. A resolved market pays each outcome by its + * payout ratio, which can be fractional, for example `0.5` for each of two outcomes. + * This is not a refund of the purchase cost. Use `finalOutcome`, + * `isWinner`, `claimAmount` and `redeemStatus` together with your + * own claim records, and Get Market Detail for `outcomes[].winner`. * * @throws ApiException if the Api call fails */ diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/trade/GetQuoteExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/trade/GetQuoteExample.java index 5bcb3d1cd..dbacd06db 100644 --- a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/trade/GetQuoteExample.java +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest/trade/GetQuoteExample.java @@ -37,11 +37,14 @@ public W3WPredictionRestApi getApi() { * Notes: - `feeAmount` is a string because it is denominated in wei (18 decimals) and * may exceed JavaScript's safe integer range. `feeDiscountBps` is also a string * to allow fractional basis-point values in the future. `feeRateBps` and - * `slippageBps` are integers and will never exceed safe integer bounds. - **MARKET - * order minimum amount:** For `MARKET` orders, `amountIn` must be at least - * approximately **1.5 USDT** (in wei: `1500000000000000000`). The exact minimum - * varies by market liquidity. If the amount is too small, the server returns `-9000 Your - * order amount is too small`. This limit does **not** apply to `LIMIT` orders. + * `slippageBps` are integers and will never exceed safe integer bounds. - **Minimum + * order amount:** The minimum order amount is set by the server and the upstream market rules + * and may change, so no fixed value is documented. `BUY` orders are checked by amount + * (`amountIn`) and `SELL` orders by share quantity, for both + * `MARKET` and `LIMIT` orders. If the `amountIn` of a + * `BUY` order is below the minimum, the server returns `-9000` with the + * message `Your order amount is too small`. A successful quote does not guarantee + * that the order is accepted or filled, so check the error message and the final order status. * * @throws ApiException if the Api call fails */ diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/BatchClaimPartiallySucceededExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/BatchClaimPartiallySucceededExample.java new file mode 100644 index 000000000..ecb38a76d --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/BatchClaimPartiallySucceededExample.java @@ -0,0 +1,43 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.BatchClaimPartiallySucceededResponse; + +/** API examples for DefaultApi */ +public class BatchClaimPartiallySucceededExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Batch claim partially succeeded + * + *

Pushed when only part of a batch claim succeeds. Only `pushId` is included — + * call the REST API for details. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void batchClaimPartiallySucceededExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().batchClaimPartiallySucceeded(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferFailedExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferFailedExample.java new file mode 100644 index 000000000..997c0bd7a --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferFailedExample.java @@ -0,0 +1,42 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.FundTransferFailedResponse; + +/** API examples for DefaultApi */ +public class FundTransferFailedExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Fund transfer failed + * + *

Pushed when a fund transfer fails. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void fundTransferFailedExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().fundTransferFailed(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferSucceededExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferSucceededExample.java new file mode 100644 index 000000000..8ae00febe --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/FundTransferSucceededExample.java @@ -0,0 +1,43 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.FundTransferSucceededResponse; + +/** API examples for DefaultApi */ +public class FundTransferSucceededExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Fund transfer succeeded + * + *

Pushed when a fund transfer into or out of the prediction wallet succeeds. The direction + * and the token are not included (currently USDT only). Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void fundTransferSucceededExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().fundTransferSucceeded(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderFullyFilledExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderFullyFilledExample.java new file mode 100644 index 000000000..03920fe4a --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderFullyFilledExample.java @@ -0,0 +1,42 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderFullyFilledResponse; + +/** API examples for DefaultApi */ +public class LimitOrderFullyFilledExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Limit order fully filled + * + *

Pushed when a **limit order** is fully filled. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void limitOrderFullyFilledExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().limitOrderFullyFilled(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderPartiallyFilledExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderPartiallyFilledExample.java new file mode 100644 index 000000000..353c578bf --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderPartiallyFilledExample.java @@ -0,0 +1,43 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderPartiallyFilledResponse; + +/** API examples for DefaultApi */ +public class LimitOrderPartiallyFilledExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Limit order partially filled + * + *

Pushed on each new partial fill of a **limit order**. One order can be pushed several + * times, so always remove duplicates by `pushId`. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void limitOrderPartiallyFilledExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().limitOrderPartiallyFilled(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmissionFailedExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmissionFailedExample.java new file mode 100644 index 000000000..93d0fa5ec --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmissionFailedExample.java @@ -0,0 +1,43 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderSubmissionFailedResponse; + +/** API examples for DefaultApi */ +public class LimitOrderSubmissionFailedExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Limit order submission failed + * + *

Pushed when a **limit order** is rejected when placed. No `amount` is included. + * Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void limitOrderSubmissionFailedExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().limitOrderSubmissionFailed(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmittedSuccessfullyExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmittedSuccessfullyExample.java new file mode 100644 index 000000000..6d58f966c --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/LimitOrderSubmittedSuccessfullyExample.java @@ -0,0 +1,43 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.LimitOrderSubmittedSuccessfullyResponse; + +/** API examples for DefaultApi */ +public class LimitOrderSubmittedSuccessfullyExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Limit order submitted successfully + * + *

Pushed when the user's **limit order** is successfully placed on the order book. + * Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void limitOrderSubmittedSuccessfullyExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().limitOrderSubmittedSuccessfully(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFailedExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFailedExample.java new file mode 100644 index 000000000..415b6f436 --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFailedExample.java @@ -0,0 +1,42 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketBuyOrderFailedResponse; + +/** API examples for DefaultApi */ +public class MarketBuyOrderFailedExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Market buy order failed / expired + * + *

Pushed when the user's **market buy order** fails or expires. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void marketBuyOrderFailedExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().marketBuyOrderFailed(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFullyFilledExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFullyFilledExample.java new file mode 100644 index 000000000..f093f6120 --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketBuyOrderFullyFilledExample.java @@ -0,0 +1,42 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketBuyOrderFullyFilledResponse; + +/** API examples for DefaultApi */ +public class MarketBuyOrderFullyFilledExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Market buy order fully filled + * + *

Pushed when the user's **market buy order** is fully filled. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void marketBuyOrderFullyFilledExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().marketBuyOrderFullyFilled(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketResolutionNotificationExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketResolutionNotificationExample.java new file mode 100644 index 000000000..5cb9be643 --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketResolutionNotificationExample.java @@ -0,0 +1,44 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketResolutionNotificationResponse; + +/** API examples for DefaultApi */ +public class MarketResolutionNotificationExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Market resolution notification + * + *

Pushed when a market is resolved, to every user holding a position in it, win or lose. No + * amount or outcome is included — call the REST API for the user's profit and loss. Update + * Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void marketResolutionNotificationExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().marketResolutionNotification(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFailedExpiredExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFailedExpiredExample.java new file mode 100644 index 000000000..5e4d39484 --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFailedExpiredExample.java @@ -0,0 +1,42 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketSellOrderFailedExpiredResponse; + +/** API examples for DefaultApi */ +public class MarketSellOrderFailedExpiredExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Market sell order failed / expired + * + *

Pushed when the user's **market sell order** fails or expires. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void marketSellOrderFailedExpiredExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().marketSellOrderFailedExpired(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFullyFilledExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFullyFilledExample.java new file mode 100644 index 000000000..8d6538d27 --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/MarketSellOrderFullyFilledExample.java @@ -0,0 +1,42 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.MarketSellOrderFullyFilledResponse; + +/** API examples for DefaultApi */ +public class MarketSellOrderFullyFilledExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Market sell order fully filled + * + *

Pushed when the user's **market sell order** is fully filled. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void marketSellOrderFullyFilledExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().marketSellOrderFullyFilled(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/PredictionOrderBookByMarketIdExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/PredictionOrderBookByMarketIdExample.java new file mode 100644 index 000000000..bd117cf07 --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/PredictionOrderBookByMarketIdExample.java @@ -0,0 +1,46 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.PredictionOrderBookByMarketIdRequest; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.PredictionOrderBookByMarketIdResponse; + +/** API examples for DefaultApi */ +public class PredictionOrderBookByMarketIdExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Prediction Order Book by marketId + * + *

Order book (bid/ask) updates for one market. Only active markets are pushed. Update Speed: + * Real-time + * + * @throws ApiException if the Api call fails + */ + public void predictionOrderBookByMarketIdExample() throws ApiException, InterruptedException { + PredictionOrderBookByMarketIdRequest predictionOrderBookByMarketIdRequest = + new PredictionOrderBookByMarketIdRequest(); + StreamBlockingQueueWrapper response = + getApi().predictionOrderBookByMarketId(predictionOrderBookByMarketIdRequest); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimFailedExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimFailedExample.java new file mode 100644 index 000000000..be38d09b7 --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimFailedExample.java @@ -0,0 +1,44 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.RewardClaimFailedResponse; + +/** API examples for DefaultApi */ +public class RewardClaimFailedExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Reward claim failed + * + *

Pushed when a claim fails completely — a single claim, or every item of a batch. For a + * batch, only the first failed item's amount and outcome are included. Update Speed: + * Real-time + * + * @throws ApiException if the Api call fails + */ + public void rewardClaimFailedExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().rewardClaimFailed(); + while (true) { + System.out.println(response.take()); + } + } +} diff --git a/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimSucceededExample.java b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimSucceededExample.java new file mode 100644 index 000000000..8a2084d25 --- /dev/null +++ b/examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/websocket/stream/defaultpkg/RewardClaimSucceededExample.java @@ -0,0 +1,43 @@ +package com.binance.connector.client.w3w_prediction.websocket.stream.defaultpkg; + +import com.binance.connector.client.common.ApiException; +import com.binance.connector.client.common.configuration.SignatureConfiguration; +import com.binance.connector.client.common.websocket.configuration.WebSocketClientConfiguration; +import com.binance.connector.client.common.websocket.service.StreamBlockingQueueWrapper; +import com.binance.connector.client.w3w_prediction.websocket.stream.W3WPredictionWebSocketStreamsUtil; +import com.binance.connector.client.w3w_prediction.websocket.stream.api.W3WPredictionWebSocketStreams; +import com.binance.connector.client.w3w_prediction.websocket.stream.model.RewardClaimSucceededResponse; + +/** API examples for DefaultApi */ +public class RewardClaimSucceededExample { + private W3WPredictionWebSocketStreams api; + + public W3WPredictionWebSocketStreams getApi() { + if (api == null) { + SignatureConfiguration signatureConfiguration = new SignatureConfiguration(); + signatureConfiguration.setApiKey("apiKey"); + signatureConfiguration.setPrivateKey("path/to/private.key"); + WebSocketClientConfiguration clientConfiguration = + W3WPredictionWebSocketStreamsUtil.getClientConfiguration( + signatureConfiguration); + api = new W3WPredictionWebSocketStreams(clientConfiguration); + } + return api; + } + + /** + * Reward claim succeeded + * + *

Pushed when a claim fully succeeds — a single claim, or every item of a batch. Only the + * total is reported; no market title or outcome is included. Update Speed: Real-time + * + * @throws ApiException if the Api call fails + */ + public void rewardClaimSucceededExample() throws ApiException, InterruptedException { + StreamBlockingQueueWrapper response = + getApi().rewardClaimSucceeded(); + while (true) { + System.out.println(response.take()); + } + } +}