forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createEmvDataDecryptRequest.go
44 lines (38 loc) · 1.02 KB
/
createEmvDataDecryptRequest.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
package models
import (
"encoding/json"
)
type CreateEmvDataDecryptRequest struct {
Cipher string `json:"cipher"`
Dukpt *CreateEmvDataDukptDecryptRequest `json:"dukpt,omitempty"`
Tags []CreateEmvDataTlvDecryptRequest `json:"tags"`
}
func (c *CreateEmvDataDecryptRequest) MarshalJSON() (
[]byte,
error) {
return json.Marshal(c.toMap())
}
func (c *CreateEmvDataDecryptRequest) toMap() map[string]any {
structMap := make(map[string]any)
structMap["cipher"] = c.Cipher
if c.Dukpt != nil {
structMap["dukpt"] = c.Dukpt
}
structMap["tags"] = c.Tags
return structMap
}
func (c *CreateEmvDataDecryptRequest) UnmarshalJSON(input []byte) error {
temp := &struct {
Cipher string `json:"cipher"`
Dukpt *CreateEmvDataDukptDecryptRequest `json:"dukpt,omitempty"`
Tags []CreateEmvDataTlvDecryptRequest `json:"tags"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
c.Cipher = temp.Cipher
c.Dukpt = temp.Dukpt
c.Tags = temp.Tags
return nil
}