forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getSetupResponse.go
57 lines (50 loc) · 1.34 KB
/
getSetupResponse.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
package models
import (
"encoding/json"
"github.com/apimatic/go-core-runtime/types"
)
// Response object for getting the setup from a subscription
type GetSetupResponse struct {
Id types.Optional[string] `json:"id"`
Description types.Optional[string] `json:"description"`
Amount types.Optional[int] `json:"amount"`
Status types.Optional[string] `json:"status"`
}
func (g *GetSetupResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetSetupResponse) toMap() map[string]any {
structMap := make(map[string]any)
if g.Id.IsValueSet() {
structMap["id"] = g.Id.Value()
}
if g.Description.IsValueSet() {
structMap["description"] = g.Description.Value()
}
if g.Amount.IsValueSet() {
structMap["amount"] = g.Amount.Value()
}
if g.Status.IsValueSet() {
structMap["status"] = g.Status.Value()
}
return structMap
}
func (g *GetSetupResponse) UnmarshalJSON(input []byte) error {
temp := &struct {
Id types.Optional[string] `json:"id"`
Description types.Optional[string] `json:"description"`
Amount types.Optional[int] `json:"amount"`
Status types.Optional[string] `json:"status"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.Id = temp.Id
g.Description = temp.Description
g.Amount = temp.Amount
g.Status = temp.Status
return nil
}