-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathRequest.java
More file actions
114 lines (90 loc) · 2.12 KB
/
Request.java
File metadata and controls
114 lines (90 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.sendgrid;
import java.util.Map;
import java.util.HashMap;
/**
* Class Response provides a standard interface to an API's HTTP request.
*/
public class Request {
private Method method;
private String baseUri;
private String endpoint;
private String body;
private final Map<String, String> headers;
private final Map<String, String> queryParams;
public Request() {
this.headers = new HashMap<String, String>();
this.queryParams = new HashMap<String, String>();
this.reset();
}
/**
* Place the object into an empty state.
*/
public void reset() {
this.clearMethod();
this.clearBaseUri();
this.clearEndpoint();
this.clearBody();
this.clearHeaders();
this.clearQueryParams();
}
public void addQueryParam(String key, String value) {
this.queryParams.put(key, value);
}
public void addHeader(String key, String value) {
this.headers.put(key, value);
}
public String removeQueryParam(String key) {
return this.queryParams.remove(key);
}
public String removeHeader(String key) {
return this.headers.remove(key);
}
public void setMethod(Method method) {
this.method = method;
}
public void setBaseUri(String baseUri) {
this.baseUri = baseUri;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public void setBody(String body) {
this.body = body;
}
public Map<String, String> getHeaders() {
return this.headers;
}
public Map<String, String> getQueryParams() {
return this.queryParams;
}
public Method getMethod() {
return this.method;
}
public String getBaseUri() {
return this.baseUri;
}
public String getEndpoint() {
return this.endpoint;
}
public String getBody() {
return this.body;
}
public void clearMethod() {
this.method = null;
}
public void clearBaseUri() {
this.baseUri = "";
}
public void clearEndpoint() {
this.endpoint = "";
}
public void clearBody() {
this.body = "";
}
public void clearQueryParams() {
this.queryParams.clear();
}
public void clearHeaders() {
this.headers.clear();
}
}