forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getPixPayerResponse.go
57 lines (50 loc) · 1.54 KB
/
getPixPayerResponse.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"
)
// Pix payer data.
type GetPixPayerResponse struct {
Name types.Optional[string] `json:"name"`
Document types.Optional[string] `json:"document"`
DocumentType types.Optional[string] `json:"document_type"`
BankAccount types.Optional[GetPixBankAccountResponse] `json:"bank_account"`
}
func (g *GetPixPayerResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetPixPayerResponse) toMap() map[string]any {
structMap := make(map[string]any)
if g.Name.IsValueSet() {
structMap["name"] = g.Name.Value()
}
if g.Document.IsValueSet() {
structMap["document"] = g.Document.Value()
}
if g.DocumentType.IsValueSet() {
structMap["document_type"] = g.DocumentType.Value()
}
if g.BankAccount.IsValueSet() {
structMap["bank_account"] = g.BankAccount.Value()
}
return structMap
}
func (g *GetPixPayerResponse) UnmarshalJSON(input []byte) error {
temp := &struct {
Name types.Optional[string] `json:"name"`
Document types.Optional[string] `json:"document"`
DocumentType types.Optional[string] `json:"document_type"`
BankAccount types.Optional[GetPixBankAccountResponse] `json:"bank_account"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.Name = temp.Name
g.Document = temp.Document
g.DocumentType = temp.DocumentType
g.BankAccount = temp.BankAccount
return nil
}