-
Notifications
You must be signed in to change notification settings - Fork 1
/
list_subscription_components_filter.go
60 lines (53 loc) · 2.45 KB
/
list_subscription_components_filter.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
package models
import (
"encoding/json"
)
// ListSubscriptionComponentsFilter represents a ListSubscriptionComponentsFilter struct.
type ListSubscriptionComponentsFilter struct {
// Allows fetching components allocation with matching currency based on provided values. Use in query `filter[currencies]=EUR,USD`.
Currencies []string `json:"currencies,omitempty"`
// Allows fetching components allocation with matching use_site_exchange_rate based on provided value. Use in query `filter[use_site_exchange_rate]=true`.
UseSiteExchangeRate *bool `json:"use_site_exchange_rate,omitempty"`
AdditionalProperties map[string]any `json:"_"`
}
// MarshalJSON implements the json.Marshaler interface for ListSubscriptionComponentsFilter.
// It customizes the JSON marshaling process for ListSubscriptionComponentsFilter objects.
func (l ListSubscriptionComponentsFilter) MarshalJSON() (
[]byte,
error) {
return json.Marshal(l.toMap())
}
// toMap converts the ListSubscriptionComponentsFilter object to a map representation for JSON marshaling.
func (l ListSubscriptionComponentsFilter) toMap() map[string]any {
structMap := make(map[string]any)
MapAdditionalProperties(structMap, l.AdditionalProperties)
if l.Currencies != nil {
structMap["currencies"] = l.Currencies
}
if l.UseSiteExchangeRate != nil {
structMap["use_site_exchange_rate"] = l.UseSiteExchangeRate
}
return structMap
}
// UnmarshalJSON implements the json.Unmarshaler interface for ListSubscriptionComponentsFilter.
// It customizes the JSON unmarshaling process for ListSubscriptionComponentsFilter objects.
func (l *ListSubscriptionComponentsFilter) UnmarshalJSON(input []byte) error {
var temp listSubscriptionComponentsFilter
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "currencies", "use_site_exchange_rate")
if err != nil {
return err
}
l.AdditionalProperties = additionalProperties
l.Currencies = temp.Currencies
l.UseSiteExchangeRate = temp.UseSiteExchangeRate
return nil
}
// listSubscriptionComponentsFilter is a temporary struct used for validating the fields of ListSubscriptionComponentsFilter.
type listSubscriptionComponentsFilter struct {
Currencies []string `json:"currencies,omitempty"`
UseSiteExchangeRate *bool `json:"use_site_exchange_rate,omitempty"`
}