-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_segment_segment_property_3_value.go
132 lines (114 loc) · 4.26 KB
/
create_segment_segment_property_3_value.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 advancedbilling
This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
package models
import (
"encoding/json"
"errors"
"strings"
)
// CreateSegmentSegmentProperty3Value represents a CreateSegmentSegmentProperty3Value struct.
// This is a container for one-of cases.
type CreateSegmentSegmentProperty3Value struct {
value any
isString bool
isPrecision bool
isNumber bool
isBoolean bool
}
// String converts the CreateSegmentSegmentProperty3Value object to a string representation.
func (c CreateSegmentSegmentProperty3Value) String() string {
if bytes, err := json.Marshal(c.value); err == nil {
return strings.Trim(string(bytes), "\"")
}
return ""
}
// MarshalJSON implements the json.Marshaler interface for CreateSegmentSegmentProperty3Value.
// It customizes the JSON marshaling process for CreateSegmentSegmentProperty3Value objects.
func (c CreateSegmentSegmentProperty3Value) MarshalJSON() (
[]byte,
error) {
if c.value == nil {
return nil, errors.New("No underlying type is set. Please use any of the `models.CreateSegmentSegmentProperty3ValueContainer.From*` functions to initialize the CreateSegmentSegmentProperty3Value object.")
}
return json.Marshal(c.toMap())
}
// toMap converts the CreateSegmentSegmentProperty3Value object to a map representation for JSON marshaling.
func (c *CreateSegmentSegmentProperty3Value) toMap() any {
switch obj := c.value.(type) {
case *string:
return *obj
case *float64:
return *obj
case *int:
return *obj
case *bool:
return *obj
}
return nil
}
// UnmarshalJSON implements the json.Unmarshaler interface for CreateSegmentSegmentProperty3Value.
// It customizes the JSON unmarshaling process for CreateSegmentSegmentProperty3Value objects.
func (c *CreateSegmentSegmentProperty3Value) UnmarshalJSON(input []byte) error {
result, err := UnmarshallOneOf(input,
NewTypeHolder(new(string), false, &c.isString),
NewTypeHolder(new(float64), false, &c.isPrecision),
NewTypeHolder(new(int), false, &c.isNumber),
NewTypeHolder(new(bool), false, &c.isBoolean),
)
c.value = result
return err
}
func (c *CreateSegmentSegmentProperty3Value) AsString() (
*string,
bool) {
if !c.isString {
return nil, false
}
return c.value.(*string), true
}
func (c *CreateSegmentSegmentProperty3Value) AsPrecision() (
*float64,
bool) {
if !c.isPrecision {
return nil, false
}
return c.value.(*float64), true
}
func (c *CreateSegmentSegmentProperty3Value) AsNumber() (
*int,
bool) {
if !c.isNumber {
return nil, false
}
return c.value.(*int), true
}
func (c *CreateSegmentSegmentProperty3Value) AsBoolean() (
*bool,
bool) {
if !c.isBoolean {
return nil, false
}
return c.value.(*bool), true
}
// internalCreateSegmentSegmentProperty3Value represents a createSegmentSegmentProperty3Value struct.
// This is a container for one-of cases.
type internalCreateSegmentSegmentProperty3Value struct {}
var CreateSegmentSegmentProperty3ValueContainer internalCreateSegmentSegmentProperty3Value
// The internalCreateSegmentSegmentProperty3Value instance, wrapping the provided string value.
func (c *internalCreateSegmentSegmentProperty3Value) FromString(val string) CreateSegmentSegmentProperty3Value {
return CreateSegmentSegmentProperty3Value{value: &val}
}
// The internalCreateSegmentSegmentProperty3Value instance, wrapping the provided float64 value.
func (c *internalCreateSegmentSegmentProperty3Value) FromPrecision(val float64) CreateSegmentSegmentProperty3Value {
return CreateSegmentSegmentProperty3Value{value: &val}
}
// The internalCreateSegmentSegmentProperty3Value instance, wrapping the provided int value.
func (c *internalCreateSegmentSegmentProperty3Value) FromNumber(val int) CreateSegmentSegmentProperty3Value {
return CreateSegmentSegmentProperty3Value{value: &val}
}
// The internalCreateSegmentSegmentProperty3Value instance, wrapping the provided bool value.
func (c *internalCreateSegmentSegmentProperty3Value) FromBoolean(val bool) CreateSegmentSegmentProperty3Value {
return CreateSegmentSegmentProperty3Value{value: &val}
}