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,1748 @@
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 Users
18
+ extend T::Sig
19
+ attr_accessor :following, :followers
20
+
21
+ sig { params(sdk_config: SDKConfiguration).void }
22
+ def initialize(sdk_config)
23
+ @sdk_configuration = sdk_config
24
+ init_sdks
25
+ end
26
+
27
+ sig { void }
28
+ def init_sdks
29
+ @following = ::XapiScraper::Following.new(@sdk_configuration)
30
+ @followers = ::XapiScraper::Followers.new(@sdk_configuration)
31
+ end
32
+
33
+ sig { params(base_url: String, url_variables: T.nilable(T::Hash[Symbol, T.any(String, T::Enum)])).returns(String) }
34
+ def get_url(base_url:, url_variables: nil)
35
+ sd_base_url, sd_options = @sdk_configuration.get_server_details
36
+
37
+ if base_url.nil?
38
+ base_url = sd_base_url
39
+ end
40
+
41
+ if url_variables.nil?
42
+ url_variables = sd_options
43
+ end
44
+
45
+ return Utils.template_url(base_url, url_variables)
46
+ end
47
+
48
+ sig {
49
+ params(
50
+ request: T::Array[::String],
51
+ retries: T.nilable(Utils::RetryConfig),
52
+ timeout_ms: T.nilable(Integer),
53
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
54
+ )
55
+ .returns(Models::Operations::UsersGetByUsernamesResponse)
56
+ }
57
+ def get_by_usernames(request:, retries: nil, timeout_ms: nil, http_headers: nil)
58
+ # get_by_usernames - Get Multiple Users by Usernames
59
+ # Retrieve detailed profile information for multiple Twitter users by their usernames or profile URLs, $0.10/1000 users. The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.
60
+ url, params = @sdk_configuration.get_server_details
61
+ base_url = Utils.template_url(url, params)
62
+ url = "#{base_url}/twitter/users"
63
+ headers = {}
64
+ headers = T.cast(headers, T::Hash[String, String])
65
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
66
+ headers["content-type"] = req_content_type
67
+ raise StandardError, "request body is required" if data.nil? && form.nil?
68
+
69
+ if form && !form.empty?
70
+ body = Utils.encode_form(form)
71
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
72
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
73
+ else
74
+ body = data
75
+ end
76
+
77
+ headers["Accept"] = "application/json"
78
+ headers["user-agent"] = @sdk_configuration.user_agent
79
+ retries ||= @sdk_configuration.retry_config
80
+ retries ||= Utils::RetryConfig.new(
81
+ backoff: Utils::BackoffStrategy.new(
82
+ exponent: 1.5,
83
+ initial_interval: 500,
84
+ max_elapsed_time: 3_600_000,
85
+ max_interval: 60_000
86
+ ),
87
+ retry_connection_errors: true,
88
+ strategy: "backoff"
89
+ )
90
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
91
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
92
+
93
+ security = @sdk_configuration.security_source&.call
94
+
95
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
96
+ timeout ||= @sdk_configuration.timeout
97
+
98
+ connection = @sdk_configuration.client.dup
99
+ connection.use(Utils::RetryMiddleware, retry_options)
100
+
101
+ hook_ctx = SDKHooks::HookContext.new(
102
+ config: @sdk_configuration,
103
+ base_url: base_url,
104
+ oauth2_scopes: nil,
105
+ operation_id: "usersGetByUsernames",
106
+ security_source: @sdk_configuration.security_source
107
+ )
108
+
109
+ error = T.let(nil, T.nilable(StandardError))
110
+ http_response = T.let(nil, T.nilable(Faraday::Response))
111
+
112
+ begin
113
+ http_response = T.must(connection).post(url) do |req|
114
+ req.body = body
115
+ req.headers.merge!(headers)
116
+ req.options.timeout = timeout unless timeout.nil?
117
+ Utils.configure_request_security(req, security)
118
+ http_headers&.each do |key, value|
119
+ req.headers[key.to_s] = value
120
+ end
121
+
122
+ @sdk_configuration.hooks.before_request(
123
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
124
+ hook_ctx: hook_ctx
125
+ ),
126
+ request: req
127
+ )
128
+ end
129
+
130
+ rescue StandardError => e
131
+ error = e
132
+ ensure
133
+ if http_response.nil? || Utils.error_status?(http_response.status)
134
+ http_response = @sdk_configuration.hooks.after_error(
135
+ error: error,
136
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
137
+ hook_ctx: hook_ctx
138
+ ),
139
+ response: http_response
140
+ )
141
+ else
142
+ http_response = @sdk_configuration.hooks.after_success(
143
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
144
+ hook_ctx: hook_ctx
145
+ ),
146
+ response: http_response
147
+ )
148
+ end
149
+
150
+ if http_response.nil?
151
+ raise error if !error.nil?
152
+ raise "no response"
153
+ end
154
+ end
155
+
156
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
157
+ if Utils.match_status_code(http_response.status, ["200"])
158
+ if Utils.match_content_type(content_type, "application/json")
159
+ http_response = @sdk_configuration.hooks.after_success(
160
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
161
+ hook_ctx: hook_ctx
162
+ ),
163
+ response: http_response
164
+ )
165
+ response_data = http_response.env.response_body
166
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), ::Object)
167
+ response = Models::Operations::UsersGetByUsernamesResponse.new(
168
+ status_code: http_response.status,
169
+ content_type: content_type,
170
+ raw_response: http_response,
171
+ any: T.unsafe(obj)
172
+ )
173
+
174
+ return response
175
+ else
176
+ raise(
177
+ ::XapiScraper::Models::Errors::APIError.new(
178
+ status_code: http_response.status,
179
+ body: http_response.env.response_body,
180
+ raw_response: http_response
181
+ ),
182
+ "Unknown content type received"
183
+ )
184
+ end
185
+ elsif Utils.match_status_code(http_response.status, ["422"])
186
+ if Utils.match_content_type(content_type, "application/json")
187
+ http_response = @sdk_configuration.hooks.after_success(
188
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
189
+ hook_ctx: hook_ctx
190
+ ),
191
+ response: http_response
192
+ )
193
+ response_data = http_response.env.response_body
194
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
195
+ obj.raw_response = http_response
196
+ raise obj
197
+ else
198
+ raise(
199
+ ::XapiScraper::Models::Errors::APIError.new(
200
+ status_code: http_response.status,
201
+ body: http_response.env.response_body,
202
+ raw_response: http_response
203
+ ),
204
+ "Unknown content type received"
205
+ )
206
+ end
207
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
208
+ raise(
209
+ ::XapiScraper::Models::Errors::APIError.new(
210
+ status_code: http_response.status,
211
+ body: http_response.env.response_body,
212
+ raw_response: http_response
213
+ ),
214
+ "API error occurred"
215
+ )
216
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
217
+ raise(
218
+ ::XapiScraper::Models::Errors::APIError.new(
219
+ status_code: http_response.status,
220
+ body: http_response.env.response_body,
221
+ raw_response: http_response
222
+ ),
223
+ "API error occurred"
224
+ )
225
+ else
226
+ raise(
227
+ ::XapiScraper::Models::Errors::APIError.new(
228
+ status_code: http_response.status,
229
+ body: http_response.env.response_body,
230
+ raw_response: http_response
231
+ ),
232
+ "Unknown status code received"
233
+ )
234
+
235
+ end
236
+ end
237
+
238
+ sig {
239
+ params(
240
+ request: T::Array[::String],
241
+ retries: T.nilable(Utils::RetryConfig),
242
+ timeout_ms: T.nilable(Integer),
243
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
244
+ )
245
+ .returns(Models::Operations::UsersGetByIdsResponse)
246
+ }
247
+ def get_by_ids(request:, retries: nil, timeout_ms: nil, http_headers: nil)
248
+ # get_by_ids - Users Details by ID
249
+ # Users Details by ID. The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.
250
+ url, params = @sdk_configuration.get_server_details
251
+ base_url = Utils.template_url(url, params)
252
+ url = "#{base_url}/twitter/users/by_ids"
253
+ headers = {}
254
+ headers = T.cast(headers, T::Hash[String, String])
255
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
256
+ headers["content-type"] = req_content_type
257
+ raise StandardError, "request body is required" if data.nil? && form.nil?
258
+
259
+ if form && !form.empty?
260
+ body = Utils.encode_form(form)
261
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
262
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
263
+ else
264
+ body = data
265
+ end
266
+
267
+ headers["Accept"] = "application/json"
268
+ headers["user-agent"] = @sdk_configuration.user_agent
269
+ retries ||= @sdk_configuration.retry_config
270
+ retries ||= Utils::RetryConfig.new(
271
+ backoff: Utils::BackoffStrategy.new(
272
+ exponent: 1.5,
273
+ initial_interval: 500,
274
+ max_elapsed_time: 3_600_000,
275
+ max_interval: 60_000
276
+ ),
277
+ retry_connection_errors: true,
278
+ strategy: "backoff"
279
+ )
280
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
281
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
282
+
283
+ security = @sdk_configuration.security_source&.call
284
+
285
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
286
+ timeout ||= @sdk_configuration.timeout
287
+
288
+ connection = @sdk_configuration.client.dup
289
+ connection.use(Utils::RetryMiddleware, retry_options)
290
+
291
+ hook_ctx = SDKHooks::HookContext.new(
292
+ config: @sdk_configuration,
293
+ base_url: base_url,
294
+ oauth2_scopes: nil,
295
+ operation_id: "usersGetByIds",
296
+ security_source: @sdk_configuration.security_source
297
+ )
298
+
299
+ error = T.let(nil, T.nilable(StandardError))
300
+ http_response = T.let(nil, T.nilable(Faraday::Response))
301
+
302
+ begin
303
+ http_response = T.must(connection).post(url) do |req|
304
+ req.body = body
305
+ req.headers.merge!(headers)
306
+ req.options.timeout = timeout unless timeout.nil?
307
+ Utils.configure_request_security(req, security)
308
+ http_headers&.each do |key, value|
309
+ req.headers[key.to_s] = value
310
+ end
311
+
312
+ @sdk_configuration.hooks.before_request(
313
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
314
+ hook_ctx: hook_ctx
315
+ ),
316
+ request: req
317
+ )
318
+ end
319
+
320
+ rescue StandardError => e
321
+ error = e
322
+ ensure
323
+ if http_response.nil? || Utils.error_status?(http_response.status)
324
+ http_response = @sdk_configuration.hooks.after_error(
325
+ error: error,
326
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
327
+ hook_ctx: hook_ctx
328
+ ),
329
+ response: http_response
330
+ )
331
+ else
332
+ http_response = @sdk_configuration.hooks.after_success(
333
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
334
+ hook_ctx: hook_ctx
335
+ ),
336
+ response: http_response
337
+ )
338
+ end
339
+
340
+ if http_response.nil?
341
+ raise error if !error.nil?
342
+ raise "no response"
343
+ end
344
+ end
345
+
346
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
347
+ if Utils.match_status_code(http_response.status, ["200"])
348
+ if Utils.match_content_type(content_type, "application/json")
349
+ http_response = @sdk_configuration.hooks.after_success(
350
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
351
+ hook_ctx: hook_ctx
352
+ ),
353
+ response: http_response
354
+ )
355
+ response_data = http_response.env.response_body
356
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::UsersDetailsResponse)
357
+ response = Models::Operations::UsersGetByIdsResponse.new(
358
+ status_code: http_response.status,
359
+ content_type: content_type,
360
+ raw_response: http_response,
361
+ users_details_response: T.unsafe(obj)
362
+ )
363
+
364
+ return response
365
+ else
366
+ raise(
367
+ ::XapiScraper::Models::Errors::APIError.new(
368
+ status_code: http_response.status,
369
+ body: http_response.env.response_body,
370
+ raw_response: http_response
371
+ ),
372
+ "Unknown content type received"
373
+ )
374
+ end
375
+ elsif Utils.match_status_code(http_response.status, ["422"])
376
+ if Utils.match_content_type(content_type, "application/json")
377
+ http_response = @sdk_configuration.hooks.after_success(
378
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
379
+ hook_ctx: hook_ctx
380
+ ),
381
+ response: http_response
382
+ )
383
+ response_data = http_response.env.response_body
384
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
385
+ obj.raw_response = http_response
386
+ raise obj
387
+ else
388
+ raise(
389
+ ::XapiScraper::Models::Errors::APIError.new(
390
+ status_code: http_response.status,
391
+ body: http_response.env.response_body,
392
+ raw_response: http_response
393
+ ),
394
+ "Unknown content type received"
395
+ )
396
+ end
397
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
398
+ raise(
399
+ ::XapiScraper::Models::Errors::APIError.new(
400
+ status_code: http_response.status,
401
+ body: http_response.env.response_body,
402
+ raw_response: http_response
403
+ ),
404
+ "API error occurred"
405
+ )
406
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
407
+ raise(
408
+ ::XapiScraper::Models::Errors::APIError.new(
409
+ status_code: http_response.status,
410
+ body: http_response.env.response_body,
411
+ raw_response: http_response
412
+ ),
413
+ "API error occurred"
414
+ )
415
+ else
416
+ raise(
417
+ ::XapiScraper::Models::Errors::APIError.new(
418
+ status_code: http_response.status,
419
+ body: http_response.env.response_body,
420
+ raw_response: http_response
421
+ ),
422
+ "Unknown status code received"
423
+ )
424
+
425
+ end
426
+ end
427
+
428
+ sig {
429
+ params(
430
+ request: T::Array[::String],
431
+ retries: T.nilable(Utils::RetryConfig),
432
+ timeout_ms: T.nilable(Integer),
433
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
434
+ )
435
+ .returns(Models::Operations::UsersVerifyAccountResponse)
436
+ }
437
+ def verify_account(request:, retries: nil, timeout_ms: nil, http_headers: nil)
438
+ # verify_account - Verify Account Status
439
+ # Retrieves the verification metadata for a specific account. This endpoint identifies whether an account holds a **Blue Verified** status (authenticity check) or is an **Official Organization Affiliate** (gold/grey labels). The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.
440
+ url, params = @sdk_configuration.get_server_details
441
+ base_url = Utils.template_url(url, params)
442
+ url = "#{base_url}/x/account/verify"
443
+ headers = {}
444
+ headers = T.cast(headers, T::Hash[String, String])
445
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
446
+ headers["content-type"] = req_content_type
447
+ raise StandardError, "request body is required" if data.nil? && form.nil?
448
+
449
+ if form && !form.empty?
450
+ body = Utils.encode_form(form)
451
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
452
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
453
+ else
454
+ body = data
455
+ end
456
+
457
+ headers["Accept"] = "application/json"
458
+ headers["user-agent"] = @sdk_configuration.user_agent
459
+ retries ||= @sdk_configuration.retry_config
460
+ retries ||= Utils::RetryConfig.new(
461
+ backoff: Utils::BackoffStrategy.new(
462
+ exponent: 1.5,
463
+ initial_interval: 500,
464
+ max_elapsed_time: 3_600_000,
465
+ max_interval: 60_000
466
+ ),
467
+ retry_connection_errors: true,
468
+ strategy: "backoff"
469
+ )
470
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
471
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
472
+
473
+ security = @sdk_configuration.security_source&.call
474
+
475
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
476
+ timeout ||= @sdk_configuration.timeout
477
+
478
+ connection = @sdk_configuration.client.dup
479
+ connection.use(Utils::RetryMiddleware, retry_options)
480
+
481
+ hook_ctx = SDKHooks::HookContext.new(
482
+ config: @sdk_configuration,
483
+ base_url: base_url,
484
+ oauth2_scopes: nil,
485
+ operation_id: "usersVerifyAccount",
486
+ security_source: @sdk_configuration.security_source
487
+ )
488
+
489
+ error = T.let(nil, T.nilable(StandardError))
490
+ http_response = T.let(nil, T.nilable(Faraday::Response))
491
+
492
+ begin
493
+ http_response = T.must(connection).post(url) do |req|
494
+ req.body = body
495
+ req.headers.merge!(headers)
496
+ req.options.timeout = timeout unless timeout.nil?
497
+ Utils.configure_request_security(req, security)
498
+ http_headers&.each do |key, value|
499
+ req.headers[key.to_s] = value
500
+ end
501
+
502
+ @sdk_configuration.hooks.before_request(
503
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
504
+ hook_ctx: hook_ctx
505
+ ),
506
+ request: req
507
+ )
508
+ end
509
+
510
+ rescue StandardError => e
511
+ error = e
512
+ ensure
513
+ if http_response.nil? || Utils.error_status?(http_response.status)
514
+ http_response = @sdk_configuration.hooks.after_error(
515
+ error: error,
516
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
517
+ hook_ctx: hook_ctx
518
+ ),
519
+ response: http_response
520
+ )
521
+ else
522
+ http_response = @sdk_configuration.hooks.after_success(
523
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
524
+ hook_ctx: hook_ctx
525
+ ),
526
+ response: http_response
527
+ )
528
+ end
529
+
530
+ if http_response.nil?
531
+ raise error if !error.nil?
532
+ raise "no response"
533
+ end
534
+ end
535
+
536
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
537
+ if Utils.match_status_code(http_response.status, ["200"])
538
+ if Utils.match_content_type(content_type, "application/json")
539
+ http_response = @sdk_configuration.hooks.after_success(
540
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
541
+ hook_ctx: hook_ctx
542
+ ),
543
+ response: http_response
544
+ )
545
+ response_data = http_response.env.response_body
546
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::AccountVerifyResponse)
547
+ response = Models::Operations::UsersVerifyAccountResponse.new(
548
+ status_code: http_response.status,
549
+ content_type: content_type,
550
+ raw_response: http_response,
551
+ account_verify_response: T.unsafe(obj)
552
+ )
553
+
554
+ return response
555
+ else
556
+ raise(
557
+ ::XapiScraper::Models::Errors::APIError.new(
558
+ status_code: http_response.status,
559
+ body: http_response.env.response_body,
560
+ raw_response: http_response
561
+ ),
562
+ "Unknown content type received"
563
+ )
564
+ end
565
+ elsif Utils.match_status_code(http_response.status, ["422"])
566
+ if Utils.match_content_type(content_type, "application/json")
567
+ http_response = @sdk_configuration.hooks.after_success(
568
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
569
+ hook_ctx: hook_ctx
570
+ ),
571
+ response: http_response
572
+ )
573
+ response_data = http_response.env.response_body
574
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
575
+ obj.raw_response = http_response
576
+ raise obj
577
+ else
578
+ raise(
579
+ ::XapiScraper::Models::Errors::APIError.new(
580
+ status_code: http_response.status,
581
+ body: http_response.env.response_body,
582
+ raw_response: http_response
583
+ ),
584
+ "Unknown content type received"
585
+ )
586
+ end
587
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
588
+ raise(
589
+ ::XapiScraper::Models::Errors::APIError.new(
590
+ status_code: http_response.status,
591
+ body: http_response.env.response_body,
592
+ raw_response: http_response
593
+ ),
594
+ "API error occurred"
595
+ )
596
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
597
+ raise(
598
+ ::XapiScraper::Models::Errors::APIError.new(
599
+ status_code: http_response.status,
600
+ body: http_response.env.response_body,
601
+ raw_response: http_response
602
+ ),
603
+ "API error occurred"
604
+ )
605
+ else
606
+ raise(
607
+ ::XapiScraper::Models::Errors::APIError.new(
608
+ status_code: http_response.status,
609
+ body: http_response.env.response_body,
610
+ raw_response: http_response
611
+ ),
612
+ "Unknown status code received"
613
+ )
614
+
615
+ end
616
+ end
617
+
618
+ sig {
619
+ params(
620
+ request: T::Array[::String],
621
+ retries: T.nilable(Utils::RetryConfig),
622
+ timeout_ms: T.nilable(Integer),
623
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
624
+ )
625
+ .returns(Models::Operations::UsersGetStatusesResponse)
626
+ }
627
+ def get_statuses(request:, retries: nil, timeout_ms: nil, http_headers: nil)
628
+ # get_statuses - Batch Get User account status
629
+ # Retrieve detailed account status for multiple Twitter users by their usernames. The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.
630
+ url, params = @sdk_configuration.get_server_details
631
+ base_url = Utils.template_url(url, params)
632
+ url = "#{base_url}/twitter/users/status"
633
+ headers = {}
634
+ headers = T.cast(headers, T::Hash[String, String])
635
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
636
+ headers["content-type"] = req_content_type
637
+ raise StandardError, "request body is required" if data.nil? && form.nil?
638
+
639
+ if form && !form.empty?
640
+ body = Utils.encode_form(form)
641
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
642
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
643
+ else
644
+ body = data
645
+ end
646
+
647
+ headers["Accept"] = "application/json"
648
+ headers["user-agent"] = @sdk_configuration.user_agent
649
+ retries ||= @sdk_configuration.retry_config
650
+ retries ||= Utils::RetryConfig.new(
651
+ backoff: Utils::BackoffStrategy.new(
652
+ exponent: 1.5,
653
+ initial_interval: 500,
654
+ max_elapsed_time: 3_600_000,
655
+ max_interval: 60_000
656
+ ),
657
+ retry_connection_errors: true,
658
+ strategy: "backoff"
659
+ )
660
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
661
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
662
+
663
+ security = @sdk_configuration.security_source&.call
664
+
665
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
666
+ timeout ||= @sdk_configuration.timeout
667
+
668
+ connection = @sdk_configuration.client.dup
669
+ connection.use(Utils::RetryMiddleware, retry_options)
670
+
671
+ hook_ctx = SDKHooks::HookContext.new(
672
+ config: @sdk_configuration,
673
+ base_url: base_url,
674
+ oauth2_scopes: nil,
675
+ operation_id: "usersGetStatuses",
676
+ security_source: @sdk_configuration.security_source
677
+ )
678
+
679
+ error = T.let(nil, T.nilable(StandardError))
680
+ http_response = T.let(nil, T.nilable(Faraday::Response))
681
+
682
+ begin
683
+ http_response = T.must(connection).post(url) do |req|
684
+ req.body = body
685
+ req.headers.merge!(headers)
686
+ req.options.timeout = timeout unless timeout.nil?
687
+ Utils.configure_request_security(req, security)
688
+ http_headers&.each do |key, value|
689
+ req.headers[key.to_s] = value
690
+ end
691
+
692
+ @sdk_configuration.hooks.before_request(
693
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
694
+ hook_ctx: hook_ctx
695
+ ),
696
+ request: req
697
+ )
698
+ end
699
+
700
+ rescue StandardError => e
701
+ error = e
702
+ ensure
703
+ if http_response.nil? || Utils.error_status?(http_response.status)
704
+ http_response = @sdk_configuration.hooks.after_error(
705
+ error: error,
706
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
707
+ hook_ctx: hook_ctx
708
+ ),
709
+ response: http_response
710
+ )
711
+ else
712
+ http_response = @sdk_configuration.hooks.after_success(
713
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
714
+ hook_ctx: hook_ctx
715
+ ),
716
+ response: http_response
717
+ )
718
+ end
719
+
720
+ if http_response.nil?
721
+ raise error if !error.nil?
722
+ raise "no response"
723
+ end
724
+ end
725
+
726
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
727
+ if Utils.match_status_code(http_response.status, ["200"])
728
+ if Utils.match_content_type(content_type, "application/json")
729
+ http_response = @sdk_configuration.hooks.after_success(
730
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
731
+ hook_ctx: hook_ctx
732
+ ),
733
+ response: http_response
734
+ )
735
+ response_data = http_response.env.response_body
736
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), ::Object)
737
+ response = Models::Operations::UsersGetStatusesResponse.new(
738
+ status_code: http_response.status,
739
+ content_type: content_type,
740
+ raw_response: http_response,
741
+ any: T.unsafe(obj)
742
+ )
743
+
744
+ return response
745
+ else
746
+ raise(
747
+ ::XapiScraper::Models::Errors::APIError.new(
748
+ status_code: http_response.status,
749
+ body: http_response.env.response_body,
750
+ raw_response: http_response
751
+ ),
752
+ "Unknown content type received"
753
+ )
754
+ end
755
+ elsif Utils.match_status_code(http_response.status, ["422"])
756
+ if Utils.match_content_type(content_type, "application/json")
757
+ http_response = @sdk_configuration.hooks.after_success(
758
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
759
+ hook_ctx: hook_ctx
760
+ ),
761
+ response: http_response
762
+ )
763
+ response_data = http_response.env.response_body
764
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
765
+ obj.raw_response = http_response
766
+ raise obj
767
+ else
768
+ raise(
769
+ ::XapiScraper::Models::Errors::APIError.new(
770
+ status_code: http_response.status,
771
+ body: http_response.env.response_body,
772
+ raw_response: http_response
773
+ ),
774
+ "Unknown content type received"
775
+ )
776
+ end
777
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
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
+ "API error occurred"
785
+ )
786
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
787
+ raise(
788
+ ::XapiScraper::Models::Errors::APIError.new(
789
+ status_code: http_response.status,
790
+ body: http_response.env.response_body,
791
+ raw_response: http_response
792
+ ),
793
+ "API error occurred"
794
+ )
795
+ else
796
+ raise(
797
+ ::XapiScraper::Models::Errors::APIError.new(
798
+ status_code: http_response.status,
799
+ body: http_response.env.response_body,
800
+ raw_response: http_response
801
+ ),
802
+ "Unknown status code received"
803
+ )
804
+
805
+ end
806
+ end
807
+
808
+ sig {
809
+ params(
810
+ request: Models::Operations::UsersSearchRequest,
811
+ retries: T.nilable(Utils::RetryConfig),
812
+ timeout_ms: T.nilable(Integer),
813
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
814
+ )
815
+ .returns(Models::Operations::UsersSearchResponse)
816
+ }
817
+ def search(request:, retries: nil, timeout_ms: nil, http_headers: nil)
818
+ # search - Search User
819
+ # Search user
820
+ url, params = @sdk_configuration.get_server_details
821
+ base_url = Utils.template_url(url, params)
822
+ url = Utils.generate_url(
823
+ Models::Operations::UsersSearchRequest,
824
+ base_url,
825
+ "/twitter/search-user/{keyword}/{target_count}",
826
+ request
827
+ )
828
+ headers = {}
829
+ headers = T.cast(headers, T::Hash[String, String])
830
+ headers["Accept"] = "application/json"
831
+ headers["user-agent"] = @sdk_configuration.user_agent
832
+ retries ||= @sdk_configuration.retry_config
833
+ retries ||= Utils::RetryConfig.new(
834
+ backoff: Utils::BackoffStrategy.new(
835
+ exponent: 1.5,
836
+ initial_interval: 500,
837
+ max_elapsed_time: 3_600_000,
838
+ max_interval: 60_000
839
+ ),
840
+ retry_connection_errors: true,
841
+ strategy: "backoff"
842
+ )
843
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
844
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
845
+
846
+ security = @sdk_configuration.security_source&.call
847
+
848
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
849
+ timeout ||= @sdk_configuration.timeout
850
+
851
+ connection = @sdk_configuration.client.dup
852
+ connection.use(Utils::RetryMiddleware, retry_options)
853
+
854
+ hook_ctx = SDKHooks::HookContext.new(
855
+ config: @sdk_configuration,
856
+ base_url: base_url,
857
+ oauth2_scopes: nil,
858
+ operation_id: "usersSearch",
859
+ security_source: @sdk_configuration.security_source
860
+ )
861
+
862
+ error = T.let(nil, T.nilable(StandardError))
863
+ http_response = T.let(nil, T.nilable(Faraday::Response))
864
+
865
+ begin
866
+ http_response = T.must(connection).get(url) do |req|
867
+ req.headers.merge!(headers)
868
+ req.options.timeout = timeout unless timeout.nil?
869
+ Utils.configure_request_security(req, security)
870
+ http_headers&.each do |key, value|
871
+ req.headers[key.to_s] = value
872
+ end
873
+
874
+ @sdk_configuration.hooks.before_request(
875
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
876
+ hook_ctx: hook_ctx
877
+ ),
878
+ request: req
879
+ )
880
+ end
881
+
882
+ rescue StandardError => e
883
+ error = e
884
+ ensure
885
+ if http_response.nil? || Utils.error_status?(http_response.status)
886
+ http_response = @sdk_configuration.hooks.after_error(
887
+ error: error,
888
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
889
+ hook_ctx: hook_ctx
890
+ ),
891
+ response: http_response
892
+ )
893
+ else
894
+ http_response = @sdk_configuration.hooks.after_success(
895
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
896
+ hook_ctx: hook_ctx
897
+ ),
898
+ response: http_response
899
+ )
900
+ end
901
+
902
+ if http_response.nil?
903
+ raise error if !error.nil?
904
+ raise "no response"
905
+ end
906
+ end
907
+
908
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
909
+ if Utils.match_status_code(http_response.status, ["200"])
910
+ if Utils.match_content_type(content_type, "application/json")
911
+ http_response = @sdk_configuration.hooks.after_success(
912
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
913
+ hook_ctx: hook_ctx
914
+ ),
915
+ response: http_response
916
+ )
917
+ response_data = http_response.env.response_body
918
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::SearchUserResponse)
919
+ response = Models::Operations::UsersSearchResponse.new(
920
+ status_code: http_response.status,
921
+ content_type: content_type,
922
+ raw_response: http_response,
923
+ search_user_response: T.unsafe(obj)
924
+ )
925
+
926
+ return response
927
+ else
928
+ raise(
929
+ ::XapiScraper::Models::Errors::APIError.new(
930
+ status_code: http_response.status,
931
+ body: http_response.env.response_body,
932
+ raw_response: http_response
933
+ ),
934
+ "Unknown content type received"
935
+ )
936
+ end
937
+ elsif Utils.match_status_code(http_response.status, ["422"])
938
+ if Utils.match_content_type(content_type, "application/json")
939
+ http_response = @sdk_configuration.hooks.after_success(
940
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
941
+ hook_ctx: hook_ctx
942
+ ),
943
+ response: http_response
944
+ )
945
+ response_data = http_response.env.response_body
946
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
947
+ obj.raw_response = http_response
948
+ raise obj
949
+ else
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
+ "Unknown content type received"
957
+ )
958
+ end
959
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
960
+ raise(
961
+ ::XapiScraper::Models::Errors::APIError.new(
962
+ status_code: http_response.status,
963
+ body: http_response.env.response_body,
964
+ raw_response: http_response
965
+ ),
966
+ "API error occurred"
967
+ )
968
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
969
+ raise(
970
+ ::XapiScraper::Models::Errors::APIError.new(
971
+ status_code: http_response.status,
972
+ body: http_response.env.response_body,
973
+ raw_response: http_response
974
+ ),
975
+ "API error occurred"
976
+ )
977
+ else
978
+ raise(
979
+ ::XapiScraper::Models::Errors::APIError.new(
980
+ status_code: http_response.status,
981
+ body: http_response.env.response_body,
982
+ raw_response: http_response
983
+ ),
984
+ "Unknown status code received"
985
+ )
986
+
987
+ end
988
+ end
989
+
990
+ sig {
991
+ params(
992
+ request: Models::Components::FollowUserQuery,
993
+ retries: T.nilable(Utils::RetryConfig),
994
+ timeout_ms: T.nilable(Integer),
995
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
996
+ )
997
+ .returns(Models::Operations::UsersFollowResponse)
998
+ }
999
+ def follow(request:, retries: nil, timeout_ms: nil, http_headers: nil)
1000
+ # follow - Follow User
1001
+ # Follow a user, $0.001 per call.
1002
+ url, params = @sdk_configuration.get_server_details
1003
+ base_url = Utils.template_url(url, params)
1004
+ url = "#{base_url}/twitter/user/follow"
1005
+ headers = {}
1006
+ headers = T.cast(headers, T::Hash[String, String])
1007
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
1008
+ headers["content-type"] = req_content_type
1009
+ raise StandardError, "request body is required" if data.nil? && form.nil?
1010
+
1011
+ if form && !form.empty?
1012
+ body = Utils.encode_form(form)
1013
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
1014
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1015
+ else
1016
+ body = data
1017
+ end
1018
+
1019
+ headers["Accept"] = "application/json"
1020
+ headers["user-agent"] = @sdk_configuration.user_agent
1021
+ retries ||= @sdk_configuration.retry_config
1022
+ retries ||= Utils::RetryConfig.new(
1023
+ backoff: Utils::BackoffStrategy.new(
1024
+ exponent: 1.5,
1025
+ initial_interval: 500,
1026
+ max_elapsed_time: 3_600_000,
1027
+ max_interval: 60_000
1028
+ ),
1029
+ retry_connection_errors: true,
1030
+ strategy: "backoff"
1031
+ )
1032
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1033
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
1034
+
1035
+ security = @sdk_configuration.security_source&.call
1036
+
1037
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1038
+ timeout ||= @sdk_configuration.timeout
1039
+
1040
+ connection = @sdk_configuration.client.dup
1041
+ connection.use(Utils::RetryMiddleware, retry_options)
1042
+
1043
+ hook_ctx = SDKHooks::HookContext.new(
1044
+ config: @sdk_configuration,
1045
+ base_url: base_url,
1046
+ oauth2_scopes: nil,
1047
+ operation_id: "usersFollow",
1048
+ security_source: @sdk_configuration.security_source
1049
+ )
1050
+
1051
+ error = T.let(nil, T.nilable(StandardError))
1052
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1053
+
1054
+ begin
1055
+ http_response = T.must(connection).post(url) do |req|
1056
+ req.body = body
1057
+ req.headers.merge!(headers)
1058
+ req.options.timeout = timeout unless timeout.nil?
1059
+ Utils.configure_request_security(req, security)
1060
+ http_headers&.each do |key, value|
1061
+ req.headers[key.to_s] = value
1062
+ end
1063
+
1064
+ @sdk_configuration.hooks.before_request(
1065
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1066
+ hook_ctx: hook_ctx
1067
+ ),
1068
+ request: req
1069
+ )
1070
+ end
1071
+
1072
+ rescue StandardError => e
1073
+ error = e
1074
+ ensure
1075
+ if http_response.nil? || Utils.error_status?(http_response.status)
1076
+ http_response = @sdk_configuration.hooks.after_error(
1077
+ error: error,
1078
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1079
+ hook_ctx: hook_ctx
1080
+ ),
1081
+ response: http_response
1082
+ )
1083
+ else
1084
+ http_response = @sdk_configuration.hooks.after_success(
1085
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1086
+ hook_ctx: hook_ctx
1087
+ ),
1088
+ response: http_response
1089
+ )
1090
+ end
1091
+
1092
+ if http_response.nil?
1093
+ raise error if !error.nil?
1094
+ raise "no response"
1095
+ end
1096
+ end
1097
+
1098
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1099
+ if Utils.match_status_code(http_response.status, ["200"])
1100
+ if Utils.match_content_type(content_type, "application/json")
1101
+ http_response = @sdk_configuration.hooks.after_success(
1102
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1103
+ hook_ctx: hook_ctx
1104
+ ),
1105
+ response: http_response
1106
+ )
1107
+ response_data = http_response.env.response_body
1108
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::BlockUserResponse)
1109
+ response = Models::Operations::UsersFollowResponse.new(
1110
+ status_code: http_response.status,
1111
+ content_type: content_type,
1112
+ raw_response: http_response,
1113
+ block_user_response: T.unsafe(obj)
1114
+ )
1115
+
1116
+ return response
1117
+ else
1118
+ raise(
1119
+ ::XapiScraper::Models::Errors::APIError.new(
1120
+ status_code: http_response.status,
1121
+ body: http_response.env.response_body,
1122
+ raw_response: http_response
1123
+ ),
1124
+ "Unknown content type received"
1125
+ )
1126
+ end
1127
+ elsif Utils.match_status_code(http_response.status, ["422"])
1128
+ if Utils.match_content_type(content_type, "application/json")
1129
+ http_response = @sdk_configuration.hooks.after_success(
1130
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1131
+ hook_ctx: hook_ctx
1132
+ ),
1133
+ response: http_response
1134
+ )
1135
+ response_data = http_response.env.response_body
1136
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
1137
+ obj.raw_response = http_response
1138
+ raise obj
1139
+ else
1140
+ raise(
1141
+ ::XapiScraper::Models::Errors::APIError.new(
1142
+ status_code: http_response.status,
1143
+ body: http_response.env.response_body,
1144
+ raw_response: http_response
1145
+ ),
1146
+ "Unknown content type received"
1147
+ )
1148
+ end
1149
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
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
+ "API error occurred"
1157
+ )
1158
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1159
+ raise(
1160
+ ::XapiScraper::Models::Errors::APIError.new(
1161
+ status_code: http_response.status,
1162
+ body: http_response.env.response_body,
1163
+ raw_response: http_response
1164
+ ),
1165
+ "API error occurred"
1166
+ )
1167
+ else
1168
+ raise(
1169
+ ::XapiScraper::Models::Errors::APIError.new(
1170
+ status_code: http_response.status,
1171
+ body: http_response.env.response_body,
1172
+ raw_response: http_response
1173
+ ),
1174
+ "Unknown status code received"
1175
+ )
1176
+
1177
+ end
1178
+ end
1179
+
1180
+ sig {
1181
+ params(
1182
+ request: Models::Components::UnfollowUserQuery,
1183
+ retries: T.nilable(Utils::RetryConfig),
1184
+ timeout_ms: T.nilable(Integer),
1185
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1186
+ )
1187
+ .returns(Models::Operations::UsersUnfollowResponse)
1188
+ }
1189
+ def unfollow(request:, retries: nil, timeout_ms: nil, http_headers: nil)
1190
+ # unfollow - Unfollow User
1191
+ # Unfollow a user, $0.001 per call.
1192
+ url, params = @sdk_configuration.get_server_details
1193
+ base_url = Utils.template_url(url, params)
1194
+ url = "#{base_url}/twitter/user/follow"
1195
+ headers = {}
1196
+ headers = T.cast(headers, T::Hash[String, String])
1197
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
1198
+ headers["content-type"] = req_content_type
1199
+ raise StandardError, "request body is required" if data.nil? && form.nil?
1200
+
1201
+ if form && !form.empty?
1202
+ body = Utils.encode_form(form)
1203
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
1204
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1205
+ else
1206
+ body = data
1207
+ end
1208
+
1209
+ headers["Accept"] = "application/json"
1210
+ headers["user-agent"] = @sdk_configuration.user_agent
1211
+ retries ||= @sdk_configuration.retry_config
1212
+ retries ||= Utils::RetryConfig.new(
1213
+ backoff: Utils::BackoffStrategy.new(
1214
+ exponent: 1.5,
1215
+ initial_interval: 500,
1216
+ max_elapsed_time: 3_600_000,
1217
+ max_interval: 60_000
1218
+ ),
1219
+ retry_connection_errors: true,
1220
+ strategy: "backoff"
1221
+ )
1222
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1223
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
1224
+
1225
+ security = @sdk_configuration.security_source&.call
1226
+
1227
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1228
+ timeout ||= @sdk_configuration.timeout
1229
+
1230
+ connection = @sdk_configuration.client.dup
1231
+ connection.use(Utils::RetryMiddleware, retry_options)
1232
+
1233
+ hook_ctx = SDKHooks::HookContext.new(
1234
+ config: @sdk_configuration,
1235
+ base_url: base_url,
1236
+ oauth2_scopes: nil,
1237
+ operation_id: "usersUnfollow",
1238
+ security_source: @sdk_configuration.security_source
1239
+ )
1240
+
1241
+ error = T.let(nil, T.nilable(StandardError))
1242
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1243
+
1244
+ begin
1245
+ http_response = T.must(connection).delete(url) do |req|
1246
+ req.body = body
1247
+ req.headers.merge!(headers)
1248
+ req.options.timeout = timeout unless timeout.nil?
1249
+ Utils.configure_request_security(req, security)
1250
+ http_headers&.each do |key, value|
1251
+ req.headers[key.to_s] = value
1252
+ end
1253
+
1254
+ @sdk_configuration.hooks.before_request(
1255
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1256
+ hook_ctx: hook_ctx
1257
+ ),
1258
+ request: req
1259
+ )
1260
+ end
1261
+
1262
+ rescue StandardError => e
1263
+ error = e
1264
+ ensure
1265
+ if http_response.nil? || Utils.error_status?(http_response.status)
1266
+ http_response = @sdk_configuration.hooks.after_error(
1267
+ error: error,
1268
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1269
+ hook_ctx: hook_ctx
1270
+ ),
1271
+ response: http_response
1272
+ )
1273
+ else
1274
+ http_response = @sdk_configuration.hooks.after_success(
1275
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1276
+ hook_ctx: hook_ctx
1277
+ ),
1278
+ response: http_response
1279
+ )
1280
+ end
1281
+
1282
+ if http_response.nil?
1283
+ raise error if !error.nil?
1284
+ raise "no response"
1285
+ end
1286
+ end
1287
+
1288
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1289
+ if Utils.match_status_code(http_response.status, ["200"])
1290
+ if Utils.match_content_type(content_type, "application/json")
1291
+ http_response = @sdk_configuration.hooks.after_success(
1292
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1293
+ hook_ctx: hook_ctx
1294
+ ),
1295
+ response: http_response
1296
+ )
1297
+ response_data = http_response.env.response_body
1298
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Components::UnfollowUserResponse)
1299
+ response = Models::Operations::UsersUnfollowResponse.new(
1300
+ status_code: http_response.status,
1301
+ content_type: content_type,
1302
+ raw_response: http_response,
1303
+ unfollow_user_response: T.unsafe(obj)
1304
+ )
1305
+
1306
+ return response
1307
+ else
1308
+ raise(
1309
+ ::XapiScraper::Models::Errors::APIError.new(
1310
+ status_code: http_response.status,
1311
+ body: http_response.env.response_body,
1312
+ raw_response: http_response
1313
+ ),
1314
+ "Unknown content type received"
1315
+ )
1316
+ end
1317
+ elsif Utils.match_status_code(http_response.status, ["422"])
1318
+ if Utils.match_content_type(content_type, "application/json")
1319
+ http_response = @sdk_configuration.hooks.after_success(
1320
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1321
+ hook_ctx: hook_ctx
1322
+ ),
1323
+ response: http_response
1324
+ )
1325
+ response_data = http_response.env.response_body
1326
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
1327
+ obj.raw_response = http_response
1328
+ raise obj
1329
+ else
1330
+ raise(
1331
+ ::XapiScraper::Models::Errors::APIError.new(
1332
+ status_code: http_response.status,
1333
+ body: http_response.env.response_body,
1334
+ raw_response: http_response
1335
+ ),
1336
+ "Unknown content type received"
1337
+ )
1338
+ end
1339
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
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
+ "API error occurred"
1347
+ )
1348
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1349
+ raise(
1350
+ ::XapiScraper::Models::Errors::APIError.new(
1351
+ status_code: http_response.status,
1352
+ body: http_response.env.response_body,
1353
+ raw_response: http_response
1354
+ ),
1355
+ "API error occurred"
1356
+ )
1357
+ else
1358
+ raise(
1359
+ ::XapiScraper::Models::Errors::APIError.new(
1360
+ status_code: http_response.status,
1361
+ body: http_response.env.response_body,
1362
+ raw_response: http_response
1363
+ ),
1364
+ "Unknown status code received"
1365
+ )
1366
+
1367
+ end
1368
+ end
1369
+
1370
+ sig {
1371
+ params(
1372
+ request: T::Array[::String],
1373
+ retries: T.nilable(Utils::RetryConfig),
1374
+ timeout_ms: T.nilable(Integer),
1375
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1376
+ )
1377
+ .returns(Models::Operations::UsersGetAccountBasedResponse)
1378
+ }
1379
+ def get_account_based(request:, retries: nil, timeout_ms: nil, http_headers: nil)
1380
+ # get_account_based - Get Twitter Account Based in
1381
+ # Get Twitter Account Based in. The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.
1382
+ url, params = @sdk_configuration.get_server_details
1383
+ base_url = Utils.template_url(url, params)
1384
+ url = "#{base_url}/twitter/account/based"
1385
+ headers = {}
1386
+ headers = T.cast(headers, T::Hash[String, String])
1387
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
1388
+ headers["content-type"] = req_content_type
1389
+ raise StandardError, "request body is required" if data.nil? && form.nil?
1390
+
1391
+ if form && !form.empty?
1392
+ body = Utils.encode_form(form)
1393
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
1394
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1395
+ else
1396
+ body = data
1397
+ end
1398
+
1399
+ headers["Accept"] = "application/json"
1400
+ headers["user-agent"] = @sdk_configuration.user_agent
1401
+ retries ||= @sdk_configuration.retry_config
1402
+ retries ||= Utils::RetryConfig.new(
1403
+ backoff: Utils::BackoffStrategy.new(
1404
+ exponent: 1.5,
1405
+ initial_interval: 500,
1406
+ max_elapsed_time: 3_600_000,
1407
+ max_interval: 60_000
1408
+ ),
1409
+ retry_connection_errors: true,
1410
+ strategy: "backoff"
1411
+ )
1412
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1413
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
1414
+
1415
+ security = @sdk_configuration.security_source&.call
1416
+
1417
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1418
+ timeout ||= @sdk_configuration.timeout
1419
+
1420
+ connection = @sdk_configuration.client.dup
1421
+ connection.use(Utils::RetryMiddleware, retry_options)
1422
+
1423
+ hook_ctx = SDKHooks::HookContext.new(
1424
+ config: @sdk_configuration,
1425
+ base_url: base_url,
1426
+ oauth2_scopes: nil,
1427
+ operation_id: "usersGetAccountBased",
1428
+ security_source: @sdk_configuration.security_source
1429
+ )
1430
+
1431
+ error = T.let(nil, T.nilable(StandardError))
1432
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1433
+
1434
+ begin
1435
+ http_response = T.must(connection).post(url) do |req|
1436
+ req.body = body
1437
+ req.headers.merge!(headers)
1438
+ req.options.timeout = timeout unless timeout.nil?
1439
+ Utils.configure_request_security(req, security)
1440
+ http_headers&.each do |key, value|
1441
+ req.headers[key.to_s] = value
1442
+ end
1443
+
1444
+ @sdk_configuration.hooks.before_request(
1445
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1446
+ hook_ctx: hook_ctx
1447
+ ),
1448
+ request: req
1449
+ )
1450
+ end
1451
+
1452
+ rescue StandardError => e
1453
+ error = e
1454
+ ensure
1455
+ if http_response.nil? || Utils.error_status?(http_response.status)
1456
+ http_response = @sdk_configuration.hooks.after_error(
1457
+ error: error,
1458
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1459
+ hook_ctx: hook_ctx
1460
+ ),
1461
+ response: http_response
1462
+ )
1463
+ else
1464
+ http_response = @sdk_configuration.hooks.after_success(
1465
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1466
+ hook_ctx: hook_ctx
1467
+ ),
1468
+ response: http_response
1469
+ )
1470
+ end
1471
+
1472
+ if http_response.nil?
1473
+ raise error if !error.nil?
1474
+ raise "no response"
1475
+ end
1476
+ end
1477
+
1478
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1479
+ if Utils.match_status_code(http_response.status, ["200"])
1480
+ if Utils.match_content_type(content_type, "application/json")
1481
+ http_response = @sdk_configuration.hooks.after_success(
1482
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1483
+ hook_ctx: hook_ctx
1484
+ ),
1485
+ response: http_response
1486
+ )
1487
+ response_data = http_response.env.response_body
1488
+ obj = Crystalline.unmarshal_json(
1489
+ JSON.parse(response_data),
1490
+ Models::Components::TwitterAccountBasedStandardResponse
1491
+ )
1492
+ response = Models::Operations::UsersGetAccountBasedResponse.new(
1493
+ status_code: http_response.status,
1494
+ content_type: content_type,
1495
+ raw_response: http_response,
1496
+ twitter_account_based_standard_response: T.unsafe(obj)
1497
+ )
1498
+
1499
+ return response
1500
+ else
1501
+ raise(
1502
+ ::XapiScraper::Models::Errors::APIError.new(
1503
+ status_code: http_response.status,
1504
+ body: http_response.env.response_body,
1505
+ raw_response: http_response
1506
+ ),
1507
+ "Unknown content type received"
1508
+ )
1509
+ end
1510
+ elsif Utils.match_status_code(http_response.status, ["422"])
1511
+ if Utils.match_content_type(content_type, "application/json")
1512
+ http_response = @sdk_configuration.hooks.after_success(
1513
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1514
+ hook_ctx: hook_ctx
1515
+ ),
1516
+ response: http_response
1517
+ )
1518
+ response_data = http_response.env.response_body
1519
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
1520
+ obj.raw_response = http_response
1521
+ raise obj
1522
+ else
1523
+ raise(
1524
+ ::XapiScraper::Models::Errors::APIError.new(
1525
+ status_code: http_response.status,
1526
+ body: http_response.env.response_body,
1527
+ raw_response: http_response
1528
+ ),
1529
+ "Unknown content type received"
1530
+ )
1531
+ end
1532
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1533
+ raise(
1534
+ ::XapiScraper::Models::Errors::APIError.new(
1535
+ status_code: http_response.status,
1536
+ body: http_response.env.response_body,
1537
+ raw_response: http_response
1538
+ ),
1539
+ "API error occurred"
1540
+ )
1541
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1542
+ raise(
1543
+ ::XapiScraper::Models::Errors::APIError.new(
1544
+ status_code: http_response.status,
1545
+ body: http_response.env.response_body,
1546
+ raw_response: http_response
1547
+ ),
1548
+ "API error occurred"
1549
+ )
1550
+ else
1551
+ raise(
1552
+ ::XapiScraper::Models::Errors::APIError.new(
1553
+ status_code: http_response.status,
1554
+ body: http_response.env.response_body,
1555
+ raw_response: http_response
1556
+ ),
1557
+ "Unknown status code received"
1558
+ )
1559
+
1560
+ end
1561
+ end
1562
+
1563
+ sig {
1564
+ params(
1565
+ request: Models::Operations::UsersGetAboutRequest,
1566
+ retries: T.nilable(Utils::RetryConfig),
1567
+ timeout_ms: T.nilable(Integer),
1568
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1569
+ )
1570
+ .returns(Models::Operations::UsersGetAboutResponse)
1571
+ }
1572
+ def get_about(request:, retries: nil, timeout_ms: nil, http_headers: nil)
1573
+ # get_about - Get Twitter User About by Screen Name
1574
+ # Get Twitter User About for a specific twitter user. get account_based_in,location_accurate
1575
+ url, params = @sdk_configuration.get_server_details
1576
+ base_url = Utils.template_url(url, params)
1577
+ url = Utils.generate_url(
1578
+ Models::Operations::UsersGetAboutRequest,
1579
+ base_url,
1580
+ "/twitter/{screen_name}/about",
1581
+ request
1582
+ )
1583
+ headers = {}
1584
+ headers = T.cast(headers, T::Hash[String, String])
1585
+ headers["Accept"] = "application/json"
1586
+ headers["user-agent"] = @sdk_configuration.user_agent
1587
+ retries ||= @sdk_configuration.retry_config
1588
+ retries ||= Utils::RetryConfig.new(
1589
+ backoff: Utils::BackoffStrategy.new(
1590
+ exponent: 1.5,
1591
+ initial_interval: 500,
1592
+ max_elapsed_time: 3_600_000,
1593
+ max_interval: 60_000
1594
+ ),
1595
+ retry_connection_errors: true,
1596
+ strategy: "backoff"
1597
+ )
1598
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1599
+ retry_options[:retry_statuses] = [408, 409, 429, 500, 501, 502, 503, 504, 505]
1600
+
1601
+ security = @sdk_configuration.security_source&.call
1602
+
1603
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1604
+ timeout ||= @sdk_configuration.timeout
1605
+
1606
+ connection = @sdk_configuration.client.dup
1607
+ connection.use(Utils::RetryMiddleware, retry_options)
1608
+
1609
+ hook_ctx = SDKHooks::HookContext.new(
1610
+ config: @sdk_configuration,
1611
+ base_url: base_url,
1612
+ oauth2_scopes: nil,
1613
+ operation_id: "usersGetAbout",
1614
+ security_source: @sdk_configuration.security_source
1615
+ )
1616
+
1617
+ error = T.let(nil, T.nilable(StandardError))
1618
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1619
+
1620
+ begin
1621
+ http_response = T.must(connection).get(url) do |req|
1622
+ req.headers.merge!(headers)
1623
+ req.options.timeout = timeout unless timeout.nil?
1624
+ Utils.configure_request_security(req, security)
1625
+ http_headers&.each do |key, value|
1626
+ req.headers[key.to_s] = value
1627
+ end
1628
+
1629
+ @sdk_configuration.hooks.before_request(
1630
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1631
+ hook_ctx: hook_ctx
1632
+ ),
1633
+ request: req
1634
+ )
1635
+ end
1636
+
1637
+ rescue StandardError => e
1638
+ error = e
1639
+ ensure
1640
+ if http_response.nil? || Utils.error_status?(http_response.status)
1641
+ http_response = @sdk_configuration.hooks.after_error(
1642
+ error: error,
1643
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1644
+ hook_ctx: hook_ctx
1645
+ ),
1646
+ response: http_response
1647
+ )
1648
+ else
1649
+ http_response = @sdk_configuration.hooks.after_success(
1650
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1651
+ hook_ctx: hook_ctx
1652
+ ),
1653
+ response: http_response
1654
+ )
1655
+ end
1656
+
1657
+ if http_response.nil?
1658
+ raise error if !error.nil?
1659
+ raise "no response"
1660
+ end
1661
+ end
1662
+
1663
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1664
+ if Utils.match_status_code(http_response.status, ["200"])
1665
+ if Utils.match_content_type(content_type, "application/json")
1666
+ http_response = @sdk_configuration.hooks.after_success(
1667
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1668
+ hook_ctx: hook_ctx
1669
+ ),
1670
+ response: http_response
1671
+ )
1672
+ response_data = http_response.env.response_body
1673
+ obj = Crystalline.unmarshal_json(
1674
+ JSON.parse(response_data),
1675
+ Models::Components::TwitterUserAboutStandardResponse
1676
+ )
1677
+ response = Models::Operations::UsersGetAboutResponse.new(
1678
+ status_code: http_response.status,
1679
+ content_type: content_type,
1680
+ raw_response: http_response,
1681
+ twitter_user_about_standard_response: T.unsafe(obj)
1682
+ )
1683
+
1684
+ return response
1685
+ else
1686
+ raise(
1687
+ ::XapiScraper::Models::Errors::APIError.new(
1688
+ status_code: http_response.status,
1689
+ body: http_response.env.response_body,
1690
+ raw_response: http_response
1691
+ ),
1692
+ "Unknown content type received"
1693
+ )
1694
+ end
1695
+ elsif Utils.match_status_code(http_response.status, ["422"])
1696
+ if Utils.match_content_type(content_type, "application/json")
1697
+ http_response = @sdk_configuration.hooks.after_success(
1698
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1699
+ hook_ctx: hook_ctx
1700
+ ),
1701
+ response: http_response
1702
+ )
1703
+ response_data = http_response.env.response_body
1704
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::HTTPValidationError)
1705
+ obj.raw_response = http_response
1706
+ raise obj
1707
+ else
1708
+ raise(
1709
+ ::XapiScraper::Models::Errors::APIError.new(
1710
+ status_code: http_response.status,
1711
+ body: http_response.env.response_body,
1712
+ raw_response: http_response
1713
+ ),
1714
+ "Unknown content type received"
1715
+ )
1716
+ end
1717
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1718
+ raise(
1719
+ ::XapiScraper::Models::Errors::APIError.new(
1720
+ status_code: http_response.status,
1721
+ body: http_response.env.response_body,
1722
+ raw_response: http_response
1723
+ ),
1724
+ "API error occurred"
1725
+ )
1726
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1727
+ raise(
1728
+ ::XapiScraper::Models::Errors::APIError.new(
1729
+ status_code: http_response.status,
1730
+ body: http_response.env.response_body,
1731
+ raw_response: http_response
1732
+ ),
1733
+ "API error occurred"
1734
+ )
1735
+ else
1736
+ raise(
1737
+ ::XapiScraper::Models::Errors::APIError.new(
1738
+ status_code: http_response.status,
1739
+ body: http_response.env.response_body,
1740
+ raw_response: http_response
1741
+ ),
1742
+ "Unknown status code received"
1743
+ )
1744
+
1745
+ end
1746
+ end
1747
+ end
1748
+ end