-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmodel_notification_target.go
106 lines (84 loc) · 2.84 KB
/
model_notification_target.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
/*
OneSignal
A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
API version: 1.2.2
Contact: [email protected]
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package onesignal
import (
"encoding/json"
"fmt"
)
// NotificationTarget struct for NotificationTarget
type NotificationTarget struct {
PlayerNotificationTarget *PlayerNotificationTarget
SegmentNotificationTarget *SegmentNotificationTarget
}
// Unmarshal JSON data into any of the pointers in the struct
func (dst *NotificationTarget) UnmarshalJSON(data []byte) error {
var err error
// try to unmarshal JSON data into PlayerNotificationTarget
err = json.Unmarshal(data, &dst.PlayerNotificationTarget);
if err == nil {
jsonPlayerNotificationTarget, _ := json.Marshal(dst.PlayerNotificationTarget)
if string(jsonPlayerNotificationTarget) == "{}" { // empty struct
dst.PlayerNotificationTarget = nil
} else {
return nil // data stored in dst.PlayerNotificationTarget, return on the first match
}
} else {
dst.PlayerNotificationTarget = nil
}
// try to unmarshal JSON data into SegmentNotificationTarget
err = json.Unmarshal(data, &dst.SegmentNotificationTarget);
if err == nil {
jsonSegmentNotificationTarget, _ := json.Marshal(dst.SegmentNotificationTarget)
if string(jsonSegmentNotificationTarget) == "{}" { // empty struct
dst.SegmentNotificationTarget = nil
} else {
return nil // data stored in dst.SegmentNotificationTarget, return on the first match
}
} else {
dst.SegmentNotificationTarget = nil
}
return fmt.Errorf("Data failed to match schemas in anyOf(NotificationTarget)")
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src *NotificationTarget) MarshalJSON() ([]byte, error) {
if src.PlayerNotificationTarget != nil {
return json.Marshal(&src.PlayerNotificationTarget)
}
if src.SegmentNotificationTarget != nil {
return json.Marshal(&src.SegmentNotificationTarget)
}
return nil, nil // no data in anyOf schemas
}
type NullableNotificationTarget struct {
value *NotificationTarget
isSet bool
}
func (v NullableNotificationTarget) Get() *NotificationTarget {
return v.value
}
func (v *NullableNotificationTarget) Set(val *NotificationTarget) {
v.value = val
v.isSet = true
}
func (v NullableNotificationTarget) IsSet() bool {
return v.isSet
}
func (v *NullableNotificationTarget) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableNotificationTarget(val *NotificationTarget) *NullableNotificationTarget {
return &NullableNotificationTarget{value: val, isSet: true}
}
func (v NullableNotificationTarget) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableNotificationTarget) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}