/
JsonResponse.go
53 lines (43 loc) · 999 Bytes
/
JsonResponse.go
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
package endpoint
import (
"bytes"
"github.com/google/uuid"
)
// Represents the base class for json response.
type JsonResponse struct {
Response
clientError error
isSuccessful bool
errorMessage string
errorId uuid.UUID
statusCode int
errorJson string
content *bytes.Buffer
statusMessage string
}
func (r *JsonResponse) ClientError() error {
return r.clientError
}
// Gets the boolean, indicating the response's status.
func (r *JsonResponse) IsSuccessful() bool {
return r.isSuccessful
}
// Gets the error message.
func (r *JsonResponse) ErrorMessage() string {
return r.errorMessage
}
// Gets the error id.
func (r *JsonResponse) ErrorId() uuid.UUID {
return r.errorId
}
// Gets the status code.
func (r *JsonResponse) StatusCode() int {
return r.statusCode
}
func (r *JsonResponse) SetStatusMessage(statusMessage string) {
r.statusMessage = statusMessage
}
// Gets the error json.
func (r *JsonResponse) ErrorJson() string {
return r.errorJson
}