forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCheckoutCreditCardPaymentResponse.go
50 lines (43 loc) · 1.61 KB
/
getCheckoutCreditCardPaymentResponse.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"
"github.com/apimatic/go-core-runtime/types"
)
type GetCheckoutCreditCardPaymentResponse struct {
StatementDescriptor types.Optional[string] `json:"statementDescriptor"`
Installments types.Optional[[]GetCheckoutCardInstallmentOptionsResponse] `json:"installments"`
Authentication types.Optional[GetPaymentAuthenticationResponse] `json:"authentication"`
}
func (g *GetCheckoutCreditCardPaymentResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetCheckoutCreditCardPaymentResponse) toMap() map[string]any {
structMap := make(map[string]any)
if g.StatementDescriptor.IsValueSet() {
structMap["statementDescriptor"] = g.StatementDescriptor.Value()
}
if g.Installments.IsValueSet() {
structMap["installments"] = g.Installments.Value()
}
if g.Authentication.IsValueSet() {
structMap["authentication"] = g.Authentication.Value()
}
return structMap
}
func (g *GetCheckoutCreditCardPaymentResponse) UnmarshalJSON(input []byte) error {
temp := &struct {
StatementDescriptor types.Optional[string] `json:"statementDescriptor"`
Installments types.Optional[[]GetCheckoutCardInstallmentOptionsResponse] `json:"installments"`
Authentication types.Optional[GetPaymentAuthenticationResponse] `json:"authentication"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.StatementDescriptor = temp.StatementDescriptor
g.Installments = temp.Installments
g.Authentication = temp.Authentication
return nil
}