forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getThreeDSecureResponse.go
63 lines (56 loc) · 1.58 KB
/
getThreeDSecureResponse.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
package models
import (
"encoding/json"
"github.com/apimatic/go-core-runtime/types"
)
// 3D-S payment authentication response
type GetThreeDSecureResponse struct {
Mpi types.Optional[string] `json:"mpi"`
Eci types.Optional[string] `json:"eci"`
Cavv types.Optional[string] `json:"cavv"`
TransactionId types.Optional[string] `json:"transaction_Id"`
SuccessUrl types.Optional[string] `json:"success_url"`
}
func (g *GetThreeDSecureResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetThreeDSecureResponse) toMap() map[string]any {
structMap := make(map[string]any)
if g.Mpi.IsValueSet() {
structMap["mpi"] = g.Mpi.Value()
}
if g.Eci.IsValueSet() {
structMap["eci"] = g.Eci.Value()
}
if g.Cavv.IsValueSet() {
structMap["cavv"] = g.Cavv.Value()
}
if g.TransactionId.IsValueSet() {
structMap["transaction_Id"] = g.TransactionId.Value()
}
if g.SuccessUrl.IsValueSet() {
structMap["success_url"] = g.SuccessUrl.Value()
}
return structMap
}
func (g *GetThreeDSecureResponse) UnmarshalJSON(input []byte) error {
temp := &struct {
Mpi types.Optional[string] `json:"mpi"`
Eci types.Optional[string] `json:"eci"`
Cavv types.Optional[string] `json:"cavv"`
TransactionId types.Optional[string] `json:"transaction_Id"`
SuccessUrl types.Optional[string] `json:"success_url"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.Mpi = temp.Mpi
g.Eci = temp.Eci
g.Cavv = temp.Cavv
g.TransactionId = temp.TransactionId
g.SuccessUrl = temp.SuccessUrl
return nil
}