rettiwt-api 1.1.8 → 1.3.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 (443) hide show
  1. package/.github/workflows/build-docs.yml +22 -21
  2. package/.github/workflows/publish-to-npm.yml +29 -0
  3. package/README.md +52 -40
  4. package/dist/config/env.d.ts +5 -5
  5. package/dist/config/env.js +8 -8
  6. package/dist/enums/Errors.d.ts +21 -20
  7. package/dist/enums/Errors.js +28 -27
  8. package/dist/enums/Errors.js.map +1 -1
  9. package/dist/enums/HTTP.d.ts +17 -17
  10. package/dist/enums/HTTP.js +22 -22
  11. package/dist/graphql/enums/Errors.d.ts +21 -21
  12. package/dist/graphql/enums/Errors.js +28 -28
  13. package/dist/graphql/queries/RootQuery.d.ts +4 -4
  14. package/dist/graphql/queries/RootQuery.js +77 -77
  15. package/dist/graphql/queries/RootQuery.js.map +1 -1
  16. package/dist/graphql/resolvers/AccountResolver.d.ts +12 -12
  17. package/dist/graphql/resolvers/AccountResolver.js +83 -83
  18. package/dist/graphql/resolvers/ResolverBase.d.ts +16 -16
  19. package/dist/graphql/resolvers/ResolverBase.js +22 -22
  20. package/dist/graphql/resolvers/TweetResolver.d.ts +46 -46
  21. package/dist/graphql/resolvers/TweetResolver.js +311 -311
  22. package/dist/graphql/resolvers/TweetResolver.js.map +1 -1
  23. package/dist/graphql/resolvers/UserResolver.d.ts +48 -48
  24. package/dist/graphql/resolvers/UserResolver.js +333 -333
  25. package/dist/graphql/resolvers/UserResolver.js.map +1 -1
  26. package/dist/graphql/types/Global.d.ts +4 -4
  27. package/dist/graphql/types/Global.js +12 -12
  28. package/dist/graphql/types/TweetTypes.d.ts +4 -4
  29. package/dist/graphql/types/TweetTypes.js +159 -159
  30. package/dist/graphql/types/UserTypes.d.ts +3 -3
  31. package/dist/graphql/types/UserTypes.js +136 -136
  32. package/dist/graphql/types/UserTypes.js.map +1 -1
  33. package/dist/index.d.ts +45 -43
  34. package/dist/index.js +72 -70
  35. package/dist/index.js.map +1 -1
  36. package/dist/models/args/TweetListArgs.d.ts +21 -21
  37. package/dist/models/args/TweetListArgs.js +53 -53
  38. package/dist/models/args/TweetListArgs.js.map +1 -1
  39. package/dist/models/args/UserListArgs.d.ts +21 -21
  40. package/dist/models/args/UserListArgs.js +53 -53
  41. package/dist/models/args/UserListArgs.js.map +1 -1
  42. package/dist/models/auth/AuthCookie.d.ts +21 -21
  43. package/dist/models/auth/AuthCookie.js +32 -32
  44. package/dist/models/data/CursoredData.d.ts +34 -34
  45. package/dist/models/data/CursoredData.js +41 -41
  46. package/dist/models/data/Tweet.d.ts +53 -53
  47. package/dist/models/data/Tweet.js +103 -103
  48. package/dist/models/data/Tweet.js.map +1 -1
  49. package/dist/models/data/User.d.ts +41 -41
  50. package/dist/models/data/User.js +31 -31
  51. package/dist/models/data/User.js.map +1 -1
  52. package/dist/server.d.ts +1 -1
  53. package/dist/server.js +75 -75
  54. package/dist/services/auth/AccountService.d.ts +83 -83
  55. package/dist/services/auth/AccountService.js +411 -411
  56. package/dist/services/auth/AuthService.d.ts +31 -31
  57. package/dist/services/auth/AuthService.js +117 -117
  58. package/dist/services/data/TweetService.d.ts +60 -74
  59. package/dist/services/data/TweetService.js +250 -254
  60. package/dist/services/data/TweetService.js.map +1 -1
  61. package/dist/services/data/UserService.d.ts +71 -87
  62. package/dist/services/data/UserService.js +277 -296
  63. package/dist/services/data/UserService.js.map +1 -1
  64. package/dist/services/helper/Headers.d.ts +19 -19
  65. package/dist/services/helper/Headers.js +61 -61
  66. package/dist/services/helper/Headers.js.map +1 -1
  67. package/dist/services/helper/Parser.d.ts +22 -28
  68. package/dist/services/helper/Parser.js +83 -104
  69. package/dist/services/helper/Parser.js.map +1 -1
  70. package/dist/services/helper/extractors/Tweets.d.ts +23 -32
  71. package/dist/services/helper/extractors/Tweets.js +199 -263
  72. package/dist/services/helper/extractors/Tweets.js.map +1 -1
  73. package/dist/services/helper/extractors/Users.d.ts +17 -26
  74. package/dist/services/helper/extractors/Users.js +150 -202
  75. package/dist/services/helper/extractors/Users.js.map +1 -1
  76. package/dist/services/helper/payloads/LoginFlows.d.ts +77 -77
  77. package/dist/services/helper/payloads/LoginFlows.js +91 -91
  78. package/dist/services/helper/urls/Authentication.d.ts +4 -4
  79. package/dist/services/helper/urls/Authentication.js +10 -10
  80. package/dist/services/util/CacheService.d.ts +33 -33
  81. package/dist/services/util/CacheService.js +95 -95
  82. package/dist/services/util/FetcherService.d.ts +65 -65
  83. package/dist/services/util/FetcherService.js +201 -213
  84. package/dist/services/util/FetcherService.js.map +1 -1
  85. package/dist/types/Args.d.ts +11 -38
  86. package/dist/types/Args.js +3 -4
  87. package/dist/types/Args.js.map +1 -1
  88. package/dist/types/Authentication.d.ts +55 -55
  89. package/dist/types/Authentication.js +5 -5
  90. package/dist/types/Resolvers.d.ts +15 -15
  91. package/dist/types/Resolvers.js +2 -2
  92. package/dist/types/Rettiwt.d.ts +16 -16
  93. package/dist/types/Rettiwt.js +2 -2
  94. package/dist/types/Service.d.ts +22 -22
  95. package/dist/types/Service.js +4 -4
  96. package/dist/types/Tweet.d.ts +46 -46
  97. package/dist/types/Tweet.js +2 -2
  98. package/dist/types/User.d.ts +35 -35
  99. package/dist/types/User.js +2 -2
  100. package/docs/.nojekyll +1 -0
  101. package/docs/assets/highlight.css +64 -0
  102. package/docs/assets/main.js +58 -0
  103. package/docs/assets/search.js +1 -0
  104. package/docs/assets/style.css +1280 -0
  105. package/docs/classes/AccountService.html +286 -0
  106. package/docs/classes/AuthCookie.html +146 -0
  107. package/docs/classes/AuthService.html +147 -0
  108. package/docs/classes/CacheService.html +157 -0
  109. package/docs/classes/Cursor.html +102 -0
  110. package/docs/classes/CursoredData.html +126 -0
  111. package/docs/classes/DataValidationError.html +120 -0
  112. package/docs/classes/FetcherService.html +225 -0
  113. package/docs/classes/Tweet.html +210 -0
  114. package/docs/classes/TweetEntities.html +128 -0
  115. package/docs/classes/TweetFilter.html +223 -0
  116. package/docs/classes/TweetListArgs.html +118 -0
  117. package/docs/classes/TweetService.html +319 -0
  118. package/docs/classes/User.html +230 -0
  119. package/docs/classes/UserListArgs.html +118 -0
  120. package/docs/classes/UserService.html +355 -0
  121. package/docs/enums/HttpMethods.html +74 -0
  122. package/docs/functions/Rettiwt.html +100 -0
  123. package/docs/index.html +159 -0
  124. package/docs/interfaces/IAuthCookie.html +104 -0
  125. package/docs/interfaces/ICursor.html +77 -0
  126. package/docs/interfaces/ICursoredData.html +93 -0
  127. package/docs/interfaces/IDataContext.html +91 -0
  128. package/docs/interfaces/IDataValidationError.html +109 -0
  129. package/docs/interfaces/IListArgs.html +87 -0
  130. package/docs/interfaces/ITweet.html +176 -0
  131. package/docs/interfaces/ITweetEntities.html +104 -0
  132. package/docs/interfaces/ITweetFilter.html +158 -0
  133. package/docs/interfaces/IUser.html +194 -0
  134. package/docs/modules.html +111 -0
  135. package/package.json +4 -3
  136. package/src/enums/Errors.ts +2 -1
  137. package/src/graphql/queries/RootQuery.ts +1 -1
  138. package/src/graphql/resolvers/TweetResolver.ts +12 -59
  139. package/src/graphql/resolvers/UserResolver.ts +4 -4
  140. package/src/graphql/types/UserTypes.ts +2 -2
  141. package/src/index.ts +5 -3
  142. package/src/models/args/TweetListArgs.ts +2 -2
  143. package/src/models/args/UserListArgs.ts +1 -1
  144. package/src/models/data/Tweet.ts +3 -3
  145. package/src/models/data/User.ts +2 -2
  146. package/src/services/data/TweetService.ts +45 -72
  147. package/src/services/data/UserService.ts +61 -71
  148. package/src/services/helper/Headers.ts +34 -34
  149. package/src/services/helper/Parser.ts +5 -26
  150. package/src/services/helper/extractors/Tweets.ts +35 -97
  151. package/src/services/helper/extractors/Users.ts +11 -62
  152. package/src/services/util/FetcherService.ts +15 -22
  153. package/src/types/Args.ts +0 -37
  154. package/Dockerfile +0 -9
  155. package/dist/Test.d.ts +0 -0
  156. package/dist/Test.js +0 -2
  157. package/dist/Test.js.map +0 -1
  158. package/dist/endpoints/Endpoints.d.ts +0 -14
  159. package/dist/endpoints/Endpoints.js +0 -20
  160. package/dist/endpoints/Endpoints.js.map +0 -1
  161. package/dist/endpoints/Url.d.ts +0 -5
  162. package/dist/endpoints/Url.js +0 -12
  163. package/dist/endpoints/Url.js.map +0 -1
  164. package/dist/enums/Endpoints.d.ts +0 -25
  165. package/dist/enums/Endpoints.js +0 -31
  166. package/dist/enums/Endpoints.js.map +0 -1
  167. package/dist/graphql/types/Errors.d.ts +0 -20
  168. package/dist/graphql/types/Errors.js +0 -28
  169. package/dist/graphql/types/Errors.js.map +0 -1
  170. package/dist/middlewares/Authentication.d.ts +0 -0
  171. package/dist/middlewares/Authentication.js +0 -2
  172. package/dist/middlewares/Authentication.js.map +0 -1
  173. package/dist/models/args/TweetFilter.d.ts +0 -59
  174. package/dist/models/args/TweetFilter.js +0 -101
  175. package/dist/models/args/TweetFilter.js.map +0 -1
  176. package/dist/models/data/DataValidationError.d.ts +0 -18
  177. package/dist/models/data/DataValidationError.js +0 -21
  178. package/dist/models/data/DataValidationError.js.map +0 -1
  179. package/dist/models/data/Errors.d.ts +0 -18
  180. package/dist/models/data/Errors.js +0 -21
  181. package/dist/models/data/Errors.js.map +0 -1
  182. package/dist/models/data/Service.d.ts +0 -33
  183. package/dist/models/data/Service.js +0 -41
  184. package/dist/models/data/Service.js.map +0 -1
  185. package/dist/models/errors/DataValidationError.d.ts +0 -20
  186. package/dist/models/errors/DataValidationError.js +0 -23
  187. package/dist/models/errors/DataValidationError.js.map +0 -1
  188. package/dist/models/graphql/Global.d.ts +0 -4
  189. package/dist/models/graphql/Global.js +0 -13
  190. package/dist/models/graphql/Global.js.map +0 -1
  191. package/dist/models/graphql/TweetTypes.d.ts +0 -6
  192. package/dist/models/graphql/TweetTypes.js +0 -156
  193. package/dist/models/graphql/TweetTypes.js.map +0 -1
  194. package/dist/models/graphql/UserTypes.d.ts +0 -3
  195. package/dist/models/graphql/UserTypes.js +0 -139
  196. package/dist/models/graphql/UserTypes.js.map +0 -1
  197. package/dist/models/query/Variables.d.ts +0 -2
  198. package/dist/models/query/Variables.js +0 -10
  199. package/dist/models/query/Variables.js.map +0 -1
  200. package/dist/queries/RootQuery.d.ts +0 -4
  201. package/dist/queries/RootQuery.js +0 -70
  202. package/dist/queries/RootQuery.js.map +0 -1
  203. package/dist/requests/Url.d.ts +0 -5
  204. package/dist/requests/Url.js +0 -12
  205. package/dist/requests/Url.js.map +0 -1
  206. package/dist/requests/payloads/Variables.d.ts +0 -23
  207. package/dist/requests/payloads/Variables.js +0 -24
  208. package/dist/requests/payloads/Variables.js.map +0 -1
  209. package/dist/resolvers/AccountResolver.d.ts +0 -12
  210. package/dist/resolvers/AccountResolver.js +0 -84
  211. package/dist/resolvers/AccountResolver.js.map +0 -1
  212. package/dist/resolvers/ResolverBase.d.ts +0 -5
  213. package/dist/resolvers/ResolverBase.js +0 -11
  214. package/dist/resolvers/ResolverBase.js.map +0 -1
  215. package/dist/resolvers/TweetResolver.d.ts +0 -54
  216. package/dist/resolvers/TweetResolver.js +0 -332
  217. package/dist/resolvers/TweetResolver.js.map +0 -1
  218. package/dist/resolvers/UserResolver.d.ts +0 -38
  219. package/dist/resolvers/UserResolver.js +0 -253
  220. package/dist/resolvers/UserResolver.js.map +0 -1
  221. package/dist/services/AuthService.d.ts +0 -22
  222. package/dist/services/AuthService.js +0 -106
  223. package/dist/services/AuthService.js.map +0 -1
  224. package/dist/services/CacheService.d.ts +0 -30
  225. package/dist/services/CacheService.js +0 -93
  226. package/dist/services/CacheService.js.map +0 -1
  227. package/dist/services/FetcherService.d.ts +0 -61
  228. package/dist/services/FetcherService.js +0 -209
  229. package/dist/services/FetcherService.js.map +0 -1
  230. package/dist/services/accounts/AccountService.d.ts +0 -65
  231. package/dist/services/accounts/AccountService.js +0 -336
  232. package/dist/services/accounts/AccountService.js.map +0 -1
  233. package/dist/services/accounts/LoginFlows.d.ts +0 -77
  234. package/dist/services/accounts/LoginFlows.js +0 -92
  235. package/dist/services/accounts/LoginFlows.js.map +0 -1
  236. package/dist/services/auth/LoginFlows.d.ts +0 -77
  237. package/dist/services/auth/LoginFlows.js +0 -92
  238. package/dist/services/auth/LoginFlows.js.map +0 -1
  239. package/dist/services/data/TrendService.d.ts +0 -17
  240. package/dist/services/data/TrendService.js +0 -116
  241. package/dist/services/data/TrendService.js.map +0 -1
  242. package/dist/services/data/UserAccountService.d.ts +0 -42
  243. package/dist/services/data/UserAccountService.js +0 -239
  244. package/dist/services/data/UserAccountService.js.map +0 -1
  245. package/dist/services/helper/Deserializers.d.ts +0 -19
  246. package/dist/services/helper/Deserializers.js +0 -115
  247. package/dist/services/helper/Deserializers.js.map +0 -1
  248. package/dist/services/helper/Extractors.d.ts +0 -104
  249. package/dist/services/helper/Extractors.js +0 -432
  250. package/dist/services/helper/Extractors.js.map +0 -1
  251. package/dist/services/helper/Urls.d.ts +0 -85
  252. package/dist/services/helper/Urls.js +0 -130
  253. package/dist/services/helper/Urls.js.map +0 -1
  254. package/dist/services/helper/deserializers/Tweets.d.ts +0 -12
  255. package/dist/services/helper/deserializers/Tweets.js +0 -92
  256. package/dist/services/helper/deserializers/Tweets.js.map +0 -1
  257. package/dist/services/helper/deserializers/Users.d.ts +0 -7
  258. package/dist/services/helper/deserializers/Users.js +0 -27
  259. package/dist/services/helper/deserializers/Users.js.map +0 -1
  260. package/dist/services/helper/extractors/Trends.d.ts +0 -3
  261. package/dist/services/helper/extractors/Trends.js +0 -51
  262. package/dist/services/helper/extractors/Trends.js.map +0 -1
  263. package/dist/services/helper/urls/Trends.d.ts +0 -7
  264. package/dist/services/helper/urls/Trends.js +0 -13
  265. package/dist/services/helper/urls/Trends.js.map +0 -1
  266. package/dist/services/helper/urls/Tweets.d.ts +0 -32
  267. package/dist/services/helper/urls/Tweets.js +0 -51
  268. package/dist/services/helper/urls/Tweets.js.map +0 -1
  269. package/dist/services/helper/urls/Users.d.ts +0 -38
  270. package/dist/services/helper/urls/Users.js +0 -76
  271. package/dist/services/helper/urls/Users.js.map +0 -1
  272. package/dist/types/HTTP.d.ts +0 -17
  273. package/dist/types/HTTP.js +0 -23
  274. package/dist/types/HTTP.js.map +0 -1
  275. package/dist/types/Query.d.ts +0 -80
  276. package/dist/types/Query.js +0 -3
  277. package/dist/types/Query.js.map +0 -1
  278. package/dist/types/Trends.d.ts +0 -50
  279. package/dist/types/Trends.js +0 -3
  280. package/dist/types/Trends.js.map +0 -1
  281. package/dist/types/UserAccount.d.ts +0 -19
  282. package/dist/types/UserAccount.js +0 -4
  283. package/dist/types/UserAccount.js.map +0 -1
  284. package/dist/types/args/TweetFilter.d.ts +0 -54
  285. package/dist/types/args/TweetFilter.js +0 -96
  286. package/dist/types/args/TweetFilter.js.map +0 -1
  287. package/dist/types/args/TweetListArg.d.ts +0 -10
  288. package/dist/types/args/TweetListArg.js +0 -42
  289. package/dist/types/args/TweetListArg.js.map +0 -1
  290. package/dist/types/args/TweetListArgs.d.ts +0 -20
  291. package/dist/types/args/TweetListArgs.js +0 -52
  292. package/dist/types/args/TweetListArgs.js.map +0 -1
  293. package/dist/types/args/UserListArgs.d.ts +0 -16
  294. package/dist/types/args/UserListArgs.js +0 -48
  295. package/dist/types/args/UserListArgs.js.map +0 -1
  296. package/dist/types/data/Errors.d.ts +0 -35
  297. package/dist/types/data/Errors.js +0 -45
  298. package/dist/types/data/Errors.js.map +0 -1
  299. package/dist/types/data/Service.d.ts +0 -43
  300. package/dist/types/data/Service.js +0 -22
  301. package/dist/types/data/Service.js.map +0 -1
  302. package/dist/types/data/Tweet.d.ts +0 -98
  303. package/dist/types/data/Tweet.js +0 -4
  304. package/dist/types/data/Tweet.js.map +0 -1
  305. package/dist/types/data/TweetFilter.d.ts +0 -49
  306. package/dist/types/data/TweetFilter.js +0 -63
  307. package/dist/types/data/TweetFilter.js.map +0 -1
  308. package/dist/types/data/User.d.ts +0 -38
  309. package/dist/types/data/User.js +0 -3
  310. package/dist/types/data/User.js.map +0 -1
  311. package/dist/types/graphql/Errors.d.ts +0 -15
  312. package/dist/types/graphql/Errors.js +0 -23
  313. package/dist/types/graphql/Errors.js.map +0 -1
  314. package/dist/types/interfaces/Args.d.ts +0 -38
  315. package/dist/types/interfaces/Args.js +0 -5
  316. package/dist/types/interfaces/Args.js.map +0 -1
  317. package/dist/types/interfaces/Authentication.d.ts +0 -40
  318. package/dist/types/interfaces/Authentication.js +0 -5
  319. package/dist/types/interfaces/Authentication.js.map +0 -1
  320. package/dist/types/interfaces/Resolvers.d.ts +0 -14
  321. package/dist/types/interfaces/Resolvers.js +0 -3
  322. package/dist/types/interfaces/Resolvers.js.map +0 -1
  323. package/dist/types/interfaces/Rettiwt.d.ts +0 -16
  324. package/dist/types/interfaces/Rettiwt.js +0 -3
  325. package/dist/types/interfaces/Rettiwt.js.map +0 -1
  326. package/dist/types/interfaces/Service.d.ts +0 -13
  327. package/dist/types/interfaces/Service.js +0 -3
  328. package/dist/types/interfaces/Service.js.map +0 -1
  329. package/dist/types/interfaces/Services.d.ts +0 -13
  330. package/dist/types/interfaces/Services.js +0 -3
  331. package/dist/types/interfaces/Services.js.map +0 -1
  332. package/dist/types/interfaces/Tweet.d.ts +0 -46
  333. package/dist/types/interfaces/Tweet.js +0 -3
  334. package/dist/types/interfaces/Tweet.js.map +0 -1
  335. package/dist/types/interfaces/TweetFilter.d.ts +0 -0
  336. package/dist/types/interfaces/TweetFilter.js +0 -2
  337. package/dist/types/interfaces/TweetFilter.js.map +0 -1
  338. package/dist/types/interfaces/User.d.ts +0 -35
  339. package/dist/types/interfaces/User.js +0 -3
  340. package/dist/types/interfaces/User.js.map +0 -1
  341. package/dist/types/raw/auth/Cookie.d.ts +0 -16
  342. package/dist/types/raw/auth/Cookie.js +0 -3
  343. package/dist/types/raw/auth/Cookie.js.map +0 -1
  344. package/dist/types/raw/data/tweet/Favouriters.d.ts +0 -164
  345. package/dist/types/raw/data/tweet/Favouriters.js +0 -3
  346. package/dist/types/raw/data/tweet/Favouriters.js.map +0 -1
  347. package/dist/types/raw/data/tweet/Retweeters.d.ts +0 -171
  348. package/dist/types/raw/data/tweet/Retweeters.js +0 -3
  349. package/dist/types/raw/data/tweet/Retweeters.js.map +0 -1
  350. package/dist/types/raw/data/tweet/Tweet.d.ts +0 -746
  351. package/dist/types/raw/data/tweet/Tweet.js +0 -3
  352. package/dist/types/raw/data/tweet/Tweet.js.map +0 -1
  353. package/dist/types/raw/data/tweet/Tweets.d.ts +0 -386
  354. package/dist/types/raw/data/tweet/Tweets.js +0 -3
  355. package/dist/types/raw/data/tweet/Tweets.js.map +0 -1
  356. package/dist/types/raw/data/user/Followers.d.ts +0 -176
  357. package/dist/types/raw/data/user/Followers.js +0 -3
  358. package/dist/types/raw/data/user/Followers.js.map +0 -1
  359. package/dist/types/raw/data/user/Following.d.ts +0 -176
  360. package/dist/types/raw/data/user/Following.js +0 -3
  361. package/dist/types/raw/data/user/Following.js.map +0 -1
  362. package/dist/types/raw/data/user/Likes.d.ts +0 -1059
  363. package/dist/types/raw/data/user/Likes.js +0 -3
  364. package/dist/types/raw/data/user/Likes.js.map +0 -1
  365. package/dist/types/raw/data/user/User.d.ts +0 -117
  366. package/dist/types/raw/data/user/User.js +0 -3
  367. package/dist/types/raw/data/user/User.js.map +0 -1
  368. package/dist/types/raw/general/Trends.d.ts +0 -324
  369. package/dist/types/raw/general/Trends.js +0 -3
  370. package/dist/types/raw/general/Trends.js.map +0 -1
  371. package/dist/types/raw/query/tweet/Details.d.ts +0 -80
  372. package/dist/types/raw/query/tweet/Details.js +0 -5
  373. package/dist/types/raw/query/tweet/Details.js.map +0 -1
  374. package/dist/types/raw/query/tweet/Engagements.d.ts +0 -29
  375. package/dist/types/raw/query/tweet/Engagements.js +0 -3
  376. package/dist/types/raw/query/tweet/Engagements.js.map +0 -1
  377. package/dist/types/raw/query/tweet/Likes.d.ts +0 -29
  378. package/dist/types/raw/query/tweet/Likes.js +0 -3
  379. package/dist/types/raw/query/tweet/Likes.js.map +0 -1
  380. package/dist/types/raw/query/tweet/Retweets.d.ts +0 -29
  381. package/dist/types/raw/query/tweet/Retweets.js +0 -3
  382. package/dist/types/raw/query/tweet/Retweets.js.map +0 -1
  383. package/dist/types/raw/query/tweet/Search.d.ts +0 -40
  384. package/dist/types/raw/query/tweet/Search.js +0 -3
  385. package/dist/types/raw/query/tweet/Search.js.map +0 -1
  386. package/dist/types/raw/query/tweet/TweetDetails.d.ts +0 -34
  387. package/dist/types/raw/query/tweet/TweetDetails.js +0 -5
  388. package/dist/types/raw/query/tweet/TweetDetails.js.map +0 -1
  389. package/dist/types/raw/query/tweet/TweetLike.d.ts +0 -29
  390. package/dist/types/raw/query/tweet/TweetLike.js +0 -3
  391. package/dist/types/raw/query/tweet/TweetLike.js.map +0 -1
  392. package/dist/types/raw/query/tweet/TweetLikes.d.ts +0 -29
  393. package/dist/types/raw/query/tweet/TweetLikes.js +0 -3
  394. package/dist/types/raw/query/tweet/TweetLikes.js.map +0 -1
  395. package/dist/types/raw/query/tweet/TweetRetweets.d.ts +0 -0
  396. package/dist/types/raw/query/tweet/TweetRetweets.js +0 -2
  397. package/dist/types/raw/query/tweet/TweetRetweets.js.map +0 -1
  398. package/dist/types/raw/query/user/Details.d.ts +0 -34
  399. package/dist/types/raw/query/user/Details.js +0 -3
  400. package/dist/types/raw/query/user/Details.js.map +0 -1
  401. package/dist/types/raw/tweet/Favouriters.d.ts +0 -164
  402. package/dist/types/raw/tweet/Favouriters.js +0 -3
  403. package/dist/types/raw/tweet/Favouriters.js.map +0 -1
  404. package/dist/types/raw/tweet/Retweeters.d.ts +0 -171
  405. package/dist/types/raw/tweet/Retweeters.js +0 -3
  406. package/dist/types/raw/tweet/Retweeters.js.map +0 -1
  407. package/dist/types/raw/tweet/Tweet.d.ts +0 -746
  408. package/dist/types/raw/tweet/Tweet.js +0 -3
  409. package/dist/types/raw/tweet/Tweet.js.map +0 -1
  410. package/dist/types/raw/tweet/Tweets.d.ts +0 -386
  411. package/dist/types/raw/tweet/Tweets.js +0 -3
  412. package/dist/types/raw/tweet/Tweets.js.map +0 -1
  413. package/dist/types/raw/user/Followers.d.ts +0 -176
  414. package/dist/types/raw/user/Followers.js +0 -3
  415. package/dist/types/raw/user/Followers.js.map +0 -1
  416. package/dist/types/raw/user/Following.d.ts +0 -176
  417. package/dist/types/raw/user/Following.js +0 -3
  418. package/dist/types/raw/user/Following.js.map +0 -1
  419. package/dist/types/raw/user/Likes.d.ts +0 -1059
  420. package/dist/types/raw/user/Likes.js +0 -3
  421. package/dist/types/raw/user/Likes.js.map +0 -1
  422. package/dist/types/raw/user/Tweets.d.ts +0 -1512
  423. package/dist/types/raw/user/Tweets.js +0 -3
  424. package/dist/types/raw/user/Tweets.js.map +0 -1
  425. package/dist/types/raw/user/User.d.ts +0 -117
  426. package/dist/types/raw/user/User.js +0 -3
  427. package/dist/types/raw/user/User.js.map +0 -1
  428. package/dist/types/services/args/TweetFilter.d.ts +0 -50
  429. package/dist/types/services/args/TweetFilter.js +0 -76
  430. package/dist/types/services/args/TweetFilter.js.map +0 -1
  431. package/src/models/args/TweetFilter.ts +0 -119
  432. package/src/models/errors/DataValidationError.ts +0 -29
  433. package/src/services/helper/urls/Tweets.ts +0 -46
  434. package/src/services/helper/urls/Users.ts +0 -78
  435. package/src/types/raw/tweet/Favouriters.ts +0 -193
  436. package/src/types/raw/tweet/Retweeters.ts +0 -201
  437. package/src/types/raw/tweet/Tweet.ts +0 -882
  438. package/src/types/raw/tweet/Tweets.ts +0 -444
  439. package/src/types/raw/user/Followers.ts +0 -208
  440. package/src/types/raw/user/Following.ts +0 -208
  441. package/src/types/raw/user/Likes.ts +0 -1247
  442. package/src/types/raw/user/Tweets.ts +0 -1747
  443. package/src/types/raw/user/User.ts +0 -135
@@ -29,13 +29,13 @@ export default class UserResolver extends ResolverBase {
29
29
 
30
30
  /**
31
31
  * @returns The list of tweets made by the given user
32
- * @param id The id of the user whose tweets are to be fetched
33
- * @param count The number of tweets to fetch, must be >= 40
32
+ * @param userName The username of the user whose tweets are to be fetched
33
+ * @param count The number of tweets to fetch, must be >= 10
34
34
  * @param all Whether to fetch list of all tweets made by user
35
35
  * @param cursor The cursor to the batch of tweets to fetch
36
36
  * @param statusesCount The total number of tweets made by target user
37
37
  */
38
- async resolveUserTweets(id: string, count: number, all: boolean, cursor: string, statusesCount: number): Promise<any> {
38
+ async resolveUserTweets(userName: string, count: number, all: boolean, cursor: string, statusesCount: number): Promise<any> {
39
39
  let likes: any[] = []; // To store the list of tweets
40
40
  let next: Cursor = new Cursor(cursor); // To store cursor to next batch
41
41
  let total: number = 0; // To store the total number of tweets fetched
@@ -52,7 +52,7 @@ export default class UserResolver extends ResolverBase {
52
52
  this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
53
53
 
54
54
  // Getting the data
55
- const res = await this.context.users.getUserTweets(id, this.batchSize, next.value).catch(error => {
55
+ const res = await this.context.tweets.getTweets({ fromUsers: [userName] }, this.batchSize, next.value).catch(error => {
56
56
  throw this.getGraphQLError(error);
57
57
  });
58
58
 
@@ -1,10 +1,10 @@
1
1
  // PACKAGE
2
2
  import { GraphQLBoolean, GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLList, GraphQLUnionType, GraphQLType } from 'graphql';
3
+ import { TweetFilter } from 'rettiwt-core';
3
4
 
4
5
  // TYPES
5
6
  import { Tweet, TweetList } from './TweetTypes'
6
7
  import { Cursor } from './Global';
7
- import { TweetFilter } from '../../models/args/TweetFilter';
8
8
 
9
9
  // RESOLVERS
10
10
  import UserResolver from '../resolvers/UserResolver';
@@ -113,7 +113,7 @@ export const User: GraphQLObjectType = new GraphQLObjectType({
113
113
  defaultValue: ''
114
114
  }
115
115
  },
116
- resolve: (parent, args, context) => new UserResolver(context).resolveUserTweets(parent.id, args.count, args.all, args.cursor, parent.statusesCount)
116
+ resolve: (parent, args, context) => new UserResolver(context).resolveUserTweets(parent.userName, args.count, args.all, args.cursor, parent.statusesCount)
117
117
  }
118
118
  })
119
119
  });
package/src/index.ts CHANGED
@@ -44,19 +44,21 @@ export * from './services/util/CacheService';
44
44
  export * from './services/util/FetcherService';
45
45
 
46
46
  // Exporting types
47
+ export { ITweetFilter } from 'rettiwt-core';
47
48
  export * from './types/Args';
48
49
  export { IAuthCookie } from './types/Authentication';
49
50
  export * from './types/Rettiwt';
50
51
  export * from './types/Service';
51
52
  export * from './types/Tweet';
52
53
  export * from './types/User';
54
+ export { IDataValidationError } from 'rettiwt-core';
53
55
 
54
56
  // Exporting models
55
- export * from './models/args/TweetFilter';
57
+ export { TweetFilter } from 'rettiwt-core';
56
58
  export * from './models/args/TweetListArgs';
57
59
  export * from './models/args/UserListArgs';
58
- export * from './models/auth/AuthCookie';
60
+ export { AuthCookie } from './models/auth/AuthCookie';
59
61
  export * from './models/data/CursoredData';
60
62
  export * from './models/data/Tweet';
61
63
  export * from './models/data/User';
62
- export * from './models/errors/DataValidationError';
64
+ export { DataValidationError } from 'rettiwt-core';
@@ -1,9 +1,9 @@
1
1
  // PACKAGES
2
2
  import { IsInt, IsString, IsOptional, Min, validateSync, Max, ValidateIf } from 'class-validator';
3
+ import { DataValidationError } from 'rettiwt-core';
3
4
 
4
5
  // TYPES
5
6
  import { IListArgs } from '../../types/Args';
6
- import { DataValidationError } from '../errors/DataValidationError';
7
7
 
8
8
  /**
9
9
  * The arguments for fetching cursored list in TweetService.
@@ -20,7 +20,7 @@ export class TweetListArgs implements IListArgs {
20
20
  @IsOptional()
21
21
  @Max(100)
22
22
  @ValidateIf(ob => ob.cursor.length == 0)
23
- @Min(10)
23
+ @Min(10)
24
24
  count: number;
25
25
 
26
26
  /** The cursor to the batch of data to fetch. */
@@ -1,9 +1,9 @@
1
1
  // PACKAGES
2
2
  import { IsInt, IsString, IsOptional, Min, validateSync, Max, ValidateIf } from 'class-validator';
3
+ import { DataValidationError } from 'rettiwt-core';
3
4
 
4
5
  // TYPES
5
6
  import { IListArgs } from '../../types/Args';
6
- import { DataValidationError } from '../errors/DataValidationError';
7
7
 
8
8
  /**
9
9
  * The arguments for fetching cursored list in TweetService.
@@ -1,6 +1,6 @@
1
1
  // TYPES
2
2
  import { ITweet, ITweetEntities } from '../../types/Tweet';
3
- import { Result as RawTweet, Entities2 as RawTweetEntities } from '../../types/raw/tweet/Tweet';
3
+ import { ITweet as IRawTweet, IEntities as IRawTweetEntities } from 'rettiwt-core';
4
4
 
5
5
  // PARSERS
6
6
  import * as Parsers from '../../services/helper/Parser';
@@ -25,7 +25,7 @@ export class TweetEntities implements ITweetEntities {
25
25
  media: string[] = [];
26
26
 
27
27
  // MEMBER METHODS
28
- constructor(entities: RawTweetEntities) {
28
+ constructor(entities: IRawTweetEntities) {
29
29
  // Extracting user mentions
30
30
  if (entities.user_mentions) {
31
31
  for (let user of entities.user_mentions) {
@@ -101,7 +101,7 @@ export class Tweet implements ITweet {
101
101
  /**
102
102
  * @param tweet The raw tweet data.
103
103
  */
104
- constructor(tweet: RawTweet) {
104
+ constructor(tweet: IRawTweet) {
105
105
  this.id = tweet.rest_id;
106
106
  this.createdAt = tweet.legacy.created_at;
107
107
  this.tweetBy = tweet.legacy.user_id_str;
@@ -1,6 +1,6 @@
1
1
  // TYPES
2
2
  import { IUser } from '../../types/User';
3
- import { Result as RawUser } from '../../types/raw/user/User';
3
+ import { IUser as IRawUser } from 'rettiwt-core';
4
4
 
5
5
  /**
6
6
  * The details of a single user.
@@ -53,7 +53,7 @@ export class User implements IUser {
53
53
  /**
54
54
  * @param user The raw user data.
55
55
  */
56
- constructor(user: RawUser) {
56
+ constructor(user: IRawUser) {
57
57
  this.id = user.rest_id;
58
58
  this.userName = user.legacy.screen_name;
59
59
  this.fullName = user.legacy.name;
@@ -1,3 +1,16 @@
1
+ // PACKAGES
2
+ import {
3
+ Url,
4
+ EResourceType,
5
+ ITweetSearchResponse,
6
+ ITweetDetailsResponse,
7
+ ITweetFavoritersResponse,
8
+ ITweetRetweetersResponse,
9
+ ITweet as IRawTweet,
10
+ IUser as IRawUser,
11
+ TweetFilter
12
+ } from 'rettiwt-core';
13
+
1
14
  // SERVICES
2
15
  import { FetcherService } from "../util/FetcherService";
3
16
  import { AuthService } from "../auth/AuthService";
@@ -6,28 +19,14 @@ import { AuthService } from "../auth/AuthService";
6
19
  import { Tweet } from "../../models/data/Tweet";
7
20
  import { User } from "../../models/data/User";
8
21
  import { TweetListArgs } from "../../models/args/TweetListArgs";
9
- import { TweetFilter } from "../../models/args/TweetFilter";
10
22
  import { CursoredData } from '../../models/data/CursoredData';
11
23
 
12
- // TYPES
13
- import RawTweet, { Result as TweetData } from '../../types/raw/tweet/Tweet';
14
- import { Result as UserData } from "../../types/raw/user/User";
15
- import RawTweets from '../../types/raw/tweet/Tweets';
16
- import RawLikers from '../../types/raw/tweet/Favouriters';
17
- import RawRetweeters from '../../types/raw/tweet/Retweeters';
18
-
19
24
  // ENUMS
20
25
  import { AuthenticationErrors } from '../../enums/Errors';
21
26
 
22
- // URLS
23
- import * as TweetUrls from '../helper/urls/Tweets';
24
-
25
27
  // EXTRACTORS
26
28
  import * as TweetExtractors from "../helper/extractors/Tweets";
27
29
 
28
- // PARSERS
29
- import { toQueryString } from '../helper/Parser';
30
-
31
30
  /**
32
31
  * Handles fetching of data related to tweets.
33
32
  * @public
@@ -42,24 +41,29 @@ export class TweetService extends FetcherService {
42
41
 
43
42
  /**
44
43
  * @param filter The filter be used for searching the tweets.
45
- * @param count The number of tweets to fetch, must be >= 10 and <= 20
44
+ * @param count The number of tweets to fetch, must be >= 10 (when no cursor is provided) and <= 20
46
45
  * @param cursor The cursor to the next batch of tweets. If blank, first batch is fetched.
47
46
  *
48
47
  * @returns The list of tweets that match the given filter.
49
48
  *
49
+ * @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
50
50
  * @throws {@link Errors.ValidationErrors.InvalidCount} error, if an invalid count has been provided.
51
- *
52
- * @remarks
53
- *
54
- * Cookies are required to use this method!
55
51
  */
56
52
  async getTweets(query: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
53
+ // If user is not authenticated, abort
54
+ if (!this.isAuthenticated) {
55
+ throw new Error(AuthenticationErrors.NotAuthenticated);
56
+ }
57
+
57
58
  // Objectifying parameters
58
59
  let filter: TweetFilter = new TweetFilter(query);
59
60
  let args: TweetListArgs = new TweetListArgs(count, cursor);
60
61
 
62
+ // Preparing the URL
63
+ const url: string = new Url(EResourceType.TWEET_SEARCH, { filter: filter.toString(), count: args.count, cursor: args.cursor }).toString();
64
+
61
65
  // Getting the raw data
62
- let res = await this.request<RawTweets>(TweetUrls.tweetsUrl(toQueryString(filter), args.count, args.cursor), this.isAuthenticated).then(res => res.data);
66
+ let res = await this.request<ITweetSearchResponse>(url).then(res => res.data);
63
67
 
64
68
  // Extracting data
65
69
  let data = TweetExtractors.extractTweets(res);
@@ -68,7 +72,7 @@ export class TweetService extends FetcherService {
68
72
  this.cacheData(data);
69
73
 
70
74
  // Parsing data
71
- let tweets = data.required.map((item: TweetData) => new Tweet(item));
75
+ let tweets = data.required.map((item: IRawTweet) => new Tweet(item));
72
76
 
73
77
  // Sorting the tweets by date, from recent to oldest
74
78
  tweets.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
@@ -81,13 +85,15 @@ export class TweetService extends FetcherService {
81
85
  *
82
86
  * @returns The details of a single tweet with the given tweet id.
83
87
  *
88
+ * @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
84
89
  * @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
85
- *
86
- * @remarks
87
- *
88
- * No cookies are required to use this method.
89
90
  */
90
91
  async getTweetDetails(id: string): Promise<Tweet> {
92
+ // If user is not authenticated, abort
93
+ if (!this.isAuthenticated) {
94
+ throw new Error(AuthenticationErrors.NotAuthenticated);
95
+ }
96
+
91
97
  // Getting data from cache
92
98
  let cachedData = await this.readData(id);
93
99
 
@@ -96,8 +102,11 @@ export class TweetService extends FetcherService {
96
102
  return cachedData;
97
103
  }
98
104
 
105
+ // Preparing the URL
106
+ const url: string = new Url(EResourceType.TWEET_DETAILS, { id: id }).toString();
107
+
99
108
  // Fetching the raw data
100
- let res = await this.request<RawTweet>(TweetUrls.tweetDetailsUrl(id), false).then(res => res.data);
109
+ let res = await this.request<ITweetDetailsResponse>(url).then(res => res.data);
101
110
 
102
111
  // Extracting data
103
112
  let data = TweetExtractors.extractTweet(res, id);
@@ -121,10 +130,6 @@ export class TweetService extends FetcherService {
121
130
  * @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
122
131
  * @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count is provided.
123
132
  * @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
124
- *
125
- * @remarks
126
- *
127
- * Cookies are required to use this method!
128
133
  */
129
134
  async getTweetLikers(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
130
135
  // If user is not authenticated, abort
@@ -135,8 +140,11 @@ export class TweetService extends FetcherService {
135
140
  // Objectifying parameters
136
141
  let args: TweetListArgs = new TweetListArgs(count, cursor);
137
142
 
143
+ // Preparing the URL
144
+ const url: string = new Url(EResourceType.TWEET_FAVORITERS, { id: tweetId, count: args.count, cursor: args.cursor }).toString();
145
+
138
146
  // Fetching the raw data
139
- let res = await this.request<RawLikers>(TweetUrls.tweetLikesUrl(tweetId, args.count, args.cursor)).then(res => res.data);
147
+ let res = await this.request<ITweetFavoritersResponse>(url).then(res => res.data);
140
148
 
141
149
  // Extracting data
142
150
  let data = TweetExtractors.extractTweetLikers(res);
@@ -145,7 +153,7 @@ export class TweetService extends FetcherService {
145
153
  this.cacheData(data);
146
154
 
147
155
  // Parsing data
148
- let users = data.required.map((item: UserData) => new User(item));
156
+ let users = data.required.map((item: IRawUser) => new User(item));
149
157
 
150
158
  return new CursoredData<User>(users, data.cursor);
151
159
  }
@@ -160,10 +168,6 @@ export class TweetService extends FetcherService {
160
168
  * @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
161
169
  * @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count is provided.
162
170
  * @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
163
- *
164
- * @remarks
165
- *
166
- * Cookies are required to use this method!
167
171
  */
168
172
  async getTweetRetweeters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
169
173
  // If user is not authenticated, abort
@@ -174,8 +178,11 @@ export class TweetService extends FetcherService {
174
178
  // Objectifying parameters
175
179
  let args: TweetListArgs = new TweetListArgs(count, cursor);
176
180
 
181
+ // Preparing the URL
182
+ const url: string = new Url(EResourceType.TWEET_RETWEETERS, { id: tweetId, count: args.count, cursor: args.cursor }).toString();
183
+
177
184
  // Fetching the raw data
178
- let res = await this.request<RawRetweeters>(TweetUrls.tweetRetweetUrl(tweetId, args.count, args.cursor)).then(res => res.data);
185
+ let res = await this.request<ITweetRetweetersResponse>(url).then(res => res.data);
179
186
 
180
187
  // Extracting data
181
188
  let data = TweetExtractors.extractTweetRetweeters(res);
@@ -184,42 +191,8 @@ export class TweetService extends FetcherService {
184
191
  this.cacheData(data);
185
192
 
186
193
  // Parsing data
187
- let users = data.required.map((item: UserData) => new User(item));
194
+ let users = data.required.map((item: IRawUser) => new User(item));
188
195
 
189
196
  return new CursoredData<User>(users, data.cursor);
190
197
  }
191
-
192
- /**
193
- * THIS IS DISABLED FOR USE FOR NOW BECAUSE TWITTER DOESN'T HAVE ANY ENDPOINT FOR FETCHING REPLIES.
194
- * THE DATA THIS RETURNS IS INCONSISTENT!
195
- *
196
- * @param tweetId The rest id of the target tweet.
197
- * @param cursor The cursor to the next batch of replies. If blank, first batch is fetched.
198
- * @returns The list of replies to the given tweet.
199
- */
200
- /*
201
- async getTweetReplies(tweetId: string, cursor: string): Promise<CursoredData<Tweet>> {
202
- // If user is not authenticated, abort
203
- if(!this.isAuthenticated) {
204
- throw new Error(Errors.AuthenticationErrors.NotAuthenticated);
205
- }
206
-
207
- // Fetching the raw data
208
- let res = await this.request<RawTweet>(TweetUrls.tweetRepliesUrl(tweetId, cursor)).then(res => res.data);
209
-
210
- // Extracting data
211
- let data = TweetExtractors.extractTweetReplies(res, tweetId);
212
-
213
- // Caching data
214
- this.cacheData(data);
215
-
216
- // Parsing data
217
- let tweets = data.required.map((item: TweetData) => TweetDeserializers.toTweet(item));
218
-
219
- return {
220
- list: tweets,
221
- next: { value: data.cursor }
222
- };
223
- }
224
- */
225
198
  }
@@ -1,3 +1,15 @@
1
+ // PACKAGES
2
+ import {
3
+ Url,
4
+ EResourceType,
5
+ IUserDetailsResponse,
6
+ IUserFollowersResponse,
7
+ IUserFollowingResponse,
8
+ IUserLikesResponse,
9
+ ITweet as IRawTweet,
10
+ IUser as IRawUser
11
+ } from 'rettiwt-core';
12
+
1
13
  // SERVICES
2
14
  import { FetcherService } from '../util/FetcherService';
3
15
  import { AuthService } from '../auth/AuthService';
@@ -9,21 +21,13 @@ import { Tweet } from '../../models/data/Tweet';
9
21
 
10
22
  // TYPES
11
23
  import { CursoredData } from '../../models/data/CursoredData';
12
- import { Result as TweetData } from '../../types/raw/tweet/Tweet';
13
- import RawUser, { Result as UserData } from '../../types/raw/user/User';
14
- import RawUserTweets from '../../types/raw/user/Tweets';
15
- import RawUserFollowers from '../../types/raw/user/Followers';
16
- import RawUserFollowing from '../../types/raw/user/Following';
17
- import RawUserLikes from '../../types/raw/user/Likes';
18
24
 
19
25
  // ENUMS
20
26
  import { AuthenticationErrors } from '../../enums/Errors';
21
27
 
22
- // URLS
23
- import * as UserUrls from '../helper/urls/Users';
24
-
25
28
  // EXTRACTORS
26
29
  import * as UserExtractors from '../helper/extractors/Users';
30
+ import { TweetService } from './TweetService';
27
31
 
28
32
  /**
29
33
  * Handles fetching of data related to user account
@@ -41,44 +45,43 @@ export class UserService extends FetcherService {
41
45
  *
42
46
  * @returns The details of the given user.
43
47
  *
48
+ * @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
44
49
  * @throws {@link Errors.DataErrors.UserNotFound} error, if no user with the given username was found.
45
- *
46
- * @remarks
47
- *
48
- * No cookies are required to use this method.
49
50
  */
50
51
  async getUserDetails(id: string): Promise<User> {
51
- let res: RawUser;
52
+ // If user is not authenticated, abort
53
+ if (!this.isAuthenticated) {
54
+ throw new Error(AuthenticationErrors.NotAuthenticated);
55
+ }
52
56
 
53
- // If id is not a numeric string => username is supplied
54
- if (isNaN(Number(id))) {
55
- // Fetching the raw data
56
- res = await this.request<RawUser>(UserUrls.userDetailsUrl(id), false).then(res => res.data);
57
+ let res: IUserDetailsResponse;
58
+
59
+ // Getting data from cache
60
+ let cachedData = await this.readData(id);
61
+
62
+ // If data exists in cache
63
+ if (cachedData) {
64
+ return cachedData;
57
65
  }
58
- // If id is a numeric string => id is supplied
66
+ // Else, fetch the data from Twitter instead
59
67
  else {
60
- // Getting data from cache
61
- let cachedData = await this.readData(id);
62
-
63
- // If data exists in cache
64
- if (cachedData) {
65
- return cachedData;
66
- }
68
+ // Preparing the URL
69
+ const url: string = new Url(EResourceType.USER_DETAILS, { id: id }).toString();
67
70
 
68
71
  // Fetching the raw data
69
- res = await this.request<RawUser>(UserUrls.userDetailsByIdUrl(id), false).then(res => res.data);
70
- }
72
+ res = await this.request<IUserDetailsResponse>(url).then(res => res.data);
71
73
 
72
- // Extracting data
73
- let data = UserExtractors.extractUserDetails(res);
74
+ // Extracting data
75
+ let data = UserExtractors.extractUserDetails(res);
74
76
 
75
- // Caching data
76
- this.cacheData(data);
77
+ // Caching data
78
+ this.cacheData(data);
77
79
 
78
- // Parsing data
79
- let user = new User(data.required[0]);
80
+ // Parsing data
81
+ let user = new User(data.required[0]);
80
82
 
81
- return user;
83
+ return user;
84
+ }
82
85
  }
83
86
 
84
87
  /**
@@ -88,30 +91,20 @@ export class UserService extends FetcherService {
88
91
  *
89
92
  * @returns The list of tweets nade by the target user.
90
93
  *
94
+ * @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
91
95
  * @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
92
96
  * @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
93
97
  *
94
- * @remarks
95
- *
96
- * No cookies are required to use this method.
98
+ * @deprecated Use [this](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#getTweets) method instead. It's better in every possible way!
97
99
  */
98
100
  async getUserTweets(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
99
- // Objectifying parameters
100
- let args: UserListArgs = new UserListArgs(count, cursor);
101
-
102
- // Fetching the raw data
103
- let res = await this.request<RawUserTweets>(UserUrls.userTweetsUrl(userId, args.count, args.cursor), false).then(res => res.data);
104
-
105
- // Extracting data
106
- let data = UserExtractors.extractUserTweets(res);
107
-
108
- // Caching data
109
- this.cacheData(data);
110
-
111
- // Parsing data
112
- let tweets = data.required.map((item: TweetData) => new Tweet(item));
101
+ // Getting the username of the target user
102
+ const userName: string = (await this.getUserDetails(userId)).userName;
113
103
 
114
- return new CursoredData<Tweet>(tweets, data.cursor);
104
+ // Getting the tweets of the target user
105
+ return new TweetService(this.auth).getTweets({
106
+ fromUsers: [userName]
107
+ }, count, cursor);
115
108
  }
116
109
 
117
110
  /**
@@ -124,10 +117,6 @@ export class UserService extends FetcherService {
124
117
  * @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
125
118
  * @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
126
119
  * @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
127
- *
128
- * @remarks
129
- *
130
- * Cookies are required to use this method!
131
120
  */
132
121
  async getUserFollowing(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
133
122
  // If user is not authenticated, abort
@@ -138,8 +127,11 @@ export class UserService extends FetcherService {
138
127
  // Objectifying parameters
139
128
  let args: UserListArgs = new UserListArgs(count, cursor);
140
129
 
130
+ // Preparing the URL
131
+ const url: string = new Url(EResourceType.USER_FOLLOWING, { id: userId, count: args.count, cursor: args.cursor }).toString();
132
+
141
133
  // Fetchin the raw data
142
- let res = await this.request<RawUserFollowing>(UserUrls.userFollowingUrl(userId, args.count, args.cursor)).then(res => res.data);
134
+ let res = await this.request<IUserFollowingResponse>(url).then(res => res.data);
143
135
 
144
136
  // Extracting data
145
137
  let data = UserExtractors.extractUserFollow(res);
@@ -148,7 +140,7 @@ export class UserService extends FetcherService {
148
140
  this.cacheData(data);
149
141
 
150
142
  // Parsing data
151
- let users = data.required.map((item: UserData) => new User(item));
143
+ let users = data.required.map((item: IRawUser) => new User(item));
152
144
 
153
145
  return new CursoredData<User>(users, data.cursor);
154
146
  }
@@ -163,10 +155,6 @@ export class UserService extends FetcherService {
163
155
  * @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
164
156
  * @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
165
157
  * @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
166
- *
167
- * @remarks
168
- *
169
- * Cookies are required to use this method!
170
158
  */
171
159
  async getUserFollowers(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
172
160
  // If user is not authenticated, abort
@@ -177,8 +165,11 @@ export class UserService extends FetcherService {
177
165
  // Objectifying parameters
178
166
  let args: UserListArgs = new UserListArgs(count, cursor);
179
167
 
168
+ // Preparing the URL
169
+ const url: string = new Url(EResourceType.USER_FOLLOWERS, { id: userId, count: args.count, cursor: args.cursor }).toString();
170
+
180
171
  // Fetching the raw data
181
- let res = await this.request<RawUserFollowers>(UserUrls.userFollowersUrl(userId, args.count, args.cursor)).then(res => res.data);
172
+ let res = await this.request<IUserFollowersResponse>(url).then(res => res.data);
182
173
 
183
174
  // Extracting data
184
175
  let data = UserExtractors.extractUserFollow(res);
@@ -187,7 +178,7 @@ export class UserService extends FetcherService {
187
178
  this.cacheData(data);
188
179
 
189
180
  // Parsing data
190
- let users = data.required.map((item: UserData) => new User(item));
181
+ let users = data.required.map((item: IRawUser) => new User(item));
191
182
 
192
183
  return new CursoredData<User>(users, data.cursor);
193
184
  }
@@ -200,10 +191,6 @@ export class UserService extends FetcherService {
200
191
  * @returns The list of tweets liked by the target user.
201
192
  *
202
193
  * @throws {@link AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
203
- *
204
- * @remarks
205
- *
206
- * Cookies are required to use this method!
207
194
  */
208
195
  async getUserLikes(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
209
196
  // If user is not authenticated, abort
@@ -214,8 +201,11 @@ export class UserService extends FetcherService {
214
201
  // Objectifying parameters
215
202
  let args: UserListArgs = new UserListArgs(count, cursor);
216
203
 
204
+ // Preparing the URL
205
+ const url: string = new Url(EResourceType.USER_LIKES, { id: userId, count: args.count, cursor: args.cursor }).toString();
206
+
217
207
  // Fetching the raw data
218
- let res = await this.request<RawUserLikes>(UserUrls.userLikesUrl(userId, args.count, args.cursor)).then(res => res.data);
208
+ let res = await this.request<IUserLikesResponse>(url).then(res => res.data);
219
209
 
220
210
  // Extracting data
221
211
  let data = UserExtractors.extractUserLikes(res);
@@ -224,7 +214,7 @@ export class UserService extends FetcherService {
224
214
  this.cacheData(data);
225
215
 
226
216
  // Parsing data
227
- let tweets = data.required.map((item: TweetData) => new Tweet(item));
217
+ let tweets = data.required.map((item: IRawTweet) => new Tweet(item));
228
218
 
229
219
  return new CursoredData<Tweet>(tweets, data.cursor);
230
220
  }