Skip to content

Commit

Permalink
Release 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jonte-z authored Jun 27, 2023
1 parent 665cfb8 commit 87c1bc8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 50 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
## 3.0.2 - 2023-06-27

### Added
- Added User-Agent header

## 3.0.1 - 2023-03-08

## Fixed
### Fixed
- Removed `symbol` as mandatory parameter in `currentAllOpenOrders()` within `UMAccount.java` and `CMAccount.java` classes

## Updated
### Updated
- Bumped `org.json` package version to `20230227`

## 3.0.0 - 2023-03-06
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.binance</groupId>
<artifactId>binance-futures-connector-java</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>lightweight connector to Futures API</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,46 @@

public final class RequestBuilder {
private static final MediaType JSON_TYPE = MediaType.parse("application/json; charset=utf-8");
private static final String USER_AGENT = "binance-futures-connector-java/3.0.2";
private static final String CONTENT_TYPE = "application/x-www-form-urlencoded";

private RequestBuilder() {
}
public static Request buildPublicRequest(String fullUrl, HttpMethod httpMethod) {
try {
final Request request;
final Request.Builder requestBuilder = new Request.Builder().addHeader("User-Agent", USER_AGENT).addHeader("Content-Type", CONTENT_TYPE).url(fullUrl);
switch (httpMethod) {
case POST:
request = new Request.Builder().url(fullUrl)
.post(RequestBody.create("", JSON_TYPE))
.build();
break;
return requestBuilder.post(RequestBody.create("", JSON_TYPE)).build();
case GET:
request = new Request.Builder().url(fullUrl)
.get()
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
break;
return requestBuilder.get().build();
case PUT:
request = new Request.Builder().url(fullUrl)
.put(RequestBody.create("", JSON_TYPE))
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
break;
return requestBuilder.put(RequestBody.create("", JSON_TYPE)).build();
case DELETE:
request = new Request.Builder().url(fullUrl)
.delete()
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
break;
return requestBuilder.delete().build();
default:
throw new BinanceConnectorException("Invalid HTTP method: " + httpMethod);
}
return request;
} catch (IllegalArgumentException e) {
throw new BinanceConnectorException("Invalid URL: " + e.getMessage());
}
}
}

public static Request buildApiKeyRequest(String fullUrl, HttpMethod httpMethod, String apiKey) {
try {
final Request request;
final Request.Builder requestBuilder = new Request.Builder().addHeader("User-Agent", USER_AGENT).addHeader("Content-Type", CONTENT_TYPE).addHeader("X-MBX-APIKEY", apiKey).url(fullUrl);
switch (httpMethod) {
case POST:
request = new Request.Builder().url(fullUrl)
.post(RequestBody.create("", JSON_TYPE))
.addHeader("X-MBX-APIKEY", apiKey)
.build();
break;
return requestBuilder.post(RequestBody.create("", JSON_TYPE)).build();
case GET:
request = new Request.Builder().url(fullUrl)
.get()
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("X-MBX-APIKEY", apiKey)
.build();
break;
return requestBuilder.get().build();
case PUT:
request = new Request.Builder().url(fullUrl)
.put(RequestBody.create("", JSON_TYPE))
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("X-MBX-APIKEY", apiKey)
.build();
break;
return requestBuilder.put(RequestBody.create("", JSON_TYPE)).build();
case DELETE:
request = new Request.Builder().url(fullUrl)
.delete()
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("X-MBX-APIKEY", apiKey)
.build();
break;
return requestBuilder.delete().build();
default:
throw new BinanceConnectorException("Invalid HTTP method: " + httpMethod);
}
return request;
} catch (IllegalArgumentException e) {
throw new BinanceConnectorException("Invalid URL: " + e.getMessage());
}
Expand Down

0 comments on commit 87c1bc8

Please sign in to comment.