-
Notifications
You must be signed in to change notification settings - Fork 1
/
subscription_group_balances.go
70 lines (63 loc) · 2.66 KB
/
subscription_group_balances.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
package models
import (
"encoding/json"
)
// SubscriptionGroupBalances represents a SubscriptionGroupBalances struct.
type SubscriptionGroupBalances struct {
Prepayments *AccountBalance `json:"prepayments,omitempty"`
ServiceCredits *AccountBalance `json:"service_credits,omitempty"`
OpenInvoices *AccountBalance `json:"open_invoices,omitempty"`
PendingDiscounts *AccountBalance `json:"pending_discounts,omitempty"`
AdditionalProperties map[string]any `json:"_"`
}
// MarshalJSON implements the json.Marshaler interface for SubscriptionGroupBalances.
// It customizes the JSON marshaling process for SubscriptionGroupBalances objects.
func (s SubscriptionGroupBalances) MarshalJSON() (
[]byte,
error) {
return json.Marshal(s.toMap())
}
// toMap converts the SubscriptionGroupBalances object to a map representation for JSON marshaling.
func (s SubscriptionGroupBalances) toMap() map[string]any {
structMap := make(map[string]any)
MapAdditionalProperties(structMap, s.AdditionalProperties)
if s.Prepayments != nil {
structMap["prepayments"] = s.Prepayments.toMap()
}
if s.ServiceCredits != nil {
structMap["service_credits"] = s.ServiceCredits.toMap()
}
if s.OpenInvoices != nil {
structMap["open_invoices"] = s.OpenInvoices.toMap()
}
if s.PendingDiscounts != nil {
structMap["pending_discounts"] = s.PendingDiscounts.toMap()
}
return structMap
}
// UnmarshalJSON implements the json.Unmarshaler interface for SubscriptionGroupBalances.
// It customizes the JSON unmarshaling process for SubscriptionGroupBalances objects.
func (s *SubscriptionGroupBalances) UnmarshalJSON(input []byte) error {
var temp subscriptionGroupBalances
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "prepayments", "service_credits", "open_invoices", "pending_discounts")
if err != nil {
return err
}
s.AdditionalProperties = additionalProperties
s.Prepayments = temp.Prepayments
s.ServiceCredits = temp.ServiceCredits
s.OpenInvoices = temp.OpenInvoices
s.PendingDiscounts = temp.PendingDiscounts
return nil
}
// subscriptionGroupBalances is a temporary struct used for validating the fields of SubscriptionGroupBalances.
type subscriptionGroupBalances struct {
Prepayments *AccountBalance `json:"prepayments,omitempty"`
ServiceCredits *AccountBalance `json:"service_credits,omitempty"`
OpenInvoices *AccountBalance `json:"open_invoices,omitempty"`
PendingDiscounts *AccountBalance `json:"pending_discounts,omitempty"`
}