forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createPrivateLabelPaymentRequest.go
91 lines (85 loc) · 3.11 KB
/
createPrivateLabelPaymentRequest.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package models
import (
"encoding/json"
)
// The settings for creating a private label payment
type CreatePrivateLabelPaymentRequest struct {
Installments *int `json:"installments,omitempty"`
StatementDescriptor *string `json:"statement_descriptor,omitempty"`
Card *CreateCardRequest `json:"card,omitempty"`
CardId *string `json:"card_id,omitempty"`
CardToken *string `json:"card_token,omitempty"`
Recurrence *bool `json:"recurrence,omitempty"`
Capture *bool `json:"capture,omitempty"`
ExtendedLimitEnabled *bool `json:"extended_limit_enabled,omitempty"`
ExtendedLimitCode *string `json:"extended_limit_code,omitempty"`
RecurrencyCycle *string `json:"recurrency_cycle,omitempty"`
}
func (c *CreatePrivateLabelPaymentRequest) MarshalJSON() (
[]byte,
error) {
return json.Marshal(c.toMap())
}
func (c *CreatePrivateLabelPaymentRequest) toMap() map[string]any {
structMap := make(map[string]any)
if c.Installments != nil {
structMap["installments"] = c.Installments
}
if c.StatementDescriptor != nil {
structMap["statement_descriptor"] = c.StatementDescriptor
}
if c.Card != nil {
structMap["card"] = c.Card
}
if c.CardId != nil {
structMap["card_id"] = c.CardId
}
if c.CardToken != nil {
structMap["card_token"] = c.CardToken
}
if c.Recurrence != nil {
structMap["recurrence"] = c.Recurrence
}
if c.Capture != nil {
structMap["capture"] = c.Capture
}
if c.ExtendedLimitEnabled != nil {
structMap["extended_limit_enabled"] = c.ExtendedLimitEnabled
}
if c.ExtendedLimitCode != nil {
structMap["extended_limit_code"] = c.ExtendedLimitCode
}
if c.RecurrencyCycle != nil {
structMap["recurrency_cycle"] = c.RecurrencyCycle
}
return structMap
}
func (c *CreatePrivateLabelPaymentRequest) UnmarshalJSON(input []byte) error {
temp := &struct {
Installments *int `json:"installments,omitempty"`
StatementDescriptor *string `json:"statement_descriptor,omitempty"`
Card *CreateCardRequest `json:"card,omitempty"`
CardId *string `json:"card_id,omitempty"`
CardToken *string `json:"card_token,omitempty"`
Recurrence *bool `json:"recurrence,omitempty"`
Capture *bool `json:"capture,omitempty"`
ExtendedLimitEnabled *bool `json:"extended_limit_enabled,omitempty"`
ExtendedLimitCode *string `json:"extended_limit_code,omitempty"`
RecurrencyCycle *string `json:"recurrency_cycle,omitempty"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
c.Installments = temp.Installments
c.StatementDescriptor = temp.StatementDescriptor
c.Card = temp.Card
c.CardId = temp.CardId
c.CardToken = temp.CardToken
c.Recurrence = temp.Recurrence
c.Capture = temp.Capture
c.ExtendedLimitEnabled = temp.ExtendedLimitEnabled
c.ExtendedLimitCode = temp.ExtendedLimitCode
c.RecurrencyCycle = temp.RecurrencyCycle
return nil
}