Skip to content

Commit ea25cbc

Browse files
authored
chore: fixed request and response (#752)
1 parent 662d24d commit ea25cbc

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.sendgrid.constant;
2+
3+
import java.util.function.Predicate;
4+
5+
public class ApplicationConstants {
6+
public static final Predicate<Integer> SUCCESS = i -> i != null && i >= 200 && i < 400;
7+
}
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
package com.sendgrid.http;
22

33
import lombok.Getter;
4-
4+
import org.apache.http.Header;
55
import java.util.Map;
66
import java.util.StringJoiner;
77

88
public class ApiResponse<T> {
99
@Getter
1010
private Integer statusCode;
1111
@Getter
12-
private String statusMessage;
13-
@Getter
1412
private T body;
1513
@Getter
16-
private Map<String, String> headers;
14+
private Header[] headers;
1715

1816

19-
public ApiResponse(int statusCode, String statusMessage, Map<String, String> headers) {
17+
public ApiResponse(int statusCode, Header[] headers) {
2018
this.body = null;
2119
this.headers = headers;
2220
this.statusCode = statusCode;
23-
this.statusMessage = statusMessage;
2421
}
2522

26-
public ApiResponse(int statusCode, String statusMessage, T body, Map<String, String> headers) {
23+
public ApiResponse(int statusCode, T body, Header[] headers) {
2724
this.statusCode = statusCode;
28-
this.statusMessage = statusMessage;
2925
this.body = body;
3026
this.headers = headers;
3127
}
@@ -34,9 +30,8 @@ public ApiResponse(int statusCode, String statusMessage, T body, Map<String, Str
3430
public String toString() {
3531
StringJoiner joiner = new StringJoiner(", ", ApiResponse.class.getSimpleName() + "(", ")");
3632
if (statusCode != null) joiner.add("statusCode=" + statusCode);
37-
if (statusMessage != null) joiner.add("statusMessage=" + statusMessage);
38-
if (statusMessage != null) joiner.add("body=" + body);
39-
if (statusMessage != null) joiner.add("headers=" + headers);
33+
if (headers != null) joiner.add("headers=" + headers);
34+
if (body != null) joiner.add("body=" + body);
4035
return joiner.toString();
4136
}
4237
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public Builder addPathParam(String key, String value) {
6060
return this;
6161
}
6262

63-
public Builder addHeaderParams(String key, String value) {
63+
public Builder addHeaderParam(String key, String value) {
6464
headers.put(key, value);
6565
return this;
6666
}
@@ -80,7 +80,7 @@ public Builder addQueryParams(String key, String value) {
8080
return this;
8181
}
8282

83-
public Builder body(String body) {
83+
public Builder addBody(String body) {
8484
this.body = body;
8585
return this;
8686
}

0 commit comments

Comments
 (0)