forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getAutomaticAnticipationResponse.go
62 lines (55 loc) · 1.63 KB
/
getAutomaticAnticipationResponse.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
package models
import (
"encoding/json"
"github.com/apimatic/go-core-runtime/types"
)
type GetAutomaticAnticipationResponse struct {
Enabled types.Optional[bool] `json:"enabled"`
Type types.Optional[string] `json:"type"`
VolumePercentage types.Optional[int] `json:"volume_percentage"`
Delay types.Optional[int] `json:"delay"`
Days types.Optional[[]int] `json:"days"`
}
func (g *GetAutomaticAnticipationResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetAutomaticAnticipationResponse) toMap() map[string]any {
structMap := make(map[string]any)
if g.Enabled.IsValueSet() {
structMap["enabled"] = g.Enabled.Value()
}
if g.Type.IsValueSet() {
structMap["type"] = g.Type.Value()
}
if g.VolumePercentage.IsValueSet() {
structMap["volume_percentage"] = g.VolumePercentage.Value()
}
if g.Delay.IsValueSet() {
structMap["delay"] = g.Delay.Value()
}
if g.Days.IsValueSet() {
structMap["days"] = g.Days.Value()
}
return structMap
}
func (g *GetAutomaticAnticipationResponse) UnmarshalJSON(input []byte) error {
temp := &struct {
Enabled types.Optional[bool] `json:"enabled"`
Type types.Optional[string] `json:"type"`
VolumePercentage types.Optional[int] `json:"volume_percentage"`
Delay types.Optional[int] `json:"delay"`
Days types.Optional[[]int] `json:"days"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.Enabled = temp.Enabled
g.Type = temp.Type
g.VolumePercentage = temp.VolumePercentage
g.Delay = temp.Delay
g.Days = temp.Days
return nil
}