forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getGatewayRecipientResponse.go
63 lines (56 loc) · 1.58 KB
/
getGatewayRecipientResponse.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
54
55
56
57
58
59
60
61
62
63
package models
import (
"encoding/json"
"github.com/apimatic/go-core-runtime/types"
)
// Information about the recipient on the gateway
type GetGatewayRecipientResponse struct {
Gateway types.Optional[string] `json:"gateway"`
Status types.Optional[string] `json:"status"`
Pgid types.Optional[string] `json:"pgid"`
CreatedAt types.Optional[string] `json:"created_at"`
UpdatedAt types.Optional[string] `json:"updated_at"`
}
func (g *GetGatewayRecipientResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetGatewayRecipientResponse) toMap() map[string]any {
structMap := make(map[string]any)
if g.Gateway.IsValueSet() {
structMap["gateway"] = g.Gateway.Value()
}
if g.Status.IsValueSet() {
structMap["status"] = g.Status.Value()
}
if g.Pgid.IsValueSet() {
structMap["pgid"] = g.Pgid.Value()
}
if g.CreatedAt.IsValueSet() {
structMap["created_at"] = g.CreatedAt.Value()
}
if g.UpdatedAt.IsValueSet() {
structMap["updated_at"] = g.UpdatedAt.Value()
}
return structMap
}
func (g *GetGatewayRecipientResponse) UnmarshalJSON(input []byte) error {
temp := &struct {
Gateway types.Optional[string] `json:"gateway"`
Status types.Optional[string] `json:"status"`
Pgid types.Optional[string] `json:"pgid"`
CreatedAt types.Optional[string] `json:"created_at"`
UpdatedAt types.Optional[string] `json:"updated_at"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.Gateway = temp.Gateway
g.Status = temp.Status
g.Pgid = temp.Pgid
g.CreatedAt = temp.CreatedAt
g.UpdatedAt = temp.UpdatedAt
return nil
}