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