Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 25 additions & 29 deletions library/src/main/java/dev/andstuff/kraken/api/KrakenAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public KrakenAPI(KrakenCredentials credentials, KrakenNonceGenerator nonceGenera
* @throws KrakenException if Kraken returns an error
*/
public ServerTime serverTime() {
return restRequester.execute(new ServerTimeEndpoint());
return query(new ServerTimeEndpoint());
}

/**
Expand All @@ -159,7 +159,7 @@ public ServerTime serverTime() {
* @throws KrakenException if Kraken returns an error
*/
public SystemStatus systemStatus() {
return restRequester.execute(new SystemStatusEndpoint());
return query(new SystemStatusEndpoint());
}

/**
Expand All @@ -170,7 +170,7 @@ public SystemStatus systemStatus() {
* @throws KrakenException if Kraken returns an error
*/
public Map<String, AssetInfo> assetInfo(List<String> assets) {
return restRequester.execute(new AssetInfoEndpoint(assets));
return query(new AssetInfoEndpoint(assets));
}

/**
Expand All @@ -182,7 +182,7 @@ public Map<String, AssetInfo> assetInfo(List<String> assets) {
* @throws KrakenException if Kraken returns an error
*/
public Map<String, AssetInfo> assetInfo(List<String> assets, String assetClass) {
return restRequester.execute(new AssetInfoEndpoint(assets, assetClass));
return query(new AssetInfoEndpoint(assets, assetClass));
}

/**
Expand All @@ -192,7 +192,7 @@ public Map<String, AssetInfo> assetInfo(List<String> assets, String assetClass)
* @throws KrakenException if Kraken returns an error
*/
public AssetPairs assetPairs() {
return restRequester.execute(new AssetPairEndpoint());
return query(new AssetPairEndpoint());
}

/**
Expand All @@ -203,7 +203,7 @@ public AssetPairs assetPairs() {
* @throws KrakenException if Kraken returns an error
*/
public AssetPairs assetPairs(List<String> pairs) {
return restRequester.execute(new AssetPairEndpoint(pairs));
return query(new AssetPairEndpoint(pairs));
}

/**
Expand All @@ -215,7 +215,7 @@ public AssetPairs assetPairs(List<String> pairs) {
* @throws KrakenException if Kraken returns an error
*/
public AssetPairs assetPairs(List<String> pair, AssetPairParams.Info info) {
return restRequester.execute(new AssetPairEndpoint(pair, info));
return query(new AssetPairEndpoint(pair, info));
}

/**
Expand All @@ -226,7 +226,7 @@ public AssetPairs assetPairs(List<String> pair, AssetPairParams.Info info) {
* @throws KrakenException if Kraken returns an error
*/
public Map<String, Ticker> ticker(List<String> pairs) {
return restRequester.execute(new TickerEndpoint(pairs));
return query(new TickerEndpoint(pairs));
}

/**
Expand Down Expand Up @@ -272,7 +272,7 @@ public PostTrade postTrade(PostTradeParams params) {
* @throws KrakenException if Kraken returns an error
*/
public LedgerInfo ledgerInfo(LedgerInfoParams params) {
return executePrivate(new LedgerInfoEndpoint(params));
return query(new LedgerInfoEndpoint(params));
}

/**
Expand All @@ -283,7 +283,7 @@ public LedgerInfo ledgerInfo(LedgerInfoParams params) {
* @throws KrakenException if Kraken returns an error
*/
public Map<String, LedgerEntry> ledgerEntries(LedgerEntriesParams params) {
return executePrivate(new LedgerEntriesEndpoint(params));
return query(new LedgerEntriesEndpoint(params));
}

/**
Expand All @@ -294,7 +294,7 @@ public Map<String, LedgerEntry> ledgerEntries(LedgerEntriesParams params) {
* @throws KrakenException if Kraken returns an error
*/
public ReportRequest requestReport(RequestReportParams params) {
return executePrivate(new RequestReportEndpoint(params));
return query(new RequestReportEndpoint(params));
}

/**
Expand All @@ -305,7 +305,7 @@ public ReportRequest requestReport(RequestReportParams params) {
* @throws KrakenException if Kraken returns an error
*/
public List<Report> reportsStatuses(ReportType type) {
return executePrivate(new ReportsStatusesEndpoint(ReportsStatusesParams.of(type)));
return query(new ReportsStatusesEndpoint(ReportsStatusesParams.of(type)));
}

/**
Expand All @@ -316,7 +316,7 @@ public List<Report> reportsStatuses(ReportType type) {
* @throws KrakenException if Kraken returns an error
*/
public List<LedgerEntry> reportData(String id) {
return executePrivate(new ReportDataEndpoint(ReportDataParams.of(id)));
return query(new ReportDataEndpoint(ReportDataParams.of(id)));
}

/**
Expand All @@ -327,7 +327,7 @@ public List<LedgerEntry> reportData(String id) {
* @throws KrakenException if Kraken returns an error
*/
public boolean deleteReport(String id) {
return executePrivate(new RemoveReportEndpoint(RemoveReportParams.of(id, RemovalType.DELETE))).wasDeleted();
return query(new RemoveReportEndpoint(RemoveReportParams.of(id, RemovalType.DELETE))).wasDeleted();
}

/**
Expand All @@ -338,7 +338,7 @@ public boolean deleteReport(String id) {
* @throws KrakenException if Kraken returns an error
*/
public boolean cancelReport(String id) {
return executePrivate(new RemoveReportEndpoint(RemoveReportParams.of(id, RemovalType.CANCEL))).wasCanceled();
return query(new RemoveReportEndpoint(RemoveReportParams.of(id, RemovalType.CANCEL))).wasCanceled();
}

/**
Expand All @@ -349,7 +349,7 @@ public boolean cancelReport(String id) {
* @throws KrakenException if Kraken returns an error
*/
public boolean createSubaccount(CreateSubaccountParams params) {
return executePrivate(new CreateSubaccountEndpoint(params));
return query(new CreateSubaccountEndpoint(params));
}

/**
Expand All @@ -360,11 +360,7 @@ public boolean createSubaccount(CreateSubaccountParams params) {
* @throws KrakenException if Kraken returns an error
*/
public AccountTransfer accountTransfer(AccountTransferParams params) {
return executePrivate(new AccountTransferEndpoint(params));
}

private <T> T executePrivate(PrivateEndpoint<T> endpoint) {
return query(endpoint);
return query(new AccountTransferEndpoint(params));
}

/* Query unimplemented endpoints */
Expand Down Expand Up @@ -406,7 +402,7 @@ public <T> T query(PrivateEndpoint<T> endpoint) {
* @throws KrakenException if Kraken returns an error
*/
public JsonNode query(Public endpoint) {
return restRequester.execute(new JsonPublicEndpoint(endpoint.getPath()));
return query(new JsonPublicEndpoint(endpoint.getPath()));
}

/**
Expand All @@ -418,7 +414,7 @@ public JsonNode query(Public endpoint) {
* @throws KrakenException if Kraken returns an error
*/
public JsonNode query(Public endpoint, Map<String, String> queryParams) {
return restRequester.execute(new JsonPublicEndpoint(endpoint.getPath(), queryParams));
return query(new JsonPublicEndpoint(endpoint.getPath(), queryParams));
}

/**
Expand All @@ -429,7 +425,7 @@ public JsonNode query(Public endpoint, Map<String, String> queryParams) {
* @throws KrakenException if Kraken returns an error
*/
public JsonNode queryPublic(String path) {
return restRequester.execute(new JsonPublicEndpoint(path));
return query(new JsonPublicEndpoint(path));
}

/**
Expand All @@ -441,7 +437,7 @@ public JsonNode queryPublic(String path) {
* @throws KrakenException if Kraken returns an error
*/
public JsonNode queryPublic(String path, Map<String, String> queryParams) {
return restRequester.execute(new JsonPublicEndpoint(path, queryParams));
return query(new JsonPublicEndpoint(path, queryParams));
}

/**
Expand All @@ -452,7 +448,7 @@ public JsonNode queryPublic(String path, Map<String, String> queryParams) {
* @throws KrakenException if Kraken returns an error
*/
public JsonNode query(Private endpoint) {
return executePrivate(new JsonPrivateEndpoint(endpoint.getPath()));
return query(new JsonPrivateEndpoint(endpoint.getPath()));
}

/**
Expand All @@ -464,7 +460,7 @@ public JsonNode query(Private endpoint) {
* @throws KrakenException if Kraken returns an error
*/
public JsonNode query(Private endpoint, Map<String, String> params) {
return executePrivate(new JsonPrivateEndpoint(endpoint.getPath(), params));
return query(new JsonPrivateEndpoint(endpoint.getPath(), params));
}

/**
Expand All @@ -475,7 +471,7 @@ public JsonNode query(Private endpoint, Map<String, String> params) {
* @throws KrakenException if Kraken returns an error
*/
public JsonNode queryPrivate(String path) {
return executePrivate(new JsonPrivateEndpoint(path));
return query(new JsonPrivateEndpoint(path));
}

/**
Expand All @@ -487,7 +483,7 @@ public JsonNode queryPrivate(String path) {
* @throws KrakenException if Kraken returns an error
*/
public JsonNode queryPrivate(String path, Map<String, String> params) {
return executePrivate(new JsonPrivateEndpoint(path, params));
return query(new JsonPrivateEndpoint(path, params));
}

/* All endpoints */
Expand Down