-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReportCreateRequest.java
More file actions
317 lines (277 loc) · 11.1 KB
/
ReportCreateRequest.java
File metadata and controls
317 lines (277 loc) · 11.1 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
/*
* 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.JsonCreator;
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.annotation.JsonValue;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** ReportCreateRequest */
@JsonPropertyOrder({
ReportCreateRequest.JSON_PROPERTY_END_DATE,
ReportCreateRequest.JSON_PROPERTY_REPORT_TYPE,
ReportCreateRequest.JSON_PROPERTY_START_DATE
})
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.12.0")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReportCreateRequest {
public static final String JSON_PROPERTY_END_DATE = "end_date";
@javax.annotation.Nonnull private String endDate;
/** Gets or Sets reportType */
public enum ReportTypeEnum {
USER_ACTIVITY(String.valueOf("user_activity")),
DOCUMENT_STATUS(String.valueOf("document_status")),
SMS_ACTIVITY(String.valueOf("sms_activity"));
private String value;
ReportTypeEnum(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static ReportTypeEnum fromValue(String value) {
for (ReportTypeEnum b : ReportTypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
public static final String JSON_PROPERTY_REPORT_TYPE = "report_type";
@javax.annotation.Nonnull private List<ReportTypeEnum> reportType = new ArrayList<>();
public static final String JSON_PROPERTY_START_DATE = "start_date";
@javax.annotation.Nonnull private String startDate;
public ReportCreateRequest() {}
/**
* Attempt to instantiate and hydrate a new instance of this class
*
* @param jsonData String of JSON data representing target object
*/
public static ReportCreateRequest init(String jsonData) throws Exception {
return new ObjectMapper().readValue(jsonData, ReportCreateRequest.class);
}
public static ReportCreateRequest init(HashMap data) throws Exception {
return new ObjectMapper()
.readValue(new ObjectMapper().writeValueAsString(data), ReportCreateRequest.class);
}
public ReportCreateRequest endDate(@javax.annotation.Nonnull String endDate) {
this.endDate = endDate;
return this;
}
/**
* The (inclusive) end date for the report data in `MM/DD/YYYY` format.
*
* @return endDate
*/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_END_DATE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getEndDate() {
return endDate;
}
@JsonProperty(JSON_PROPERTY_END_DATE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setEndDate(@javax.annotation.Nonnull String endDate) {
this.endDate = endDate;
}
public ReportCreateRequest reportType(
@javax.annotation.Nonnull List<ReportTypeEnum> reportType) {
this.reportType = reportType;
return this;
}
public ReportCreateRequest addReportTypeItem(ReportTypeEnum reportTypeItem) {
if (this.reportType == null) {
this.reportType = new ArrayList<>();
}
this.reportType.add(reportTypeItem);
return this;
}
/**
* The type(s) of the report you are requesting. Allowed values are `user_activity`
* and `document_status`. User activity reports contain list of all users and their
* activity during the specified date range. Document status report contain a list of signature
* requests created in the specified time range (and their status).
*
* @return reportType
*/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_REPORT_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public List<ReportTypeEnum> getReportType() {
return reportType;
}
@JsonProperty(JSON_PROPERTY_REPORT_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setReportType(@javax.annotation.Nonnull List<ReportTypeEnum> reportType) {
this.reportType = reportType;
}
public ReportCreateRequest startDate(@javax.annotation.Nonnull String startDate) {
this.startDate = startDate;
return this;
}
/**
* The (inclusive) start date for the report data in `MM/DD/YYYY` format.
*
* @return startDate
*/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_START_DATE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getStartDate() {
return startDate;
}
@JsonProperty(JSON_PROPERTY_START_DATE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setStartDate(@javax.annotation.Nonnull String startDate) {
this.startDate = startDate;
}
/** Return true if this ReportCreateRequest object is equal to o. */
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ReportCreateRequest reportCreateRequest = (ReportCreateRequest) o;
return Objects.equals(this.endDate, reportCreateRequest.endDate)
&& Objects.equals(this.reportType, reportCreateRequest.reportType)
&& Objects.equals(this.startDate, reportCreateRequest.startDate);
}
@Override
public int hashCode() {
return Objects.hash(endDate, reportType, startDate);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ReportCreateRequest {\n");
sb.append(" endDate: ").append(toIndentedString(endDate)).append("\n");
sb.append(" reportType: ").append(toIndentedString(reportType)).append("\n");
sb.append(" startDate: ").append(toIndentedString(startDate)).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 (endDate != null) {
if (isFileTypeOrListOfFiles(endDate)) {
fileTypeFound = true;
}
if (endDate.getClass().equals(java.io.File.class)
|| endDate.getClass().equals(Integer.class)
|| endDate.getClass().equals(String.class)
|| endDate.getClass().isEnum()) {
map.put("end_date", endDate);
} else if (isListOfFile(endDate)) {
for (int i = 0; i < getListSize(endDate); i++) {
map.put("end_date[" + i + "]", getFromList(endDate, i));
}
} else {
map.put("end_date", JSON.getDefault().getMapper().writeValueAsString(endDate));
}
}
if (reportType != null) {
if (isFileTypeOrListOfFiles(reportType)) {
fileTypeFound = true;
}
if (reportType.getClass().equals(java.io.File.class)
|| reportType.getClass().equals(Integer.class)
|| reportType.getClass().equals(String.class)
|| reportType.getClass().isEnum()) {
map.put("report_type", reportType);
} else if (isListOfFile(reportType)) {
for (int i = 0; i < getListSize(reportType); i++) {
map.put("report_type[" + i + "]", getFromList(reportType, i));
}
} else {
map.put(
"report_type",
JSON.getDefault().getMapper().writeValueAsString(reportType));
}
}
if (startDate != null) {
if (isFileTypeOrListOfFiles(startDate)) {
fileTypeFound = true;
}
if (startDate.getClass().equals(java.io.File.class)
|| startDate.getClass().equals(Integer.class)
|| startDate.getClass().equals(String.class)
|| startDate.getClass().isEnum()) {
map.put("start_date", startDate);
} else if (isListOfFile(startDate)) {
for (int i = 0; i < getListSize(startDate); i++) {
map.put("start_date[" + i + "]", getFromList(startDate, i));
}
} else {
map.put(
"start_date",
JSON.getDefault().getMapper().writeValueAsString(startDate));
}
}
} 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 ");
}
}