diff --git a/src/main/java/com/poloniex/api/client/future/rest/future/SpotPoloRestClient.java b/src/main/java/com/poloniex/api/client/future/rest/future/SpotPoloRestClient.java index 9e96256..aa71ade 100644 --- a/src/main/java/com/poloniex/api/client/future/rest/future/SpotPoloRestClient.java +++ b/src/main/java/com/poloniex/api/client/future/rest/future/SpotPoloRestClient.java @@ -155,6 +155,9 @@ public GetCurrentPositionResponse getCurrentPosition(String symbol) { return execute(spotPoloPrivateApiService.getCurrentPosition(symbol)); } + public GetLeveragesResponse getLeverages(String symbol,String mgnModel) { + return execute(spotPoloPrivateApiService.getLeverages(symbol,mgnModel)); + } public GetPositionHistoryResponse getPositionHistory(String symbol, String mgnMode, @@ -191,6 +194,9 @@ public SetLeverageResponse setLeverage(SetLeverageRequest request) { return execute(spotPoloPrivateApiService.setLeverage(request)); } + public GetModeResponse getPositionMode() { + return execute(spotPoloPrivateApiService.getPositionMode()); + } public GetOrderBookResponse getOrderBook(String symbol, String scale, diff --git a/src/test/java/com/poloniex/api/client/future/rest/FuturePoloRestClientTest.java b/src/test/java/com/poloniex/api/client/future/rest/FuturePoloRestClientTest.java index c229a40..3a8061e 100644 --- a/src/test/java/com/poloniex/api/client/future/rest/FuturePoloRestClientTest.java +++ b/src/test/java/com/poloniex/api/client/future/rest/FuturePoloRestClientTest.java @@ -302,7 +302,7 @@ void testgetCurrentPosition() throws IOException { @Test void testAdjustMargin() throws IOException { - AdjustMarginRequest request = AdjustMarginRequest.builder().symbol("BTC").type("ADD").amt("10").build(); + AdjustMarginRequest request = AdjustMarginRequest.builder().symbol("BTC").type("ADD").amt("10").posSide("null").build(); AdjustMarginResponse atr = new AdjustMarginResponse(); atr.getData().setSymbol("test"); @@ -315,6 +315,7 @@ void testAdjustMargin() throws IOException { verify(spotPoloPrivateApiService, times(1)).adjustMargin(request); assertEquals("test", response.getData().getSymbol()); } + // @Test // void testSwitchCross() throws IOException { // SwitchCrossRequest request = SwitchCrossRequest.builder().symbol("BTC").mgnMode("CROSS").build(); @@ -365,7 +366,7 @@ void testAdjustMargin() throws IOException { @Test void testSetLeverage() throws IOException { - SetLeverageRequest request = SetLeverageRequest.builder().symbol("BTC").lever("7").build(); + SetLeverageRequest request = SetLeverageRequest.builder().symbol("BTC").lever("7").mgnMode("").posSide("").build(); SetLeverageResponse atr = new SetLeverageResponse(); atr.getData().setSymbol("test"); @@ -379,6 +380,56 @@ void testSetLeverage() throws IOException { assertEquals("test", response.getData().getSymbol()); } + @Test + void testGetLeverages() throws IOException { + + GetLeveragesResponse atr = new GetLeveragesResponse(); + GetLeveragesResponse.GetLeverages getLeverages = new GetLeveragesResponse.GetLeverages(); + getLeverages.setSymbol("test"); + atr.getData().add(getLeverages); + + Call call = mock(Call.class); + when(call.execute()).thenReturn(Response.success(atr)); + + when(spotPoloPrivateApiService.getLeverages("test","mgnMode")).thenReturn(call); + GetLeveragesResponse response = spotPoloRestClient.getLeverages("test","mgnMode"); + verify(spotPoloPrivateApiService, times(1)).getLeverages("test","mgnMode"); + assertEquals("test", response.getData().get(0).getSymbol()); + } + + @Test + void testSetPositionMode() throws IOException { + + SetModeRequest request = SetModeRequest.builder().posMode("test").build(); + SetModeResponse atr = new SetModeResponse(); + // atr.getData()("test"); + + Call call = mock(Call.class); + when(call.execute()).thenReturn(Response.success(atr)); + + when(spotPoloPrivateApiService.setPositionMode(request)).thenReturn(call); + GetModeResponse response = spotPoloRestClient.getPositionMode(); + verify(spotPoloPrivateApiService, times(1)).getPositionMode(); + assertEquals("test", response.getData().getPosMode()); + } + + @Test + void testGetPositionMode() throws IOException { + + GetModeResponse atr = new GetModeResponse(); + GetModeResponse.PositionMode data = new GetModeResponse.PositionMode(); + data.setPosMode("test"); + atr.setData(data); + + Call call = mock(Call.class); + when(call.execute()).thenReturn(Response.success(atr)); + + when(spotPoloPrivateApiService.getPositionMode()).thenReturn(call); + GetModeResponse response = spotPoloRestClient.getPositionMode(); + verify(spotPoloPrivateApiService, times(1)).getPositionMode(); + assertEquals("test", response.getData().getPosMode()); + } + @Test void testGetOrderBook() throws IOException { // SwitchCrossRequest request = SwitchCrossRequest.builder().build();