forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getMovementObjectRefundResponse.go
167 lines (147 loc) · 5.16 KB
/
getMovementObjectRefundResponse.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package models
import (
"encoding/json"
"fmt"
"github.com/apimatic/go-core-runtime/types"
)
// Generic response object for getting a MovementObjectRefund.
type GetMovementObjectRefundResponse struct {
GetMovementObjectBaseResponse
FraudCoverageFee types.Optional[string] `json:"fraud_coverage_fee"`
ChargeFeeRecipientId types.Optional[string] `json:"charge_fee_recipient_id"`
BankAccountId types.Optional[string] `json:"bank_account_id"`
LocalTransactionId types.Optional[string] `json:"local_transaction_id"`
UpdatedAt types.Optional[string] `json:"updated_at"`
}
func (g *GetMovementObjectRefundResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetMovementObjectRefundResponse) toMap() map[string]any {
structMap := g.GetMovementObjectBaseResponse.toMap()
if g.Object != nil {
structMap["object"] = *g.Object
} else {
structMap["object"] = "refund"
}
if g.FraudCoverageFee.IsValueSet() {
structMap["fraud_coverage_fee"] = g.FraudCoverageFee.Value()
}
if g.ChargeFeeRecipientId.IsValueSet() {
structMap["charge_fee_recipient_id"] = g.ChargeFeeRecipientId.Value()
}
if g.BankAccountId.IsValueSet() {
structMap["bank_account_id"] = g.BankAccountId.Value()
}
if g.LocalTransactionId.IsValueSet() {
structMap["local_transaction_id"] = g.LocalTransactionId.Value()
}
if g.UpdatedAt.IsValueSet() {
structMap["updated_at"] = g.UpdatedAt.Value()
}
return structMap
}
func (g *GetMovementObjectRefundResponse) UnmarshalJSON(input []byte) error {
g.GetMovementObjectBaseResponse.UnmarshalJSON(input)
temp := &struct {
FraudCoverageFee types.Optional[string] `json:"fraud_coverage_fee"`
ChargeFeeRecipientId types.Optional[string] `json:"charge_fee_recipient_id"`
BankAccountId types.Optional[string] `json:"bank_account_id"`
LocalTransactionId types.Optional[string] `json:"local_transaction_id"`
UpdatedAt types.Optional[string] `json:"updated_at"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.FraudCoverageFee = temp.FraudCoverageFee
g.ChargeFeeRecipientId = temp.ChargeFeeRecipientId
g.BankAccountId = temp.BankAccountId
g.LocalTransactionId = temp.LocalTransactionId
g.UpdatedAt = temp.UpdatedAt
return nil
}
// Getter for fraud_coverage_fee.
func (g *GetMovementObjectRefundResponse) GetFraudCoverageFee() types.Optional[string] {
return g.FraudCoverageFee
}
// Getter for charge_fee_recipient_id.
func (g *GetMovementObjectRefundResponse) GetChargeFeeRecipientId() types.Optional[string] {
return g.ChargeFeeRecipientId
}
// Getter for bank_account_id.
func (g *GetMovementObjectRefundResponse) GetBankAccountId() types.Optional[string] {
return g.BankAccountId
}
// Getter for local_transaction_id.
func (g *GetMovementObjectRefundResponse) GetLocalTransactionId() types.Optional[string] {
return g.LocalTransactionId
}
// Getter for updated_at.
func (g *GetMovementObjectRefundResponse) GetUpdatedAt() types.Optional[string] {
return g.UpdatedAt
}
func UnmarshalGetMovementObjectRefundResponse(input []byte) (
GetMovementObjectRefundResponseInterface,
error) {
getMovementObjectBaseResponse, err := UnmarshalGetMovementObjectBaseResponse(input)
if err != nil {
return nil, err
}
if getMovementObjectRefundResponse, ok := getMovementObjectBaseResponse.(GetMovementObjectRefundResponseInterface); ok {
return getMovementObjectRefundResponse, nil
}
return nil, fmt.Errorf("Cannot unmarshal getMovementObjectRefundResponse %v", getMovementObjectBaseResponse)
}
func ToGetMovementObjectRefundResponseArray(getMovementObjectRefundResponse []GetMovementObjectRefundResponseField) []GetMovementObjectRefundResponseInterface {
var items []GetMovementObjectRefundResponseInterface
for _, temp := range getMovementObjectRefundResponse {
items = append(items, temp.GetMovementObjectRefundResponseInterface)
}
return items
}
// Utility struct that helps the go JSON deserializer to invoke the proper deserialization logic.
type GetMovementObjectRefundResponseField struct {
GetMovementObjectRefundResponseInterface
}
func (g *GetMovementObjectRefundResponseField) UnmarshalJSON(input []byte) error {
var err error
g.GetMovementObjectRefundResponseInterface, err = UnmarshalGetMovementObjectRefundResponse(input)
return err
}
// Utility struct that helps in the unmarshalling of slices.
type GetMovementObjectRefundResponseSlice struct {
Slice []GetMovementObjectRefundResponseInterface
}
func (ga *GetMovementObjectRefundResponseSlice) UnmarshalJSON(input []byte) error {
tempStruct := struct {
Slice []json.RawMessage
}{}
temp := []json.RawMessage{}
err := json.Unmarshal(input, &tempStruct)
if err != nil {
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
} else {
temp = tempStruct.Slice
}
ga.Slice = nil
if temp != nil {
ga.Slice = []GetMovementObjectRefundResponseInterface{}
for _, getMovementObjectRefundResponse := range temp {
if getMovementObjectRefundResponse == nil {
ga.Slice = append(ga.Slice, nil)
}
var obj GetMovementObjectRefundResponse
err := json.Unmarshal(getMovementObjectRefundResponse, &obj)
if err != nil {
return err
}
ga.Slice = append(ga.Slice, &obj)
}
}
return nil
}