-
Notifications
You must be signed in to change notification settings - Fork 13
/
chatmessage.go
184 lines (119 loc) · 3.76 KB
/
chatmessage.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
175
176
177
178
179
180
181
182
183
184
package platformclientv2
import (
"github.com/leekchan/timeutil"
"encoding/json"
"strconv"
"strings"
)
// Chatmessage
type Chatmessage struct {
// Body - The message body
Body *string `json:"body,omitempty"`
// Id
Id *string `json:"id,omitempty"`
// To - The message recipient
To *string `json:"to,omitempty"`
// From - The message sender
From *string `json:"from,omitempty"`
// Utc
Utc *string `json:"utc,omitempty"`
// Chat - The interaction id (if available)
Chat *string `json:"chat,omitempty"`
// Message - The message id
Message *string `json:"message,omitempty"`
// VarType
VarType *string `json:"type,omitempty"`
// BodyType - Type of the message body (v2 chats only)
BodyType *string `json:"bodyType,omitempty"`
// SenderCommunicationId - Communication of sender (v2 chats only)
SenderCommunicationId *string `json:"senderCommunicationId,omitempty"`
// ParticipantPurpose - Participant purpose of sender (v2 chats only)
ParticipantPurpose *string `json:"participantPurpose,omitempty"`
// User - The user information for the sender (if available)
User *Chatmessageuser `json:"user,omitempty"`
}
func (o *Chatmessage) MarshalJSON() ([]byte, error) {
// Redundant initialization to avoid unused import errors for models with no Time values
_ = timeutil.Timedelta{}
type Alias Chatmessage
return json.Marshal(&struct {
Body *string `json:"body,omitempty"`
Id *string `json:"id,omitempty"`
To *string `json:"to,omitempty"`
From *string `json:"from,omitempty"`
Utc *string `json:"utc,omitempty"`
Chat *string `json:"chat,omitempty"`
Message *string `json:"message,omitempty"`
VarType *string `json:"type,omitempty"`
BodyType *string `json:"bodyType,omitempty"`
SenderCommunicationId *string `json:"senderCommunicationId,omitempty"`
ParticipantPurpose *string `json:"participantPurpose,omitempty"`
User *Chatmessageuser `json:"user,omitempty"`
*Alias
}{
Body: o.Body,
Id: o.Id,
To: o.To,
From: o.From,
Utc: o.Utc,
Chat: o.Chat,
Message: o.Message,
VarType: o.VarType,
BodyType: o.BodyType,
SenderCommunicationId: o.SenderCommunicationId,
ParticipantPurpose: o.ParticipantPurpose,
User: o.User,
Alias: (*Alias)(o),
})
}
func (o *Chatmessage) UnmarshalJSON(b []byte) error {
var ChatmessageMap map[string]interface{}
err := json.Unmarshal(b, &ChatmessageMap)
if err != nil {
return err
}
if Body, ok := ChatmessageMap["body"].(string); ok {
o.Body = &Body
}
if Id, ok := ChatmessageMap["id"].(string); ok {
o.Id = &Id
}
if To, ok := ChatmessageMap["to"].(string); ok {
o.To = &To
}
if From, ok := ChatmessageMap["from"].(string); ok {
o.From = &From
}
if Utc, ok := ChatmessageMap["utc"].(string); ok {
o.Utc = &Utc
}
if Chat, ok := ChatmessageMap["chat"].(string); ok {
o.Chat = &Chat
}
if Message, ok := ChatmessageMap["message"].(string); ok {
o.Message = &Message
}
if VarType, ok := ChatmessageMap["type"].(string); ok {
o.VarType = &VarType
}
if BodyType, ok := ChatmessageMap["bodyType"].(string); ok {
o.BodyType = &BodyType
}
if SenderCommunicationId, ok := ChatmessageMap["senderCommunicationId"].(string); ok {
o.SenderCommunicationId = &SenderCommunicationId
}
if ParticipantPurpose, ok := ChatmessageMap["participantPurpose"].(string); ok {
o.ParticipantPurpose = &ParticipantPurpose
}
if User, ok := ChatmessageMap["user"].(map[string]interface{}); ok {
UserString, _ := json.Marshal(User)
json.Unmarshal(UserString, &o.User)
}
return nil
}
// String returns a JSON representation of the model
func (o *Chatmessage) String() string {
j, _ := json.Marshal(o)
str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\u`, `\u`, -1))
return str
}