/
model_things_event.go
174 lines (130 loc) · 3.56 KB
/
model_things_event.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/**
* Webhook Type Definition
* Webhook event definition of the LINE Messaging API
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
//go:generate python3 ../../generate-code.py
package webhook
import (
"encoding/json"
"fmt"
)
// ThingsEvent
// Indicates that a user linked a device with LINE.
type ThingsEvent struct {
Event
/**
* Get Source
*/
Source SourceInterface `json:"source,omitempty"`
/**
* Time of the event in milliseconds. (Required)
*/
Timestamp int64 `json:"timestamp"`
/**
* Get Mode
*/
Mode EventMode `json:"mode"`
/**
* Webhook Event ID. An ID that uniquely identifies a webhook event. This is a string in ULID format. (Required)
*/
WebhookEventId string `json:"webhookEventId"`
/**
* Get DeliveryContext
*/
DeliveryContext *DeliveryContext `json:"deliveryContext"`
/**
* Reply token used to send reply message to this event (Required)
*/
ReplyToken string `json:"replyToken"`
/**
* Get Things
*/
Things ThingsContentInterface `json:"things"`
}
func (cr *ThingsEvent) UnmarshalJSON(data []byte) error {
var raw map[string]json.RawMessage
err := json.Unmarshal(data, &raw)
if err != nil {
return fmt.Errorf("JSON parse error in map: %w", err)
}
if raw["type"] != nil {
err = json.Unmarshal(raw["type"], &cr.Type)
if err != nil {
return fmt.Errorf("JSON parse error in string(Type): %w", err)
}
}
if raw["source"] != nil {
if rawsource, ok := raw["source"]; ok && rawsource != nil {
Source, err := UnmarshalSource(rawsource)
if err != nil {
return fmt.Errorf("JSON parse error in Source(discriminator): %w", err)
}
cr.Source = Source
}
}
if raw["timestamp"] != nil {
err = json.Unmarshal(raw["timestamp"], &cr.Timestamp)
if err != nil {
return fmt.Errorf("JSON parse error in int64(Timestamp): %w", err)
}
}
if raw["mode"] != nil {
err = json.Unmarshal(raw["mode"], &cr.Mode)
if err != nil {
return fmt.Errorf("JSON parse error in EventMode(Mode): %w", err)
}
}
if raw["webhookEventId"] != nil {
err = json.Unmarshal(raw["webhookEventId"], &cr.WebhookEventId)
if err != nil {
return fmt.Errorf("JSON parse error in string(WebhookEventId): %w", err)
}
}
if raw["deliveryContext"] != nil {
err = json.Unmarshal(raw["deliveryContext"], &cr.DeliveryContext)
if err != nil {
return fmt.Errorf("JSON parse error in DeliveryContext(DeliveryContext): %w", err)
}
}
if raw["replyToken"] != nil {
err = json.Unmarshal(raw["replyToken"], &cr.ReplyToken)
if err != nil {
return fmt.Errorf("JSON parse error in string(ReplyToken): %w", err)
}
}
if raw["things"] != nil {
if rawthings, ok := raw["things"]; ok && rawthings != nil {
Things, err := UnmarshalThingsContent(rawthings)
if err != nil {
return fmt.Errorf("JSON parse error in ThingsContent(discriminator): %w", err)
}
cr.Things = Things
}
}
return nil
}
// MarshalJSON customizes the JSON serialization of the ThingsEvent struct.
func (r *ThingsEvent) MarshalJSON() ([]byte, error) {
r.Source = setDiscriminatorPropertySource(r.Source)
r.Things = setDiscriminatorPropertyThingsContent(r.Things)
type Alias ThingsEvent
return json.Marshal(&struct {
*Alias
Type string `json:"type"`
}{
Alias: (*Alias)(r),
Type: "things",
})
}