forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createApplePayHeaderRequest.go
47 lines (41 loc) · 1.21 KB
/
createApplePayHeaderRequest.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
package models
import (
"encoding/json"
)
// The ApplePay header request
type CreateApplePayHeaderRequest struct {
PublicKeyHash *string `json:"public_key_hash,omitempty"`
EphemeralPublicKey string `json:"ephemeral_public_key"`
TransactionId *string `json:"transaction_id,omitempty"`
}
func (c *CreateApplePayHeaderRequest) MarshalJSON() (
[]byte,
error) {
return json.Marshal(c.toMap())
}
func (c *CreateApplePayHeaderRequest) toMap() map[string]any {
structMap := make(map[string]any)
if c.PublicKeyHash != nil {
structMap["public_key_hash"] = c.PublicKeyHash
}
structMap["ephemeral_public_key"] = c.EphemeralPublicKey
if c.TransactionId != nil {
structMap["transaction_id"] = c.TransactionId
}
return structMap
}
func (c *CreateApplePayHeaderRequest) UnmarshalJSON(input []byte) error {
temp := &struct {
PublicKeyHash *string `json:"public_key_hash,omitempty"`
EphemeralPublicKey string `json:"ephemeral_public_key"`
TransactionId *string `json:"transaction_id,omitempty"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
c.PublicKeyHash = temp.PublicKeyHash
c.EphemeralPublicKey = temp.EphemeralPublicKey
c.TransactionId = temp.TransactionId
return nil
}