-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathOAuthTokenRefreshRequest.java
More file actions
319 lines (283 loc) · 12 KB
/
OAuthTokenRefreshRequest.java
File metadata and controls
319 lines (283 loc) · 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/*
* Dropbox Sign API
* Dropbox Sign v3 API
*
* The version of the OpenAPI document: 3.0.0
* Contact: apisupport@hellosign.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.dropbox.sign.model;
import com.dropbox.sign.ApiException;
import com.dropbox.sign.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/** OAuthTokenRefreshRequest */
@JsonPropertyOrder({
OAuthTokenRefreshRequest.JSON_PROPERTY_GRANT_TYPE,
OAuthTokenRefreshRequest.JSON_PROPERTY_REFRESH_TOKEN,
OAuthTokenRefreshRequest.JSON_PROPERTY_CLIENT_ID,
OAuthTokenRefreshRequest.JSON_PROPERTY_CLIENT_SECRET
})
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.12.0")
@JsonIgnoreProperties(ignoreUnknown = true)
public class OAuthTokenRefreshRequest {
public static final String JSON_PROPERTY_GRANT_TYPE = "grant_type";
@javax.annotation.Nonnull private String grantType = "refresh_token";
public static final String JSON_PROPERTY_REFRESH_TOKEN = "refresh_token";
@javax.annotation.Nonnull private String refreshToken;
public static final String JSON_PROPERTY_CLIENT_ID = "client_id";
@javax.annotation.Nullable private String clientId;
public static final String JSON_PROPERTY_CLIENT_SECRET = "client_secret";
@javax.annotation.Nullable private String clientSecret;
public OAuthTokenRefreshRequest() {}
/**
* Attempt to instantiate and hydrate a new instance of this class
*
* @param jsonData String of JSON data representing target object
*/
public static OAuthTokenRefreshRequest init(String jsonData) throws Exception {
return new ObjectMapper().readValue(jsonData, OAuthTokenRefreshRequest.class);
}
public static OAuthTokenRefreshRequest init(HashMap data) throws Exception {
return new ObjectMapper()
.readValue(
new ObjectMapper().writeValueAsString(data),
OAuthTokenRefreshRequest.class);
}
public OAuthTokenRefreshRequest grantType(@javax.annotation.Nonnull String grantType) {
this.grantType = grantType;
return this;
}
/**
* When refreshing an existing token use `refresh_token`.
*
* @return grantType
*/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_GRANT_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getGrantType() {
return grantType;
}
@JsonProperty(JSON_PROPERTY_GRANT_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setGrantType(@javax.annotation.Nonnull String grantType) {
this.grantType = grantType;
}
public OAuthTokenRefreshRequest refreshToken(@javax.annotation.Nonnull String refreshToken) {
this.refreshToken = refreshToken;
return this;
}
/**
* The token provided when you got the expired access token.
*
* @return refreshToken
*/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_REFRESH_TOKEN)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getRefreshToken() {
return refreshToken;
}
@JsonProperty(JSON_PROPERTY_REFRESH_TOKEN)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setRefreshToken(@javax.annotation.Nonnull String refreshToken) {
this.refreshToken = refreshToken;
}
public OAuthTokenRefreshRequest clientId(@javax.annotation.Nullable String clientId) {
this.clientId = clientId;
return this;
}
/**
* The client ID for your API app. Required for new API apps. To enhance security, we recommend
* making it required for existing apps in your app settings.
*
* @return clientId
*/
@javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_CLIENT_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getClientId() {
return clientId;
}
@JsonProperty(JSON_PROPERTY_CLIENT_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setClientId(@javax.annotation.Nullable String clientId) {
this.clientId = clientId;
}
public OAuthTokenRefreshRequest clientSecret(@javax.annotation.Nullable String clientSecret) {
this.clientSecret = clientSecret;
return this;
}
/**
* The client secret for your API app. Required for new API apps. To enhance security, we
* recommend making it required for existing apps in your app settings.
*
* @return clientSecret
*/
@javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_CLIENT_SECRET)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getClientSecret() {
return clientSecret;
}
@JsonProperty(JSON_PROPERTY_CLIENT_SECRET)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setClientSecret(@javax.annotation.Nullable String clientSecret) {
this.clientSecret = clientSecret;
}
/** Return true if this OAuthTokenRefreshRequest object is equal to o. */
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
OAuthTokenRefreshRequest oauthTokenRefreshRequest = (OAuthTokenRefreshRequest) o;
return Objects.equals(this.grantType, oauthTokenRefreshRequest.grantType)
&& Objects.equals(this.refreshToken, oauthTokenRefreshRequest.refreshToken)
&& Objects.equals(this.clientId, oauthTokenRefreshRequest.clientId)
&& Objects.equals(this.clientSecret, oauthTokenRefreshRequest.clientSecret);
}
@Override
public int hashCode() {
return Objects.hash(grantType, refreshToken, clientId, clientSecret);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OAuthTokenRefreshRequest {\n");
sb.append(" grantType: ").append(toIndentedString(grantType)).append("\n");
sb.append(" refreshToken: ").append(toIndentedString(refreshToken)).append("\n");
sb.append(" clientId: ").append(toIndentedString(clientId)).append("\n");
sb.append(" clientSecret: ").append(toIndentedString(clientSecret)).append("\n");
sb.append("}");
return sb.toString();
}
public Map<String, Object> createFormData() throws ApiException {
Map<String, Object> map = new HashMap<>();
boolean fileTypeFound = false;
try {
if (grantType != null) {
if (isFileTypeOrListOfFiles(grantType)) {
fileTypeFound = true;
}
if (grantType.getClass().equals(java.io.File.class)
|| grantType.getClass().equals(Integer.class)
|| grantType.getClass().equals(String.class)
|| grantType.getClass().isEnum()) {
map.put("grant_type", grantType);
} else if (isListOfFile(grantType)) {
for (int i = 0; i < getListSize(grantType); i++) {
map.put("grant_type[" + i + "]", getFromList(grantType, i));
}
} else {
map.put(
"grant_type",
JSON.getDefault().getMapper().writeValueAsString(grantType));
}
}
if (refreshToken != null) {
if (isFileTypeOrListOfFiles(refreshToken)) {
fileTypeFound = true;
}
if (refreshToken.getClass().equals(java.io.File.class)
|| refreshToken.getClass().equals(Integer.class)
|| refreshToken.getClass().equals(String.class)
|| refreshToken.getClass().isEnum()) {
map.put("refresh_token", refreshToken);
} else if (isListOfFile(refreshToken)) {
for (int i = 0; i < getListSize(refreshToken); i++) {
map.put("refresh_token[" + i + "]", getFromList(refreshToken, i));
}
} else {
map.put(
"refresh_token",
JSON.getDefault().getMapper().writeValueAsString(refreshToken));
}
}
if (clientId != null) {
if (isFileTypeOrListOfFiles(clientId)) {
fileTypeFound = true;
}
if (clientId.getClass().equals(java.io.File.class)
|| clientId.getClass().equals(Integer.class)
|| clientId.getClass().equals(String.class)
|| clientId.getClass().isEnum()) {
map.put("client_id", clientId);
} else if (isListOfFile(clientId)) {
for (int i = 0; i < getListSize(clientId); i++) {
map.put("client_id[" + i + "]", getFromList(clientId, i));
}
} else {
map.put(
"client_id",
JSON.getDefault().getMapper().writeValueAsString(clientId));
}
}
if (clientSecret != null) {
if (isFileTypeOrListOfFiles(clientSecret)) {
fileTypeFound = true;
}
if (clientSecret.getClass().equals(java.io.File.class)
|| clientSecret.getClass().equals(Integer.class)
|| clientSecret.getClass().equals(String.class)
|| clientSecret.getClass().isEnum()) {
map.put("client_secret", clientSecret);
} else if (isListOfFile(clientSecret)) {
for (int i = 0; i < getListSize(clientSecret); i++) {
map.put("client_secret[" + i + "]", getFromList(clientSecret, i));
}
} else {
map.put(
"client_secret",
JSON.getDefault().getMapper().writeValueAsString(clientSecret));
}
}
} catch (Exception e) {
throw new ApiException(e);
}
return fileTypeFound ? map : new HashMap<>();
}
private boolean isFileTypeOrListOfFiles(Object obj) throws Exception {
return obj.getClass().equals(java.io.File.class) || isListOfFile(obj);
}
private boolean isListOfFile(Object obj) throws Exception {
return obj instanceof java.util.List
&& !isListEmpty(obj)
&& getFromList(obj, 0) instanceof java.io.File;
}
private boolean isListEmpty(Object obj) throws Exception {
return (boolean)
Class.forName(java.util.List.class.getName()).getMethod("isEmpty").invoke(obj);
}
private Object getFromList(Object obj, int index) throws Exception {
return Class.forName(java.util.List.class.getName())
.getMethod("get", int.class)
.invoke(obj, index);
}
private int getListSize(Object obj) throws Exception {
return (int) Class.forName(java.util.List.class.getName()).getMethod("size").invoke(obj);
}
/**
* Convert the given object to string with each line indented by 4 spaces (except the first
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}