x_api_scraper 0.1.0

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 (459) hide show
  1. checksums.yaml +7 -0
  2. data/lib/crystalline/enum.rbi +17 -0
  3. data/lib/crystalline/metadata_fields.rb +265 -0
  4. data/lib/crystalline/module.rb +188 -0
  5. data/lib/crystalline/types.rb +170 -0
  6. data/lib/crystalline/utils.rb +69 -0
  7. data/lib/crystalline.rb +13 -0
  8. data/lib/x_api_scraper.rb +41 -0
  9. data/lib/xapi_scraper/account.rb +194 -0
  10. data/lib/xapi_scraper/actions.rb +2166 -0
  11. data/lib/xapi_scraper/analysis.rb +230 -0
  12. data/lib/xapi_scraper/articles.rb +410 -0
  13. data/lib/xapi_scraper/client.rb +133 -0
  14. data/lib/xapi_scraper/communities.rb +1352 -0
  15. data/lib/xapi_scraper/dm.rb +990 -0
  16. data/lib/xapi_scraper/engagement.rb +792 -0
  17. data/lib/xapi_scraper/followers.rb +420 -0
  18. data/lib/xapi_scraper/following.rb +230 -0
  19. data/lib/xapi_scraper/lists.rb +1156 -0
  20. data/lib/xapi_scraper/models/callbacks.rb +12 -0
  21. data/lib/xapi_scraper/models/components/accountverifymodel.rb +82 -0
  22. data/lib/xapi_scraper/models/components/accountverifymodel.rbi +38 -0
  23. data/lib/xapi_scraper/models/components/accountverifyresponse.rb +47 -0
  24. data/lib/xapi_scraper/models/components/accountverifyresponse.rbi +26 -0
  25. data/lib/xapi_scraper/models/components/advancedsearchcursorquery.rb +51 -0
  26. data/lib/xapi_scraper/models/components/advancedsearchcursorquery.rbi +26 -0
  27. data/lib/xapi_scraper/models/components/advancedsearchcursorresponse.rb +76 -0
  28. data/lib/xapi_scraper/models/components/advancedsearchcursorresponse.rbi +38 -0
  29. data/lib/xapi_scraper/models/components/articleblock.rb +50 -0
  30. data/lib/xapi_scraper/models/components/articleblock.rbi +26 -0
  31. data/lib/xapi_scraper/models/components/articleblockrange.rb +47 -0
  32. data/lib/xapi_scraper/models/components/articleblockrange.rbi +26 -0
  33. data/lib/xapi_scraper/models/components/blockuserresponse.rb +54 -0
  34. data/lib/xapi_scraper/models/components/blockuserresponse.rbi +26 -0
  35. data/lib/xapi_scraper/models/components/bookmarkbody.rb +43 -0
  36. data/lib/xapi_scraper/models/components/bookmarkbody.rbi +20 -0
  37. data/lib/xapi_scraper/models/components/cashtagsquery.rb +192 -0
  38. data/lib/xapi_scraper/models/components/cashtagsquery.rbi +98 -0
  39. data/lib/xapi_scraper/models/components/cashtagsquery_language.rb +76 -0
  40. data/lib/xapi_scraper/models/components/cashtagsquery_language.rbi +9 -0
  41. data/lib/xapi_scraper/models/components/cashtagsquery_sortby.rb +18 -0
  42. data/lib/xapi_scraper/models/components/cashtagsquery_sortby.rbi +9 -0
  43. data/lib/xapi_scraper/models/components/communitymodel.rb +164 -0
  44. data/lib/xapi_scraper/models/components/communitymodel.rbi +92 -0
  45. data/lib/xapi_scraper/models/components/communitytweetsresponse.rb +47 -0
  46. data/lib/xapi_scraper/models/components/communitytweetsresponse.rbi +26 -0
  47. data/lib/xapi_scraper/models/components/context.rb +25 -0
  48. data/lib/xapi_scraper/models/components/context.rbi +9 -0
  49. data/lib/xapi_scraper/models/components/conversationv3model.rb +57 -0
  50. data/lib/xapi_scraper/models/components/conversationv3model.rbi +32 -0
  51. data/lib/xapi_scraper/models/components/createthreaddata.rb +35 -0
  52. data/lib/xapi_scraper/models/components/createthreaddata.rbi +14 -0
  53. data/lib/xapi_scraper/models/components/createthreadquery.rb +51 -0
  54. data/lib/xapi_scraper/models/components/createthreadquery.rbi +26 -0
  55. data/lib/xapi_scraper/models/components/createthreadresponse.rb +47 -0
  56. data/lib/xapi_scraper/models/components/createthreadresponse.rbi +26 -0
  57. data/lib/xapi_scraper/models/components/createthreadtweetitem.rb +31 -0
  58. data/lib/xapi_scraper/models/components/createthreadtweetitem.rbi +14 -0
  59. data/lib/xapi_scraper/models/components/deletebookmarkquery.rb +35 -0
  60. data/lib/xapi_scraper/models/components/deletebookmarkquery.rbi +14 -0
  61. data/lib/xapi_scraper/models/components/deleteretweetquery.rb +35 -0
  62. data/lib/xapi_scraper/models/components/deleteretweetquery.rbi +14 -0
  63. data/lib/xapi_scraper/models/components/deletetweetquery.rb +51 -0
  64. data/lib/xapi_scraper/models/components/deletetweetquery.rbi +26 -0
  65. data/lib/xapi_scraper/models/components/deletetweetresponse.rb +51 -0
  66. data/lib/xapi_scraper/models/components/deletetweetresponse.rbi +26 -0
  67. data/lib/xapi_scraper/models/components/dmhistoryv3data.rb +54 -0
  68. data/lib/xapi_scraper/models/components/dmhistoryv3data.rbi +26 -0
  69. data/lib/xapi_scraper/models/components/dmstatusmodelv2.rb +122 -0
  70. data/lib/xapi_scraper/models/components/dmstatusmodelv2.rbi +62 -0
  71. data/lib/xapi_scraper/models/components/dmstatusresponsev2.rb +47 -0
  72. data/lib/xapi_scraper/models/components/dmstatusresponsev2.rbi +26 -0
  73. data/lib/xapi_scraper/models/components/followersfollowingv3query.rb +51 -0
  74. data/lib/xapi_scraper/models/components/followersfollowingv3query.rbi +26 -0
  75. data/lib/xapi_scraper/models/components/followuserquery.rb +43 -0
  76. data/lib/xapi_scraper/models/components/followuserquery.rbi +20 -0
  77. data/lib/xapi_scraper/models/components/getalltweetsrepliescursorquery.rb +43 -0
  78. data/lib/xapi_scraper/models/components/getalltweetsrepliescursorquery.rbi +20 -0
  79. data/lib/xapi_scraper/models/components/getalltweetsrepliescursorresponse.rb +76 -0
  80. data/lib/xapi_scraper/models/components/getalltweetsrepliescursorresponse.rbi +38 -0
  81. data/lib/xapi_scraper/models/components/getcommunitymemberscursorquery.rb +43 -0
  82. data/lib/xapi_scraper/models/components/getcommunitymemberscursorquery.rbi +20 -0
  83. data/lib/xapi_scraper/models/components/getcommunitymemberscursorresponse.rb +72 -0
  84. data/lib/xapi_scraper/models/components/getcommunitymemberscursorresponse.rbi +38 -0
  85. data/lib/xapi_scraper/models/components/getcommunityresponse.rb +47 -0
  86. data/lib/xapi_scraper/models/components/getcommunityresponse.rbi +26 -0
  87. data/lib/xapi_scraper/models/components/getcommunitytweetscursorquery.rb +60 -0
  88. data/lib/xapi_scraper/models/components/getcommunitytweetscursorquery.rbi +26 -0
  89. data/lib/xapi_scraper/models/components/getcommunitytweetscursorresponse.rb +72 -0
  90. data/lib/xapi_scraper/models/components/getcommunitytweetscursorresponse.rbi +38 -0
  91. data/lib/xapi_scraper/models/components/getconversationsv3query.rb +62 -0
  92. data/lib/xapi_scraper/models/components/getconversationsv3query.rbi +32 -0
  93. data/lib/xapi_scraper/models/components/getconversationsv3response.rb +47 -0
  94. data/lib/xapi_scraper/models/components/getconversationsv3response.rbi +26 -0
  95. data/lib/xapi_scraper/models/components/getdmhistoryv3query.rb +94 -0
  96. data/lib/xapi_scraper/models/components/getdmhistoryv3query.rbi +50 -0
  97. data/lib/xapi_scraper/models/components/getdmhistoryv3response.rb +47 -0
  98. data/lib/xapi_scraper/models/components/getdmhistoryv3response.rbi +26 -0
  99. data/lib/xapi_scraper/models/components/getdmmediav3data.rb +77 -0
  100. data/lib/xapi_scraper/models/components/getdmmediav3data.rbi +44 -0
  101. data/lib/xapi_scraper/models/components/getdmmediav3query.rb +112 -0
  102. data/lib/xapi_scraper/models/components/getdmmediav3query.rbi +56 -0
  103. data/lib/xapi_scraper/models/components/getdmmediav3response.rb +47 -0
  104. data/lib/xapi_scraper/models/components/getdmmediav3response.rbi +26 -0
  105. data/lib/xapi_scraper/models/components/getlistmemberscursorquery.rb +43 -0
  106. data/lib/xapi_scraper/models/components/getlistmemberscursorquery.rbi +20 -0
  107. data/lib/xapi_scraper/models/components/getlistmemberscursorresponse.rb +72 -0
  108. data/lib/xapi_scraper/models/components/getlistmemberscursorresponse.rbi +38 -0
  109. data/lib/xapi_scraper/models/components/getlisttweetscursorquery.rb +43 -0
  110. data/lib/xapi_scraper/models/components/getlisttweetscursorquery.rbi +20 -0
  111. data/lib/xapi_scraper/models/components/getlisttweetscursorresponse.rb +72 -0
  112. data/lib/xapi_scraper/models/components/getlisttweetscursorresponse.rbi +38 -0
  113. data/lib/xapi_scraper/models/components/getquotescursorquery.rb +63 -0
  114. data/lib/xapi_scraper/models/components/getquotescursorquery.rbi +26 -0
  115. data/lib/xapi_scraper/models/components/getquotescursorquery_sort_by.rb +18 -0
  116. data/lib/xapi_scraper/models/components/getquotescursorquery_sort_by.rbi +9 -0
  117. data/lib/xapi_scraper/models/components/getquotescursorresponse.rb +72 -0
  118. data/lib/xapi_scraper/models/components/getquotescursorresponse.rbi +38 -0
  119. data/lib/xapi_scraper/models/components/getquotesquery.rb +59 -0
  120. data/lib/xapi_scraper/models/components/getquotesquery.rbi +26 -0
  121. data/lib/xapi_scraper/models/components/getquotesquery_sort_by.rb +18 -0
  122. data/lib/xapi_scraper/models/components/getquotesquery_sort_by.rbi +9 -0
  123. data/lib/xapi_scraper/models/components/getquotesresponse.rb +47 -0
  124. data/lib/xapi_scraper/models/components/getquotesresponse.rbi +26 -0
  125. data/lib/xapi_scraper/models/components/getrepliespagequery.rb +51 -0
  126. data/lib/xapi_scraper/models/components/getrepliespagequery.rbi +20 -0
  127. data/lib/xapi_scraper/models/components/getrepliespagequery_sort_by.rb +19 -0
  128. data/lib/xapi_scraper/models/components/getrepliespagequery_sort_by.rbi +9 -0
  129. data/lib/xapi_scraper/models/components/getrepliespageresponse.rb +85 -0
  130. data/lib/xapi_scraper/models/components/getrepliespageresponse.rbi +44 -0
  131. data/lib/xapi_scraper/models/components/getretweeterscursorquery.rb +43 -0
  132. data/lib/xapi_scraper/models/components/getretweeterscursorquery.rbi +20 -0
  133. data/lib/xapi_scraper/models/components/getretweeterscursorresponse.rb +72 -0
  134. data/lib/xapi_scraper/models/components/getretweeterscursorresponse.rbi +38 -0
  135. data/lib/xapi_scraper/models/components/gettweetsbyidresponse.rb +58 -0
  136. data/lib/xapi_scraper/models/components/gettweetsbyidresponse.rbi +26 -0
  137. data/lib/xapi_scraper/models/components/hashtagsquery.rb +192 -0
  138. data/lib/xapi_scraper/models/components/hashtagsquery.rbi +98 -0
  139. data/lib/xapi_scraper/models/components/hashtagsquery_language.rb +76 -0
  140. data/lib/xapi_scraper/models/components/hashtagsquery_language.rbi +9 -0
  141. data/lib/xapi_scraper/models/components/hashtagsquery_sortby.rb +18 -0
  142. data/lib/xapi_scraper/models/components/hashtagsquery_sortby.rbi +9 -0
  143. data/lib/xapi_scraper/models/components/likeactionbody.rb +43 -0
  144. data/lib/xapi_scraper/models/components/likeactionbody.rbi +20 -0
  145. data/lib/xapi_scraper/models/components/listmembersresponse.rb +47 -0
  146. data/lib/xapi_scraper/models/components/listmembersresponse.rbi +26 -0
  147. data/lib/xapi_scraper/models/components/listmodel.rb +77 -0
  148. data/lib/xapi_scraper/models/components/listmodel.rbi +44 -0
  149. data/lib/xapi_scraper/models/components/listsubscribersresponse.rb +47 -0
  150. data/lib/xapi_scraper/models/components/listsubscribersresponse.rbi +26 -0
  151. data/lib/xapi_scraper/models/components/listtweetsresponse.rb +47 -0
  152. data/lib/xapi_scraper/models/components/listtweetsresponse.rbi +26 -0
  153. data/lib/xapi_scraper/models/components/loc.rb +25 -0
  154. data/lib/xapi_scraper/models/components/loc.rbi +9 -0
  155. data/lib/xapi_scraper/models/components/mediamodel.rb +194 -0
  156. data/lib/xapi_scraper/models/components/mediamodel.rbi +110 -0
  157. data/lib/xapi_scraper/models/components/messagemodel.rb +100 -0
  158. data/lib/xapi_scraper/models/components/messagemodel.rbi +56 -0
  159. data/lib/xapi_scraper/models/components/posttweetdata.rb +51 -0
  160. data/lib/xapi_scraper/models/components/posttweetdata.rbi +26 -0
  161. data/lib/xapi_scraper/models/components/posttweetquery.rb +122 -0
  162. data/lib/xapi_scraper/models/components/posttweetquery.rbi +62 -0
  163. data/lib/xapi_scraper/models/components/posttweetresponse.rb +58 -0
  164. data/lib/xapi_scraper/models/components/posttweetresponse.rbi +26 -0
  165. data/lib/xapi_scraper/models/components/posttweetwithoutcookiequery.rb +102 -0
  166. data/lib/xapi_scraper/models/components/posttweetwithoutcookiequery.rbi +50 -0
  167. data/lib/xapi_scraper/models/components/quotetweetquery.rb +112 -0
  168. data/lib/xapi_scraper/models/components/quotetweetquery.rbi +56 -0
  169. data/lib/xapi_scraper/models/components/retweetactionbody.rb +43 -0
  170. data/lib/xapi_scraper/models/components/retweetactionbody.rbi +20 -0
  171. data/lib/xapi_scraper/models/components/searchcommunityquery.rb +43 -0
  172. data/lib/xapi_scraper/models/components/searchcommunityquery.rbi +20 -0
  173. data/lib/xapi_scraper/models/components/searchcommunityresponse.rb +47 -0
  174. data/lib/xapi_scraper/models/components/searchcommunityresponse.rbi +26 -0
  175. data/lib/xapi_scraper/models/components/searchcommunitytweetsquery.rb +51 -0
  176. data/lib/xapi_scraper/models/components/searchcommunitytweetsquery.rbi +26 -0
  177. data/lib/xapi_scraper/models/components/searchlistquery.rb +43 -0
  178. data/lib/xapi_scraper/models/components/searchlistquery.rbi +20 -0
  179. data/lib/xapi_scraper/models/components/searchlistresponse.rb +47 -0
  180. data/lib/xapi_scraper/models/components/searchlistresponse.rbi +26 -0
  181. data/lib/xapi_scraper/models/components/searchresponse.rb +54 -0
  182. data/lib/xapi_scraper/models/components/searchresponse.rbi +26 -0
  183. data/lib/xapi_scraper/models/components/searchuserresponse.rb +47 -0
  184. data/lib/xapi_scraper/models/components/searchuserresponse.rbi +26 -0
  185. data/lib/xapi_scraper/models/components/security.rb +34 -0
  186. data/lib/xapi_scraper/models/components/security.rbi +14 -0
  187. data/lib/xapi_scraper/models/components/senddmresponse.rb +47 -0
  188. data/lib/xapi_scraper/models/components/senddmresponse.rbi +26 -0
  189. data/lib/xapi_scraper/models/components/senddmv3query.rb +90 -0
  190. data/lib/xapi_scraper/models/components/senddmv3query.rbi +50 -0
  191. data/lib/xapi_scraper/models/components/sentimentanalysismodel.rb +43 -0
  192. data/lib/xapi_scraper/models/components/sentimentanalysismodel.rbi +20 -0
  193. data/lib/xapi_scraper/models/components/sentimentanalysisquery.rb +31 -0
  194. data/lib/xapi_scraper/models/components/sentimentanalysisquery.rbi +14 -0
  195. data/lib/xapi_scraper/models/components/sentimentanalysisresponse.rb +47 -0
  196. data/lib/xapi_scraper/models/components/sentimentanalysisresponse.rbi +26 -0
  197. data/lib/xapi_scraper/models/components/standardresponse.rb +47 -0
  198. data/lib/xapi_scraper/models/components/standardresponse.rbi +26 -0
  199. data/lib/xapi_scraper/models/components/streammodel.rb +51 -0
  200. data/lib/xapi_scraper/models/components/streammodel.rbi +26 -0
  201. data/lib/xapi_scraper/models/components/tweet_type.rb +19 -0
  202. data/lib/xapi_scraper/models/components/tweet_type.rbi +9 -0
  203. data/lib/xapi_scraper/models/components/tweetactionresponse.rb +51 -0
  204. data/lib/xapi_scraper/models/components/tweetactionresponse.rbi +26 -0
  205. data/lib/xapi_scraper/models/components/tweetmodel.rb +518 -0
  206. data/lib/xapi_scraper/models/components/tweetmodel.rbi +302 -0
  207. data/lib/xapi_scraper/models/components/tweetthreadbyidbody.rb +53 -0
  208. data/lib/xapi_scraper/models/components/tweetthreadbyidbody.rbi +26 -0
  209. data/lib/xapi_scraper/models/components/twitteraccountbasedstandardresponse.rb +58 -0
  210. data/lib/xapi_scraper/models/components/twitteraccountbasedstandardresponse.rbi +26 -0
  211. data/lib/xapi_scraper/models/components/twitteruseraboutresponse.rb +208 -0
  212. data/lib/xapi_scraper/models/components/twitteruseraboutresponse.rbi +116 -0
  213. data/lib/xapi_scraper/models/components/twitteruseraboutstandardresponse.rb +58 -0
  214. data/lib/xapi_scraper/models/components/twitteruseraboutstandardresponse.rbi +26 -0
  215. data/lib/xapi_scraper/models/components/unfavoritetweetquery.rb +35 -0
  216. data/lib/xapi_scraper/models/components/unfavoritetweetquery.rbi +14 -0
  217. data/lib/xapi_scraper/models/components/unfollowuserquery.rb +43 -0
  218. data/lib/xapi_scraper/models/components/unfollowuserquery.rbi +20 -0
  219. data/lib/xapi_scraper/models/components/unfollowuserresponse.rb +47 -0
  220. data/lib/xapi_scraper/models/components/unfollowuserresponse.rbi +26 -0
  221. data/lib/xapi_scraper/models/components/urlmodel.rb +47 -0
  222. data/lib/xapi_scraper/models/components/urlmodel.rbi +26 -0
  223. data/lib/xapi_scraper/models/components/userinfo.rb +348 -0
  224. data/lib/xapi_scraper/models/components/userinfo.rbi +200 -0
  225. data/lib/xapi_scraper/models/components/usermodel.rb +344 -0
  226. data/lib/xapi_scraper/models/components/usermodel.rbi +200 -0
  227. data/lib/xapi_scraper/models/components/usersdetailsresponse.rb +47 -0
  228. data/lib/xapi_scraper/models/components/usersdetailsresponse.rbi +26 -0
  229. data/lib/xapi_scraper/models/components/usertimelinefillquery.rb +35 -0
  230. data/lib/xapi_scraper/models/components/usertimelinefillquery.rbi +14 -0
  231. data/lib/xapi_scraper/models/components/usertimelinepagequery.rb +43 -0
  232. data/lib/xapi_scraper/models/components/usertimelinepagequery.rbi +20 -0
  233. data/lib/xapi_scraper/models/components/usertimelinepageresponse.rb +112 -0
  234. data/lib/xapi_scraper/models/components/usertimelinepageresponse.rbi +56 -0
  235. data/lib/xapi_scraper/models/components/usertimelineresponse.rb +76 -0
  236. data/lib/xapi_scraper/models/components/usertimelineresponse.rbi +38 -0
  237. data/lib/xapi_scraper/models/components/usertweetitem.rb +225 -0
  238. data/lib/xapi_scraper/models/components/usertweetitem.rbi +122 -0
  239. data/lib/xapi_scraper/models/components/validationerror.rb +67 -0
  240. data/lib/xapi_scraper/models/components/validationerror.rbi +38 -0
  241. data/lib/xapi_scraper/models/components/verifiedfollowersdata.rb +58 -0
  242. data/lib/xapi_scraper/models/components/verifiedfollowersdata.rbi +26 -0
  243. data/lib/xapi_scraper/models/components/verifiedfollowersresponse.rb +47 -0
  244. data/lib/xapi_scraper/models/components/verifiedfollowersresponse.rbi +26 -0
  245. data/lib/xapi_scraper/models/components/xarticlemodel.rb +305 -0
  246. data/lib/xapi_scraper/models/components/xarticlemodel.rbi +170 -0
  247. data/lib/xapi_scraper/models/components/xarticleresponse.rb +47 -0
  248. data/lib/xapi_scraper/models/components/xarticleresponse.rbi +26 -0
  249. data/lib/xapi_scraper/models/components.rb +128 -0
  250. data/lib/xapi_scraper/models/errors/apierror.rb +39 -0
  251. data/lib/xapi_scraper/models/errors/apierror.rbi +27 -0
  252. data/lib/xapi_scraper/models/errors/httpvalidationerror.rb +48 -0
  253. data/lib/xapi_scraper/models/errors/httpvalidationerror.rbi +20 -0
  254. data/lib/xapi_scraper/models/errors.rb +13 -0
  255. data/lib/xapi_scraper/models/operations/accountgetbalance_response.rb +51 -0
  256. data/lib/xapi_scraper/models/operations/accountgetbalance_response.rbi +32 -0
  257. data/lib/xapi_scraper/models/operations/analysissentiment_response.rb +51 -0
  258. data/lib/xapi_scraper/models/operations/analysissentiment_response.rbi +32 -0
  259. data/lib/xapi_scraper/models/operations/articlesfetch_response.rb +51 -0
  260. data/lib/xapi_scraper/models/operations/articlesfetch_response.rbi +32 -0
  261. data/lib/xapi_scraper/models/operations/articlesmarkdown_request.rb +31 -0
  262. data/lib/xapi_scraper/models/operations/articlesmarkdown_request.rbi +14 -0
  263. data/lib/xapi_scraper/models/operations/articlesmarkdown_response.rb +51 -0
  264. data/lib/xapi_scraper/models/operations/articlesmarkdown_response.rbi +32 -0
  265. data/lib/xapi_scraper/models/operations/communitiesget_request.rb +34 -0
  266. data/lib/xapi_scraper/models/operations/communitiesget_request.rbi +14 -0
  267. data/lib/xapi_scraper/models/operations/communitiesget_response.rb +51 -0
  268. data/lib/xapi_scraper/models/operations/communitiesget_response.rbi +32 -0
  269. data/lib/xapi_scraper/models/operations/communitiesmembers_request.rb +42 -0
  270. data/lib/xapi_scraper/models/operations/communitiesmembers_request.rbi +20 -0
  271. data/lib/xapi_scraper/models/operations/communitiesmembers_response.rb +51 -0
  272. data/lib/xapi_scraper/models/operations/communitiesmembers_response.rbi +32 -0
  273. data/lib/xapi_scraper/models/operations/communitiesmemberspage_response.rb +54 -0
  274. data/lib/xapi_scraper/models/operations/communitiesmemberspage_response.rbi +32 -0
  275. data/lib/xapi_scraper/models/operations/communitiessearch_response.rb +51 -0
  276. data/lib/xapi_scraper/models/operations/communitiessearch_response.rbi +32 -0
  277. data/lib/xapi_scraper/models/operations/communitiessearchtweets_response.rb +51 -0
  278. data/lib/xapi_scraper/models/operations/communitiessearchtweets_response.rbi +32 -0
  279. data/lib/xapi_scraper/models/operations/communitiestweets_request.rb +50 -0
  280. data/lib/xapi_scraper/models/operations/communitiestweets_request.rbi +26 -0
  281. data/lib/xapi_scraper/models/operations/communitiestweets_response.rb +51 -0
  282. data/lib/xapi_scraper/models/operations/communitiestweets_response.rbi +32 -0
  283. data/lib/xapi_scraper/models/operations/communitiestweetspage_response.rb +54 -0
  284. data/lib/xapi_scraper/models/operations/communitiestweetspage_response.rbi +32 -0
  285. data/lib/xapi_scraper/models/operations/country.rb +79 -0
  286. data/lib/xapi_scraper/models/operations/country.rbi +9 -0
  287. data/lib/xapi_scraper/models/operations/dmconversations_response.rb +51 -0
  288. data/lib/xapi_scraper/models/operations/dmconversations_response.rbi +32 -0
  289. data/lib/xapi_scraper/models/operations/dmhistory_response.rb +51 -0
  290. data/lib/xapi_scraper/models/operations/dmhistory_response.rbi +32 -0
  291. data/lib/xapi_scraper/models/operations/dmmedia_response.rb +51 -0
  292. data/lib/xapi_scraper/models/operations/dmmedia_response.rbi +32 -0
  293. data/lib/xapi_scraper/models/operations/dmsend_response.rb +51 -0
  294. data/lib/xapi_scraper/models/operations/dmsend_response.rbi +32 -0
  295. data/lib/xapi_scraper/models/operations/dmstatus_response.rb +51 -0
  296. data/lib/xapi_scraper/models/operations/dmstatus_response.rbi +32 -0
  297. data/lib/xapi_scraper/models/operations/listsmembers_request.rb +38 -0
  298. data/lib/xapi_scraper/models/operations/listsmembers_request.rbi +20 -0
  299. data/lib/xapi_scraper/models/operations/listsmembers_response.rb +51 -0
  300. data/lib/xapi_scraper/models/operations/listsmembers_response.rbi +32 -0
  301. data/lib/xapi_scraper/models/operations/listsmemberspage_response.rb +54 -0
  302. data/lib/xapi_scraper/models/operations/listsmemberspage_response.rbi +32 -0
  303. data/lib/xapi_scraper/models/operations/listssearch_response.rb +51 -0
  304. data/lib/xapi_scraper/models/operations/listssearch_response.rbi +32 -0
  305. data/lib/xapi_scraper/models/operations/listssubscribers_request.rb +38 -0
  306. data/lib/xapi_scraper/models/operations/listssubscribers_request.rbi +20 -0
  307. data/lib/xapi_scraper/models/operations/listssubscribers_response.rb +51 -0
  308. data/lib/xapi_scraper/models/operations/listssubscribers_response.rbi +32 -0
  309. data/lib/xapi_scraper/models/operations/liststweets_request.rb +38 -0
  310. data/lib/xapi_scraper/models/operations/liststweets_request.rbi +20 -0
  311. data/lib/xapi_scraper/models/operations/liststweets_response.rb +51 -0
  312. data/lib/xapi_scraper/models/operations/liststweets_response.rbi +32 -0
  313. data/lib/xapi_scraper/models/operations/liststweetspage_response.rb +54 -0
  314. data/lib/xapi_scraper/models/operations/liststweetspage_response.rbi +32 -0
  315. data/lib/xapi_scraper/models/operations/searchadvanced_response.rb +54 -0
  316. data/lib/xapi_scraper/models/operations/searchadvanced_response.rbi +32 -0
  317. data/lib/xapi_scraper/models/operations/searchcashtags_response.rb +51 -0
  318. data/lib/xapi_scraper/models/operations/searchcashtags_response.rbi +32 -0
  319. data/lib/xapi_scraper/models/operations/searchhashtags_response.rb +51 -0
  320. data/lib/xapi_scraper/models/operations/searchhashtags_response.rbi +32 -0
  321. data/lib/xapi_scraper/models/operations/timelinestweetsandreplies_request.rb +35 -0
  322. data/lib/xapi_scraper/models/operations/timelinestweetsandreplies_request.rbi +20 -0
  323. data/lib/xapi_scraper/models/operations/timelinestweetsandreplies_response.rb +51 -0
  324. data/lib/xapi_scraper/models/operations/timelinestweetsandreplies_response.rbi +32 -0
  325. data/lib/xapi_scraper/models/operations/timelinestweetsandrepliespage_response.rb +54 -0
  326. data/lib/xapi_scraper/models/operations/timelinestweetsandrepliespage_response.rbi +32 -0
  327. data/lib/xapi_scraper/models/operations/timelinesuser_request.rb +35 -0
  328. data/lib/xapi_scraper/models/operations/timelinesuser_request.rbi +20 -0
  329. data/lib/xapi_scraper/models/operations/timelinesuser_response.rb +51 -0
  330. data/lib/xapi_scraper/models/operations/timelinesuser_response.rbi +32 -0
  331. data/lib/xapi_scraper/models/operations/timelinesuserpage_request.rb +35 -0
  332. data/lib/xapi_scraper/models/operations/timelinesuserpage_request.rbi +20 -0
  333. data/lib/xapi_scraper/models/operations/timelinesuserpage_response.rb +51 -0
  334. data/lib/xapi_scraper/models/operations/timelinesuserpage_response.rbi +32 -0
  335. data/lib/xapi_scraper/models/operations/trendingbycountry_request.rb +35 -0
  336. data/lib/xapi_scraper/models/operations/trendingbycountry_request.rbi +14 -0
  337. data/lib/xapi_scraper/models/operations/trendingbycountry_response.rb +51 -0
  338. data/lib/xapi_scraper/models/operations/trendingbycountry_response.rbi +32 -0
  339. data/lib/xapi_scraper/models/operations/trendingcontents_request.rb +35 -0
  340. data/lib/xapi_scraper/models/operations/trendingcontents_request.rbi +20 -0
  341. data/lib/xapi_scraper/models/operations/trendingcontents_response.rb +51 -0
  342. data/lib/xapi_scraper/models/operations/trendingcontents_response.rbi +32 -0
  343. data/lib/xapi_scraper/models/operations/trendingcountries_response.rb +51 -0
  344. data/lib/xapi_scraper/models/operations/trendingcountries_response.rbi +32 -0
  345. data/lib/xapi_scraper/models/operations/trendingtopics_response.rb +51 -0
  346. data/lib/xapi_scraper/models/operations/trendingtopics_response.rbi +32 -0
  347. data/lib/xapi_scraper/models/operations/trendingtweets_request.rb +63 -0
  348. data/lib/xapi_scraper/models/operations/trendingtweets_request.rbi +32 -0
  349. data/lib/xapi_scraper/models/operations/trendingtweets_response.rb +51 -0
  350. data/lib/xapi_scraper/models/operations/trendingtweets_response.rbi +32 -0
  351. data/lib/xapi_scraper/models/operations/tweet_type.rb +19 -0
  352. data/lib/xapi_scraper/models/operations/tweet_type.rbi +9 -0
  353. data/lib/xapi_scraper/models/operations/tweetsactionsbookmark_request.rb +35 -0
  354. data/lib/xapi_scraper/models/operations/tweetsactionsbookmark_request.rbi +20 -0
  355. data/lib/xapi_scraper/models/operations/tweetsactionsbookmark_response.rb +51 -0
  356. data/lib/xapi_scraper/models/operations/tweetsactionsbookmark_response.rbi +32 -0
  357. data/lib/xapi_scraper/models/operations/tweetsactionscreate_response.rb +51 -0
  358. data/lib/xapi_scraper/models/operations/tweetsactionscreate_response.rbi +32 -0
  359. data/lib/xapi_scraper/models/operations/tweetsactionscreatethread_response.rb +51 -0
  360. data/lib/xapi_scraper/models/operations/tweetsactionscreatethread_response.rbi +32 -0
  361. data/lib/xapi_scraper/models/operations/tweetsactionscreatewithoutcookie_response.rb +51 -0
  362. data/lib/xapi_scraper/models/operations/tweetsactionscreatewithoutcookie_response.rbi +32 -0
  363. data/lib/xapi_scraper/models/operations/tweetsactionsdeletebatch_response.rb +51 -0
  364. data/lib/xapi_scraper/models/operations/tweetsactionsdeletebatch_response.rbi +32 -0
  365. data/lib/xapi_scraper/models/operations/tweetsactionslike_request.rb +35 -0
  366. data/lib/xapi_scraper/models/operations/tweetsactionslike_request.rbi +20 -0
  367. data/lib/xapi_scraper/models/operations/tweetsactionslike_response.rb +51 -0
  368. data/lib/xapi_scraper/models/operations/tweetsactionslike_response.rbi +32 -0
  369. data/lib/xapi_scraper/models/operations/tweetsactionsquote_response.rb +51 -0
  370. data/lib/xapi_scraper/models/operations/tweetsactionsquote_response.rbi +32 -0
  371. data/lib/xapi_scraper/models/operations/tweetsactionsretweet_request.rb +35 -0
  372. data/lib/xapi_scraper/models/operations/tweetsactionsretweet_request.rbi +20 -0
  373. data/lib/xapi_scraper/models/operations/tweetsactionsretweet_response.rb +51 -0
  374. data/lib/xapi_scraper/models/operations/tweetsactionsretweet_response.rbi +32 -0
  375. data/lib/xapi_scraper/models/operations/tweetsactionsunbookmark_request.rb +35 -0
  376. data/lib/xapi_scraper/models/operations/tweetsactionsunbookmark_request.rbi +20 -0
  377. data/lib/xapi_scraper/models/operations/tweetsactionsunbookmark_response.rb +51 -0
  378. data/lib/xapi_scraper/models/operations/tweetsactionsunbookmark_response.rbi +32 -0
  379. data/lib/xapi_scraper/models/operations/tweetsactionsunlike_request.rb +35 -0
  380. data/lib/xapi_scraper/models/operations/tweetsactionsunlike_request.rbi +20 -0
  381. data/lib/xapi_scraper/models/operations/tweetsactionsunlike_response.rb +51 -0
  382. data/lib/xapi_scraper/models/operations/tweetsactionsunlike_response.rbi +32 -0
  383. data/lib/xapi_scraper/models/operations/tweetsactionsunretweet_request.rb +35 -0
  384. data/lib/xapi_scraper/models/operations/tweetsactionsunretweet_request.rbi +20 -0
  385. data/lib/xapi_scraper/models/operations/tweetsactionsunretweet_response.rb +51 -0
  386. data/lib/xapi_scraper/models/operations/tweetsactionsunretweet_response.rbi +32 -0
  387. data/lib/xapi_scraper/models/operations/tweetsdetail_response.rb +51 -0
  388. data/lib/xapi_scraper/models/operations/tweetsdetail_response.rbi +32 -0
  389. data/lib/xapi_scraper/models/operations/tweetsengagementquotes_response.rb +51 -0
  390. data/lib/xapi_scraper/models/operations/tweetsengagementquotes_response.rbi +32 -0
  391. data/lib/xapi_scraper/models/operations/tweetsengagementquotespage_response.rb +51 -0
  392. data/lib/xapi_scraper/models/operations/tweetsengagementquotespage_response.rbi +32 -0
  393. data/lib/xapi_scraper/models/operations/tweetsengagementretweeters_request.rb +39 -0
  394. data/lib/xapi_scraper/models/operations/tweetsengagementretweeters_request.rbi +20 -0
  395. data/lib/xapi_scraper/models/operations/tweetsengagementretweeters_response.rb +51 -0
  396. data/lib/xapi_scraper/models/operations/tweetsengagementretweeters_response.rbi +32 -0
  397. data/lib/xapi_scraper/models/operations/tweetsengagementretweeterspage_response.rb +51 -0
  398. data/lib/xapi_scraper/models/operations/tweetsengagementretweeterspage_response.rbi +32 -0
  399. data/lib/xapi_scraper/models/operations/tweetslookup_response.rb +51 -0
  400. data/lib/xapi_scraper/models/operations/tweetslookup_response.rbi +32 -0
  401. data/lib/xapi_scraper/models/operations/tweetsrepliespage_request.rb +35 -0
  402. data/lib/xapi_scraper/models/operations/tweetsrepliespage_request.rbi +20 -0
  403. data/lib/xapi_scraper/models/operations/tweetsrepliespage_response.rb +51 -0
  404. data/lib/xapi_scraper/models/operations/tweetsrepliespage_response.rbi +32 -0
  405. data/lib/xapi_scraper/models/operations/tweetssimilar_request.rb +30 -0
  406. data/lib/xapi_scraper/models/operations/tweetssimilar_request.rbi +14 -0
  407. data/lib/xapi_scraper/models/operations/tweetssimilar_response.rb +51 -0
  408. data/lib/xapi_scraper/models/operations/tweetssimilar_response.rbi +32 -0
  409. data/lib/xapi_scraper/models/operations/tweetsthread_response.rb +51 -0
  410. data/lib/xapi_scraper/models/operations/tweetsthread_response.rbi +32 -0
  411. data/lib/xapi_scraper/models/operations/usersfollow_response.rb +51 -0
  412. data/lib/xapi_scraper/models/operations/usersfollow_response.rbi +32 -0
  413. data/lib/xapi_scraper/models/operations/usersfollowerslist_response.rb +51 -0
  414. data/lib/xapi_scraper/models/operations/usersfollowerslist_response.rbi +32 -0
  415. data/lib/xapi_scraper/models/operations/usersfollowersverified_response.rb +51 -0
  416. data/lib/xapi_scraper/models/operations/usersfollowersverified_response.rbi +32 -0
  417. data/lib/xapi_scraper/models/operations/usersfollowinglist_response.rb +51 -0
  418. data/lib/xapi_scraper/models/operations/usersfollowinglist_response.rbi +32 -0
  419. data/lib/xapi_scraper/models/operations/usersgetabout_request.rb +31 -0
  420. data/lib/xapi_scraper/models/operations/usersgetabout_request.rbi +14 -0
  421. data/lib/xapi_scraper/models/operations/usersgetabout_response.rb +54 -0
  422. data/lib/xapi_scraper/models/operations/usersgetabout_response.rbi +32 -0
  423. data/lib/xapi_scraper/models/operations/usersgetaccountbased_response.rb +54 -0
  424. data/lib/xapi_scraper/models/operations/usersgetaccountbased_response.rbi +32 -0
  425. data/lib/xapi_scraper/models/operations/usersgetbyids_response.rb +51 -0
  426. data/lib/xapi_scraper/models/operations/usersgetbyids_response.rbi +32 -0
  427. data/lib/xapi_scraper/models/operations/usersgetbyusernames_response.rb +51 -0
  428. data/lib/xapi_scraper/models/operations/usersgetbyusernames_response.rbi +32 -0
  429. data/lib/xapi_scraper/models/operations/usersgetstatuses_response.rb +51 -0
  430. data/lib/xapi_scraper/models/operations/usersgetstatuses_response.rbi +32 -0
  431. data/lib/xapi_scraper/models/operations/userssearch_request.rb +39 -0
  432. data/lib/xapi_scraper/models/operations/userssearch_request.rbi +20 -0
  433. data/lib/xapi_scraper/models/operations/userssearch_response.rb +51 -0
  434. data/lib/xapi_scraper/models/operations/userssearch_response.rbi +32 -0
  435. data/lib/xapi_scraper/models/operations/usersunfollow_response.rb +51 -0
  436. data/lib/xapi_scraper/models/operations/usersunfollow_response.rbi +32 -0
  437. data/lib/xapi_scraper/models/operations/usersverifyaccount_response.rb +51 -0
  438. data/lib/xapi_scraper/models/operations/usersverifyaccount_response.rbi +32 -0
  439. data/lib/xapi_scraper/models/operations.rb +127 -0
  440. data/lib/xapi_scraper/replies.rb +235 -0
  441. data/lib/xapi_scraper/sdk_hooks/hooks.rb +99 -0
  442. data/lib/xapi_scraper/sdk_hooks/registration.rb +34 -0
  443. data/lib/xapi_scraper/sdk_hooks/types.rb +180 -0
  444. data/lib/xapi_scraper/sdkconfiguration.rb +107 -0
  445. data/lib/xapi_scraper/sdkconfiguration.rbi +83 -0
  446. data/lib/xapi_scraper/search.rb +610 -0
  447. data/lib/xapi_scraper/timelines.rb +805 -0
  448. data/lib/xapi_scraper/trending.rb +888 -0
  449. data/lib/xapi_scraper/tweets.rb +801 -0
  450. data/lib/xapi_scraper/users.rb +1748 -0
  451. data/lib/xapi_scraper/utils/forms.rb +232 -0
  452. data/lib/xapi_scraper/utils/headers.rb +82 -0
  453. data/lib/xapi_scraper/utils/query_params.rb +167 -0
  454. data/lib/xapi_scraper/utils/request_bodies.rb +79 -0
  455. data/lib/xapi_scraper/utils/retries.rb +139 -0
  456. data/lib/xapi_scraper/utils/security.rb +158 -0
  457. data/lib/xapi_scraper/utils/url.rb +124 -0
  458. data/lib/xapi_scraper/utils/utils.rb +241 -0
  459. metadata +720 -0
@@ -0,0 +1,1352 @@
1
+ # Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2
+
3
+ # typed: true
4
+ # frozen_string_literal: true
5
+
6
+ require "faraday"
7
+ require "faraday/multipart"
8
+ require "faraday/retry"
9
+ require "sorbet-runtime"
10
+
11
+ require_relative "sdk_hooks/hooks"
12
+ require_relative "utils/retries"
13
+
14
+ module XapiScraper
15
+ extend T::Sig
16
+
17
+ class Communities
18
+ extend T::Sig
19
+
20
+ sig { params(sdk_config: SDKConfiguration).void }
21
+ def initialize(sdk_config)
22
+ @sdk_configuration = sdk_config
23
+ end
24
+
25
+ sig { params(base_url: String, url_variables: T.nilable(T::Hash[Symbol, T.any(String, T::Enum)])).returns(String) }
26
+ def get_url(base_url:, url_variables: nil)
27
+ sd_base_url, sd_options = @sdk_configuration.get_server_details
28
+
29
+ if base_url.nil?
30
+ base_url = sd_base_url
31
+ end
32
+
33
+ if url_variables.nil?
34
+ url_variables = sd_options
35
+ end
36
+
37
+ return Utils.template_url(base_url, url_variables)
38
+ end
39
+
40
+ sig {
41
+ params(
42
+ request: Models::Operations::CommunitiesMembersRequest,
43
+ retries: T.nilable(Utils::RetryConfig),
44
+ timeout_ms: T.nilable(Integer),
45
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
46
+ )
47
+ .returns(Models::Operations::CommunitiesMembersResponse)
48
+ }
49
+ def members(request:, retries: nil, timeout_ms: nil, http_headers: nil)
50
+ # members - Get Community Members
51
+ # Get community members
52
+ url, params = @sdk_configuration.get_server_details
53
+ base_url = Utils.template_url(url, params)
54
+ url = Utils.generate_url(
55
+ Models::Operations::CommunitiesMembersRequest,
56
+ base_url,
57
+ "/twitter/community/{community_id}/members/{target_count}",
58
+ request
59
+ )
60
+ headers = {}
61
+ headers = T.cast(headers, T::Hash[String, String])
62
+ headers["Accept"] = "application/json"
63
+ headers["user-agent"] = @sdk_configuration.user_agent
64
+ retries ||= @sdk_configuration.retry_config
65
+ retries ||= Utils::RetryConfig.new(
66
+ backoff: Utils::BackoffStrategy.new(
67
+ exponent: 1.5,
68
+ initial_interval: 500,
69
+ max_elapsed_time: 3_600_000,
70
+ max_interval: 60_000
71
+ ),
72
+ retry_connection_errors: true,
73
+ strategy: "backoff"
74
+ )
75
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
76
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
77
+
78
+ security = @sdk_configuration.security_source&.call
79
+
80
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
81
+ timeout ||= @sdk_configuration.timeout
82
+
83
+ connection = @sdk_configuration.client.dup
84
+ connection.use(Utils::RetryMiddleware, retry_options)
85
+
86
+ hook_ctx = SDKHooks::HookContext.new(
87
+ config: @sdk_configuration,
88
+ base_url: base_url,
89
+ oauth2_scopes: nil,
90
+ operation_id: "communitiesMembers",
91
+ security_source: @sdk_configuration.security_source
92
+ )
93
+
94
+ error = T.let(nil, T.nilable(StandardError))
95
+ http_response = T.let(nil, T.nilable(Faraday::Response))
96
+
97
+ begin
98
+ http_response = T.must(connection).get(url) do |req|
99
+ req.headers.merge!(headers)
100
+ req.options.timeout = timeout unless timeout.nil?
101
+ Utils.configure_request_security(req, security)
102
+ http_headers&.each do |key, value|
103
+ req.headers[key.to_s] = value
104
+ end
105
+
106
+ @sdk_configuration.hooks.before_request(
107
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
108
+ hook_ctx: hook_ctx
109
+ ),
110
+ request: req
111
+ )
112
+ end
113
+
114
+ rescue StandardError => e
115
+ error = e
116
+ ensure
117
+ if http_response.nil? || Utils.error_status?(http_response.status)
118
+ http_response = @sdk_configuration.hooks.after_error(
119
+ error: error,
120
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
121
+ hook_ctx: hook_ctx
122
+ ),
123
+ response: http_response
124
+ )
125
+ else
126
+ http_response = @sdk_configuration.hooks.after_success(
127
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
128
+ hook_ctx: hook_ctx
129
+ ),
130
+ response: http_response
131
+ )
132
+ end
133
+
134
+ if http_response.nil?
135
+ raise error if !error.nil?
136
+ raise "no response"
137
+ end
138
+ end
139
+
140
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
141
+ if Utils.match_status_code(http_response.status, ["200"])
142
+ if Utils.match_content_type(content_type, "application/json")
143
+ http_response = @sdk_configuration.hooks.after_success(
144
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
145
+ hook_ctx: hook_ctx
146
+ ),
147
+ response: http_response
148
+ )
149
+ response_data = http_response.env.response_body
150
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::SearchUserResponse)
151
+ response = Models::Operations::CommunitiesMembersResponse.new(
152
+ status_code: http_response.status,
153
+ content_type: content_type,
154
+ raw_response: http_response,
155
+ search_user_response: T.unsafe(obj)
156
+ )
157
+
158
+ return response
159
+ else
160
+ raise(
161
+ ::XapiScraper::Models::Errors::APIError.new(
162
+ status_code: http_response.status,
163
+ body: http_response.env.response_body,
164
+ raw_response: http_response
165
+ ),
166
+ "Unknown content type received"
167
+ )
168
+ end
169
+ elsif Utils.match_status_code(http_response.status, ["422"])
170
+ if Utils.match_content_type(content_type, "application/json")
171
+ http_response = @sdk_configuration.hooks.after_success(
172
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
173
+ hook_ctx: hook_ctx
174
+ ),
175
+ response: http_response
176
+ )
177
+ response_data = http_response.env.response_body
178
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
179
+ obj.raw_response = http_response
180
+ raise obj
181
+ else
182
+ raise(
183
+ ::XapiScraper::Models::Errors::APIError.new(
184
+ status_code: http_response.status,
185
+ body: http_response.env.response_body,
186
+ raw_response: http_response
187
+ ),
188
+ "Unknown content type received"
189
+ )
190
+ end
191
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
192
+ raise(
193
+ ::XapiScraper::Models::Errors::APIError.new(
194
+ status_code: http_response.status,
195
+ body: http_response.env.response_body,
196
+ raw_response: http_response
197
+ ),
198
+ "API error occurred"
199
+ )
200
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
201
+ raise(
202
+ ::XapiScraper::Models::Errors::APIError.new(
203
+ status_code: http_response.status,
204
+ body: http_response.env.response_body,
205
+ raw_response: http_response
206
+ ),
207
+ "API error occurred"
208
+ )
209
+ else
210
+ raise(
211
+ ::XapiScraper::Models::Errors::APIError.new(
212
+ status_code: http_response.status,
213
+ body: http_response.env.response_body,
214
+ raw_response: http_response
215
+ ),
216
+ "Unknown status code received"
217
+ )
218
+
219
+ end
220
+ end
221
+
222
+ sig {
223
+ params(
224
+ request: Models::Components::GetCommunityMembersCursorQuery,
225
+ retries: T.nilable(Utils::RetryConfig),
226
+ timeout_ms: T.nilable(Integer),
227
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
228
+ )
229
+ .returns(Models::Operations::CommunitiesMembersPageResponse)
230
+ }
231
+ def members_page(request:, retries: nil, timeout_ms: nil, http_headers: nil)
232
+ # members_page - Get Community Members by Page
233
+ # Retrieve a paginated list of community members using cursor-based pagination. Each page returns up to 20 members. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 members.
234
+ url, params = @sdk_configuration.get_server_details
235
+ base_url = Utils.template_url(url, params)
236
+ url = "#{base_url}/twitter/community/members/page"
237
+ headers = {}
238
+ headers = T.cast(headers, T::Hash[String, String])
239
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
240
+ headers["content-type"] = req_content_type
241
+ raise StandardError, "request body is required" if data.nil? && form.nil?
242
+
243
+ if form && !form.empty?
244
+ body = Utils.encode_form(form)
245
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
246
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
247
+ else
248
+ body = data
249
+ end
250
+
251
+ headers["Accept"] = "application/json"
252
+ headers["user-agent"] = @sdk_configuration.user_agent
253
+ retries ||= @sdk_configuration.retry_config
254
+ retries ||= Utils::RetryConfig.new(
255
+ backoff: Utils::BackoffStrategy.new(
256
+ exponent: 1.5,
257
+ initial_interval: 500,
258
+ max_elapsed_time: 3_600_000,
259
+ max_interval: 60_000
260
+ ),
261
+ retry_connection_errors: true,
262
+ strategy: "backoff"
263
+ )
264
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
265
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
266
+
267
+ security = @sdk_configuration.security_source&.call
268
+
269
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
270
+ timeout ||= @sdk_configuration.timeout
271
+
272
+ connection = @sdk_configuration.client.dup
273
+ connection.use(Utils::RetryMiddleware, retry_options)
274
+
275
+ hook_ctx = SDKHooks::HookContext.new(
276
+ config: @sdk_configuration,
277
+ base_url: base_url,
278
+ oauth2_scopes: nil,
279
+ operation_id: "communitiesMembersPage",
280
+ security_source: @sdk_configuration.security_source
281
+ )
282
+
283
+ error = T.let(nil, T.nilable(StandardError))
284
+ http_response = T.let(nil, T.nilable(Faraday::Response))
285
+
286
+ begin
287
+ http_response = T.must(connection).post(url) do |req|
288
+ req.body = body
289
+ req.headers.merge!(headers)
290
+ req.options.timeout = timeout unless timeout.nil?
291
+ Utils.configure_request_security(req, security)
292
+ http_headers&.each do |key, value|
293
+ req.headers[key.to_s] = value
294
+ end
295
+
296
+ @sdk_configuration.hooks.before_request(
297
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
298
+ hook_ctx: hook_ctx
299
+ ),
300
+ request: req
301
+ )
302
+ end
303
+
304
+ rescue StandardError => e
305
+ error = e
306
+ ensure
307
+ if http_response.nil? || Utils.error_status?(http_response.status)
308
+ http_response = @sdk_configuration.hooks.after_error(
309
+ error: error,
310
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
311
+ hook_ctx: hook_ctx
312
+ ),
313
+ response: http_response
314
+ )
315
+ else
316
+ http_response = @sdk_configuration.hooks.after_success(
317
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
318
+ hook_ctx: hook_ctx
319
+ ),
320
+ response: http_response
321
+ )
322
+ end
323
+
324
+ if http_response.nil?
325
+ raise error if !error.nil?
326
+ raise "no response"
327
+ end
328
+ end
329
+
330
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
331
+ if Utils.match_status_code(http_response.status, ["200"])
332
+ if Utils.match_content_type(content_type, "application/json")
333
+ http_response = @sdk_configuration.hooks.after_success(
334
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
335
+ hook_ctx: hook_ctx
336
+ ),
337
+ response: http_response
338
+ )
339
+ response_data = http_response.env.response_body
340
+ obj = Crystalline.unmarshal_json(
341
+ JSON.parse(response_data),
342
+ Models::Components::GetCommunityMembersCursorResponse
343
+ )
344
+ response = Models::Operations::CommunitiesMembersPageResponse.new(
345
+ status_code: http_response.status,
346
+ content_type: content_type,
347
+ raw_response: http_response,
348
+ get_community_members_cursor_response: T.unsafe(obj)
349
+ )
350
+
351
+ return response
352
+ else
353
+ raise(
354
+ ::XapiScraper::Models::Errors::APIError.new(
355
+ status_code: http_response.status,
356
+ body: http_response.env.response_body,
357
+ raw_response: http_response
358
+ ),
359
+ "Unknown content type received"
360
+ )
361
+ end
362
+ elsif Utils.match_status_code(http_response.status, ["422"])
363
+ if Utils.match_content_type(content_type, "application/json")
364
+ http_response = @sdk_configuration.hooks.after_success(
365
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
366
+ hook_ctx: hook_ctx
367
+ ),
368
+ response: http_response
369
+ )
370
+ response_data = http_response.env.response_body
371
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
372
+ obj.raw_response = http_response
373
+ raise obj
374
+ else
375
+ raise(
376
+ ::XapiScraper::Models::Errors::APIError.new(
377
+ status_code: http_response.status,
378
+ body: http_response.env.response_body,
379
+ raw_response: http_response
380
+ ),
381
+ "Unknown content type received"
382
+ )
383
+ end
384
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
385
+ raise(
386
+ ::XapiScraper::Models::Errors::APIError.new(
387
+ status_code: http_response.status,
388
+ body: http_response.env.response_body,
389
+ raw_response: http_response
390
+ ),
391
+ "API error occurred"
392
+ )
393
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
394
+ raise(
395
+ ::XapiScraper::Models::Errors::APIError.new(
396
+ status_code: http_response.status,
397
+ body: http_response.env.response_body,
398
+ raw_response: http_response
399
+ ),
400
+ "API error occurred"
401
+ )
402
+ else
403
+ raise(
404
+ ::XapiScraper::Models::Errors::APIError.new(
405
+ status_code: http_response.status,
406
+ body: http_response.env.response_body,
407
+ raw_response: http_response
408
+ ),
409
+ "Unknown status code received"
410
+ )
411
+
412
+ end
413
+ end
414
+
415
+ sig {
416
+ params(
417
+ request: Models::Operations::CommunitiesTweetsRequest,
418
+ retries: T.nilable(Utils::RetryConfig),
419
+ timeout_ms: T.nilable(Integer),
420
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
421
+ )
422
+ .returns(Models::Operations::CommunitiesTweetsResponse)
423
+ }
424
+ def tweets(request:, retries: nil, timeout_ms: nil, http_headers: nil)
425
+ # tweets - Get Community Tweets
426
+ # Get community tweets
427
+ url, params = @sdk_configuration.get_server_details
428
+ base_url = Utils.template_url(url, params)
429
+ url = Utils.generate_url(
430
+ Models::Operations::CommunitiesTweetsRequest,
431
+ base_url,
432
+ "/twitter/community/{community_id}/tweets/{tweet_type}/{target_count}",
433
+ request
434
+ )
435
+ headers = {}
436
+ headers = T.cast(headers, T::Hash[String, String])
437
+ headers["Accept"] = "application/json"
438
+ headers["user-agent"] = @sdk_configuration.user_agent
439
+ retries ||= @sdk_configuration.retry_config
440
+ retries ||= Utils::RetryConfig.new(
441
+ backoff: Utils::BackoffStrategy.new(
442
+ exponent: 1.5,
443
+ initial_interval: 500,
444
+ max_elapsed_time: 3_600_000,
445
+ max_interval: 60_000
446
+ ),
447
+ retry_connection_errors: true,
448
+ strategy: "backoff"
449
+ )
450
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
451
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
452
+
453
+ security = @sdk_configuration.security_source&.call
454
+
455
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
456
+ timeout ||= @sdk_configuration.timeout
457
+
458
+ connection = @sdk_configuration.client.dup
459
+ connection.use(Utils::RetryMiddleware, retry_options)
460
+
461
+ hook_ctx = SDKHooks::HookContext.new(
462
+ config: @sdk_configuration,
463
+ base_url: base_url,
464
+ oauth2_scopes: nil,
465
+ operation_id: "communitiesTweets",
466
+ security_source: @sdk_configuration.security_source
467
+ )
468
+
469
+ error = T.let(nil, T.nilable(StandardError))
470
+ http_response = T.let(nil, T.nilable(Faraday::Response))
471
+
472
+ begin
473
+ http_response = T.must(connection).get(url) do |req|
474
+ req.headers.merge!(headers)
475
+ req.options.timeout = timeout unless timeout.nil?
476
+ Utils.configure_request_security(req, security)
477
+ http_headers&.each do |key, value|
478
+ req.headers[key.to_s] = value
479
+ end
480
+
481
+ @sdk_configuration.hooks.before_request(
482
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
483
+ hook_ctx: hook_ctx
484
+ ),
485
+ request: req
486
+ )
487
+ end
488
+
489
+ rescue StandardError => e
490
+ error = e
491
+ ensure
492
+ if http_response.nil? || Utils.error_status?(http_response.status)
493
+ http_response = @sdk_configuration.hooks.after_error(
494
+ error: error,
495
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
496
+ hook_ctx: hook_ctx
497
+ ),
498
+ response: http_response
499
+ )
500
+ else
501
+ http_response = @sdk_configuration.hooks.after_success(
502
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
503
+ hook_ctx: hook_ctx
504
+ ),
505
+ response: http_response
506
+ )
507
+ end
508
+
509
+ if http_response.nil?
510
+ raise error if !error.nil?
511
+ raise "no response"
512
+ end
513
+ end
514
+
515
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
516
+ if Utils.match_status_code(http_response.status, ["200"])
517
+ if Utils.match_content_type(content_type, "application/json")
518
+ http_response = @sdk_configuration.hooks.after_success(
519
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
520
+ hook_ctx: hook_ctx
521
+ ),
522
+ response: http_response
523
+ )
524
+ response_data = http_response.env.response_body
525
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::CommunityTweetsResponse)
526
+ response = Models::Operations::CommunitiesTweetsResponse.new(
527
+ status_code: http_response.status,
528
+ content_type: content_type,
529
+ raw_response: http_response,
530
+ community_tweets_response: T.unsafe(obj)
531
+ )
532
+
533
+ return response
534
+ else
535
+ raise(
536
+ ::XapiScraper::Models::Errors::APIError.new(
537
+ status_code: http_response.status,
538
+ body: http_response.env.response_body,
539
+ raw_response: http_response
540
+ ),
541
+ "Unknown content type received"
542
+ )
543
+ end
544
+ elsif Utils.match_status_code(http_response.status, ["422"])
545
+ if Utils.match_content_type(content_type, "application/json")
546
+ http_response = @sdk_configuration.hooks.after_success(
547
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
548
+ hook_ctx: hook_ctx
549
+ ),
550
+ response: http_response
551
+ )
552
+ response_data = http_response.env.response_body
553
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
554
+ obj.raw_response = http_response
555
+ raise obj
556
+ else
557
+ raise(
558
+ ::XapiScraper::Models::Errors::APIError.new(
559
+ status_code: http_response.status,
560
+ body: http_response.env.response_body,
561
+ raw_response: http_response
562
+ ),
563
+ "Unknown content type received"
564
+ )
565
+ end
566
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
567
+ raise(
568
+ ::XapiScraper::Models::Errors::APIError.new(
569
+ status_code: http_response.status,
570
+ body: http_response.env.response_body,
571
+ raw_response: http_response
572
+ ),
573
+ "API error occurred"
574
+ )
575
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
576
+ raise(
577
+ ::XapiScraper::Models::Errors::APIError.new(
578
+ status_code: http_response.status,
579
+ body: http_response.env.response_body,
580
+ raw_response: http_response
581
+ ),
582
+ "API error occurred"
583
+ )
584
+ else
585
+ raise(
586
+ ::XapiScraper::Models::Errors::APIError.new(
587
+ status_code: http_response.status,
588
+ body: http_response.env.response_body,
589
+ raw_response: http_response
590
+ ),
591
+ "Unknown status code received"
592
+ )
593
+
594
+ end
595
+ end
596
+
597
+ sig {
598
+ params(
599
+ request: Models::Components::GetCommunityTweetsCursorQuery,
600
+ retries: T.nilable(Utils::RetryConfig),
601
+ timeout_ms: T.nilable(Integer),
602
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
603
+ )
604
+ .returns(Models::Operations::CommunitiesTweetsPageResponse)
605
+ }
606
+ def tweets_page(request:, retries: nil, timeout_ms: nil, http_headers: nil)
607
+ # tweets_page - Get Community Tweets by Page
608
+ # Retrieve a paginated list of community tweets using cursor-based pagination. Each page returns up to 20 tweets. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 tweets.
609
+ url, params = @sdk_configuration.get_server_details
610
+ base_url = Utils.template_url(url, params)
611
+ url = "#{base_url}/twitter/community/tweets/page"
612
+ headers = {}
613
+ headers = T.cast(headers, T::Hash[String, String])
614
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
615
+ headers["content-type"] = req_content_type
616
+ raise StandardError, "request body is required" if data.nil? && form.nil?
617
+
618
+ if form && !form.empty?
619
+ body = Utils.encode_form(form)
620
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
621
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
622
+ else
623
+ body = data
624
+ end
625
+
626
+ headers["Accept"] = "application/json"
627
+ headers["user-agent"] = @sdk_configuration.user_agent
628
+ retries ||= @sdk_configuration.retry_config
629
+ retries ||= Utils::RetryConfig.new(
630
+ backoff: Utils::BackoffStrategy.new(
631
+ exponent: 1.5,
632
+ initial_interval: 500,
633
+ max_elapsed_time: 3_600_000,
634
+ max_interval: 60_000
635
+ ),
636
+ retry_connection_errors: true,
637
+ strategy: "backoff"
638
+ )
639
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
640
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
641
+
642
+ security = @sdk_configuration.security_source&.call
643
+
644
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
645
+ timeout ||= @sdk_configuration.timeout
646
+
647
+ connection = @sdk_configuration.client.dup
648
+ connection.use(Utils::RetryMiddleware, retry_options)
649
+
650
+ hook_ctx = SDKHooks::HookContext.new(
651
+ config: @sdk_configuration,
652
+ base_url: base_url,
653
+ oauth2_scopes: nil,
654
+ operation_id: "communitiesTweetsPage",
655
+ security_source: @sdk_configuration.security_source
656
+ )
657
+
658
+ error = T.let(nil, T.nilable(StandardError))
659
+ http_response = T.let(nil, T.nilable(Faraday::Response))
660
+
661
+ begin
662
+ http_response = T.must(connection).post(url) do |req|
663
+ req.body = body
664
+ req.headers.merge!(headers)
665
+ req.options.timeout = timeout unless timeout.nil?
666
+ Utils.configure_request_security(req, security)
667
+ http_headers&.each do |key, value|
668
+ req.headers[key.to_s] = value
669
+ end
670
+
671
+ @sdk_configuration.hooks.before_request(
672
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
673
+ hook_ctx: hook_ctx
674
+ ),
675
+ request: req
676
+ )
677
+ end
678
+
679
+ rescue StandardError => e
680
+ error = e
681
+ ensure
682
+ if http_response.nil? || Utils.error_status?(http_response.status)
683
+ http_response = @sdk_configuration.hooks.after_error(
684
+ error: error,
685
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
686
+ hook_ctx: hook_ctx
687
+ ),
688
+ response: http_response
689
+ )
690
+ else
691
+ http_response = @sdk_configuration.hooks.after_success(
692
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
693
+ hook_ctx: hook_ctx
694
+ ),
695
+ response: http_response
696
+ )
697
+ end
698
+
699
+ if http_response.nil?
700
+ raise error if !error.nil?
701
+ raise "no response"
702
+ end
703
+ end
704
+
705
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
706
+ if Utils.match_status_code(http_response.status, ["200"])
707
+ if Utils.match_content_type(content_type, "application/json")
708
+ http_response = @sdk_configuration.hooks.after_success(
709
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
710
+ hook_ctx: hook_ctx
711
+ ),
712
+ response: http_response
713
+ )
714
+ response_data = http_response.env.response_body
715
+ obj = Crystalline.unmarshal_json(
716
+ JSON.parse(response_data),
717
+ Models::Components::GetCommunityTweetsCursorResponse
718
+ )
719
+ response = Models::Operations::CommunitiesTweetsPageResponse.new(
720
+ status_code: http_response.status,
721
+ content_type: content_type,
722
+ raw_response: http_response,
723
+ get_community_tweets_cursor_response: T.unsafe(obj)
724
+ )
725
+
726
+ return response
727
+ else
728
+ raise(
729
+ ::XapiScraper::Models::Errors::APIError.new(
730
+ status_code: http_response.status,
731
+ body: http_response.env.response_body,
732
+ raw_response: http_response
733
+ ),
734
+ "Unknown content type received"
735
+ )
736
+ end
737
+ elsif Utils.match_status_code(http_response.status, ["422"])
738
+ if Utils.match_content_type(content_type, "application/json")
739
+ http_response = @sdk_configuration.hooks.after_success(
740
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
741
+ hook_ctx: hook_ctx
742
+ ),
743
+ response: http_response
744
+ )
745
+ response_data = http_response.env.response_body
746
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
747
+ obj.raw_response = http_response
748
+ raise obj
749
+ else
750
+ raise(
751
+ ::XapiScraper::Models::Errors::APIError.new(
752
+ status_code: http_response.status,
753
+ body: http_response.env.response_body,
754
+ raw_response: http_response
755
+ ),
756
+ "Unknown content type received"
757
+ )
758
+ end
759
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
760
+ raise(
761
+ ::XapiScraper::Models::Errors::APIError.new(
762
+ status_code: http_response.status,
763
+ body: http_response.env.response_body,
764
+ raw_response: http_response
765
+ ),
766
+ "API error occurred"
767
+ )
768
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
769
+ raise(
770
+ ::XapiScraper::Models::Errors::APIError.new(
771
+ status_code: http_response.status,
772
+ body: http_response.env.response_body,
773
+ raw_response: http_response
774
+ ),
775
+ "API error occurred"
776
+ )
777
+ else
778
+ raise(
779
+ ::XapiScraper::Models::Errors::APIError.new(
780
+ status_code: http_response.status,
781
+ body: http_response.env.response_body,
782
+ raw_response: http_response
783
+ ),
784
+ "Unknown status code received"
785
+ )
786
+
787
+ end
788
+ end
789
+
790
+ sig {
791
+ params(
792
+ request: Models::Components::SearchCommunityQuery,
793
+ retries: T.nilable(Utils::RetryConfig),
794
+ timeout_ms: T.nilable(Integer),
795
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
796
+ )
797
+ .returns(Models::Operations::CommunitiesSearchResponse)
798
+ }
799
+ def search(request:, retries: nil, timeout_ms: nil, http_headers: nil)
800
+ # search - Search Community
801
+ # Search community
802
+ url, params = @sdk_configuration.get_server_details
803
+ base_url = Utils.template_url(url, params)
804
+ url = "#{base_url}/twitter/community/search"
805
+ headers = {}
806
+ headers = T.cast(headers, T::Hash[String, String])
807
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
808
+ headers["content-type"] = req_content_type
809
+ raise StandardError, "request body is required" if data.nil? && form.nil?
810
+
811
+ if form && !form.empty?
812
+ body = Utils.encode_form(form)
813
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
814
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
815
+ else
816
+ body = data
817
+ end
818
+
819
+ headers["Accept"] = "application/json"
820
+ headers["user-agent"] = @sdk_configuration.user_agent
821
+ retries ||= @sdk_configuration.retry_config
822
+ retries ||= Utils::RetryConfig.new(
823
+ backoff: Utils::BackoffStrategy.new(
824
+ exponent: 1.5,
825
+ initial_interval: 500,
826
+ max_elapsed_time: 3_600_000,
827
+ max_interval: 60_000
828
+ ),
829
+ retry_connection_errors: true,
830
+ strategy: "backoff"
831
+ )
832
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
833
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
834
+
835
+ security = @sdk_configuration.security_source&.call
836
+
837
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
838
+ timeout ||= @sdk_configuration.timeout
839
+
840
+ connection = @sdk_configuration.client.dup
841
+ connection.use(Utils::RetryMiddleware, retry_options)
842
+
843
+ hook_ctx = SDKHooks::HookContext.new(
844
+ config: @sdk_configuration,
845
+ base_url: base_url,
846
+ oauth2_scopes: nil,
847
+ operation_id: "communitiesSearch",
848
+ security_source: @sdk_configuration.security_source
849
+ )
850
+
851
+ error = T.let(nil, T.nilable(StandardError))
852
+ http_response = T.let(nil, T.nilable(Faraday::Response))
853
+
854
+ begin
855
+ http_response = T.must(connection).post(url) do |req|
856
+ req.body = body
857
+ req.headers.merge!(headers)
858
+ req.options.timeout = timeout unless timeout.nil?
859
+ Utils.configure_request_security(req, security)
860
+ http_headers&.each do |key, value|
861
+ req.headers[key.to_s] = value
862
+ end
863
+
864
+ @sdk_configuration.hooks.before_request(
865
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
866
+ hook_ctx: hook_ctx
867
+ ),
868
+ request: req
869
+ )
870
+ end
871
+
872
+ rescue StandardError => e
873
+ error = e
874
+ ensure
875
+ if http_response.nil? || Utils.error_status?(http_response.status)
876
+ http_response = @sdk_configuration.hooks.after_error(
877
+ error: error,
878
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
879
+ hook_ctx: hook_ctx
880
+ ),
881
+ response: http_response
882
+ )
883
+ else
884
+ http_response = @sdk_configuration.hooks.after_success(
885
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
886
+ hook_ctx: hook_ctx
887
+ ),
888
+ response: http_response
889
+ )
890
+ end
891
+
892
+ if http_response.nil?
893
+ raise error if !error.nil?
894
+ raise "no response"
895
+ end
896
+ end
897
+
898
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
899
+ if Utils.match_status_code(http_response.status, ["200"])
900
+ if Utils.match_content_type(content_type, "application/json")
901
+ http_response = @sdk_configuration.hooks.after_success(
902
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
903
+ hook_ctx: hook_ctx
904
+ ),
905
+ response: http_response
906
+ )
907
+ response_data = http_response.env.response_body
908
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::SearchCommunityResponse)
909
+ response = Models::Operations::CommunitiesSearchResponse.new(
910
+ status_code: http_response.status,
911
+ content_type: content_type,
912
+ raw_response: http_response,
913
+ search_community_response: T.unsafe(obj)
914
+ )
915
+
916
+ return response
917
+ else
918
+ raise(
919
+ ::XapiScraper::Models::Errors::APIError.new(
920
+ status_code: http_response.status,
921
+ body: http_response.env.response_body,
922
+ raw_response: http_response
923
+ ),
924
+ "Unknown content type received"
925
+ )
926
+ end
927
+ elsif Utils.match_status_code(http_response.status, ["422"])
928
+ if Utils.match_content_type(content_type, "application/json")
929
+ http_response = @sdk_configuration.hooks.after_success(
930
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
931
+ hook_ctx: hook_ctx
932
+ ),
933
+ response: http_response
934
+ )
935
+ response_data = http_response.env.response_body
936
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
937
+ obj.raw_response = http_response
938
+ raise obj
939
+ else
940
+ raise(
941
+ ::XapiScraper::Models::Errors::APIError.new(
942
+ status_code: http_response.status,
943
+ body: http_response.env.response_body,
944
+ raw_response: http_response
945
+ ),
946
+ "Unknown content type received"
947
+ )
948
+ end
949
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
950
+ raise(
951
+ ::XapiScraper::Models::Errors::APIError.new(
952
+ status_code: http_response.status,
953
+ body: http_response.env.response_body,
954
+ raw_response: http_response
955
+ ),
956
+ "API error occurred"
957
+ )
958
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
959
+ raise(
960
+ ::XapiScraper::Models::Errors::APIError.new(
961
+ status_code: http_response.status,
962
+ body: http_response.env.response_body,
963
+ raw_response: http_response
964
+ ),
965
+ "API error occurred"
966
+ )
967
+ else
968
+ raise(
969
+ ::XapiScraper::Models::Errors::APIError.new(
970
+ status_code: http_response.status,
971
+ body: http_response.env.response_body,
972
+ raw_response: http_response
973
+ ),
974
+ "Unknown status code received"
975
+ )
976
+
977
+ end
978
+ end
979
+
980
+ sig {
981
+ params(
982
+ request: Models::Operations::CommunitiesGetRequest,
983
+ retries: T.nilable(Utils::RetryConfig),
984
+ timeout_ms: T.nilable(Integer),
985
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
986
+ )
987
+ .returns(Models::Operations::CommunitiesGetResponse)
988
+ }
989
+ def get(request:, retries: nil, timeout_ms: nil, http_headers: nil)
990
+ # get - Get Community
991
+ # Get community
992
+ url, params = @sdk_configuration.get_server_details
993
+ base_url = Utils.template_url(url, params)
994
+ url = Utils.generate_url(
995
+ Models::Operations::CommunitiesGetRequest,
996
+ base_url,
997
+ "/twitter/community/{community_id}",
998
+ request
999
+ )
1000
+ headers = {}
1001
+ headers = T.cast(headers, T::Hash[String, String])
1002
+ headers["Accept"] = "application/json"
1003
+ headers["user-agent"] = @sdk_configuration.user_agent
1004
+ retries ||= @sdk_configuration.retry_config
1005
+ retries ||= Utils::RetryConfig.new(
1006
+ backoff: Utils::BackoffStrategy.new(
1007
+ exponent: 1.5,
1008
+ initial_interval: 500,
1009
+ max_elapsed_time: 3_600_000,
1010
+ max_interval: 60_000
1011
+ ),
1012
+ retry_connection_errors: true,
1013
+ strategy: "backoff"
1014
+ )
1015
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1016
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
1017
+
1018
+ security = @sdk_configuration.security_source&.call
1019
+
1020
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1021
+ timeout ||= @sdk_configuration.timeout
1022
+
1023
+ connection = @sdk_configuration.client.dup
1024
+ connection.use(Utils::RetryMiddleware, retry_options)
1025
+
1026
+ hook_ctx = SDKHooks::HookContext.new(
1027
+ config: @sdk_configuration,
1028
+ base_url: base_url,
1029
+ oauth2_scopes: nil,
1030
+ operation_id: "communitiesGet",
1031
+ security_source: @sdk_configuration.security_source
1032
+ )
1033
+
1034
+ error = T.let(nil, T.nilable(StandardError))
1035
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1036
+
1037
+ begin
1038
+ http_response = T.must(connection).get(url) do |req|
1039
+ req.headers.merge!(headers)
1040
+ req.options.timeout = timeout unless timeout.nil?
1041
+ Utils.configure_request_security(req, security)
1042
+ http_headers&.each do |key, value|
1043
+ req.headers[key.to_s] = value
1044
+ end
1045
+
1046
+ @sdk_configuration.hooks.before_request(
1047
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1048
+ hook_ctx: hook_ctx
1049
+ ),
1050
+ request: req
1051
+ )
1052
+ end
1053
+
1054
+ rescue StandardError => e
1055
+ error = e
1056
+ ensure
1057
+ if http_response.nil? || Utils.error_status?(http_response.status)
1058
+ http_response = @sdk_configuration.hooks.after_error(
1059
+ error: error,
1060
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1061
+ hook_ctx: hook_ctx
1062
+ ),
1063
+ response: http_response
1064
+ )
1065
+ else
1066
+ http_response = @sdk_configuration.hooks.after_success(
1067
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1068
+ hook_ctx: hook_ctx
1069
+ ),
1070
+ response: http_response
1071
+ )
1072
+ end
1073
+
1074
+ if http_response.nil?
1075
+ raise error if !error.nil?
1076
+ raise "no response"
1077
+ end
1078
+ end
1079
+
1080
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1081
+ if Utils.match_status_code(http_response.status, ["200"])
1082
+ if Utils.match_content_type(content_type, "application/json")
1083
+ http_response = @sdk_configuration.hooks.after_success(
1084
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1085
+ hook_ctx: hook_ctx
1086
+ ),
1087
+ response: http_response
1088
+ )
1089
+ response_data = http_response.env.response_body
1090
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::GetCommunityResponse)
1091
+ response = Models::Operations::CommunitiesGetResponse.new(
1092
+ status_code: http_response.status,
1093
+ content_type: content_type,
1094
+ raw_response: http_response,
1095
+ get_community_response: T.unsafe(obj)
1096
+ )
1097
+
1098
+ return response
1099
+ else
1100
+ raise(
1101
+ ::XapiScraper::Models::Errors::APIError.new(
1102
+ status_code: http_response.status,
1103
+ body: http_response.env.response_body,
1104
+ raw_response: http_response
1105
+ ),
1106
+ "Unknown content type received"
1107
+ )
1108
+ end
1109
+ elsif Utils.match_status_code(http_response.status, ["422"])
1110
+ if Utils.match_content_type(content_type, "application/json")
1111
+ http_response = @sdk_configuration.hooks.after_success(
1112
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1113
+ hook_ctx: hook_ctx
1114
+ ),
1115
+ response: http_response
1116
+ )
1117
+ response_data = http_response.env.response_body
1118
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
1119
+ obj.raw_response = http_response
1120
+ raise obj
1121
+ else
1122
+ raise(
1123
+ ::XapiScraper::Models::Errors::APIError.new(
1124
+ status_code: http_response.status,
1125
+ body: http_response.env.response_body,
1126
+ raw_response: http_response
1127
+ ),
1128
+ "Unknown content type received"
1129
+ )
1130
+ end
1131
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1132
+ raise(
1133
+ ::XapiScraper::Models::Errors::APIError.new(
1134
+ status_code: http_response.status,
1135
+ body: http_response.env.response_body,
1136
+ raw_response: http_response
1137
+ ),
1138
+ "API error occurred"
1139
+ )
1140
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1141
+ raise(
1142
+ ::XapiScraper::Models::Errors::APIError.new(
1143
+ status_code: http_response.status,
1144
+ body: http_response.env.response_body,
1145
+ raw_response: http_response
1146
+ ),
1147
+ "API error occurred"
1148
+ )
1149
+ else
1150
+ raise(
1151
+ ::XapiScraper::Models::Errors::APIError.new(
1152
+ status_code: http_response.status,
1153
+ body: http_response.env.response_body,
1154
+ raw_response: http_response
1155
+ ),
1156
+ "Unknown status code received"
1157
+ )
1158
+
1159
+ end
1160
+ end
1161
+
1162
+ sig {
1163
+ params(
1164
+ request: Models::Components::SearchCommunityTweetsQuery,
1165
+ retries: T.nilable(Utils::RetryConfig),
1166
+ timeout_ms: T.nilable(Integer),
1167
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1168
+ )
1169
+ .returns(Models::Operations::CommunitiesSearchTweetsResponse)
1170
+ }
1171
+ def search_tweets(request:, retries: nil, timeout_ms: nil, http_headers: nil)
1172
+ # search_tweets - Search Community Tweets
1173
+ # Search community tweets
1174
+ url, params = @sdk_configuration.get_server_details
1175
+ base_url = Utils.template_url(url, params)
1176
+ url = "#{base_url}/twitter/community/search-tweets"
1177
+ headers = {}
1178
+ headers = T.cast(headers, T::Hash[String, String])
1179
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
1180
+ headers["content-type"] = req_content_type
1181
+ raise StandardError, "request body is required" if data.nil? && form.nil?
1182
+
1183
+ if form && !form.empty?
1184
+ body = Utils.encode_form(form)
1185
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
1186
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1187
+ else
1188
+ body = data
1189
+ end
1190
+
1191
+ headers["Accept"] = "application/json"
1192
+ headers["user-agent"] = @sdk_configuration.user_agent
1193
+ retries ||= @sdk_configuration.retry_config
1194
+ retries ||= Utils::RetryConfig.new(
1195
+ backoff: Utils::BackoffStrategy.new(
1196
+ exponent: 1.5,
1197
+ initial_interval: 500,
1198
+ max_elapsed_time: 3_600_000,
1199
+ max_interval: 60_000
1200
+ ),
1201
+ retry_connection_errors: true,
1202
+ strategy: "backoff"
1203
+ )
1204
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1205
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
1206
+
1207
+ security = @sdk_configuration.security_source&.call
1208
+
1209
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1210
+ timeout ||= @sdk_configuration.timeout
1211
+
1212
+ connection = @sdk_configuration.client.dup
1213
+ connection.use(Utils::RetryMiddleware, retry_options)
1214
+
1215
+ hook_ctx = SDKHooks::HookContext.new(
1216
+ config: @sdk_configuration,
1217
+ base_url: base_url,
1218
+ oauth2_scopes: nil,
1219
+ operation_id: "communitiesSearchTweets",
1220
+ security_source: @sdk_configuration.security_source
1221
+ )
1222
+
1223
+ error = T.let(nil, T.nilable(StandardError))
1224
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1225
+
1226
+ begin
1227
+ http_response = T.must(connection).post(url) do |req|
1228
+ req.body = body
1229
+ req.headers.merge!(headers)
1230
+ req.options.timeout = timeout unless timeout.nil?
1231
+ Utils.configure_request_security(req, security)
1232
+ http_headers&.each do |key, value|
1233
+ req.headers[key.to_s] = value
1234
+ end
1235
+
1236
+ @sdk_configuration.hooks.before_request(
1237
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1238
+ hook_ctx: hook_ctx
1239
+ ),
1240
+ request: req
1241
+ )
1242
+ end
1243
+
1244
+ rescue StandardError => e
1245
+ error = e
1246
+ ensure
1247
+ if http_response.nil? || Utils.error_status?(http_response.status)
1248
+ http_response = @sdk_configuration.hooks.after_error(
1249
+ error: error,
1250
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1251
+ hook_ctx: hook_ctx
1252
+ ),
1253
+ response: http_response
1254
+ )
1255
+ else
1256
+ http_response = @sdk_configuration.hooks.after_success(
1257
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1258
+ hook_ctx: hook_ctx
1259
+ ),
1260
+ response: http_response
1261
+ )
1262
+ end
1263
+
1264
+ if http_response.nil?
1265
+ raise error if !error.nil?
1266
+ raise "no response"
1267
+ end
1268
+ end
1269
+
1270
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1271
+ if Utils.match_status_code(http_response.status, ["200"])
1272
+ if Utils.match_content_type(content_type, "application/json")
1273
+ http_response = @sdk_configuration.hooks.after_success(
1274
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1275
+ hook_ctx: hook_ctx
1276
+ ),
1277
+ response: http_response
1278
+ )
1279
+ response_data = http_response.env.response_body
1280
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::CommunityTweetsResponse)
1281
+ response = Models::Operations::CommunitiesSearchTweetsResponse.new(
1282
+ status_code: http_response.status,
1283
+ content_type: content_type,
1284
+ raw_response: http_response,
1285
+ community_tweets_response: T.unsafe(obj)
1286
+ )
1287
+
1288
+ return response
1289
+ else
1290
+ raise(
1291
+ ::XapiScraper::Models::Errors::APIError.new(
1292
+ status_code: http_response.status,
1293
+ body: http_response.env.response_body,
1294
+ raw_response: http_response
1295
+ ),
1296
+ "Unknown content type received"
1297
+ )
1298
+ end
1299
+ elsif Utils.match_status_code(http_response.status, ["422"])
1300
+ if Utils.match_content_type(content_type, "application/json")
1301
+ http_response = @sdk_configuration.hooks.after_success(
1302
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1303
+ hook_ctx: hook_ctx
1304
+ ),
1305
+ response: http_response
1306
+ )
1307
+ response_data = http_response.env.response_body
1308
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
1309
+ obj.raw_response = http_response
1310
+ raise obj
1311
+ else
1312
+ raise(
1313
+ ::XapiScraper::Models::Errors::APIError.new(
1314
+ status_code: http_response.status,
1315
+ body: http_response.env.response_body,
1316
+ raw_response: http_response
1317
+ ),
1318
+ "Unknown content type received"
1319
+ )
1320
+ end
1321
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1322
+ raise(
1323
+ ::XapiScraper::Models::Errors::APIError.new(
1324
+ status_code: http_response.status,
1325
+ body: http_response.env.response_body,
1326
+ raw_response: http_response
1327
+ ),
1328
+ "API error occurred"
1329
+ )
1330
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1331
+ raise(
1332
+ ::XapiScraper::Models::Errors::APIError.new(
1333
+ status_code: http_response.status,
1334
+ body: http_response.env.response_body,
1335
+ raw_response: http_response
1336
+ ),
1337
+ "API error occurred"
1338
+ )
1339
+ else
1340
+ raise(
1341
+ ::XapiScraper::Models::Errors::APIError.new(
1342
+ status_code: http_response.status,
1343
+ body: http_response.env.response_body,
1344
+ raw_response: http_response
1345
+ ),
1346
+ "Unknown status code received"
1347
+ )
1348
+
1349
+ end
1350
+ end
1351
+ end
1352
+ end