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