Twitch SDK (Internal)
chatjsonobjectdescriptions.h
Go to the documentation of this file.
1 /********************************************************************************************
2  * Twitch Broadcasting SDK
3  *
4  * This software is supplied under the terms of a license agreement with Twitch Interactive, Inc. and
5  * may not be copied or used except in accordance with the terms of that agreement
6  * Copyright (c) 2012-2016 Twitch Interactive, Inc.
7  *********************************************************************************************/
8 
9 #pragma once
10 
13 
14 namespace ttv
15 {
16  namespace chat
17  {
18  namespace json
19  {
20  namespace description
21  {
22  struct GraphQLChatRoomMessage;
23  struct GraphQLChatRoomInfo;
24  struct GraphQLChatRoomView;
25  struct GraphQLUserInfo;
26  struct GraphQLRoomPermissions;
27  struct GraphQLChatMode;
28  struct PubSubChatRoomMessage;
29  struct PubSubChatRoomInfo;
30  struct PubSubChatRoomView;
31  struct PubSubRoomPermissions;
32  struct PubSubChatMode;
33  struct PubSubHostTargetChange;
34  struct PubSubBitsSentEvent;
35  struct ChatRoomRole;
36  struct ChatRoomMentionInfo;
37  struct GraphQLErrorCode;
38  struct SendRoomMessageError;
39  struct CreateRoomError;
40  struct UpdateRoomError;
41  struct UpdateRoomModesError;
42  struct BanUserError;
43  struct UnbanUserError;
44  struct Emoticon;
45  }
46  }
47  }
48 }
49 
50 
52 {
53  template <typename ChatRoomMessageType>
54  static auto BindFields(ChatRoomMessageType& message)
55  {
56  using namespace ttv::json;
57 
58  return std::make_tuple
59  (
60  make_field<RequiredField>("id", message.roomMessageId),
61  make_field<RequiredField>(MakeKeyPath("room", "id"), message.roomId),
62  make_field<DateSchema, OptionalField>("sentAt", message.messageInfo.timestamp),
63  make_field<RoomMessageDeletedSchema, OptionalField>("deletedAt", message.messageInfo.flags),
64  make_field<GraphQLChatRoomMessageContentSchema, RequiredField>("content", message.messageInfo),
65  make_field<GraphQLChatRoomMessageSenderSchema, RequiredField>("sender", message.messageInfo)
66  );
67  }
68 };
69 
70 
72 {
73  template <typename ChatRoomInfoType>
74  static auto BindFields(ChatRoomInfoType& info)
75  {
76  using namespace ttv::json;
77 
78  return std::make_tuple
79  (
80  make_field<RequiredField>("id", info.id),
81  make_field<RequiredField>("name", info.name),
82  make_field<RequiredField>("topic", info.topic),
83  make_field<RequiredField>("isPreviewable", info.isPreviewable),
84  make_field<RequiredField>("minimumAllowedRole", info.minimumAllowedRole),
88  );
89  }
90 };
91 
92 
94 {
95  template <typename ChatRoomViewType>
96  static auto BindFields(ChatRoomViewType& view)
97  {
98  using namespace ttv::json;
99 
100  return std::make_tuple
101  (
102  make_field<DateSchema, OptionalField>("lastReadAt", view.lastReadAt),
103  make_field<RequiredField>("isMuted", view.isMuted),
104  make_field<RequiredField>("isArchived", view.isArchived),
105  make_field<RequiredField>("isUnread", view.isUnread),
106  make_field<RequiredField>("unreadMentionCount", view.unreadMentionCount),
107  make_field<ObjectSchema<GraphQLRoomPermissions>, OptionalField>("permissions", view.permissions)
108  );
109  }
110 };
111 
112 
114 {
115  template <typename UserInfoType>
116  static auto BindFields(UserInfoType& info)
117  {
118  using namespace ttv::json;
119 
120  return std::make_tuple
121  (
122  make_field<RequiredField>("id", info.userId),
123  make_field<RequiredField>("login", info.userName),
124  make_field("displayName", info.displayName),
125  make_field("description", info.bio),
126  make_field("profileImageURL", info.logoImageUrl),
127  make_field<DateSchema, OptionalField>("createdAt", info.createdTimestamp)
128  );
129  }
130 };
131 
132 
134 {
135  template <typename RoomPermissionsType>
136  static auto BindFields(RoomPermissionsType& permissions)
137  {
138  using namespace ttv::json;
139 
140  return std::make_tuple
141  (
142  make_field<RequiredField>("readMessages", permissions.readMessages),
143  make_field<RequiredField>("sendMessages", permissions.sendMessages),
144  make_field<RequiredField>("moderate", permissions.moderate)
145  );
146  }
147 };
148 
149 
151 {
152  template <typename ChatModeType>
153  static auto BindFields(ChatModeType& mode)
154  {
155  using namespace ttv::json;
156 
157  return std::make_tuple
158  (
159  make_field<RequiredField>("slowModeDurationSeconds", mode.slowModeDurationSeconds),
160  make_field<RequiredField>("r9kModeEnabled", mode.r9kMode),
161  make_field<RequiredField>("emotesOnlyModeEnabled", mode.emotesOnlyMode)
162  );
163  }
164 };
165 
166 
168 {
169  template <typename ChatRoomMessageType>
170  static auto BindFields(ChatRoomMessageType& message)
171  {
172  using namespace ttv::json;
173 
174  return std::make_tuple
175  (
176  make_field<RequiredField>("id", message.roomMessageId),
177  make_field<RequiredField>("room", message.roomId),
178  make_field<DateSchema, OptionalField>("sent_at", message.messageInfo.timestamp),
179  make_field<PubSubChatRoomMessageContentSchema, RequiredField>("content", message.messageInfo),
180  make_field<PubSubChatRoomMessageSenderSchema, RequiredField>("sender", message.messageInfo)
181  );
182  }
183 };
184 
185 
187 {
188  template <typename ChatRoomInfoType>
189  static auto BindFields(ChatRoomInfoType& roomInfo)
190  {
191  using namespace ttv::json;
192 
193  return std::make_tuple
194  (
195  make_field<RequiredField>("room_id", roomInfo.id),
196  make_field<RequiredField>("name", roomInfo.name),
197  make_field<RequiredField>("topic", roomInfo.topic),
198  make_field<RequiredField>("is_previewable", roomInfo.isPreviewable),
199  make_field<RequiredField>("minimum_allowed_role", roomInfo.minimumAllowedRole),
200  make_field<ObjectSchema<PubSubChatMode>, RequiredField>("modes", roomInfo.modes)
201  );
202  }
203 };
204 
205 
207 {
208  template <typename ChatModeType>
209  static auto BindFields(ChatModeType& mode)
210  {
211  using namespace ttv::json;
212 
213  return std::make_tuple
214  (
215  make_field<RequiredField>("slow_mode_duration_seconds", mode.slowModeDurationSeconds),
216  make_field<RequiredField>("r9k_enabled", mode.r9kMode),
217  make_field<RequiredField>("emotes_only_mode_enabled", mode.emotesOnlyMode)
218  );
219  }
220 };
221 
222 
224 {
225  template <typename ChatRoomViewType>
226  static auto BindFields(ChatRoomViewType& roomView)
227  {
228  using namespace ttv::json;
229 
230  return std::make_tuple
231  (
232  make_field<RequiredField>("is_muted", roomView.isMuted),
233  make_field<RequiredField>("is_archived", roomView.isArchived),
234  make_field<RequiredField>("is_unread", roomView.isUnread),
235  make_field<DateSchema, OptionalField>("last_read_at", roomView.lastReadAt),
236  make_field<RequiredField>("unread_mention_count", roomView.unreadMentionCount),
237  make_field<ObjectSchema<PubSubRoomPermissions>, OptionalField>("permissions", roomView.permissions)
238  );
239  }
240 };
241 
242 
244 {
245  template <typename RoomPermissionsType>
246  static auto BindFields(RoomPermissionsType& permissions)
247  {
248  using namespace ttv::json;
249 
250  return std::make_tuple
251  (
252  make_field<RequiredField>("read_messages", permissions.readMessages),
253  make_field<RequiredField>("send_messages", permissions.sendMessages),
254  make_field<RequiredField>("moderate", permissions.moderate)
255  );
256  }
257 };
258 
259 
261 {
262  template <typename HostTargetChangeType>
263  static auto BindFields(HostTargetChangeType& change)
264  {
265  using namespace ttv::json;
266 
267  return std::make_tuple
268  (
269  make_field<OptionalField>("target_channel_login", change.targetChannelName),
270  make_field<OptionalField>("target_channel_id", change.targetChannelId),
271  make_field<OptionalField>("previous_target_channel_id", change.previousChannelId)
272  );
273  }
274 };
275 
276 
278 {
279  template <typename BitsSentEventType>
280  static auto BindFields(BitsSentEventType& bitsSentEvent)
281  {
282  using namespace ttv::json;
283 
284  return std::make_tuple
285  (
286  make_field<RequiredField>("balance", bitsSentEvent.userBitsBalance),
287  make_field<RequiredField>(MakeKeyPath("channel_total", "channel_id"), bitsSentEvent.channelId),
288  make_field<RequiredField>(MakeKeyPath("channel_total", "total"), bitsSentEvent.channelBitsTotal)
289  );
290  }
291 };
292 
293 
295 {
296  static auto EnumMap()
297  {
298  using namespace ttv::json;
299 
300  return std::make_tuple
301  (
305  );
306  }
307 
308  static auto GetFallbackValue()
309  {
310  return RoomRole::Unknown;
311  }
312 };
313 
314 
316 {
317  template <typename ChatRoomMentionInfoType>
318  static auto BindFields(ChatRoomMentionInfoType& mentionInfo)
319  {
320  using namespace ttv::json;
321 
322  return std::make_tuple
323  (
324  make_field<RequiredField>("channel_id", mentionInfo.roomOwnerId),
325  make_field<RequiredField>("channel_display_name", mentionInfo.roomOwnerName),
326  make_field<RequiredField>("channel_login", mentionInfo.roomOwnerLogin),
327  make_field<RequiredField>("sender_id", mentionInfo.senderId),
328  make_field<RequiredField>("sender_display_name", mentionInfo.senderName),
329  make_field<RequiredField>("room_id", mentionInfo.roomId),
330  make_field<RequiredField>("room_name", mentionInfo.roomName),
331  make_field<RequiredField>("message_id", mentionInfo.messageId),
332  make_field<DateSchema, RequiredField>("sent_at", mentionInfo.sentAt)
333  );
334  }
335 };
336 
337 
339 {
340  static auto EnumMap()
341  {
342  using namespace ttv::json;
343 
344  return std::make_tuple
345  (
380  );
381  }
382 
383  static auto GetFallbackValue()
384  {
386  }
387 };
388 
389 
391 {
392  template <typename SendRoomMessageErrorType>
393  static auto BindFields(SendRoomMessageErrorType& error)
394  {
395  using namespace ttv::json;
396 
397  return std::make_tuple
398  (
399  make_field<RequiredField>("code", error.code),
400  make_field<OptionalField>("slowModeDurationSeconds", error.slowModeDurationSeconds),
401  make_field<OptionalField>("remainingDurationSeconds", error.remainingDurationSeconds)
402  );
403  }
404 };
405 
406 
408 {
409  template <typename CreateRoomErrorType>
410  static auto BindFields(CreateRoomErrorType& error)
411  {
412  using namespace ttv::json;
413 
414  return std::make_tuple
415  (
416  make_field<RequiredField>("code", error.code),
417  make_field<OptionalField>("maxAllowedRooms", error.maxAllowedRooms),
418  make_field<OptionalField>("minLength", error.minLength),
419  make_field<OptionalField>("maxLength", error.maxLength)
420  );
421  }
422 };
423 
424 
426 {
427  template <typename UpdateRoomErrorType>
428  static auto BindFields(UpdateRoomErrorType& error)
429  {
430  using namespace ttv::json;
431 
432  return std::make_tuple
433  (
434  make_field<RequiredField>("code", error.code),
435  make_field<OptionalField>("minLength", error.minLength),
436  make_field<OptionalField>("maxLength", error.maxLength)
437  );
438  }
439 };
440 
441 
443 {
444  template <typename UpdateRoomErrorType>
445  static auto BindFields(UpdateRoomErrorType& error)
446  {
447  using namespace ttv::json;
448 
449  return std::make_tuple
450  (
451  make_field<RequiredField>("code", error.code),
452  make_field<OptionalField>("minimumSlowModeDurationSeconds", error.minimumSlowModeDurationSeconds),
453  make_field<OptionalField>("maximumSlowModeDurationSeconds", error.maximumSlowModeDurationSeconds)
454  );
455  }
456 };
457 
458 
460 {
461  template <typename BanUserErrorType>
462  static auto BindFields(BanUserErrorType& error)
463  {
464  using namespace ttv::json;
465 
466  return std::make_tuple
467  (
468  make_field<RequiredField>("code", error.code)
469  );
470  }
471 };
472 
473 
475 {
476  template <typename UnbanUserErrorType>
477  static auto BindFields(UnbanUserErrorType& error)
478  {
479  using namespace ttv::json;
480 
481  return std::make_tuple
482  (
483  make_field<RequiredField>("code", error.code)
484  );
485  }
486 };
487 
488 
490 {
491  template <typename EmoticonType>
492  static auto BindFields(EmoticonType& emoticon)
493  {
494  using namespace ttv::json;
495 
496  return std::make_tuple
497  (
498  make_field<RequiredField>("id", emoticon.emoticonId),
499  make_field<EmoticonTokenSchema, RequiredField>("token", emoticon)
500  );
501  }
502 };
503 
504 
505 
506 template<>
508 {
510 };
511 
512 
513 template<>
515 {
517 };
518 
519 
520 template<>
522 {
524 };
525 
526 
527 template<>
529 {
531 };
532 
533 
534 template<>
536 {
538 };
539 
540 
541 template<>
543 {
545 };
546 
547 
548 template<>
550 {
552 };
553 
554 
555 template<>
557 {
559 };
560 
561 
562 template<>
564 {
566 };
567 
568 
569 template<>
571 {
573 };
574 
575 
576 template<>
578 {
580 };
581 
582 
583 template<>
585 {
587 };
Definition: chaterrortypes.h:125
Definition: chatjsonobjectdescriptions.h:425
User tried to ban moderator without permission. banUser.
Definition: chatjsonobjectdescriptions.h:338
Definition: chatjsonobjectdescriptions.h:71
Definition: chatjsonobjectdescriptions.h:489
Definition: chatjsonobjectdescriptions.h:133
Received an unrecognized error code.
static auto BindFields(BanUserErrorType &error)
Definition: chatjsonobjectdescriptions.h:462
Target channel does not exist. modUser, unmodUser.
static auto BindFields(ChatRoomMentionInfoType &mentionInfo)
Definition: chatjsonobjectdescriptions.h:318
Definition: chatjsonobjectdescriptions.h:474
Target is not banned in channel. unbanUser.
User tried to ban admin. banUser.
User is timed out from the channel sendRoomMessage.
static auto EnumMap()
Definition: chatjsonobjectdescriptions.h:340
static auto BindFields(ChatModeType &mode)
Definition: chatjsonobjectdescriptions.h:209
Definition: jsonserialization.h:761
std::array< const char *, sizeof...(Args)> MakeKeyPath(Args... args)
Definition: jsonserialization.h:958
Definition: chaterrortypes.h:153
RoomRole
Definition: chattypes.h:775
static auto BindFields(SendRoomMessageErrorType &error)
Definition: chatjsonobjectdescriptions.h:393
static auto BindFields(UpdateRoomErrorType &error)
Definition: chatjsonobjectdescriptions.h:428
Definition: jsonserialization.h:127
Room is in slow mode and user tried to send a message too quickly. sendRoomMessage.
auto make_enum_mapping(const char *string, EnumType value)
Definition: jsonserialization.h:657
Definition: chaterrortypes.h:162
Definition: chaterrortypes.h:134
static auto BindFields(EmoticonType &emoticon)
Definition: chatjsonobjectdescriptions.h:492
Target is already a mod. modUser.
User tried to ban themselves. banUser.
Definition: chatjsonobjectdescriptions.h:51
static auto BindFields(CreateRoomErrorType &error)
Definition: chatjsonobjectdescriptions.h:410
auto make_field(const char *key, ObjectType &field)
Definition: jsonserialization.h:874
static auto BindFields(HostTargetChangeType &change)
Definition: chatjsonobjectdescriptions.h:263
Definition: chatjsonobjectdescriptions.h:243
static auto BindFields(ChatRoomViewType &view)
Definition: chatjsonobjectdescriptions.h:96
Name failed automod check. createRoom, updateRoom.
Topic is too short or too long. createRoom, updateRoom.
User tried to ban admin. banUser.
Definition: chatjsonobjectdescriptions.h:186
Duration provided was too short or too long. banUser.
Definition: chatjsonobjectdescriptions.h:315
Definition: chatjsonobjectdescriptions.h:167
Topic failed automod check. createRoom, updateRoom.
static auto BindFields(ChatRoomInfoType &info)
Definition: chatjsonobjectdescriptions.h:74
Definition: chatjsonobjectdescriptions.h:294
Definition: chatjsonobjectdescriptions.h:93
Definition: jsonserialization.h:235
static auto BindFields(RoomPermissionsType &permissions)
Definition: chatjsonobjectdescriptions.h:136
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
Definition: chatjsonobjectdescriptions.h:260
static auto BindFields(ChatRoomMessageType &message)
Definition: chatjsonobjectdescriptions.h:54
Definition: jsonserialization.h:766
Message contained zalgo characters. sendRoomMessage.
Definition: chatjsonobjectdescriptions.h:113
Target does not exist. banUser, unbanUser, modUser, unmodUser.
static auto GetFallbackValue()
Definition: chatjsonobjectdescriptions.h:383
static auto GetFallbackValue()
Definition: chatjsonobjectdescriptions.h:308
Definition: chattypes.h:652
User tried to ban anonymous user. banUser.
Name contains invalid characters (e.g. spaces). createRoom, updateRoom.
Definition: jsonserialization.h:165
Room is in R9K mode and message was not unique. sendRoomMessage.
User is not allowed to perform the action.
Target is not a mod. unmodUser.
Could not find a room with the given room ID. updateRoom. updateRoomModes.
Definition: chattypes.h:874
Definition: chattypes.h:487
Room is in emotes only mode and message contained non-emote text. sendRoomMessage.
Definition: chaterrortypes.h:169
Definition: chatjsonobjectdescriptions.h:223
User is rate limited. sendRoomMessage.
Definition: chatjsonobjectdescriptions.h:150
Definition: features.h:8
Message failed spam check. sendRoomMessage.
static auto EnumMap()
Definition: chatjsonobjectdescriptions.h:296
Definition: chatjsonobjectdescriptions.h:277
Name is too short or too long. createRoom, updateRoom.
Slow mode duration was too short, too long, or not a number. updateRoomModes.
User tried to ban broadcaster. banUser.
static auto BindFields(UnbanUserErrorType &error)
Definition: chatjsonobjectdescriptions.h:477
static auto BindFields(ChatRoomMessageType &message)
Definition: chatjsonobjectdescriptions.h:170
User is banned from the channel. sendRoomMessage.
static auto BindFields(ChatModeType &mode)
Definition: chatjsonobjectdescriptions.h:153
Definition: chaterrortypes.h:144
static auto BindFields(BitsSentEventType &bitsSentEvent)
Definition: chatjsonobjectdescriptions.h:280
Definition: chatjsonobjectdescriptions.h:407
User is banned from chat. modUser.
static auto BindFields(RoomPermissionsType &permissions)
Definition: chatjsonobjectdescriptions.h:246
Definition: chatjsonobjectdescriptions.h:442
Definition: chatjsonobjectdescriptions.h:206
static auto BindFields(ChatRoomInfoType &roomInfo)
Definition: chatjsonobjectdescriptions.h:189
Definition: chatjsonobjectdescriptions.h:459
GraphQLErrorCode
Definition: chaterrortypes.h:85
User tried to ban staff. banUser.
User cannot create any more rooms. createRoom.
User tried to ban already banned user. banUser.
Definition: chatjsonobjectdescriptions.h:390
Message failed automod check. sendRoomMessage.
Definition: chattypes.h:834
static auto BindFields(UpdateRoomErrorType &error)
Definition: chatjsonobjectdescriptions.h:445
User is suspended from Twitch. sendRoomMessage.
static auto BindFields(UserInfoType &info)
Definition: chatjsonobjectdescriptions.h:116
static auto BindFields(ChatRoomViewType &roomView)
Definition: chatjsonobjectdescriptions.h:226