forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createAutomaticAnticipationSettingsRequest.go
50 lines (44 loc) · 1.26 KB
/
createAutomaticAnticipationSettingsRequest.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
package models
import (
"encoding/json"
)
type CreateAutomaticAnticipationSettingsRequest struct {
Enabled bool `json:"enabled"`
Type string `json:"type"`
VolumePercentage int `json:"volume_percentage"`
Delay int `json:"delay"`
Days []int `json:"days"`
}
func (c *CreateAutomaticAnticipationSettingsRequest) MarshalJSON() (
[]byte,
error) {
return json.Marshal(c.toMap())
}
func (c *CreateAutomaticAnticipationSettingsRequest) toMap() map[string]any {
structMap := make(map[string]any)
structMap["enabled"] = c.Enabled
structMap["type"] = c.Type
structMap["volume_percentage"] = c.VolumePercentage
structMap["delay"] = c.Delay
structMap["days"] = c.Days
return structMap
}
func (c *CreateAutomaticAnticipationSettingsRequest) UnmarshalJSON(input []byte) error {
temp := &struct {
Enabled bool `json:"enabled"`
Type string `json:"type"`
VolumePercentage int `json:"volume_percentage"`
Delay int `json:"delay"`
Days []int `json:"days"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
c.Enabled = temp.Enabled
c.Type = temp.Type
c.VolumePercentage = temp.VolumePercentage
c.Delay = temp.Delay
c.Days = temp.Days
return nil
}