forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createCardPaymentContactlessRequest.go
53 lines (47 loc) · 1.33 KB
/
createCardPaymentContactlessRequest.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
package models
import (
"encoding/json"
)
// The card payment contactless request
type CreateCardPaymentContactlessRequest struct {
Type string `json:"type"`
ApplePay *CreateApplePayRequest `json:"apple_pay,omitempty"`
GooglePay *CreateGooglePayRequest `json:"google_pay,omitempty"`
Emv *CreateEmvDecryptRequest `json:"emv,omitempty"`
}
func (c *CreateCardPaymentContactlessRequest) MarshalJSON() (
[]byte,
error) {
return json.Marshal(c.toMap())
}
func (c *CreateCardPaymentContactlessRequest) toMap() map[string]any {
structMap := make(map[string]any)
structMap["type"] = c.Type
if c.ApplePay != nil {
structMap["apple_pay"] = c.ApplePay
}
if c.GooglePay != nil {
structMap["google_pay"] = c.GooglePay
}
if c.Emv != nil {
structMap["emv"] = c.Emv
}
return structMap
}
func (c *CreateCardPaymentContactlessRequest) UnmarshalJSON(input []byte) error {
temp := &struct {
Type string `json:"type"`
ApplePay *CreateApplePayRequest `json:"apple_pay,omitempty"`
GooglePay *CreateGooglePayRequest `json:"google_pay,omitempty"`
Emv *CreateEmvDecryptRequest `json:"emv,omitempty"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
c.Type = temp.Type
c.ApplePay = temp.ApplePay
c.GooglePay = temp.GooglePay
c.Emv = temp.Emv
return nil
}