11package com .binance .api .client ;
22
33import com .binance .api .client .impl .*;
4-
4+ import com . binance . api . client . config . BinanceApiConfig ;
55import static com .binance .api .client .impl .BinanceApiServiceGenerator .getSharedClient ;
66
77/**
@@ -28,6 +28,23 @@ public class BinanceApiClientFactory {
2828 private BinanceApiClientFactory (String apiKey , String secret ) {
2929 this .apiKey = apiKey ;
3030 this .secret = secret ;
31+ BinanceApiConfig .useTestnet = false ;
32+ BinanceApiConfig .useTestnetStreaming = false ;
33+ }
34+
35+ /**
36+ * Instantiates a new binance api client factory.
37+ *
38+ * @param apiKey the API key
39+ * @param secret the Secret
40+ * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL.
41+ * @param useTestnetStreaming true for spot test network websocket streaming; false for no streaming.
42+ */
43+ private BinanceApiClientFactory (String apiKey , String secret , boolean useTestnet , boolean useTestnetStreaming ) {
44+ this (apiKey , secret );
45+ if (useTestnet ) {
46+ BinanceApiConfig .useTestnet = true ;
47+ BinanceApiConfig .useTestnetStreaming = useTestnetStreaming ; }
3148 }
3249
3350 /**
@@ -42,6 +59,20 @@ public static BinanceApiClientFactory newInstance(String apiKey, String secret)
4259 return new BinanceApiClientFactory (apiKey , secret );
4360 }
4461
62+ /**
63+ * New instance with optional Spot Test Network endpoint.
64+ *
65+ * @param apiKey the API key
66+ * @param secret the Secret
67+ * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL.
68+ * @param useTestnetStreaming true for spot test network websocket streaming; false for no streaming.
69+ *
70+ * @return the binance api client factory.
71+ */
72+ public static BinanceApiClientFactory newInstance (String apiKey , String secret , boolean useTestnet , boolean useTestnetStreaming ) {
73+ return new BinanceApiClientFactory (apiKey , secret , useTestnet , useTestnetStreaming );
74+ }
75+
4576 /**
4677 * New instance without authentication.
4778 *
@@ -51,6 +82,18 @@ public static BinanceApiClientFactory newInstance() {
5182 return new BinanceApiClientFactory (null , null );
5283 }
5384
85+ /**
86+ * New instance without authentication and with optional Spot Test Network endpoint.
87+ *
88+ * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL.
89+ * @param useTestnetStreaming true for spot test network websocket streaming; false for no streaming.
90+ *
91+ * @return the binance api client factory.
92+ */
93+ public static BinanceApiClientFactory newInstance (boolean useTestnet , boolean useTestnetStreaming ) {
94+ return new BinanceApiClientFactory (null , null , useTestnet , useTestnetStreaming );
95+ }
96+
5497 /**
5598 * Creates a new synchronous/blocking REST client.
5699 */
0 commit comments