-
Notifications
You must be signed in to change notification settings - Fork 1
/
proforma_invoice_discount.go
94 lines (87 loc) · 3.87 KB
/
proforma_invoice_discount.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
package models
import (
"encoding/json"
)
// ProformaInvoiceDiscount represents a ProformaInvoiceDiscount struct.
type ProformaInvoiceDiscount struct {
Uid *string `json:"uid,omitempty"`
Title *string `json:"title,omitempty"`
Code *string `json:"code,omitempty"`
SourceType *ProformaInvoiceDiscountSourceType `json:"source_type,omitempty"`
DiscountType *InvoiceDiscountType `json:"discount_type,omitempty"`
EligibleAmount *string `json:"eligible_amount,omitempty"`
DiscountAmount *string `json:"discount_amount,omitempty"`
LineItemBreakouts []InvoiceDiscountBreakout `json:"line_item_breakouts,omitempty"`
AdditionalProperties map[string]any `json:"_"`
}
// MarshalJSON implements the json.Marshaler interface for ProformaInvoiceDiscount.
// It customizes the JSON marshaling process for ProformaInvoiceDiscount objects.
func (p ProformaInvoiceDiscount) MarshalJSON() (
[]byte,
error) {
return json.Marshal(p.toMap())
}
// toMap converts the ProformaInvoiceDiscount object to a map representation for JSON marshaling.
func (p ProformaInvoiceDiscount) toMap() map[string]any {
structMap := make(map[string]any)
MapAdditionalProperties(structMap, p.AdditionalProperties)
if p.Uid != nil {
structMap["uid"] = p.Uid
}
if p.Title != nil {
structMap["title"] = p.Title
}
if p.Code != nil {
structMap["code"] = p.Code
}
if p.SourceType != nil {
structMap["source_type"] = p.SourceType
}
if p.DiscountType != nil {
structMap["discount_type"] = p.DiscountType
}
if p.EligibleAmount != nil {
structMap["eligible_amount"] = p.EligibleAmount
}
if p.DiscountAmount != nil {
structMap["discount_amount"] = p.DiscountAmount
}
if p.LineItemBreakouts != nil {
structMap["line_item_breakouts"] = p.LineItemBreakouts
}
return structMap
}
// UnmarshalJSON implements the json.Unmarshaler interface for ProformaInvoiceDiscount.
// It customizes the JSON unmarshaling process for ProformaInvoiceDiscount objects.
func (p *ProformaInvoiceDiscount) UnmarshalJSON(input []byte) error {
var temp proformaInvoiceDiscount
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "uid", "title", "code", "source_type", "discount_type", "eligible_amount", "discount_amount", "line_item_breakouts")
if err != nil {
return err
}
p.AdditionalProperties = additionalProperties
p.Uid = temp.Uid
p.Title = temp.Title
p.Code = temp.Code
p.SourceType = temp.SourceType
p.DiscountType = temp.DiscountType
p.EligibleAmount = temp.EligibleAmount
p.DiscountAmount = temp.DiscountAmount
p.LineItemBreakouts = temp.LineItemBreakouts
return nil
}
// proformaInvoiceDiscount is a temporary struct used for validating the fields of ProformaInvoiceDiscount.
type proformaInvoiceDiscount struct {
Uid *string `json:"uid,omitempty"`
Title *string `json:"title,omitempty"`
Code *string `json:"code,omitempty"`
SourceType *ProformaInvoiceDiscountSourceType `json:"source_type,omitempty"`
DiscountType *InvoiceDiscountType `json:"discount_type,omitempty"`
EligibleAmount *string `json:"eligible_amount,omitempty"`
DiscountAmount *string `json:"discount_amount,omitempty"`
LineItemBreakouts []InvoiceDiscountBreakout `json:"line_item_breakouts,omitempty"`
}