forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getGatewayResponseResponse.go
45 lines (38 loc) · 1022 Bytes
/
getGatewayResponseResponse.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
package models
import (
"encoding/json"
"github.com/apimatic/go-core-runtime/types"
)
// The Transaction Gateway Response
type GetGatewayResponseResponse struct {
Code types.Optional[string] `json:"code"`
Errors types.Optional[[]GetGatewayErrorResponse] `json:"errors"`
}
func (g *GetGatewayResponseResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetGatewayResponseResponse) toMap() map[string]any {
structMap := make(map[string]any)
if g.Code.IsValueSet() {
structMap["code"] = g.Code.Value()
}
if g.Errors.IsValueSet() {
structMap["errors"] = g.Errors.Value()
}
return structMap
}
func (g *GetGatewayResponseResponse) UnmarshalJSON(input []byte) error {
temp := &struct {
Code types.Optional[string] `json:"code"`
Errors types.Optional[[]GetGatewayErrorResponse] `json:"errors"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.Code = temp.Code
g.Errors = temp.Errors
return nil
}