sidechat.js 2.5.6 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/classes/SidechatAPIClient.d.ts +32 -3
  2. package/dist/classes/SidechatAPIClient.d.ts.map +1 -1
  3. package/dist/index.cjs +121 -8
  4. package/dist/index.mjs +121 -8
  5. package/dist/types/SidechatTypes.d.ts +69 -3
  6. package/dist/types/SidechatTypes.d.ts.map +1 -1
  7. package/docs/sidechat.js/2.6.0/SidechatAPIClient.html +3 -0
  8. package/docs/sidechat.js/2.6.0/SidechatAPIError.html +3 -0
  9. package/docs/sidechat.js/2.6.0/SidechatColorList.html +3 -0
  10. package/docs/sidechat.js/{2.4.9 → 2.6.0}/classes_SidechatAPIClient.js.html +237 -9
  11. package/docs/sidechat.js/2.6.0/classes_SidechatAPIError.js.html +16 -0
  12. package/docs/sidechat.js/2.6.0/classes_SidechatColorList.js.html +79 -0
  13. package/docs/sidechat.js/2.6.0/data/search.json +1 -0
  14. package/docs/sidechat.js/2.6.0/global.html +3 -0
  15. package/docs/sidechat.js/2.6.0/index.html +4 -0
  16. package/docs/sidechat.js/2.6.0/tutorial-Authentication.html +14 -0
  17. package/docs/sidechat.js/2.6.0/tutorial-Email Registration.html +6 -0
  18. package/docs/sidechat.js/{2.4.9 → 2.6.0}/types_SidechatTypes.js.html +51 -7
  19. package/docs/sidechat.js/2.6.1/SidechatAPIClient.html +3 -0
  20. package/docs/sidechat.js/2.6.1/SidechatAPIError.html +3 -0
  21. package/docs/sidechat.js/2.6.1/SidechatColorList.html +3 -0
  22. package/docs/sidechat.js/2.6.1/classes_SidechatAPIClient.js.html +1358 -0
  23. package/docs/sidechat.js/2.6.1/classes_SidechatAPIError.js.html +16 -0
  24. package/docs/sidechat.js/2.6.1/classes_SidechatColorList.js.html +79 -0
  25. package/docs/sidechat.js/2.6.1/data/search.json +1 -0
  26. package/docs/sidechat.js/2.6.1/fonts/Inconsolata-Regular.ttf +0 -0
  27. package/docs/sidechat.js/2.6.1/fonts/OpenSans-Regular.ttf +0 -0
  28. package/docs/sidechat.js/2.6.1/fonts/WorkSans-Bold.ttf +0 -0
  29. package/docs/sidechat.js/2.6.1/global.html +3 -0
  30. package/docs/sidechat.js/2.6.1/index.html +4 -0
  31. package/docs/sidechat.js/2.6.1/scripts/core.js +726 -0
  32. package/docs/sidechat.js/2.6.1/scripts/core.min.js +23 -0
  33. package/docs/sidechat.js/2.6.1/scripts/resize.js +90 -0
  34. package/docs/sidechat.js/2.6.1/scripts/search.js +265 -0
  35. package/docs/sidechat.js/2.6.1/scripts/search.min.js +6 -0
  36. package/docs/sidechat.js/2.6.1/scripts/third-party/Apache-License-2.0.txt +202 -0
  37. package/docs/sidechat.js/2.6.1/scripts/third-party/fuse.js +9 -0
  38. package/docs/sidechat.js/2.6.1/scripts/third-party/hljs-line-num-original.js +369 -0
  39. package/docs/sidechat.js/2.6.1/scripts/third-party/hljs-line-num.js +1 -0
  40. package/docs/sidechat.js/2.6.1/scripts/third-party/hljs-original.js +5171 -0
  41. package/docs/sidechat.js/2.6.1/scripts/third-party/hljs.js +1 -0
  42. package/docs/sidechat.js/2.6.1/scripts/third-party/popper.js +5 -0
  43. package/docs/sidechat.js/2.6.1/scripts/third-party/tippy.js +1 -0
  44. package/docs/sidechat.js/2.6.1/scripts/third-party/tocbot.js +672 -0
  45. package/docs/sidechat.js/2.6.1/scripts/third-party/tocbot.min.js +1 -0
  46. package/docs/sidechat.js/2.6.1/styles/clean-jsdoc-theme-base.css +1159 -0
  47. package/docs/sidechat.js/2.6.1/styles/clean-jsdoc-theme-dark.css +412 -0
  48. package/docs/sidechat.js/2.6.1/styles/clean-jsdoc-theme-light.css +482 -0
  49. package/docs/sidechat.js/2.6.1/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  50. package/docs/sidechat.js/2.6.1/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  51. package/docs/sidechat.js/2.6.1/styles/clean-jsdoc-theme.min.css +1 -0
  52. package/docs/sidechat.js/2.6.1/tutorial-Authentication.html +14 -0
  53. package/docs/sidechat.js/2.6.1/tutorial-Email Registration.html +6 -0
  54. package/docs/sidechat.js/2.6.1/types_SidechatTypes.js.html +204 -0
  55. package/package.json +1 -1
  56. package/src/classes/SidechatAPIClient.js +90 -2
  57. package/src/types/SidechatTypes.js +31 -6
  58. package/docs/sidechat.js/2.4.9/SidechatAPIClient.html +0 -3
  59. package/docs/sidechat.js/2.4.9/SidechatAPIError.html +0 -3
  60. package/docs/sidechat.js/2.4.9/SidechatColorList.html +0 -3
  61. package/docs/sidechat.js/2.4.9/classes_SidechatAPIError.js.html +0 -16
  62. package/docs/sidechat.js/2.4.9/classes_SidechatColorList.js.html +0 -79
  63. package/docs/sidechat.js/2.4.9/data/search.json +0 -1
  64. package/docs/sidechat.js/2.4.9/global.html +0 -3
  65. package/docs/sidechat.js/2.4.9/index.html +0 -4
  66. package/docs/sidechat.js/2.4.9/tutorial-Authentication.html +0 -14
  67. package/docs/sidechat.js/2.4.9/tutorial-Email Registration.html +0 -6
  68. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/fonts/Inconsolata-Regular.ttf +0 -0
  69. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/fonts/OpenSans-Regular.ttf +0 -0
  70. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/fonts/WorkSans-Bold.ttf +0 -0
  71. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/core.js +0 -0
  72. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/core.min.js +0 -0
  73. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/resize.js +0 -0
  74. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/search.js +0 -0
  75. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/search.min.js +0 -0
  76. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/Apache-License-2.0.txt +0 -0
  77. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/fuse.js +0 -0
  78. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/hljs-line-num-original.js +0 -0
  79. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/hljs-line-num.js +0 -0
  80. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/hljs-original.js +0 -0
  81. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/hljs.js +0 -0
  82. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/popper.js +0 -0
  83. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/tippy.js +0 -0
  84. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/tocbot.js +0 -0
  85. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/scripts/third-party/tocbot.min.js +0 -0
  86. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/styles/clean-jsdoc-theme-base.css +0 -0
  87. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/styles/clean-jsdoc-theme-dark.css +0 -0
  88. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/styles/clean-jsdoc-theme-light.css +0 -0
  89. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/styles/clean-jsdoc-theme-scrollbar.css +0 -0
  90. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
  91. /package/docs/sidechat.js/{2.4.9 → 2.6.0}/styles/clean-jsdoc-theme.min.css +0 -0
@@ -0,0 +1,1358 @@
1
+ <!DOCTYPE html><html lang="en" style="font-size:16px"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Source: classes/SidechatAPIClient.js</title><!--[if lt IE 9]>
2
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
3
+ <![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(baseURL=(baseURL="https://micahlindley.com/sidechat.js/").replace(/https?:\/\//i,"")).substr(baseURL.indexOf("/"))</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="dark"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">sidechat.js</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-Authentication.html">Authentication</a></div><div class="sidebar-section-children"><a href="tutorial-Email Registration.html">Email Registration</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="SidechatAPIClient.html">SidechatAPIClient</a></div><div class="sidebar-section-children"><a href="SidechatAPIError.html">SidechatAPIError</a></div><div class="sidebar-section-children"><a href="SidechatColorList.html">SidechatColorList</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#SidechatAssetMetadata">SidechatAssetMetadata</a></div><div class="sidebar-section-children"><a href="global.html#SidechatAuthToken">SidechatAuthToken</a></div><div class="sidebar-section-children"><a href="global.html#SidechatColor">SidechatColor</a></div><div class="sidebar-section-children"><a href="global.html#SidechatCurrentUser">SidechatCurrentUser</a></div><div class="sidebar-section-children"><a href="global.html#SidechatCursorString">SidechatCursorString</a></div><div class="sidebar-section-children"><a href="global.html#SidechatDirectMessage">SidechatDirectMessage</a></div><div class="sidebar-section-children"><a href="global.html#SidechatDirectThread">SidechatDirectThread</a></div><div class="sidebar-section-children"><a href="global.html#SidechatGroup">SidechatGroup</a></div><div class="sidebar-section-children"><a href="global.html#SidechatIcon">SidechatIcon</a></div><div class="sidebar-section-children"><a href="global.html#SidechatIdentity">SidechatIdentity</a></div><div class="sidebar-section-children"><a href="global.html#SidechatLibraryAsset">SidechatLibraryAsset</a></div><div class="sidebar-section-children"><a href="global.html#SidechatMembership">SidechatMembership</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPoll">SidechatPoll</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPollChoice">SidechatPollChoice</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPostOrComment">SidechatPostOrComment</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPostsAndCursor">SidechatPostsAndCursor</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPrivateAssetURL">SidechatPrivateAssetURL</a></div><div class="sidebar-section-children"><a href="global.html#SidechatProfile">SidechatProfile</a></div><div class="sidebar-section-children"><a href="global.html#SidechatSimpleAsset">SidechatSimpleAsset</a></div><div class="sidebar-section-children"><a href="global.html#SidechatVoteString">SidechatVoteString</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"><div class="navbar-item"><a id="" href="https://github.com/micahlt/sidechat.js" target="_blank">GitHub</a></div><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/sidechat.js" target="_blank">NPM</a></div><div class="navbar-item"><a id="" href="https://offsides.micahlindley.com" target="_blank">Offsides (Sidechat for Android)</a></div></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#light-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section id="source-page" class="source-page"><header><h1 id="title" class="has-anchor">classes_SidechatAPIClient.js</h1></header><article><pre class="prettyprint source lang-js"><code>import "../types/SidechatTypes.js";
4
+ import SidechatAPIError from "../classes/SidechatAPIError.js";
5
+
6
+ /**
7
+ * API client class for making requests to Sidechat's private API. You'll need to [authenticate]{@tutorial Authentication} before using most of the methods.
8
+ * @class
9
+ * @since 2.0.0-alpha.0
10
+ */
11
+ class SidechatAPIClient {
12
+ /**
13
+ * User bearer token
14
+ * @type {SidechatAuthToken}
15
+ * */
16
+ userToken;
17
+
18
+ /**
19
+ * Default headers for every API request
20
+ * @type {Object}
21
+ * @static
22
+ * @constant
23
+ */
24
+ defaultHeaders = {
25
+ Accept: "application/json",
26
+ "Content-Type": "application/json",
27
+ "App-Version": "6.0.0",
28
+ Dnt: 1,
29
+ };
30
+
31
+ /**
32
+ * Root URL for every API request
33
+ * @type {String}
34
+ * @default "https://api.sidechat.lol"
35
+ */
36
+ apiRoot = "https://api.sidechat.lol";
37
+
38
+ /**
39
+ * Create a new instance of the API client
40
+ * @param {SidechatAuthToken} [token] - user bearer token
41
+ * @param {String} rootUrl - custom API root URL for mocking or using other server
42
+ */
43
+ constructor(token = "", rootUrl = "") {
44
+ if (token) {
45
+ this.userToken = token;
46
+ }
47
+ if (rootUrl) {
48
+ this.apiRoot = rootUrl;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Manually set the currently signed in user's token. Generally try to avoid this and instead either pass a token to the constructor or login automatically through the auth functions
54
+ * @method
55
+ * @param {SidechatAuthToken} token - user bearer token
56
+ */
57
+ setToken = (token) => {
58
+ this.userToken = token;
59
+ };
60
+
61
+ /**
62
+ * Manually set the root URL for all API requests. This can be used for mocking requests or redirecting them to a different server
63
+ * @method
64
+ * @param {String} url - new root URL to set
65
+ * @since 2.3.9
66
+ */
67
+ setAPIRoot = (url) => {
68
+ this.apiRoot = url;
69
+ };
70
+
71
+ /**
72
+ * Run an arbitrary API request using the current client's authentication
73
+ * @method
74
+ * @param {String} endpoint - API endpoint to request (e.g. "/v1/posts")
75
+ * @param {"GET"|"POST"|"PUT"|"DELETE"|"PATCH"|"OPTIONS"} [method] - HTTP method to use
76
+ * @param {Object} [body] - body to send with the request
77
+ * @param {Object} [headers] - custom headers to send with the request
78
+ * @param {Boolean} [stripHeaders] - remove the default headers from the request
79
+ * @since 2.4.9
80
+ */
81
+ sendRequest = (
82
+ endpoint,
83
+ method = "GET",
84
+ body = undefined,
85
+ headers = {},
86
+ stripHeaders = false
87
+ ) => {
88
+ let requestHeaders = this.defaultHeaders;
89
+ if (stripHeaders) {
90
+ headers = {};
91
+ }
92
+ requestHeaders = { ...requestHeaders, ...headers };
93
+ return fetch(`${this.apiRoot}${endpoint}`, {
94
+ headers: { Authorization: `Bearer ${this.userToken}`, ...requestHeaders },
95
+ body: body,
96
+ method: method,
97
+ });
98
+ };
99
+
100
+ /**
101
+ * Initiate the login process with a phone number. Should be followed up with verifySMSCode().
102
+ * @method
103
+ * @since 1.0.0
104
+ * @param {Number} phoneNumber - US phone number (WITHOUT +1) to send verification code to
105
+ */
106
+ loginViaSMS = async (phoneNumber) => {
107
+ try {
108
+ const res = await fetch(`${this.apiRoot}/v1/login_register`, {
109
+ method: "POST",
110
+ headers: this.defaultHeaders,
111
+ body: JSON.stringify({
112
+ phone_number: `+1${phoneNumber}`,
113
+ version: 3,
114
+ }),
115
+ });
116
+ const json = await res.json();
117
+ return json;
118
+ } catch (err) {
119
+ console.error(err);
120
+ throw new SidechatAPIError("Failed to request SMS verification.");
121
+ }
122
+ };
123
+
124
+ /**
125
+ * Verify the code sent via SMS with loginViaSMS(). If this function succeeds, the user will be authenticated for future requests.
126
+ * @method
127
+ * @since 1.0.0
128
+ * @param {Number} phoneNumber - US phone number (WITHOUT +1) that verification code was sent to
129
+ * @param {String} code - the verification code
130
+ */
131
+ verifySMSCode = async (phoneNumber, code) => {
132
+ try {
133
+ const res = await fetch(`${this.apiRoot}/v1/verify_phone_number`, {
134
+ method: "POST",
135
+ headers: this.defaultHeaders,
136
+ body: JSON.stringify({
137
+ phone_number: `+1${phoneNumber}`,
138
+ code: code.toUpperCase(),
139
+ }),
140
+ });
141
+ const json = await res.json();
142
+ if (json?.logged_in_user?.token) {
143
+ this.userToken = json.logged_in_user.token;
144
+ }
145
+ return json;
146
+ } catch (err) {
147
+ console.error(err);
148
+ throw new SidechatAPIError("Failed verify this code.");
149
+ }
150
+ };
151
+
152
+ /**
153
+ * Set the user's age. If this function succeeds, the user will be authenticated for future requests.
154
+ * @method
155
+ * @since 1.0.0
156
+ * @param {Number} age - user's age in years
157
+ * @param {String} registrationID - the registration ID generated by verifySMSCode()
158
+ */
159
+ setAge = async (age, registrationID) => {
160
+ if (age &lt; 13) {
161
+ throw new SidechatAPIError("You're too young to use Offsides.");
162
+ }
163
+ try {
164
+ const res = await fetch(`${this.apiRoot}/v1/complete_registration`, {
165
+ method: "POST",
166
+ headers: this.defaultHeaders,
167
+ body: JSON.stringify({
168
+ age: Number(age),
169
+ registration_id: registrationID,
170
+ }),
171
+ });
172
+ const json = await res.json();
173
+ if (json.token) {
174
+ this.userToken = json.token;
175
+ }
176
+ return json;
177
+ } catch (err) {
178
+ console.error(err);
179
+ throw new SidechatAPIError("Failed verify this code.");
180
+ }
181
+ };
182
+
183
+ /**
184
+ * Initiate the email setup process. Should be followed up with checkEmailVerification().
185
+ * @method
186
+ * @since 1.0.0
187
+ * @param {String} email - school email address to send verification code to
188
+ * @tutorial Email Registration
189
+ */
190
+ registerEmail = async (email) => {
191
+ if (!this.userToken) {
192
+ throw new SidechatAPIError("User is not authenticated.");
193
+ }
194
+ try {
195
+ const res = await fetch(`${this.apiRoot}/v2/users/register_email`, {
196
+ method: "POST",
197
+ headers: {
198
+ ...this.defaultHeaders,
199
+ Authorization: `Bearer ${this.userToken}`,
200
+ },
201
+ body: JSON.stringify({
202
+ email: email,
203
+ }),
204
+ });
205
+ const json = await res.json();
206
+ if (json.message) {
207
+ throw new SidechatAPIError(json.message);
208
+ }
209
+ return json;
210
+ } catch (err) {
211
+ console.error(err);
212
+ throw new SidechatAPIError("Failed to request email verification.");
213
+ }
214
+ };
215
+
216
+ /**
217
+ * Check is the user's email is verified.
218
+ * @method
219
+ * @since 1.0.0
220
+ */
221
+ checkEmailVerification = async () => {
222
+ if (!this.userToken) {
223
+ throw new SidechatAPIError("User is not authenticated.");
224
+ }
225
+ try {
226
+ const res = await fetch(`${this.apiRoot}/v1/users/check_email_verified`, {
227
+ method: "GET",
228
+ headers: {
229
+ ...this.defaultHeaders,
230
+ Authorization: `Bearer ${this.userToken}`,
231
+ },
232
+ });
233
+ const json = await res.json();
234
+ if (json.verified_email_updates_response) {
235
+ return json.verified_email_updates_response;
236
+ } else {
237
+ throw new SidechatAPIError(json?.message || "Email is not verified.");
238
+ }
239
+ } catch (err) {
240
+ console.error(err);
241
+ throw new SidechatAPIError("Email is not verified.");
242
+ }
243
+ };
244
+
245
+ /**
246
+ * Set the device ID of the current user
247
+ * @method
248
+ * @since 1.0.0
249
+ * @param {String} deviceId - the device ID to set
250
+ */
251
+ setDeviceID = async (deviceID) => {
252
+ if (!this.userToken) {
253
+ throw new SidechatAPIError("User is not authenticated.");
254
+ }
255
+ try {
256
+ const res = await fetch(`${this.apiRoot}/v1/register_device_token`, {
257
+ method: "POST",
258
+ headers: {
259
+ ...this.defaultHeaders,
260
+ Authorization: `Bearer ${this.userToken}`,
261
+ },
262
+ body: JSON.stringify({
263
+ build_type: "release",
264
+ bundle_id: "com.flowerave.sidechat",
265
+ device_token: deviceID,
266
+ }),
267
+ });
268
+ const json = await res.json();
269
+ return json;
270
+ } catch (err) {
271
+ console.error(err);
272
+ throw new SidechatAPIError("Failed verify this code.");
273
+ }
274
+ };
275
+
276
+ /**
277
+ * Get updated status for user and group
278
+ * @method
279
+ * @since 1.0.0
280
+ * @deprecated since 2.1.0, will be removed by 3.0.0. Please use `getUpdates` instead!
281
+ * @param {String} [groupID] - ID of a specific group to retrieve info from. Falls back to user's primary group.
282
+ */
283
+ getUserAndGroup = async (groupID = "") => {
284
+ const json = await this.getUpdates(groupID);
285
+ return json;
286
+ };
287
+
288
+ /**
289
+ * Get updated status for user and group
290
+ * @method
291
+ * @since 2.1.0
292
+ * @param {String} [groupID] - ID of a specific group to retrieve info from. Falls back to user's primary group.
293
+ */
294
+ getUpdates = async (groupID = "") => {
295
+ if (!this.userToken) {
296
+ throw new SidechatAPIError("User is not authenticated.");
297
+ }
298
+ try {
299
+ const res = await fetch(
300
+ `${this.apiRoot}/v1/updates?group_id=${groupID}`,
301
+ {
302
+ method: "GET",
303
+ headers: {
304
+ ...this.defaultHeaders,
305
+ Authorization: `Bearer ${this.userToken}`,
306
+ },
307
+ }
308
+ );
309
+ const json = await res.json();
310
+ return json;
311
+ } catch (err) {
312
+ console.error(err);
313
+ throw new SidechatAPIError(`Failed to get posts from group.`);
314
+ }
315
+ };
316
+
317
+ /**
318
+ * Fetches posts from the specified category in a group
319
+ * @method
320
+ * @since 1.0.0
321
+ * @param {String} groupID - group ID
322
+ * @param {"hot"|"recent"|"top"} category - category to filter posts
323
+ * @param {SidechatCursorString} [cursor] - cursor string
324
+ * @returns {SidechatPostsAndCursor} List of posts and cursor
325
+ */
326
+ getGroupPosts = async (groupID, category = "hot", cursor) => {
327
+ if (!this.userToken) {
328
+ throw new SidechatAPIError("User is not authenticated.");
329
+ }
330
+ try {
331
+ const res = await fetch(
332
+ `${this.apiRoot}/v1/posts?${cursor ? "cursor=" + encodeURIComponent(cursor) + "&amp;" : ""
333
+ }group_id=${groupID}&amp;type=${category}`,
334
+ {
335
+ method: "GET",
336
+ headers: {
337
+ ...this.defaultHeaders,
338
+ Authorization: `Bearer ${this.userToken}`,
339
+ },
340
+ }
341
+ );
342
+ const json = await res.json();
343
+ return json;
344
+ } catch (err) {
345
+ console.error(err);
346
+ throw new SidechatAPIError(`Failed to get posts from group.`);
347
+ }
348
+ };
349
+
350
+ /**
351
+ * Upvote or downvote, or unvote a post
352
+ * @method
353
+ * @since 2.0.0-alpha.0
354
+ * @param {String} postID - post ID to vote on
355
+ * @param {SidechatVoteString} action - whether to upvote, downvote, or reset vote
356
+ */
357
+ setVote = async (postID, action) => {
358
+ if (!this.userToken) {
359
+ throw new SidechatAPIError("User is not authenticated.");
360
+ }
361
+ try {
362
+ const res = await fetch(`${this.apiRoot}/v1/posts/set_vote`, {
363
+ method: "POST",
364
+ headers: {
365
+ ...this.defaultHeaders,
366
+ Authorization: `Bearer ${this.userToken}`,
367
+ },
368
+ body: JSON.stringify({
369
+ post_id: postID,
370
+ vote_status: action,
371
+ }),
372
+ });
373
+ const json = await res.json();
374
+ return json;
375
+ } catch (err) {
376
+ console.error(err);
377
+ throw new SidechatAPIError(`Failed to change the vote on post.`);
378
+ }
379
+ };
380
+
381
+ /**
382
+ * Fetches a single post with just its ID
383
+ * @method
384
+ * @since 2.3.0
385
+ * @param {String} postID - ID of post to fetch
386
+ * @param {Boolean} includeDeleted - undocumented
387
+ * @returns {SidechatPostOrComment} post object
388
+ */
389
+ getPost = async (postID, includeDeleted = false) => {
390
+ if (!this.userToken) {
391
+ throw new SidechatAPIError("User is not authenticated.");
392
+ }
393
+ try {
394
+ const res = await fetch(
395
+ `${this.apiRoot}/v1/posts/get?include_deleted=${includeDeleted}&amp;post_id=${postID}`,
396
+ {
397
+ method: "GET",
398
+ headers: {
399
+ ...this.defaultHeaders,
400
+ Authorization: `Bearer ${this.userToken}`,
401
+ },
402
+ }
403
+ );
404
+ const json = await res.json();
405
+ return json.post;
406
+ } catch (err) {
407
+ console.error(err);
408
+ throw new SidechatAPIError(`Failed to get post from ID.`);
409
+ }
410
+ };
411
+
412
+ /**
413
+ * Fetches the posts or comments that the user has created
414
+ * @method
415
+ * @since 2.3.5
416
+ * @param {"posts"|"comments"} contentType - type of user content to fetch
417
+ * @returns {SidechatPostOrComment[]} post object
418
+ */
419
+ getUserContent = async (contentType) => {
420
+ if (!this.userToken) {
421
+ throw new SidechatAPIError("User is not authenticated.");
422
+ }
423
+ if (contentType == "posts") {
424
+ contentType = "my_posts";
425
+ } else if (contentType == "comments") {
426
+ contentType = "my_comments";
427
+ }
428
+ try {
429
+ const res = await fetch(`${this.apiRoot}/v1/posts&amp;type=${contentType}`, {
430
+ method: "GET",
431
+ headers: {
432
+ ...this.defaultHeaders,
433
+ Authorization: `Bearer ${this.userToken}`,
434
+ },
435
+ });
436
+ const json = await res.json();
437
+ return json.posts;
438
+ } catch (err) {
439
+ console.error(err);
440
+ throw new SidechatAPIError(`Failed to get content from user.`);
441
+ }
442
+ };
443
+
444
+ /**
445
+ * Get all the commments on a post
446
+ * @method
447
+ * @since 2.0.0-alpha.0
448
+ * @param {String} postID - post ID to get comments for
449
+ * @returns {SidechatPostOrComment[]} list of comments
450
+ */
451
+ getPostComments = async (postID) => {
452
+ if (!this.userToken) {
453
+ throw new SidechatAPIError("User is not authenticated.");
454
+ }
455
+ try {
456
+ const res = await fetch(
457
+ `${this.apiRoot}/v1/posts/comments/?post_id=${postID}`,
458
+ {
459
+ method: "GET",
460
+ headers: {
461
+ ...this.defaultHeaders,
462
+ Authorization: `Bearer ${this.userToken}`,
463
+ },
464
+ }
465
+ );
466
+ const json = await res.json();
467
+ // Function to preprocess the comments and organize them into a nested structure
468
+ function preprocessComments(apiComments) {
469
+ // Map to store comments by their IDs for efficient lookup
470
+ const commentMap = new Map();
471
+ // List to store top-level comments
472
+ const topLevelComments = [];
473
+
474
+ // Iterate through the API comments
475
+ apiComments.forEach((comment) => {
476
+ // Store the comment in the map with its ID as the key
477
+ commentMap.set(comment.id, comment);
478
+ // Get the parent comment using the reply_post_id
479
+ const parentComment = commentMap.get(comment.reply_post_id);
480
+ // Check if the comment is a top-level comment
481
+ if (
482
+ !parentComment ||
483
+ comment.reply_post_id === comment.parent_post_id
484
+ ) {
485
+ // If it's a top-level comment, push it to the topLevelComments array
486
+ topLevelComments.push(comment);
487
+ } else {
488
+ // If it's a reply, add it to the parent comment's replies array
489
+ if (!parentComment.replies) parentComment.replies = [];
490
+ parentComment.replies.push(comment);
491
+ }
492
+ });
493
+
494
+ // Flatten the nested structure and return a single list of comments
495
+ return flattenComments(topLevelComments);
496
+ }
497
+
498
+ // Function to flatten nested comments into a single list
499
+ function flattenComments(comments) {
500
+ // Use reduce to flatten the nested comments array into a single list
501
+ return comments.reduce((flatComments, comment) => {
502
+ // Push the current comment to the flatComments array
503
+ flatComments.push(comment);
504
+ // If the current comment has replies, recursively flatten them and push to the flatComments array
505
+ if (comment.replies)
506
+ flatComments.push(...flattenComments(comment.replies));
507
+ // Return the flatComments array
508
+ return flatComments;
509
+ }, []);
510
+ }
511
+
512
+ const sortedComments = preprocessComments(json.posts);
513
+ return sortedComments;
514
+ } catch (err) {
515
+ console.error(err);
516
+ throw new SidechatAPIError(`Failed to get comments on post.`);
517
+ }
518
+ };
519
+
520
+ /**
521
+ * Gets groups to be displayed on the "Explore Groups" page
522
+ * @method
523
+ * @since 2.0.0-alpha.0
524
+ * @param {Boolean} onePage - whether or not results should be returned as a single page
525
+ * @returns {SidechatGroup[]}
526
+ */
527
+ getAvailableGroups = async (onePage = true) => {
528
+ if (!this.userToken) {
529
+ throw new SidechatAPIError("User is not authenticated.");
530
+ }
531
+ try {
532
+ const res = await fetch(`${this.apiRoot}/v1/groups/explore`, {
533
+ method: "GET",
534
+ headers: {
535
+ ...this.defaultHeaders,
536
+ "App-Version": onePage ? "0" : this.defaultHeaders["App-Version"],
537
+ Authorization: `Bearer ${this.userToken}`,
538
+ },
539
+ });
540
+ const json = await res.json();
541
+ return await json.groups;
542
+ } catch (err) {
543
+ console.error(err);
544
+ throw new SidechatAPIError(`Failed to get groups from explore.`);
545
+ }
546
+ };
547
+
548
+ /**
549
+ * Searches for new groups based on a query keyword
550
+ * @method
551
+ * @since 2.6.0
552
+ * @param {String} query - the string to search for. This will be encoded, so strings with spaces and special characters are okay.
553
+ * @returns {SidechatGroup[]}
554
+ */
555
+ searchAvailableGroups = async (query) => {
556
+ if (!this.userToken) {
557
+ throw new SidechatAPIError("User is not authenticated.");
558
+ }
559
+ try {
560
+ const res = await fetch(`${this.apiRoot}/v1/groups/explore/search?term=${encodeURIComponent(query)}`, {
561
+ method: "GET",
562
+ headers: {
563
+ ...this.defaultHeaders,
564
+ Authorization: `Bearer ${this.userToken}`,
565
+ },
566
+ });
567
+ const json = await res.json();
568
+ return await json.results;
569
+ } catch (err) {
570
+ console.error(err);
571
+ throw new SidechatAPIError(`Failed to search groups.`);
572
+ }
573
+ };
574
+
575
+ /**
576
+ * Retrieves the entire accessible asset library. Be warned that as of the time of this documentation, it's a 1.5MB JSON download and this request is very expensive.
577
+ * @method
578
+ * @since 2.0.6
579
+ * @returns {SidechatLibraryAsset[]}
580
+ */
581
+ getAssetLibrary = async () => {
582
+ if (!this.userToken) {
583
+ throw new SidechatAPIError("User is not authenticated.");
584
+ }
585
+ try {
586
+ const res = await fetch(`${this.apiRoot}/v1/assets/library`, {
587
+ method: "GET",
588
+ headers: {
589
+ ...this.defaultHeaders,
590
+ Authorization: `Bearer ${this.userToken}`,
591
+ },
592
+ });
593
+ const json = await res.json();
594
+ return await json.items;
595
+ } catch (err) {
596
+ console.error(err);
597
+ throw new SidechatAPIError(`Failed to get asset library.`);
598
+ }
599
+ };
600
+
601
+ /**
602
+ * Gets the current authenticated user and a list of the groups of which they are members.
603
+ * @method
604
+ * @since 2.1.0
605
+ * @returns {SidechatCurrentUser}
606
+ */
607
+ getCurrentUser = async () => {
608
+ if (!this.userToken) {
609
+ throw new SidechatAPIError("User is not authenticated.");
610
+ }
611
+ try {
612
+ const res = await fetch(`${this.apiRoot}/v1/users/me`, {
613
+ method: "GET",
614
+ headers: {
615
+ ...this.defaultHeaders,
616
+ Authorization: `Bearer ${this.userToken}`,
617
+ },
618
+ });
619
+ const json = await res.json();
620
+ return await json;
621
+ } catch (err) {
622
+ console.error(err);
623
+ throw new SidechatAPIError(`Failed to get asset library.`);
624
+ }
625
+ };
626
+
627
+ /**
628
+ * Gets the metadata of a group from its ID
629
+ * @method
630
+ * @since 2.1.0
631
+ * @param {String} [groupID] - alphanumeric ID of a group to get. Falls back to user's primary group.
632
+ * @returns {SidechatGroup}
633
+ */
634
+ getGroupMetadata = async (groupID = "") => {
635
+ if (!this.userToken) {
636
+ throw new SidechatAPIError("User is not authenticated.");
637
+ }
638
+ try {
639
+ const res = await fetch(`${this.apiRoot}/v1/groups/${groupID}`, {
640
+ method: "GET",
641
+ headers: {
642
+ ...this.defaultHeaders,
643
+ Authorization: `Bearer ${this.userToken}`,
644
+ },
645
+ });
646
+ const json = await res.json();
647
+ return await json.group;
648
+ } catch (err) {
649
+ console.error(err);
650
+ throw new SidechatAPIError(`Failed to get group metadata.`);
651
+ }
652
+ };
653
+
654
+ /**
655
+ * Joins or leaves a group
656
+ * @method
657
+ * @param {String} groupID - alphanumeric ID of group to join or leave
658
+ * @param {Boolean} isMember - whether or not the user should be a member of the group
659
+ * @since 2.3.8
660
+ */
661
+ setGroupMembership = async (groupID, isMember) => {
662
+ if (!this.userToken) {
663
+ throw new SidechatAPIError("User is not authenticated.");
664
+ }
665
+ try {
666
+ const res = await fetch(
667
+ `${this.apiRoot}/v1/groups/${isMember ? "join" : "leave"}`,
668
+ {
669
+ method: "POST",
670
+ headers: {
671
+ ...this.defaultHeaders,
672
+ Authorization: `Bearer ${this.userToken}`,
673
+ },
674
+ body: JSON.stringify({
675
+ group_id: groupID,
676
+ }),
677
+ }
678
+ );
679
+ const json = await res.json();
680
+ return await json;
681
+ } catch (err) {
682
+ console.error(err);
683
+ throw new SidechatAPIError(`Failed to modify group membership.`);
684
+ }
685
+ };
686
+
687
+ /**
688
+ * Creates a comment on a post
689
+ * @method
690
+ * @since 2.2.0
691
+ * @param {String} parentPostID - alphanumeric ID of post on which this comment is made
692
+ * @param {String} text - text content of comment
693
+ * @param {String} groupID - alphanumeric ID of group in which the parent post resides
694
+ * @param {String} [replyCommentID] - alphanumeric ID of comment to reply to. Falls back to parentPostID
695
+ * @param {String} [topLevelReplyID] - alphanumeric ID of the top-level comment to reply to. Used only when replying to replies. Falls back to parentPostID
696
+ * @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach
697
+ * @param {Boolean} [disableDMs] - prevent direct messages being sent to comment's author
698
+ * @param {Boolean} [anonymous] - whether or not to hide user's name and icon on comment
699
+ * @returns {SidechatPostOrComment} created comment
700
+ */
701
+ createComment = async (
702
+ parentPostID,
703
+ text,
704
+ groupID,
705
+ replyCommentID,
706
+ topLevelReplyID,
707
+ assetList = [],
708
+ disableDMs = false,
709
+ anonymous = false
710
+ ) => {
711
+ if (!this.userToken) {
712
+ throw new SidechatAPIError("User is not authenticated.");
713
+ }
714
+ try {
715
+ const res = await fetch(`${this.apiRoot}/v1/posts`, {
716
+ method: "POST",
717
+ headers: {
718
+ ...this.defaultHeaders,
719
+ Authorization: `Bearer ${this.userToken}`,
720
+ },
721
+ body: JSON.stringify({
722
+ type: "comment",
723
+ assets: assetList,
724
+ group_ids: [groupID],
725
+ text: text,
726
+ reply_post_id: topLevelReplyID || replyCommentID || parentPostID,
727
+ reply_comment_post_id: replyCommentID || parentPostID,
728
+ parent_post_id: parentPostID,
729
+ dms_disabled: disableDMs,
730
+ using_identity: !anonymous,
731
+ }),
732
+ });
733
+ const json = await res.json();
734
+ return await json.comment;
735
+ } catch (err) {
736
+ console.error(err);
737
+ throw new SidechatAPIError(`Failed to post comment.`);
738
+ }
739
+ };
740
+
741
+ /**
742
+ * Creates a new post in the specified group
743
+ * @method
744
+ * @since 2.2.0
745
+ * @param {String} text - text content of comment
746
+ * @param {String} groupID - alphanumeric ID of group in which the parent post resides
747
+ * @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach.
748
+ * @param {Boolean} [disableDMs] - prevent direct messages from being sent to post's author
749
+ * @param {Boolean} [disableComments] - whether or not comments should be disabled on post
750
+ * @param {Boolean} [anonymous] - whether or not to hide user's name and icon on post
751
+ * @returns {SidechatPostOrComment} the created post
752
+ */
753
+ createPost = async (
754
+ text,
755
+ groupID,
756
+ assetList = [],
757
+ disableDMs = false,
758
+ disableComments = false,
759
+ anonymous = false,
760
+ repostId = undefined
761
+ ) => {
762
+ if (!this.userToken) {
763
+ throw new SidechatAPIError("User is not authenticated.");
764
+ }
765
+ try {
766
+ const res = await fetch(`${this.apiRoot}/v1/posts`, {
767
+ method: "POST",
768
+ headers: {
769
+ ...this.defaultHeaders,
770
+ Authorization: `Bearer ${this.userToken}`,
771
+ },
772
+ body: JSON.stringify({
773
+ type: "post",
774
+ assets: assetList,
775
+ group_ids: [groupID],
776
+ text: text,
777
+ attachments: [],
778
+ dms_disabled: disableDMs,
779
+ comments_disabled: disableComments,
780
+ using_identity: !anonymous,
781
+ quote_post_id: repostId
782
+ }),
783
+ });
784
+ const json = await res.json();
785
+ return await json.posts[0];
786
+ } catch (err) {
787
+ console.error(err);
788
+ throw new SidechatAPIError(`Failed to make post.`);
789
+ }
790
+ };
791
+
792
+ /**
793
+ * Deletes a post or comment that the user created
794
+ * @method
795
+ * @since 2.2.0
796
+ * @param {String} postOrCommentID - alphanumeric ID of post to delete
797
+ */
798
+ deletePostOrComment = async (postOrCommentID) => {
799
+ if (!this.userToken) {
800
+ throw new SidechatAPIError("User is not authenticated.");
801
+ }
802
+ try {
803
+ const res = await fetch(`${this.apiRoot}/v1/posts/delete`, {
804
+ method: "POST",
805
+ headers: {
806
+ ...this.defaultHeaders,
807
+ Authorization: `Bearer ${this.userToken}`,
808
+ },
809
+ body: JSON.stringify({
810
+ post_id: postOrCommentID,
811
+ }),
812
+ });
813
+ const json = await res.json();
814
+ return await json;
815
+ } catch (err) {
816
+ console.error(err);
817
+ throw new SidechatAPIError(`Failed to delete post.`);
818
+ }
819
+ };
820
+
821
+ /**
822
+ * Votes on a poll attached to a post
823
+ * @method
824
+ * @param {String} pollId - alphanumeric ID of poll to vote on
825
+ * @param {Number} choiceIndex - index of the choice to vote on
826
+ * @since 2.5.4
827
+ */
828
+ voteOnPoll = async (pollId, choiceIndex) => {
829
+ if (!this.userToken) {
830
+ throw new SidechatAPIError("User is not authenticated.");
831
+ }
832
+ try {
833
+ const res = await fetch(`${this.apiRoot}/v1/polls/vote`, {
834
+ method: "POST",
835
+ headers: {
836
+ ...this.defaultHeaders,
837
+ Authorization: `Bearer ${this.userToken}`,
838
+ },
839
+ body: JSON.stringify({
840
+ poll_id: pollId,
841
+ choice: choiceIndex,
842
+ }),
843
+ });
844
+ const json = await res.json();
845
+ return await json;
846
+ } catch (err) {
847
+ console.error(err);
848
+ throw new SidechatAPIError(`Failed to vote on poll`);
849
+ }
850
+ };
851
+
852
+ /**
853
+ * Marks that the user has viewed results on a poll. Note that this does not actually return the results of the poll.
854
+ * @method
855
+ * @param {String} pollId - alphanumeric ID of poll to vote on
856
+ * @since 2.5.4
857
+ */
858
+ viewPollResults = async (pollId) => {
859
+ if (!this.userToken) {
860
+ throw new SidechatAPIError("User is not authenticated.");
861
+ }
862
+ try {
863
+ const res = await fetch(`${this.apiRoot}/v1/polls/view_results`, {
864
+ method: "POST",
865
+ headers: {
866
+ ...this.defaultHeaders,
867
+ Authorization: `Bearer ${this.userToken}`,
868
+ },
869
+ body: JSON.stringify({
870
+ poll_id: pollId,
871
+ }),
872
+ });
873
+ const json = await res.json();
874
+ return await json;
875
+ } catch (err) {
876
+ console.error(err);
877
+ throw new SidechatAPIError(`Failed to mark poll results as viewed.`);
878
+ }
879
+ };
880
+
881
+ /**
882
+ * Uploads an asset to AWS S3 for use in posts and comments. Currently photos only
883
+ * @method
884
+ * @param {String} uri - URI of the asset to upload
885
+ * @param {String} mimeType - mimetype of the asset (e.g. "image/png")
886
+ * @param {String} [name] - filename of the asset
887
+ * @returns {String} URL of the uploaded asset
888
+ * @since 2.5.1
889
+ */
890
+ uploadAsset = async (uri, mimeType, name = "") => {
891
+ if (!this.userToken) {
892
+ throw new SidechatAPIError("User is not authenticated.");
893
+ }
894
+
895
+ let imageType = mimeType.split("/")[1];
896
+ if (!["png", "jpeg", "gif"].includes(imageType)) {
897
+ throw new SidechatAPIError("Unsupported image format.");
898
+ }
899
+
900
+ const data = new FormData();
901
+ data.append("image", {
902
+ name: name,
903
+ type: mimeType,
904
+ uri: uri,
905
+ });
906
+
907
+ const urlReq = await this.sendRequest(`/v1/assets/upload_url?content_type=${imageType}`);
908
+ const urlJson = await urlReq.json();
909
+
910
+ try {
911
+ const uploadReq = await fetch(urlJson.upload_url, {
912
+ body: data.getAll("image")[0],
913
+ method: "PUT",
914
+ headers: {
915
+ "Content-Type": mimeType,
916
+ },
917
+ });
918
+ if (uploadReq.status == 200) {
919
+ return `${this.apiRoot}/v1/assets/library/${urlJson.asset_id}`;
920
+ } else {
921
+ throw new SidechatAPIError(
922
+ `Couldn't upload image - error ${uploadReq.status}`
923
+ );
924
+ }
925
+ } catch (e) {
926
+ throw new SidechatAPIError(e.message);
927
+ }
928
+ };
929
+
930
+ /**
931
+ * Sets the conversation icon of a user
932
+ * @method
933
+ * @since 2.2.1
934
+ * @param {String} userID - alphanumeric ID of user
935
+ * @param {String} emoji - emoji to set as icon
936
+ * @param {String} primaryColor - hex string (including #) of primary color
937
+ * @param {String} secondaryColor - hex string (including #) of secondary color
938
+ */
939
+ setUserIcon = async (userID, emoji, primaryColor, secondaryColor) => {
940
+ if (!this.userToken) {
941
+ throw new SidechatAPIError("User is not authenticated.");
942
+ }
943
+ try {
944
+ const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
945
+ method: "PATCH",
946
+ headers: {
947
+ ...this.defaultHeaders,
948
+ "App-Version": "0",
949
+ Authorization: `Bearer ${this.userToken}`,
950
+ },
951
+ body: JSON.stringify({
952
+ conversation_icon: {
953
+ emoji: emoji,
954
+ secondary_color: secondaryColor,
955
+ is_migrated: true,
956
+ color: primaryColor,
957
+ },
958
+ }),
959
+ });
960
+ const json = await res.json();
961
+ return await json;
962
+ } catch (err) {
963
+ console.error(err);
964
+ throw new SidechatAPIError(`Failed to set icon.`);
965
+ }
966
+ };
967
+
968
+ /**
969
+ * Sets the bio text of a user
970
+ * @method
971
+ * @since 2.5.6
972
+ * @param {String} userID - alphanumeric ID of user
973
+ * @param {String} bio - text to set as bio
974
+ */
975
+ setUserBio = async (userID, bio) => {
976
+ if (!this.userToken) {
977
+ throw new SidechatAPIError("User is not authenticated.");
978
+ }
979
+ try {
980
+ const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
981
+ method: "PATCH",
982
+ headers: {
983
+ ...this.defaultHeaders,
984
+ "App-Version": "5.4.22",
985
+ Authorization: `Bearer ${this.userToken}`,
986
+ },
987
+ body: JSON.stringify({
988
+ bio: bio
989
+ }),
990
+ });
991
+ const json = await res.json();
992
+ return await json;
993
+ } catch (err) {
994
+ console.error(err);
995
+ throw new SidechatAPIError(`Failed to set bio.`);
996
+ }
997
+ };
998
+
999
+ /**
1000
+ * Checks if user can set their username to a string
1001
+ * @method
1002
+ * @since 2.3.6
1003
+ * @param {String} username - string to check
1004
+ * @returns {Boolean} whether or not username is valid and unused
1005
+ */
1006
+ checkUsername = async (username) => {
1007
+ if (!this.userToken) {
1008
+ throw new SidechatAPIError("User is not authenticated.");
1009
+ }
1010
+ try {
1011
+ const res = await fetch(
1012
+ `${this.apiRoot}/v1/users/username?username=${username}`,
1013
+ {
1014
+ method: "GET",
1015
+ headers: {
1016
+ ...this.defaultHeaders,
1017
+ Authorization: `Bearer ${this.userToken}`,
1018
+ },
1019
+ }
1020
+ );
1021
+ if (res?.status == 200 || res?.status == 204) {
1022
+ return true;
1023
+ } else {
1024
+ return false;
1025
+ }
1026
+ } catch (err) {
1027
+ console.error(err);
1028
+ throw new SidechatAPIError(`Failed to check username.`);
1029
+ }
1030
+ };
1031
+
1032
+ /**
1033
+ * Changes the username of the current user
1034
+ * @method
1035
+ * @since 2.3.6
1036
+ * @param {String} userID - alphanumeric ID of user
1037
+ * @param {String} username - new username to set
1038
+ */
1039
+ setUsername = async (userID, username) => {
1040
+ if (!this.userToken) {
1041
+ throw new SidechatAPIError("User is not authenticated.");
1042
+ }
1043
+ try {
1044
+ const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
1045
+ method: "PATCH",
1046
+ headers: {
1047
+ ...this.defaultHeaders,
1048
+ Authorization: `Bearer ${this.userToken}`,
1049
+ },
1050
+ body: JSON.stringify({
1051
+ username: username,
1052
+ }),
1053
+ });
1054
+ const json = await res.json();
1055
+ return await json.user;
1056
+ } catch (err) {
1057
+ console.error(err);
1058
+ throw new SidechatAPIError(`Failed to set icon.`);
1059
+ }
1060
+ };
1061
+
1062
+ /**
1063
+ * Fetches a public user profile
1064
+ * @method
1065
+ * @since 2.6.0
1066
+ * @param {String} username - username of the user to fetch
1067
+ * @returns {SidechatProfile}
1068
+ */
1069
+ getUserProfile = async (username) => {
1070
+ if (!this.userToken) {
1071
+ throw new SidechatAPIError("User is not authenticated.");
1072
+ }
1073
+ try {
1074
+ const res = await fetch(`${this.apiRoot}/v1/groups/username?username=${username}`, {
1075
+ method: "GET",
1076
+ headers: {
1077
+ ...this.defaultHeaders,
1078
+ Authorization: `Bearer ${this.userToken}`,
1079
+ }
1080
+ });
1081
+ const json = await res.json();
1082
+ return await json.group;
1083
+ } catch (err) {
1084
+ console.error(err);
1085
+ throw new SidechatAPIError(`Failed to set icon.`);
1086
+ }
1087
+ };
1088
+
1089
+ /**
1090
+ * Fetches a public user's posts
1091
+ * @method
1092
+ * @since 2.6.0
1093
+ * @param {String} username - username of the user to fetch
1094
+ * @returns {SidechatPostOrComment[]}
1095
+ */
1096
+ getUserPosts = async (username) => {
1097
+ if (!this.userToken) {
1098
+ throw new SidechatAPIError("User is not authenticated.");
1099
+ }
1100
+ try {
1101
+ const res = await fetch(`${this.apiRoot}/v1/users/posts?username=${username}`, {
1102
+ method: "GET",
1103
+ headers: {
1104
+ ...this.defaultHeaders,
1105
+ Authorization: `Bearer ${this.userToken}`,
1106
+ }
1107
+ });
1108
+ const json = await res.json();
1109
+ return await json.posts;
1110
+ } catch (err) {
1111
+ console.error(err);
1112
+ throw new SidechatAPIError(`Failed to set icon.`);
1113
+ }
1114
+ };
1115
+
1116
+ /**
1117
+ * Marks an activity item as read
1118
+ * @method
1119
+ * @since 2.3.2
1120
+ * @param {String} activityID - alphanumeric ID of activity object
1121
+ */
1122
+ readActivity = async (activityID) => {
1123
+ if (!this.userToken) {
1124
+ throw new SidechatAPIError("User is not authenticated.");
1125
+ }
1126
+ try {
1127
+ const res = await fetch(`${this.apiRoot}/v1/activity/seen`, {
1128
+ method: "POST",
1129
+ headers: {
1130
+ ...this.defaultHeaders,
1131
+ Authorization: `Bearer ${this.userToken}`,
1132
+ },
1133
+ body: JSON.stringify({
1134
+ ids: [activityID],
1135
+ }),
1136
+ });
1137
+ const json = await res.json();
1138
+ return await json;
1139
+ } catch (err) {
1140
+ console.error(err);
1141
+ throw new SidechatAPIError(`Failed to mark activity as read.`);
1142
+ }
1143
+ };
1144
+
1145
+ /**
1146
+ * Retrieves joinable group chats
1147
+ * @method
1148
+ * @since 2.3.5
1149
+ */
1150
+ getGroupChats = async () => {
1151
+ if (!this.userToken) {
1152
+ throw new SidechatAPIError("User is not authenticated.");
1153
+ }
1154
+ try {
1155
+ const res = await fetch(`${this.apiRoot}/v1/chats/explore`, {
1156
+ method: "GET",
1157
+ headers: {
1158
+ ...this.defaultHeaders,
1159
+ Authorization: `Bearer ${this.userToken}`,
1160
+ },
1161
+ });
1162
+ const json = await res.json();
1163
+ return await json.chats;
1164
+ } catch (err) {
1165
+ console.error(err);
1166
+ throw new SidechatAPIError(`Failed to get groupchats.`);
1167
+ }
1168
+ };
1169
+
1170
+ /**
1171
+ * Joins a group chat. To mimic the official client, use the user's display name and icon by default.
1172
+ * @method
1173
+ * @param {String} groupChatID - alphanumeric ID of group chat to join
1174
+ * @param {String} displayName - display name to use in chat
1175
+ * @param {String} emoji - emoji to use as icon
1176
+ * @param {String} primaryColor - hex string of primary color
1177
+ * @param {String} secondaryColor - hex string of secondary color
1178
+ * @since 2.3.5
1179
+ */
1180
+ joinGroupChat = async (
1181
+ groupChatID,
1182
+ displayName,
1183
+ emoji,
1184
+ primaryColor,
1185
+ secondaryColor
1186
+ ) => {
1187
+ if (!this.userToken) {
1188
+ throw new SidechatAPIError("User is not authenticated.");
1189
+ }
1190
+ try {
1191
+ const res = await fetch(`${this.apiRoot}/v1/chats/groups/join`, {
1192
+ method: "POST",
1193
+ headers: {
1194
+ ...this.defaultHeaders,
1195
+ Authorization: `Bearer ${this.userToken}`,
1196
+ },
1197
+ body: JSON.stringify({
1198
+ chat_id: groupChatID,
1199
+ identity: {
1200
+ display_name: displayName,
1201
+ emoji: emoji,
1202
+ secondary_color: secondaryColor,
1203
+ color: primaryColor,
1204
+ },
1205
+ }),
1206
+ });
1207
+ const json = await res.json();
1208
+ return await json;
1209
+ } catch (err) {
1210
+ console.error(err);
1211
+ throw new SidechatAPIError(`Failed to join groupchat.`);
1212
+ }
1213
+ };
1214
+
1215
+ /**
1216
+ * Gets a list of the user's direct messages
1217
+ * @method
1218
+ * @returns {SidechatDirectThread[]}
1219
+ * @since 2.4.4
1220
+ */
1221
+ getDMs = async () => {
1222
+ if (!this.userToken) {
1223
+ throw new SidechatAPIError("User is not authenticated.");
1224
+ }
1225
+ try {
1226
+ const res = await fetch(`${this.apiRoot}/v1/chats`, {
1227
+ method: "GET",
1228
+ headers: {
1229
+ ...this.defaultHeaders,
1230
+ Authorization: `Bearer ${this.userToken}`,
1231
+ },
1232
+ });
1233
+ const json = await res.json();
1234
+ const list = await json.chats;
1235
+ let r = [];
1236
+ list.forEach((o) => {
1237
+ r.push(o.chat);
1238
+ });
1239
+ return await r;
1240
+ } catch (err) {
1241
+ console.error(err);
1242
+ throw new SidechatAPIError(`Failed to fetch DMs.`);
1243
+ }
1244
+ };
1245
+
1246
+ /**
1247
+ * Gets a single direct message thread
1248
+ * @method
1249
+ * @param {String} id - alphanumeric ID of the chat to fetch
1250
+ * @returns {SidechatDirectThread}
1251
+ * @since 2.4.4
1252
+ */
1253
+ getDMThread = async (id) => {
1254
+ if (!this.userToken) {
1255
+ throw new SidechatAPIError("User is not authenticated.");
1256
+ }
1257
+ try {
1258
+ const res = await fetch(
1259
+ `${this.apiRoot}/v1/chats/messages?chat_id=${id}`,
1260
+ {
1261
+ method: "GET",
1262
+ headers: {
1263
+ ...this.defaultHeaders,
1264
+ Authorization: `Bearer ${this.userToken}`,
1265
+ },
1266
+ }
1267
+ );
1268
+ const json = await res.json();
1269
+ return await json.chat;
1270
+ } catch (err) {
1271
+ console.error(err);
1272
+ throw new SidechatAPIError(`Failed to fetch DM thread.`);
1273
+ }
1274
+ };
1275
+
1276
+ /**
1277
+ * Sends a message to an existing direct message thread - note that you must first use startDM() to start a thread.
1278
+ * @method
1279
+ * @param {String} chatID - alphanumeric ID of the chat to send to
1280
+ * @param {String} text - text content of message
1281
+ * @param {String} clientID - alphanumeric device ID
1282
+ * @param {SidechatAsset[]} assets - array of assets to send
1283
+ * @param {Boolean} anonymous - whether the DM should be sent anonymously
1284
+ * @since 2.4.4
1285
+ */
1286
+ sendDM = async (chatID, text, clientID, assets = [], anonymous = false) => {
1287
+ if (!this.userToken) {
1288
+ throw new SidechatAPIError("User is not authenticated.");
1289
+ }
1290
+ try {
1291
+ const res = await fetch(`${this.apiRoot}/v1/chats/send`, {
1292
+ method: "POST",
1293
+ headers: {
1294
+ ...this.defaultHeaders,
1295
+ Authorization: `Bearer ${this.userToken}`,
1296
+ },
1297
+ body: JSON.stringify({
1298
+ chat_id: chatID,
1299
+ text: text,
1300
+ client_id: clientID,
1301
+ anonymous: anonymous,
1302
+ assets: assets,
1303
+ }),
1304
+ });
1305
+ const json = await res.json();
1306
+ return await json;
1307
+ } catch (err) {
1308
+ console.error(err);
1309
+ throw new SidechatAPIError(`Failed to send message.`);
1310
+ }
1311
+ };
1312
+
1313
+ /**
1314
+ * Creates a new direct message thread
1315
+ * @method
1316
+ * @param {String} text - text content of message
1317
+ * @param {String} clientID - alphanumeric ID of devide
1318
+ * @param {String} postID - alphanumeric ID of post or comment
1319
+ * @param {Boolean} anonymous - whether the DM should be sent anonymously
1320
+ * @param {"feed"} postContext - context of post (mostly undocumented, defaults to "feed")
1321
+ * @since 2.4.4
1322
+ */
1323
+ startDM = async (
1324
+ text,
1325
+ clientID,
1326
+ postID,
1327
+ anonymous = false,
1328
+ postContext = "feed"
1329
+ ) => {
1330
+ if (!this.userToken) {
1331
+ throw new SidechatAPIError("User is not authenticated.");
1332
+ }
1333
+ try {
1334
+ const res = await fetch(`${this.apiRoot}/v1/chats/start`, {
1335
+ method: "POST",
1336
+ headers: {
1337
+ ...this.defaultHeaders,
1338
+ Authorization: `Bearer ${this.userToken}`,
1339
+ },
1340
+ body: JSON.stringify({
1341
+ text: text,
1342
+ client_id: clientID,
1343
+ post_id: postID,
1344
+ anonymous: anonymous,
1345
+ post_context: postContext,
1346
+ }),
1347
+ });
1348
+ const json = await res.json();
1349
+ return await json;
1350
+ } catch (err) {
1351
+ console.error(err);
1352
+ throw new SidechatAPIError(`Failed to start DM.`);
1353
+ }
1354
+ };
1355
+ }
1356
+
1357
+ export default SidechatAPIClient;
1358
+ </code></pre></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">sidechat.js</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://github.com/micahlt/sidechat.js" target="_blank">GitHub</a></div><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/sidechat.js" target="_blank">NPM</a></div><div class="navbar-item"><a id="" href="https://offsides.micahlindley.com" target="_blank">Offsides (Sidechat for Android)</a></div></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-Authentication.html">Authentication</a></div><div class="sidebar-section-children"><a href="tutorial-Email Registration.html">Email Registration</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="SidechatAPIClient.html">SidechatAPIClient</a></div><div class="sidebar-section-children"><a href="SidechatAPIError.html">SidechatAPIError</a></div><div class="sidebar-section-children"><a href="SidechatColorList.html">SidechatColorList</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#SidechatAssetMetadata">SidechatAssetMetadata</a></div><div class="sidebar-section-children"><a href="global.html#SidechatAuthToken">SidechatAuthToken</a></div><div class="sidebar-section-children"><a href="global.html#SidechatColor">SidechatColor</a></div><div class="sidebar-section-children"><a href="global.html#SidechatCurrentUser">SidechatCurrentUser</a></div><div class="sidebar-section-children"><a href="global.html#SidechatCursorString">SidechatCursorString</a></div><div class="sidebar-section-children"><a href="global.html#SidechatDirectMessage">SidechatDirectMessage</a></div><div class="sidebar-section-children"><a href="global.html#SidechatDirectThread">SidechatDirectThread</a></div><div class="sidebar-section-children"><a href="global.html#SidechatGroup">SidechatGroup</a></div><div class="sidebar-section-children"><a href="global.html#SidechatIcon">SidechatIcon</a></div><div class="sidebar-section-children"><a href="global.html#SidechatIdentity">SidechatIdentity</a></div><div class="sidebar-section-children"><a href="global.html#SidechatLibraryAsset">SidechatLibraryAsset</a></div><div class="sidebar-section-children"><a href="global.html#SidechatMembership">SidechatMembership</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPoll">SidechatPoll</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPollChoice">SidechatPollChoice</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPostOrComment">SidechatPostOrComment</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPostsAndCursor">SidechatPostsAndCursor</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPrivateAssetURL">SidechatPrivateAssetURL</a></div><div class="sidebar-section-children"><a href="global.html#SidechatProfile">SidechatProfile</a></div><div class="sidebar-section-children"><a href="global.html#SidechatSimpleAsset">SidechatSimpleAsset</a></div><div class="sidebar-section-children"><a href="global.html#SidechatVoteString">SidechatVoteString</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#light-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>