forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateRecipientRequest.go
55 lines (49 loc) · 1.4 KB
/
updateRecipientRequest.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
package models
import (
"encoding/json"
)
// Request for updating a Recipient
type UpdateRecipientRequest struct {
Name string `json:"name"`
Email string `json:"email"`
Description string `json:"description"`
Type string `json:"type"`
Status string `json:"status"`
Metadata map[string]string `json:"metadata"`
}
func (u *UpdateRecipientRequest) MarshalJSON() (
[]byte,
error) {
return json.Marshal(u.toMap())
}
func (u *UpdateRecipientRequest) toMap() map[string]any {
structMap := make(map[string]any)
structMap["name"] = u.Name
structMap["email"] = u.Email
structMap["description"] = u.Description
structMap["type"] = u.Type
structMap["status"] = u.Status
structMap["metadata"] = u.Metadata
return structMap
}
func (u *UpdateRecipientRequest) UnmarshalJSON(input []byte) error {
temp := &struct {
Name string `json:"name"`
Email string `json:"email"`
Description string `json:"description"`
Type string `json:"type"`
Status string `json:"status"`
Metadata map[string]string `json:"metadata"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
u.Name = temp.Name
u.Email = temp.Email
u.Description = temp.Description
u.Type = temp.Type
u.Status = temp.Status
u.Metadata = temp.Metadata
return nil
}