-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepaid_configuration.go
76 lines (69 loc) · 3.21 KB
/
prepaid_configuration.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
package models
import (
"encoding/json"
)
// PrepaidConfiguration represents a PrepaidConfiguration struct.
type PrepaidConfiguration struct {
Id *int `json:"id,omitempty"`
InitialFundingAmountInCents *int64 `json:"initial_funding_amount_in_cents,omitempty"`
ReplenishToAmountInCents *int64 `json:"replenish_to_amount_in_cents,omitempty"`
AutoReplenish *bool `json:"auto_replenish,omitempty"`
ReplenishThresholdAmountInCents *int64 `json:"replenish_threshold_amount_in_cents,omitempty"`
AdditionalProperties map[string]any `json:"_"`
}
// MarshalJSON implements the json.Marshaler interface for PrepaidConfiguration.
// It customizes the JSON marshaling process for PrepaidConfiguration objects.
func (p PrepaidConfiguration) MarshalJSON() (
[]byte,
error) {
return json.Marshal(p.toMap())
}
// toMap converts the PrepaidConfiguration object to a map representation for JSON marshaling.
func (p PrepaidConfiguration) toMap() map[string]any {
structMap := make(map[string]any)
MapAdditionalProperties(structMap, p.AdditionalProperties)
if p.Id != nil {
structMap["id"] = p.Id
}
if p.InitialFundingAmountInCents != nil {
structMap["initial_funding_amount_in_cents"] = p.InitialFundingAmountInCents
}
if p.ReplenishToAmountInCents != nil {
structMap["replenish_to_amount_in_cents"] = p.ReplenishToAmountInCents
}
if p.AutoReplenish != nil {
structMap["auto_replenish"] = p.AutoReplenish
}
if p.ReplenishThresholdAmountInCents != nil {
structMap["replenish_threshold_amount_in_cents"] = p.ReplenishThresholdAmountInCents
}
return structMap
}
// UnmarshalJSON implements the json.Unmarshaler interface for PrepaidConfiguration.
// It customizes the JSON unmarshaling process for PrepaidConfiguration objects.
func (p *PrepaidConfiguration) UnmarshalJSON(input []byte) error {
var temp prepaidConfiguration
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "initial_funding_amount_in_cents", "replenish_to_amount_in_cents", "auto_replenish", "replenish_threshold_amount_in_cents")
if err != nil {
return err
}
p.AdditionalProperties = additionalProperties
p.Id = temp.Id
p.InitialFundingAmountInCents = temp.InitialFundingAmountInCents
p.ReplenishToAmountInCents = temp.ReplenishToAmountInCents
p.AutoReplenish = temp.AutoReplenish
p.ReplenishThresholdAmountInCents = temp.ReplenishThresholdAmountInCents
return nil
}
// prepaidConfiguration is a temporary struct used for validating the fields of PrepaidConfiguration.
type prepaidConfiguration struct {
Id *int `json:"id,omitempty"`
InitialFundingAmountInCents *int64 `json:"initial_funding_amount_in_cents,omitempty"`
ReplenishToAmountInCents *int64 `json:"replenish_to_amount_in_cents,omitempty"`
AutoReplenish *bool `json:"auto_replenish,omitempty"`
ReplenishThresholdAmountInCents *int64 `json:"replenish_threshold_amount_in_cents,omitempty"`
}