Repository navigation
Expand file tree
/
Copy pathBaseResponse.java
More file actions
74 lines (63 loc) · 1.81 KB
/
Copy pathBaseResponse.java
File metadata and controls
74 lines (63 loc) · 1.81 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
package co.dapi.response;
import co.dapi.types.APIStatus;
import co.dapi.types.UserInput;
import java.util.Optional;
public class BaseResponse {
private APIStatus status;
private boolean success;
private String operationID;
private UserInput[] userInputs;
private String type;
private String msg;
BaseResponse() {
}
/**
* This is used to construct an error response from the reading of the got response.
* This is a private constructor to this lib
*/
BaseResponse(String errType, String errMsg) {
this.status = APIStatus.failed;
this.success = false;
this.type = errType;
this.msg = errMsg;
}
/**
* returns the status of the operation.
*/
public APIStatus getStatus() {
return status;
}
/**
* returns true if request is successful and false otherwise.
*/
public boolean isSuccess() {
return success;
}
/**
* returns a unique ID generated to identify a specific operation.
*/
public Optional<String> getOperationID() {
return Optional.ofNullable(operationID);
}
/**
* returns the UserInputs required for this operation, which are the further information
* required from the user before the job can be completed.
*/
public Optional<UserInput[]> getUserInputs() {
return Optional.ofNullable(userInputs);
}
/**
* returns the type of error encountered.
* only available if the operation was not successful.
*/
public Optional<String> getType() {
return Optional.ofNullable(type);
}
/**
* returns the message of the error encountered.
* only available if the operation was not successful.
*/
public Optional<String> getMsg() {
return Optional.ofNullable(msg);
}
}