sidechat.js 2.4.5 → 2.4.6

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 (109) hide show
  1. package/dist/index.cjs +5 -5
  2. package/dist/index.mjs +5 -5
  3. package/docs/sidechat.js/2.4.6/SidechatAPIClient.html +3 -0
  4. package/docs/sidechat.js/2.4.6/SidechatAPIError.html +3 -0
  5. package/docs/sidechat.js/{2.3.3/classes_SidechatAPIError.js.html → 2.4.6/SidechatColorList.html} +2 -15
  6. package/docs/sidechat.js/{2.3.6 → 2.4.6}/classes_SidechatAPIClient.js.html +278 -97
  7. package/docs/sidechat.js/{2.3.6 → 2.4.6}/classes_SidechatAPIError.js.html +2 -2
  8. package/docs/sidechat.js/{2.3.6 → 2.4.6}/classes_SidechatColorList.js.html +7 -8
  9. package/docs/sidechat.js/2.4.6/data/search.json +1 -0
  10. package/docs/sidechat.js/2.4.6/global.html +3 -0
  11. package/docs/sidechat.js/{2.3.6 → 2.4.6}/index.html +2 -2
  12. package/docs/sidechat.js/{2.3.6 → 2.4.6}/scripts/core.js +24 -0
  13. package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/core.min.js +23 -23
  14. package/docs/sidechat.js/2.4.6/styles/clean-jsdoc-theme-base.css +1161 -0
  15. package/docs/sidechat.js/{2.3.6 → 2.4.6}/styles/clean-jsdoc-theme-dark.css +15 -10
  16. package/docs/sidechat.js/{2.3.6 → 2.4.6}/styles/clean-jsdoc-theme-light.css +196 -102
  17. package/docs/sidechat.js/2.4.6/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  18. package/docs/sidechat.js/2.4.6/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  19. package/docs/sidechat.js/2.4.6/styles/clean-jsdoc-theme.min.css +1 -0
  20. package/docs/sidechat.js/{2.3.6 → 2.4.6}/tutorial-Authentication.html +2 -2
  21. package/docs/sidechat.js/{2.3.6 → 2.4.6}/tutorial-Email Registration.html +2 -2
  22. package/docs/sidechat.js/{2.3.6 → 2.4.6}/types_SidechatTypes.js.html +28 -2
  23. package/package.json +1 -1
  24. package/src/classes/SidechatAPIClient.js +5 -5
  25. package/docs/sidechat.js/2.3.2/SidechatAPIClient.html +0 -3
  26. package/docs/sidechat.js/2.3.2/SidechatAPIError.html +0 -3
  27. package/docs/sidechat.js/2.3.2/classes_SidechatAPIClient.js.html +0 -750
  28. package/docs/sidechat.js/2.3.2/classes_SidechatAPIError.js.html +0 -16
  29. package/docs/sidechat.js/2.3.2/data/search.json +0 -1
  30. package/docs/sidechat.js/2.3.2/global.html +0 -3
  31. package/docs/sidechat.js/2.3.2/index.html +0 -4
  32. package/docs/sidechat.js/2.3.2/scripts/core.js +0 -702
  33. package/docs/sidechat.js/2.3.2/styles/clean-jsdoc-theme-base.css +0 -975
  34. package/docs/sidechat.js/2.3.2/styles/clean-jsdoc-theme-dark.css +0 -407
  35. package/docs/sidechat.js/2.3.2/styles/clean-jsdoc-theme-light.css +0 -388
  36. package/docs/sidechat.js/2.3.2/styles/clean-jsdoc-theme.min.css +0 -1
  37. package/docs/sidechat.js/2.3.2/tutorial-Authentication.html +0 -14
  38. package/docs/sidechat.js/2.3.2/tutorial-Email Registration.html +0 -6
  39. package/docs/sidechat.js/2.3.2/types_SidechatTypes.js.html +0 -134
  40. package/docs/sidechat.js/2.3.3/SidechatAPIClient.html +0 -3
  41. package/docs/sidechat.js/2.3.3/SidechatAPIError.html +0 -3
  42. package/docs/sidechat.js/2.3.3/classes_SidechatAPIClient.js.html +0 -752
  43. package/docs/sidechat.js/2.3.3/data/search.json +0 -1
  44. package/docs/sidechat.js/2.3.3/fonts/Inconsolata-Regular.ttf +0 -0
  45. package/docs/sidechat.js/2.3.3/fonts/OpenSans-Regular.ttf +0 -0
  46. package/docs/sidechat.js/2.3.3/fonts/WorkSans-Bold.ttf +0 -0
  47. package/docs/sidechat.js/2.3.3/global.html +0 -3
  48. package/docs/sidechat.js/2.3.3/index.html +0 -4
  49. package/docs/sidechat.js/2.3.3/scripts/core.js +0 -702
  50. package/docs/sidechat.js/2.3.3/scripts/core.min.js +0 -23
  51. package/docs/sidechat.js/2.3.3/scripts/resize.js +0 -90
  52. package/docs/sidechat.js/2.3.3/scripts/search.js +0 -265
  53. package/docs/sidechat.js/2.3.3/scripts/search.min.js +0 -6
  54. package/docs/sidechat.js/2.3.3/scripts/third-party/Apache-License-2.0.txt +0 -202
  55. package/docs/sidechat.js/2.3.3/scripts/third-party/fuse.js +0 -9
  56. package/docs/sidechat.js/2.3.3/scripts/third-party/hljs-line-num-original.js +0 -369
  57. package/docs/sidechat.js/2.3.3/scripts/third-party/hljs-line-num.js +0 -1
  58. package/docs/sidechat.js/2.3.3/scripts/third-party/hljs-original.js +0 -5171
  59. package/docs/sidechat.js/2.3.3/scripts/third-party/hljs.js +0 -1
  60. package/docs/sidechat.js/2.3.3/scripts/third-party/popper.js +0 -5
  61. package/docs/sidechat.js/2.3.3/scripts/third-party/tippy.js +0 -1
  62. package/docs/sidechat.js/2.3.3/scripts/third-party/tocbot.js +0 -672
  63. package/docs/sidechat.js/2.3.3/scripts/third-party/tocbot.min.js +0 -1
  64. package/docs/sidechat.js/2.3.3/styles/clean-jsdoc-theme-base.css +0 -975
  65. package/docs/sidechat.js/2.3.3/styles/clean-jsdoc-theme-dark.css +0 -407
  66. package/docs/sidechat.js/2.3.3/styles/clean-jsdoc-theme-light.css +0 -388
  67. package/docs/sidechat.js/2.3.3/styles/clean-jsdoc-theme.min.css +0 -1
  68. package/docs/sidechat.js/2.3.3/tutorial-Authentication.html +0 -14
  69. package/docs/sidechat.js/2.3.3/tutorial-Email Registration.html +0 -6
  70. package/docs/sidechat.js/2.3.3/types_SidechatTypes.js.html +0 -134
  71. package/docs/sidechat.js/2.3.6/SidechatAPIClient.html +0 -3
  72. package/docs/sidechat.js/2.3.6/SidechatAPIError.html +0 -3
  73. package/docs/sidechat.js/2.3.6/data/search.json +0 -1
  74. package/docs/sidechat.js/2.3.6/fonts/Inconsolata-Regular.ttf +0 -0
  75. package/docs/sidechat.js/2.3.6/fonts/OpenSans-Regular.ttf +0 -0
  76. package/docs/sidechat.js/2.3.6/fonts/WorkSans-Bold.ttf +0 -0
  77. package/docs/sidechat.js/2.3.6/global.html +0 -3
  78. package/docs/sidechat.js/2.3.6/scripts/core.min.js +0 -23
  79. package/docs/sidechat.js/2.3.6/scripts/resize.js +0 -90
  80. package/docs/sidechat.js/2.3.6/scripts/search.js +0 -265
  81. package/docs/sidechat.js/2.3.6/scripts/search.min.js +0 -6
  82. package/docs/sidechat.js/2.3.6/scripts/third-party/Apache-License-2.0.txt +0 -202
  83. package/docs/sidechat.js/2.3.6/scripts/third-party/fuse.js +0 -9
  84. package/docs/sidechat.js/2.3.6/scripts/third-party/hljs-line-num-original.js +0 -369
  85. package/docs/sidechat.js/2.3.6/scripts/third-party/hljs-line-num.js +0 -1
  86. package/docs/sidechat.js/2.3.6/scripts/third-party/hljs-original.js +0 -5171
  87. package/docs/sidechat.js/2.3.6/scripts/third-party/hljs.js +0 -1
  88. package/docs/sidechat.js/2.3.6/scripts/third-party/popper.js +0 -5
  89. package/docs/sidechat.js/2.3.6/scripts/third-party/tippy.js +0 -1
  90. package/docs/sidechat.js/2.3.6/scripts/third-party/tocbot.js +0 -672
  91. package/docs/sidechat.js/2.3.6/scripts/third-party/tocbot.min.js +0 -1
  92. package/docs/sidechat.js/2.3.6/styles/clean-jsdoc-theme-base.css +0 -975
  93. package/docs/sidechat.js/2.3.6/styles/clean-jsdoc-theme.min.css +0 -1
  94. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/fonts/Inconsolata-Regular.ttf +0 -0
  95. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/fonts/OpenSans-Regular.ttf +0 -0
  96. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/fonts/WorkSans-Bold.ttf +0 -0
  97. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/resize.js +0 -0
  98. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/search.js +0 -0
  99. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/search.min.js +0 -0
  100. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/Apache-License-2.0.txt +0 -0
  101. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/fuse.js +0 -0
  102. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/hljs-line-num-original.js +0 -0
  103. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/hljs-line-num.js +0 -0
  104. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/hljs-original.js +0 -0
  105. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/hljs.js +0 -0
  106. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/popper.js +0 -0
  107. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/tippy.js +0 -0
  108. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/tocbot.js +0 -0
  109. /package/docs/sidechat.js/{2.3.2 → 2.4.6}/scripts/third-party/tocbot.min.js +0 -0
@@ -1,6 +1,6 @@
1
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
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">Home</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><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#SidechatColorList">SidechatColorList</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#SidechatGroup">SidechatGroup</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#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#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/offsides#README.md" 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";
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">Home</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#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#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#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/offsides#README.md" 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
4
  import SidechatAPIError from "../classes/SidechatAPIError.js";
5
5
 
6
6
  /**
@@ -14,6 +14,7 @@ class SidechatAPIClient {
14
14
  * @type {SidechatAuthToken}
15
15
  * */
16
16
  userToken;
17
+
17
18
  /**
18
19
  * Default headers for every API request
19
20
  * @type {Object}
@@ -23,18 +24,29 @@ class SidechatAPIClient {
23
24
  defaultHeaders = {
24
25
  Accept: "application/json",
25
26
  "Content-Type": "application/json",
26
- "App-Version": "4.2.0",
27
+ "App-Version": "6.0.0",
27
28
  Dnt: 1,
28
29
  };
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
+
30
38
  /**
31
39
  * Create a new instance of the API client
32
40
  * @param {SidechatAuthToken} [token] - user bearer token
41
+ * @param {String} rootUrl - custom API root URL for mocking or using other server
33
42
  */
34
- constructor(token = "") {
43
+ constructor(token = "", rootUrl = "") {
35
44
  if (token) {
36
45
  this.userToken = token;
37
46
  }
47
+ if (rootUrl) {
48
+ this.apiRoot = rootUrl;
49
+ }
38
50
  }
39
51
 
40
52
  /**
@@ -46,6 +58,16 @@ class SidechatAPIClient {
46
58
  this.userToken = token;
47
59
  };
48
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
+
49
71
  /**
50
72
  * Initiate the login process with a phone number. Should be followed up with verifySMSCode().
51
73
  * @method
@@ -54,7 +76,7 @@ class SidechatAPIClient {
54
76
  */
55
77
  loginViaSMS = async (phoneNumber) => {
56
78
  try {
57
- const res = await fetch(`https://api.sidechat.lol/v1/login_register`, {
79
+ const res = await fetch(`${this.apiRoot}/v1/login_register`, {
58
80
  method: "POST",
59
81
  headers: this.defaultHeaders,
60
82
  body: JSON.stringify({
@@ -79,17 +101,14 @@ class SidechatAPIClient {
79
101
  */
80
102
  verifySMSCode = async (phoneNumber, code) => {
81
103
  try {
82
- const res = await fetch(
83
- `https://api.sidechat.lol/v1/verify_phone_number`,
84
- {
85
- method: "POST",
86
- headers: this.defaultHeaders,
87
- body: JSON.stringify({
88
- phone_number: `+1${phoneNumber}`,
89
- code: code.toUpperCase(),
90
- }),
91
- }
92
- );
104
+ const res = await fetch(`${this.apiRoot}/v1/verify_phone_number`, {
105
+ method: "POST",
106
+ headers: this.defaultHeaders,
107
+ body: JSON.stringify({
108
+ phone_number: `+1${phoneNumber}`,
109
+ code: code.toUpperCase(),
110
+ }),
111
+ });
93
112
  const json = await res.json();
94
113
  if (json?.logged_in_user?.token) {
95
114
  this.userToken = json.logged_in_user.token;
@@ -113,17 +132,14 @@ class SidechatAPIClient {
113
132
  throw new SidechatAPIError("You're too young to use Offsides.");
114
133
  }
115
134
  try {
116
- const res = await fetch(
117
- `https://api.sidechat.lol/v1/complete_registration`,
118
- {
119
- method: "POST",
120
- headers: this.defaultHeaders,
121
- body: JSON.stringify({
122
- age: Number(age),
123
- registration_id: registrationID,
124
- }),
125
- }
126
- );
135
+ const res = await fetch(`${this.apiRoot}/v1/complete_registration`, {
136
+ method: "POST",
137
+ headers: this.defaultHeaders,
138
+ body: JSON.stringify({
139
+ age: Number(age),
140
+ registration_id: registrationID,
141
+ }),
142
+ });
127
143
  const json = await res.json();
128
144
  if (json.token) {
129
145
  this.userToken = json.token;
@@ -147,19 +163,16 @@ class SidechatAPIClient {
147
163
  throw new SidechatAPIError("User is not authenticated.");
148
164
  }
149
165
  try {
150
- const res = await fetch(
151
- `https://api.sidechat.lol/v2/users/register_email`,
152
- {
153
- method: "POST",
154
- headers: {
155
- ...this.defaultHeaders,
156
- Authorization: `Bearer ${this.userToken}`,
157
- },
158
- body: JSON.stringify({
159
- email: email,
160
- }),
161
- }
162
- );
166
+ const res = await fetch(`${this.apiRoot}/v2/users/register_email`, {
167
+ method: "POST",
168
+ headers: {
169
+ ...this.defaultHeaders,
170
+ Authorization: `Bearer ${this.userToken}`,
171
+ },
172
+ body: JSON.stringify({
173
+ email: email,
174
+ }),
175
+ });
163
176
  const json = await res.json();
164
177
  if (json.message) {
165
178
  throw new SidechatAPIError(json.message);
@@ -181,16 +194,13 @@ class SidechatAPIClient {
181
194
  throw new SidechatAPIError("User is not authenticated.");
182
195
  }
183
196
  try {
184
- const res = await fetch(
185
- `https://api.sidechat.lol/v1/users/check_email_verified`,
186
- {
187
- method: "GET",
188
- headers: {
189
- ...this.defaultHeaders,
190
- Authorization: `Bearer ${this.userToken}`,
191
- },
192
- }
193
- );
197
+ const res = await fetch(`${this.apiRoot}/v1/users/check_email_verified`, {
198
+ method: "GET",
199
+ headers: {
200
+ ...this.defaultHeaders,
201
+ Authorization: `Bearer ${this.userToken}`,
202
+ },
203
+ });
194
204
  const json = await res.json();
195
205
  if (json.verified_email_updates_response) {
196
206
  return json.verified_email_updates_response;
@@ -214,21 +224,18 @@ class SidechatAPIClient {
214
224
  throw new SidechatAPIError("User is not authenticated.");
215
225
  }
216
226
  try {
217
- const res = await fetch(
218
- `https://api.sidechat.lol/v1/register_device_token`,
219
- {
220
- method: "POST",
221
- headers: {
222
- ...this.defaultHeaders,
223
- Authorization: `Bearer ${this.userToken}`,
224
- },
225
- body: JSON.stringify({
226
- build_type: "release",
227
- bundle_id: "com.flowerave.sidechat",
228
- device_token: deviceID,
229
- }),
230
- }
231
- );
227
+ const res = await fetch(`${this.apiRoot}/v1/register_device_token`, {
228
+ method: "POST",
229
+ headers: {
230
+ ...this.defaultHeaders,
231
+ Authorization: `Bearer ${this.userToken}`,
232
+ },
233
+ body: JSON.stringify({
234
+ build_type: "release",
235
+ bundle_id: "com.flowerave.sidechat",
236
+ device_token: deviceID,
237
+ }),
238
+ });
232
239
  const json = await res.json();
233
240
  await AsyncStorage.setItem("deviceID", deviceID);
234
241
  return json;
@@ -262,7 +269,7 @@ class SidechatAPIClient {
262
269
  }
263
270
  try {
264
271
  const res = await fetch(
265
- `https://api.sidechat.lol/v1/updates?group_id=${groupID}`,
272
+ `${this.apiRoot}/v1/updates?group_id=${groupID}`,
266
273
  {
267
274
  method: "GET",
268
275
  headers: {
@@ -294,9 +301,9 @@ class SidechatAPIClient {
294
301
  }
295
302
  try {
296
303
  const res = await fetch(
297
- `https://api.sidechat.lol/v1/posts?group_id=${groupID}&amp;type=${category}${
298
- cursor ? "&amp;cursor=" + cursor : ""
299
- }`,
304
+ `${this.apiRoot}/v1/posts?${
305
+ cursor ? "cursor=" + encodeURIComponent(cursor) + "&amp;" : ""
306
+ }group_id=${groupID}&amp;type=${category}`,
300
307
  {
301
308
  method: "GET",
302
309
  headers: {
@@ -325,7 +332,7 @@ class SidechatAPIClient {
325
332
  throw new SidechatAPIError("User is not authenticated.");
326
333
  }
327
334
  try {
328
- const res = await fetch(`https://api.sidechat.lol/v1/posts/set_vote`, {
335
+ const res = await fetch(`${this.apiRoot}/v1/posts/set_vote`, {
329
336
  method: "POST",
330
337
  headers: {
331
338
  ...this.defaultHeaders,
@@ -358,7 +365,7 @@ class SidechatAPIClient {
358
365
  }
359
366
  try {
360
367
  const res = await fetch(
361
- `https://api.sidechat.lol/v1/posts/get?include_deleted=${includeDeleted}&amp;post_id=${postID}`,
368
+ `${this.apiRoot}/v1/posts/get?include_deleted=${includeDeleted}&amp;post_id=${postID}`,
362
369
  {
363
370
  method: "GET",
364
371
  headers: {
@@ -392,16 +399,13 @@ class SidechatAPIClient {
392
399
  contentType = "my_comments";
393
400
  }
394
401
  try {
395
- const res = await fetch(
396
- `https://api.sidechat.lol/v1/posts&amp;type=${contentType}`,
397
- {
398
- method: "GET",
399
- headers: {
400
- ...this.defaultHeaders,
401
- Authorization: `Bearer ${this.userToken}`,
402
- },
403
- }
404
- );
402
+ const res = await fetch(`${this.apiRoot}/v1/posts&amp;type=${contentType}`, {
403
+ method: "GET",
404
+ headers: {
405
+ ...this.defaultHeaders,
406
+ Authorization: `Bearer ${this.userToken}`,
407
+ },
408
+ });
405
409
  const json = await res.json();
406
410
  return json.posts;
407
411
  } catch (err) {
@@ -423,7 +427,7 @@ class SidechatAPIClient {
423
427
  }
424
428
  try {
425
429
  const res = await fetch(
426
- `https://api.sidechat.lol/v1/posts/comments/?post_id=${postID}`,
430
+ `${this.apiRoot}/v1/posts/comments/?post_id=${postID}`,
427
431
  {
428
432
  method: "GET",
429
433
  headers: {
@@ -498,7 +502,7 @@ class SidechatAPIClient {
498
502
  throw new SidechatAPIError("User is not authenticated.");
499
503
  }
500
504
  try {
501
- const res = await fetch(`https://api.sidechat.lol/v1/groups/explore`, {
505
+ const res = await fetch(`${this.apiRoot}/v1/groups/explore`, {
502
506
  method: "GET",
503
507
  headers: {
504
508
  ...this.defaultHeaders,
@@ -525,7 +529,7 @@ class SidechatAPIClient {
525
529
  throw new SidechatAPIError("User is not authenticated.");
526
530
  }
527
531
  try {
528
- const res = await fetch(`https://api.sidechat.lol/v1/assets/library`, {
532
+ const res = await fetch(`${this.apiRoot}/v1/assets/library`, {
529
533
  method: "GET",
530
534
  headers: {
531
535
  ...this.defaultHeaders,
@@ -551,7 +555,7 @@ class SidechatAPIClient {
551
555
  throw new SidechatAPIError("User is not authenticated.");
552
556
  }
553
557
  try {
554
- const res = await fetch(`https://api.sidechat.lol/v1/users/me`, {
558
+ const res = await fetch(`${this.apiRoot}/v1/users/me`, {
555
559
  method: "GET",
556
560
  headers: {
557
561
  ...this.defaultHeaders,
@@ -578,7 +582,7 @@ class SidechatAPIClient {
578
582
  throw new SidechatAPIError("User is not authenticated.");
579
583
  }
580
584
  try {
581
- const res = await fetch(`https://api.sidechat.lol/v1/groups/${groupID}`, {
585
+ const res = await fetch(`${this.apiRoot}/v1/groups/${groupID}`, {
582
586
  method: "GET",
583
587
  headers: {
584
588
  ...this.defaultHeaders,
@@ -593,6 +597,39 @@ class SidechatAPIClient {
593
597
  }
594
598
  };
595
599
 
600
+ /**
601
+ * Joins or leaves a group
602
+ * @method
603
+ * @param {String} groupID - alphanumeric ID of group to join or leave
604
+ * @param {Boolean} isMember - whether or not the user should be a member of the group
605
+ * @since 2.3.8
606
+ */
607
+ setGroupMembership = async (groupID, isMember) => {
608
+ if (!this.userToken) {
609
+ throw new SidechatAPIError("User is not authenticated.");
610
+ }
611
+ try {
612
+ const res = await fetch(
613
+ `${this.apiRoot}/v1/groups/${isMember ? "join" : "leave"}`,
614
+ {
615
+ method: "POST",
616
+ headers: {
617
+ ...this.defaultHeaders,
618
+ Authorization: `Bearer ${this.userToken}`,
619
+ },
620
+ body: JSON.stringify({
621
+ group_id: groupID,
622
+ }),
623
+ }
624
+ );
625
+ const json = await res.json();
626
+ return await json;
627
+ } catch (err) {
628
+ console.error(err);
629
+ throw new SidechatAPIError(`Failed to modify group membership.`);
630
+ }
631
+ };
632
+
596
633
  /**
597
634
  * Creates a comment on a post
598
635
  * @method
@@ -603,6 +640,7 @@ class SidechatAPIClient {
603
640
  * @param {String} [replyCommentID] - alphanumeric ID of comment to reply to. Falls back to parentPostID
604
641
  * @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach
605
642
  * @param {Boolean} [disableDMs] - prevent direct messages being sent to comment's author
643
+ * @param {Boolean} [anonymous] - whether or not to hide user's name and icon on comment
606
644
  * @returns {SidechatPostOrComment} created comment
607
645
  */
608
646
  createComment = async (
@@ -611,13 +649,14 @@ class SidechatAPIClient {
611
649
  groupID,
612
650
  replyCommentID = parentPostID,
613
651
  assetList = [],
614
- disableDMs = false
652
+ disableDMs = false,
653
+ anonymous = false
615
654
  ) => {
616
655
  if (!this.userToken) {
617
656
  throw new SidechatAPIError("User is not authenticated.");
618
657
  }
619
658
  try {
620
- const res = await fetch(`https://api.sidechat.lol/v1/posts`, {
659
+ const res = await fetch(`${this.apiRoot}/v1/posts`, {
621
660
  method: "POST",
622
661
  headers: {
623
662
  ...this.defaultHeaders,
@@ -631,6 +670,7 @@ class SidechatAPIClient {
631
670
  reply_post_id: replyCommentID,
632
671
  parent_post_id: parentPostID,
633
672
  dms_disabled: disableDMs,
673
+ using_identity: !anonymous,
634
674
  }),
635
675
  });
636
676
  const json = await res.json();
@@ -665,7 +705,7 @@ class SidechatAPIClient {
665
705
  throw new SidechatAPIError("User is not authenticated.");
666
706
  }
667
707
  try {
668
- const res = await fetch(`https://api.sidechat.lol/v1/posts`, {
708
+ const res = await fetch(`${this.apiRoot}/v1/posts`, {
669
709
  method: "POST",
670
710
  headers: {
671
711
  ...this.defaultHeaders,
@@ -701,7 +741,7 @@ class SidechatAPIClient {
701
741
  throw new SidechatAPIError("User is not authenticated.");
702
742
  }
703
743
  try {
704
- const res = await fetch(`https://api.sidechat.lol/v1/posts/delete`, {
744
+ const res = await fetch(`${this.apiRoot}/v1/posts/delete`, {
705
745
  method: "POST",
706
746
  headers: {
707
747
  ...this.defaultHeaders,
@@ -733,7 +773,7 @@ class SidechatAPIClient {
733
773
  throw new SidechatAPIError("User is not authenticated.");
734
774
  }
735
775
  try {
736
- const res = await fetch(`https://api.sidechat.lol/v1/users/${userID}`, {
776
+ const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
737
777
  method: "PATCH",
738
778
  headers: {
739
779
  ...this.defaultHeaders,
@@ -770,7 +810,7 @@ class SidechatAPIClient {
770
810
  }
771
811
  try {
772
812
  const res = await fetch(
773
- `https://api.sidechat.lol/v1/users/username?username=${username}`,
813
+ `${this.apiRoot}/v1/users/username?username=${username}`,
774
814
  {
775
815
  method: "GET",
776
816
  headers: {
@@ -802,7 +842,7 @@ class SidechatAPIClient {
802
842
  throw new SidechatAPIError("User is not authenticated.");
803
843
  }
804
844
  try {
805
- const res = await fetch(`https://api.sidechat.lol/v1/users/${userID}`, {
845
+ const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
806
846
  method: "PATCH",
807
847
  headers: {
808
848
  ...this.defaultHeaders,
@@ -831,7 +871,7 @@ class SidechatAPIClient {
831
871
  throw new SidechatAPIError("User is not authenticated.");
832
872
  }
833
873
  try {
834
- const res = await fetch(`https://api.sidechat.lol/v1/activity/seen`, {
874
+ const res = await fetch(`${this.apiRoot}/v1/activity/seen`, {
835
875
  method: "POST",
836
876
  headers: {
837
877
  ...this.defaultHeaders,
@@ -859,7 +899,7 @@ class SidechatAPIClient {
859
899
  throw new SidechatAPIError("User is not authenticated.");
860
900
  }
861
901
  try {
862
- const res = await fetch(`https://api.sidechat.lol/v1/chats/explore`, {
902
+ const res = await fetch(`${this.apiRoot}/v1/chats/explore`, {
863
903
  method: "GET",
864
904
  headers: {
865
905
  ...this.defaultHeaders,
@@ -890,8 +930,8 @@ class SidechatAPIClient {
890
930
  throw new SidechatAPIError("User is not authenticated.");
891
931
  }
892
932
  try {
893
- const res = await fetch(`https://api.sidechat.lol/v1/chats/groups/join`, {
894
- method: "GET",
933
+ const res = await fetch(`${this.apiRoot}/v1/chats/groups/join`, {
934
+ method: "POST",
895
935
  headers: {
896
936
  ...this.defaultHeaders,
897
937
  Authorization: `Bearer ${this.userToken}`,
@@ -913,7 +953,148 @@ class SidechatAPIClient {
913
953
  throw new SidechatAPIError(`Failed to join groupchat.`);
914
954
  }
915
955
  };
956
+
957
+ /**
958
+ * Gets a list of the user's direct messages
959
+ * @method
960
+ * @returns {SidechatDirectThread[]}
961
+ * @since 2.4.4
962
+ */
963
+ getDMs = async () => {
964
+ if (!this.userToken) {
965
+ throw new SidechatAPIError("User is not authenticated.");
966
+ }
967
+ try {
968
+ const res = await fetch(`${this.apiRoot}/v1/chats`, {
969
+ method: "GET",
970
+ headers: {
971
+ ...this.defaultHeaders,
972
+ Authorization: `Bearer ${this.userToken}`,
973
+ },
974
+ });
975
+ const json = await res.json();
976
+ const list = await json.chats;
977
+ let r = [];
978
+ list.forEach((o) => {
979
+ r.push(o.chat);
980
+ });
981
+ return await r;
982
+ } catch (err) {
983
+ console.error(err);
984
+ throw new SidechatAPIError(`Failed to fetch DMs.`);
985
+ }
986
+ };
987
+
988
+ /**
989
+ * Gets a single direct message thread
990
+ * @method
991
+ * @param {String} id - alphanumeric ID of the chat to fetch
992
+ * @returns {SidechatDirectThread}
993
+ * @since 2.4.4
994
+ */
995
+ getDMThread = async (id) => {
996
+ if (!this.userToken) {
997
+ throw new SidechatAPIError("User is not authenticated.");
998
+ }
999
+ try {
1000
+ const res = await fetch(
1001
+ `${this.apiRoot}/v1/chats/messages?chat_id=${id}`,
1002
+ {
1003
+ method: "GET",
1004
+ headers: {
1005
+ ...this.defaultHeaders,
1006
+ Authorization: `Bearer ${this.userToken}`,
1007
+ },
1008
+ }
1009
+ );
1010
+ const json = await res.json();
1011
+ return await json.chat;
1012
+ } catch (err) {
1013
+ console.error(err);
1014
+ throw new SidechatAPIError(`Failed to fetch DM thread.`);
1015
+ }
1016
+ };
1017
+
1018
+ /**
1019
+ * Sends a message to an existing direct message thread - note that you must first use startDM() to start a thread.
1020
+ * @method
1021
+ * @param {String} chatID - alphanumeric ID of the chat to send to
1022
+ * @param {String} text - text content of message
1023
+ * @param {String} clientID - alphanumeric device ID
1024
+ * @param {SidechatAsset[]} - array of assets to send
1025
+ * @param {Boolean} anonymous - whether the DM should be sent anonymously
1026
+ * @since 2.4.4
1027
+ */
1028
+ sendDM = async (chatID, text, clientID, assets = [], anonymous = false) => {
1029
+ if (!this.userToken) {
1030
+ throw new SidechatAPIError("User is not authenticated.");
1031
+ }
1032
+ try {
1033
+ const res = await fetch(`${this.apiRoot}/v1/chats/send`, {
1034
+ method: "POST",
1035
+ headers: {
1036
+ ...this.defaultHeaders,
1037
+ Authorization: `Bearer ${this.userToken}`,
1038
+ },
1039
+ body: JSON.stringify({
1040
+ chat_id: chatID,
1041
+ text: text,
1042
+ client_id: clientID,
1043
+ anonymous: anonymous,
1044
+ assets: assets,
1045
+ }),
1046
+ });
1047
+ const json = await res.json();
1048
+ return await json;
1049
+ } catch (err) {
1050
+ console.error(err);
1051
+ throw new SidechatAPIError(`Failed to send message.`);
1052
+ }
1053
+ };
1054
+
1055
+ /**
1056
+ * Creates a new direct message thread
1057
+ * @method
1058
+ * @param {String} text - text content of message
1059
+ * @param {String} clientID - alphanumeric ID of devide
1060
+ * @param {String} postID - alphanumeric ID of post or comment
1061
+ * @param {Boolean} anonymous - whether the DM should be sent anonymously
1062
+ * @param {"feed"} postContext - context of post (mostly undocumented, defaults to "feed")
1063
+ * @since 2.4.4
1064
+ */
1065
+ startDM = async (
1066
+ text,
1067
+ clientID,
1068
+ postID,
1069
+ anonymous = false,
1070
+ postContext = "feed"
1071
+ ) => {
1072
+ if (!this.userToken) {
1073
+ throw new SidechatAPIError("User is not authenticated.");
1074
+ }
1075
+ try {
1076
+ const res = await fetch(`${this.apiRoot}/v1/chats/start`, {
1077
+ method: "POST",
1078
+ headers: {
1079
+ ...this.defaultHeaders,
1080
+ Authorization: `Bearer ${this.userToken}`,
1081
+ },
1082
+ body: JSON.stringify({
1083
+ text: text,
1084
+ client_id: clientID,
1085
+ post_id: postID,
1086
+ anonymous: anonymous,
1087
+ post_context: postContext,
1088
+ }),
1089
+ });
1090
+ const json = await res.json();
1091
+ return await json;
1092
+ } catch (err) {
1093
+ console.error(err);
1094
+ throw new SidechatAPIError(`Failed to start DM.`);
1095
+ }
1096
+ };
916
1097
  }
917
1098
 
918
1099
  export default SidechatAPIClient;
919
- </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">Home</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://github.com/micahlt/offsides#README.md" 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><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#SidechatColorList">SidechatColorList</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#SidechatGroup">SidechatGroup</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#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#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>
1100
+ </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">Home</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://github.com/micahlt/offsides#README.md" 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#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#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#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>