-
Notifications
You must be signed in to change notification settings - Fork 1
/
renewal_preview_line_item.go
132 lines (125 loc) · 5.9 KB
/
renewal_preview_line_item.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package models
import (
"encoding/json"
)
// RenewalPreviewLineItem represents a RenewalPreviewLineItem struct.
type RenewalPreviewLineItem struct {
// A handle for the line item transaction type
TransactionType *LineItemTransactionType `json:"transaction_type,omitempty"`
// A handle for the line item kind
Kind *LineItemKind `json:"kind,omitempty"`
AmountInCents *int64 `json:"amount_in_cents,omitempty"`
Memo *string `json:"memo,omitempty"`
DiscountAmountInCents *int64 `json:"discount_amount_in_cents,omitempty"`
TaxableAmountInCents *int64 `json:"taxable_amount_in_cents,omitempty"`
ProductId *int `json:"product_id,omitempty"`
ProductName *string `json:"product_name,omitempty"`
ComponentId *int `json:"component_id,omitempty"`
ComponentHandle *string `json:"component_handle,omitempty"`
ComponentName *string `json:"component_name,omitempty"`
ProductHandle *string `json:"product_handle,omitempty"`
PeriodRangeStart *string `json:"period_range_start,omitempty"`
PeriodRangeEnd *string `json:"period_range_end,omitempty"`
AdditionalProperties map[string]any `json:"_"`
}
// MarshalJSON implements the json.Marshaler interface for RenewalPreviewLineItem.
// It customizes the JSON marshaling process for RenewalPreviewLineItem objects.
func (r RenewalPreviewLineItem) MarshalJSON() (
[]byte,
error) {
return json.Marshal(r.toMap())
}
// toMap converts the RenewalPreviewLineItem object to a map representation for JSON marshaling.
func (r RenewalPreviewLineItem) toMap() map[string]any {
structMap := make(map[string]any)
MapAdditionalProperties(structMap, r.AdditionalProperties)
if r.TransactionType != nil {
structMap["transaction_type"] = r.TransactionType
}
if r.Kind != nil {
structMap["kind"] = r.Kind
}
if r.AmountInCents != nil {
structMap["amount_in_cents"] = r.AmountInCents
}
if r.Memo != nil {
structMap["memo"] = r.Memo
}
if r.DiscountAmountInCents != nil {
structMap["discount_amount_in_cents"] = r.DiscountAmountInCents
}
if r.TaxableAmountInCents != nil {
structMap["taxable_amount_in_cents"] = r.TaxableAmountInCents
}
if r.ProductId != nil {
structMap["product_id"] = r.ProductId
}
if r.ProductName != nil {
structMap["product_name"] = r.ProductName
}
if r.ComponentId != nil {
structMap["component_id"] = r.ComponentId
}
if r.ComponentHandle != nil {
structMap["component_handle"] = r.ComponentHandle
}
if r.ComponentName != nil {
structMap["component_name"] = r.ComponentName
}
if r.ProductHandle != nil {
structMap["product_handle"] = r.ProductHandle
}
if r.PeriodRangeStart != nil {
structMap["period_range_start"] = r.PeriodRangeStart
}
if r.PeriodRangeEnd != nil {
structMap["period_range_end"] = r.PeriodRangeEnd
}
return structMap
}
// UnmarshalJSON implements the json.Unmarshaler interface for RenewalPreviewLineItem.
// It customizes the JSON unmarshaling process for RenewalPreviewLineItem objects.
func (r *RenewalPreviewLineItem) UnmarshalJSON(input []byte) error {
var temp renewalPreviewLineItem
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "transaction_type", "kind", "amount_in_cents", "memo", "discount_amount_in_cents", "taxable_amount_in_cents", "product_id", "product_name", "component_id", "component_handle", "component_name", "product_handle", "period_range_start", "period_range_end")
if err != nil {
return err
}
r.AdditionalProperties = additionalProperties
r.TransactionType = temp.TransactionType
r.Kind = temp.Kind
r.AmountInCents = temp.AmountInCents
r.Memo = temp.Memo
r.DiscountAmountInCents = temp.DiscountAmountInCents
r.TaxableAmountInCents = temp.TaxableAmountInCents
r.ProductId = temp.ProductId
r.ProductName = temp.ProductName
r.ComponentId = temp.ComponentId
r.ComponentHandle = temp.ComponentHandle
r.ComponentName = temp.ComponentName
r.ProductHandle = temp.ProductHandle
r.PeriodRangeStart = temp.PeriodRangeStart
r.PeriodRangeEnd = temp.PeriodRangeEnd
return nil
}
// renewalPreviewLineItem is a temporary struct used for validating the fields of RenewalPreviewLineItem.
type renewalPreviewLineItem struct {
TransactionType *LineItemTransactionType `json:"transaction_type,omitempty"`
Kind *LineItemKind `json:"kind,omitempty"`
AmountInCents *int64 `json:"amount_in_cents,omitempty"`
Memo *string `json:"memo,omitempty"`
DiscountAmountInCents *int64 `json:"discount_amount_in_cents,omitempty"`
TaxableAmountInCents *int64 `json:"taxable_amount_in_cents,omitempty"`
ProductId *int `json:"product_id,omitempty"`
ProductName *string `json:"product_name,omitempty"`
ComponentId *int `json:"component_id,omitempty"`
ComponentHandle *string `json:"component_handle,omitempty"`
ComponentName *string `json:"component_name,omitempty"`
ProductHandle *string `json:"product_handle,omitempty"`
PeriodRangeStart *string `json:"period_range_start,omitempty"`
PeriodRangeEnd *string `json:"period_range_end,omitempty"`
}