Skip to content

Commit 65ff972

Browse files
authored
chore: added no content body (#753)
1 parent ea25cbc commit 65ff972

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
package com.sendgrid.constant;
22

3+
import lombok.AccessLevel;
4+
import lombok.NoArgsConstructor;
5+
36
import java.util.function.Predicate;
47

8+
9+
@NoArgsConstructor(access = AccessLevel.PRIVATE)
510
public class ApplicationConstants {
11+
public static final int HTTP_STATUS_CODE_CREATED = 201;
12+
public static final int HTTP_STATUS_CODE_NO_CONTENT = 204;
13+
public static final int HTTP_STATUS_CODE_OK = 200;
614
public static final Predicate<Integer> SUCCESS = i -> i != null && i >= 200 && i < 400;
715
}

src/main/java/com/sendgrid/constant/Config.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.sendgrid.constant;
22

3+
import lombok.experimental.UtilityClass;
4+
5+
@UtilityClass
36
public class Config {
47
public static final String VERSION = "5.0.0-rc.0";
58
public static final String JAVA_VERSION = System.getProperty("java.version");

src/main/java/com/sendgrid/http/ApiResponse.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import lombok.Getter;
44
import org.apache.http.Header;
5-
import java.util.Map;
65
import java.util.StringJoiner;
76

87
public class ApiResponse<T> {
@@ -12,10 +11,10 @@ public class ApiResponse<T> {
1211
private T body;
1312
@Getter
1413
private Header[] headers;
15-
14+
public static final Void NO_CONTENT = null;
1615

1716
public ApiResponse(int statusCode, Header[] headers) {
18-
this.body = null;
17+
this.body = (T) NO_CONTENT;
1918
this.headers = headers;
2019
this.statusCode = statusCode;
2120
}
@@ -30,8 +29,8 @@ public ApiResponse(int statusCode, T body, Header[] headers) {
3029
public String toString() {
3130
StringJoiner joiner = new StringJoiner(", ", ApiResponse.class.getSimpleName() + "(", ")");
3231
if (statusCode != null) joiner.add("statusCode=" + statusCode);
33-
if (headers != null) joiner.add("headers=" + headers);
3432
if (body != null) joiner.add("body=" + body);
33+
if (headers != null) joiner.add("headers=" + headers);
3534
return joiner.toString();
3635
}
3736
}

src/main/java/com/sendgrid/http/Request.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Builder addHeaderParam(String key, String value) {
7272
* query: If there is query parameter apart from limit and offset.
7373
* It will be the responsibility of the client to build a compound query, encode it and pass it as a query parameter in the query field.
7474
*/
75-
public Builder addQueryParams(String key, String value) {
75+
public Builder addQueryParam(String key, String value) {
7676
if (!queryParams.containsKey(key)) {
7777
queryParams.put(key, new ArrayList<String>());
7878
}

0 commit comments

Comments
 (0)