-
Notifications
You must be signed in to change notification settings - Fork 1
/
payment_profile_attributes_expiration_month.go
96 lines (82 loc) · 3.3 KB
/
payment_profile_attributes_expiration_month.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"
)
// PaymentProfileAttributesExpirationMonth represents a PaymentProfileAttributesExpirationMonth struct.
// This is a container for one-of cases.
type PaymentProfileAttributesExpirationMonth struct {
value any
isNumber bool
isString bool
}
// String converts the PaymentProfileAttributesExpirationMonth object to a string representation.
func (p PaymentProfileAttributesExpirationMonth) String() string {
if bytes, err := json.Marshal(p.value); err == nil {
return strings.Trim(string(bytes), "\"")
}
return ""
}
// MarshalJSON implements the json.Marshaler interface for PaymentProfileAttributesExpirationMonth.
// It customizes the JSON marshaling process for PaymentProfileAttributesExpirationMonth objects.
func (p PaymentProfileAttributesExpirationMonth) MarshalJSON() (
[]byte,
error) {
if p.value == nil {
return nil, errors.New("No underlying type is set. Please use any of the `models.PaymentProfileAttributesExpirationMonthContainer.From*` functions to initialize the PaymentProfileAttributesExpirationMonth object.")
}
return json.Marshal(p.toMap())
}
// toMap converts the PaymentProfileAttributesExpirationMonth object to a map representation for JSON marshaling.
func (p *PaymentProfileAttributesExpirationMonth) toMap() any {
switch obj := p.value.(type) {
case *int:
return *obj
case *string:
return *obj
}
return nil
}
// UnmarshalJSON implements the json.Unmarshaler interface for PaymentProfileAttributesExpirationMonth.
// It customizes the JSON unmarshaling process for PaymentProfileAttributesExpirationMonth objects.
func (p *PaymentProfileAttributesExpirationMonth) UnmarshalJSON(input []byte) error {
result, err := UnmarshallOneOf(input,
NewTypeHolder(new(int), false, &p.isNumber),
NewTypeHolder(new(string), false, &p.isString),
)
p.value = result
return err
}
func (p *PaymentProfileAttributesExpirationMonth) AsNumber() (
*int,
bool) {
if !p.isNumber {
return nil, false
}
return p.value.(*int), true
}
func (p *PaymentProfileAttributesExpirationMonth) AsString() (
*string,
bool) {
if !p.isString {
return nil, false
}
return p.value.(*string), true
}
// internalPaymentProfileAttributesExpirationMonth represents a paymentProfileAttributesExpirationMonth struct.
// This is a container for one-of cases.
type internalPaymentProfileAttributesExpirationMonth struct {}
var PaymentProfileAttributesExpirationMonthContainer internalPaymentProfileAttributesExpirationMonth
// The internalPaymentProfileAttributesExpirationMonth instance, wrapping the provided int value.
func (p *internalPaymentProfileAttributesExpirationMonth) FromNumber(val int) PaymentProfileAttributesExpirationMonth {
return PaymentProfileAttributesExpirationMonth{value: &val}
}
// The internalPaymentProfileAttributesExpirationMonth instance, wrapping the provided string value.
func (p *internalPaymentProfileAttributesExpirationMonth) FromString(val string) PaymentProfileAttributesExpirationMonth {
return PaymentProfileAttributesExpirationMonth{value: &val}
}