nodejs-insta-private-api-mqt 1.3.70

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 (240) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3677 -0
  3. package/dist/constants/constants.js +342 -0
  4. package/dist/constants/index.js +58 -0
  5. package/dist/core/client.js +419 -0
  6. package/dist/core/nav-chain.js +282 -0
  7. package/dist/core/repository.js +7 -0
  8. package/dist/core/request.js +390 -0
  9. package/dist/core/state.js +1473 -0
  10. package/dist/core/utils.js +786 -0
  11. package/dist/downloadMedia.js +381 -0
  12. package/dist/errors/index.d.ts +16 -0
  13. package/dist/errors/index.js +38 -0
  14. package/dist/errors/index.js.map +1 -0
  15. package/dist/extend.js +167 -0
  16. package/dist/fbns/fbns.client.d.ts +32 -0
  17. package/dist/fbns/fbns.client.events.d.ts +41 -0
  18. package/dist/fbns/fbns.client.events.js +3 -0
  19. package/dist/fbns/fbns.client.events.js.map +1 -0
  20. package/dist/fbns/fbns.client.js +252 -0
  21. package/dist/fbns/fbns.client.js.map +1 -0
  22. package/dist/fbns/fbns.device-auth.d.ts +17 -0
  23. package/dist/fbns/fbns.device-auth.js +54 -0
  24. package/dist/fbns/fbns.device-auth.js.map +1 -0
  25. package/dist/fbns/fbns.types.d.ts +83 -0
  26. package/dist/fbns/fbns.types.js +3 -0
  27. package/dist/fbns/fbns.types.js.map +1 -0
  28. package/dist/fbns/fbns.utilities.d.ts +2 -0
  29. package/dist/fbns/fbns.utilities.js +79 -0
  30. package/dist/fbns/fbns.utilities.js.map +1 -0
  31. package/dist/fbns/index.d.ts +4 -0
  32. package/dist/fbns/index.js +21 -0
  33. package/dist/fbns/index.js.map +1 -0
  34. package/dist/index.js +139 -0
  35. package/dist/mqtt-shim.d.ts +96 -0
  36. package/dist/mqtt-shim.js +15 -0
  37. package/dist/mqttot/index.d.ts +4 -0
  38. package/dist/mqttot/index.js +21 -0
  39. package/dist/mqttot/index.js.map +1 -0
  40. package/dist/mqttot/mqttot.client.d.ts +39 -0
  41. package/dist/mqttot/mqttot.client.js +318 -0
  42. package/dist/mqttot/mqttot.client.js.map +1 -0
  43. package/dist/mqttot/mqttot.connect.request.packet.d.ts +7 -0
  44. package/dist/mqttot/mqttot.connect.request.packet.js +9 -0
  45. package/dist/mqttot/mqttot.connect.request.packet.js.map +1 -0
  46. package/dist/mqttot/mqttot.connect.response.packet.d.ts +7 -0
  47. package/dist/mqttot/mqttot.connect.response.packet.js +24 -0
  48. package/dist/mqttot/mqttot.connect.response.packet.js.map +1 -0
  49. package/dist/mqttot/mqttot.connection.d.ts +57 -0
  50. package/dist/mqttot/mqttot.connection.js +79 -0
  51. package/dist/mqttot/mqttot.connection.js.map +1 -0
  52. package/dist/package.json +59 -0
  53. package/dist/realtime/commands/commands.d.ts +15 -0
  54. package/dist/realtime/commands/commands.js +71 -0
  55. package/dist/realtime/commands/commands.js.map +1 -0
  56. package/dist/realtime/commands/direct.commands.d.ts +75 -0
  57. package/dist/realtime/commands/direct.commands.js +417 -0
  58. package/dist/realtime/commands/direct.commands.js.map +1 -0
  59. package/dist/realtime/commands/enhanced.direct.commands.js +1731 -0
  60. package/dist/realtime/commands/enhanced.direct.commands.js.bak +967 -0
  61. package/dist/realtime/commands/index.d.ts +2 -0
  62. package/dist/realtime/commands/index.js +20 -0
  63. package/dist/realtime/commands/index.js.map +1 -0
  64. package/dist/realtime/delta-sync.manager.js +293 -0
  65. package/dist/realtime/features/dm-sender.js +88 -0
  66. package/dist/realtime/features/error-handler.js +185 -0
  67. package/dist/realtime/features/gap-handler.js +61 -0
  68. package/dist/realtime/features/persistent-logger.js +186 -0
  69. package/dist/realtime/features/presence.manager.js +66 -0
  70. package/dist/realtime/features/session-health-monitor.js +345 -0
  71. package/dist/realtime/index.js +30 -0
  72. package/dist/realtime/messages/app-presence.event.d.ts +9 -0
  73. package/dist/realtime/messages/app-presence.event.js +3 -0
  74. package/dist/realtime/messages/app-presence.event.js.map +1 -0
  75. package/dist/realtime/messages/index.d.ts +3 -0
  76. package/dist/realtime/messages/index.js +20 -0
  77. package/dist/realtime/messages/index.js.map +1 -0
  78. package/dist/realtime/messages/message-sync.message.d.ts +222 -0
  79. package/dist/realtime/messages/message-sync.message.js +43 -0
  80. package/dist/realtime/messages/message-sync.message.js.map +1 -0
  81. package/dist/realtime/messages/realtime-sub.direct.data.d.ts +11 -0
  82. package/dist/realtime/messages/realtime-sub.direct.data.js +3 -0
  83. package/dist/realtime/messages/realtime-sub.direct.data.js.map +1 -0
  84. package/dist/realtime/messages/thread-update.message.d.ts +68 -0
  85. package/dist/realtime/messages/thread-update.message.js +3 -0
  86. package/dist/realtime/messages/thread-update.message.js.map +1 -0
  87. package/dist/realtime/mixins/index.d.ts +3 -0
  88. package/dist/realtime/mixins/index.js +20 -0
  89. package/dist/realtime/mixins/index.js.map +1 -0
  90. package/dist/realtime/mixins/message-sync.mixin.d.ts +8 -0
  91. package/dist/realtime/mixins/message-sync.mixin.js +596 -0
  92. package/dist/realtime/mixins/message-sync.mixin.js.map +1 -0
  93. package/dist/realtime/mixins/mixin.d.ts +19 -0
  94. package/dist/realtime/mixins/mixin.js +41 -0
  95. package/dist/realtime/mixins/mixin.js.map +1 -0
  96. package/dist/realtime/mixins/presence-typing.mixin.js +33 -0
  97. package/dist/realtime/mixins/realtime-sub.mixin.d.ts +8 -0
  98. package/dist/realtime/mixins/realtime-sub.mixin.js +181 -0
  99. package/dist/realtime/mixins/realtime-sub.mixin.js.map +1 -0
  100. package/dist/realtime/parsers/graphql-parser.js +43 -0
  101. package/dist/realtime/parsers/graphql.parser.d.ts +15 -0
  102. package/dist/realtime/parsers/graphql.parser.js +22 -0
  103. package/dist/realtime/parsers/graphql.parser.js.map +1 -0
  104. package/dist/realtime/parsers/index.d.ts +6 -0
  105. package/dist/realtime/parsers/index.js +23 -0
  106. package/dist/realtime/parsers/index.js.map +1 -0
  107. package/dist/realtime/parsers/iris-parser.js +43 -0
  108. package/dist/realtime/parsers/iris.parser.d.ts +17 -0
  109. package/dist/realtime/parsers/iris.parser.js +10 -0
  110. package/dist/realtime/parsers/iris.parser.js.map +1 -0
  111. package/dist/realtime/parsers/json-parser.js +43 -0
  112. package/dist/realtime/parsers/json.parser.d.ts +6 -0
  113. package/dist/realtime/parsers/json.parser.js +10 -0
  114. package/dist/realtime/parsers/json.parser.js.map +1 -0
  115. package/dist/realtime/parsers/parser.d.ts +9 -0
  116. package/dist/realtime/parsers/parser.js +3 -0
  117. package/dist/realtime/parsers/parser.js.map +1 -0
  118. package/dist/realtime/parsers/region-hint-parser.js +43 -0
  119. package/dist/realtime/parsers/region-hint.parser.d.ts +12 -0
  120. package/dist/realtime/parsers/region-hint.parser.js +15 -0
  121. package/dist/realtime/parsers/region-hint.parser.js.map +1 -0
  122. package/dist/realtime/parsers/skywalker-parser.js +43 -0
  123. package/dist/realtime/parsers/skywalker.parser.d.ts +12 -0
  124. package/dist/realtime/parsers/skywalker.parser.js +15 -0
  125. package/dist/realtime/parsers/skywalker.parser.js.map +1 -0
  126. package/dist/realtime/parsers-advanced.js +158 -0
  127. package/dist/realtime/proto/common.proto +38 -0
  128. package/dist/realtime/proto/direct.proto +65 -0
  129. package/dist/realtime/proto/ig-messages.proto +83 -0
  130. package/dist/realtime/proto/iris.proto +188 -0
  131. package/dist/realtime/proto-parser.js +195 -0
  132. package/dist/realtime/protocols/iris.handshake.js +74 -0
  133. package/dist/realtime/protocols/proto-definitions.js +80 -0
  134. package/dist/realtime/protocols/skywalker.protocol.js +91 -0
  135. package/dist/realtime/realtime.client.events.js +3 -0
  136. package/dist/realtime/realtime.client.js +1915 -0
  137. package/dist/realtime/realtime.service.js +462 -0
  138. package/dist/realtime/reconnect.manager.js +88 -0
  139. package/dist/realtime/session.manager.js +121 -0
  140. package/dist/realtime/subscriptions/graphql.subscription.d.ts +47 -0
  141. package/dist/realtime/subscriptions/graphql.subscription.js +99 -0
  142. package/dist/realtime/subscriptions/graphql.subscription.js.map +1 -0
  143. package/dist/realtime/subscriptions/index.d.ts +2 -0
  144. package/dist/realtime/subscriptions/index.js +19 -0
  145. package/dist/realtime/subscriptions/index.js.map +1 -0
  146. package/dist/realtime/subscriptions/skywalker.subscription.d.ts +4 -0
  147. package/dist/realtime/subscriptions/skywalker.subscription.js +13 -0
  148. package/dist/realtime/subscriptions/skywalker.subscription.js.map +1 -0
  149. package/dist/realtime/topic-map.js +71 -0
  150. package/dist/realtime/topic.js +80 -0
  151. package/dist/repositories/account.repository.js +575 -0
  152. package/dist/repositories/bloks.repository.js +70 -0
  153. package/dist/repositories/captcha.repository.js +44 -0
  154. package/dist/repositories/challenge.repository.js +120 -0
  155. package/dist/repositories/clip.repository.js +165 -0
  156. package/dist/repositories/close-friends.repository.js +46 -0
  157. package/dist/repositories/collection.repository.js +68 -0
  158. package/dist/repositories/direct-thread.repository.js +446 -0
  159. package/dist/repositories/direct.repository.js +232 -0
  160. package/dist/repositories/explore.repository.js +70 -0
  161. package/dist/repositories/fbsearch.repository.js +140 -0
  162. package/dist/repositories/feed.repository.js +245 -0
  163. package/dist/repositories/friendship.repository.js +296 -0
  164. package/dist/repositories/fundraiser.repository.js +49 -0
  165. package/dist/repositories/hashtag.repository.js +99 -0
  166. package/dist/repositories/highlights.repository.js +121 -0
  167. package/dist/repositories/insights.repository.js +82 -0
  168. package/dist/repositories/location.repository.js +84 -0
  169. package/dist/repositories/media.repository.js +395 -0
  170. package/dist/repositories/multiple-accounts.repository.js +41 -0
  171. package/dist/repositories/news.repository.js +35 -0
  172. package/dist/repositories/note.repository.js +57 -0
  173. package/dist/repositories/notification.repository.js +79 -0
  174. package/dist/repositories/share.repository.js +35 -0
  175. package/dist/repositories/signup.repository.js +218 -0
  176. package/dist/repositories/story.repository.js +290 -0
  177. package/dist/repositories/timeline.repository.js +60 -0
  178. package/dist/repositories/totp.repository.js +139 -0
  179. package/dist/repositories/track.repository.js +53 -0
  180. package/dist/repositories/upload.repository.js +204 -0
  181. package/dist/repositories/user.repository.js +360 -0
  182. package/dist/sendmedia/index.js +27 -0
  183. package/dist/sendmedia/sendFile.js +72 -0
  184. package/dist/sendmedia/sendPhoto.js +142 -0
  185. package/dist/sendmedia/sendRavenPhoto.js +153 -0
  186. package/dist/sendmedia/sendRavenVideo.js +158 -0
  187. package/dist/sendmedia/uploadPhoto.js +107 -0
  188. package/dist/sendmedia/uploadfFile.js +130 -0
  189. package/dist/services/live.service.js +139 -0
  190. package/dist/services/search.service.js +115 -0
  191. package/dist/shared/index.js +96 -0
  192. package/dist/shared/shared.js +86 -0
  193. package/dist/thrift/index.d.ts +3 -0
  194. package/dist/thrift/index.js +20 -0
  195. package/dist/thrift/index.js.map +1 -0
  196. package/dist/thrift/thrift.d.ts +59 -0
  197. package/dist/thrift/thrift.js +101 -0
  198. package/dist/thrift/thrift.js.map +1 -0
  199. package/dist/thrift/thrift.reading.d.ts +41 -0
  200. package/dist/thrift/thrift.reading.js +327 -0
  201. package/dist/thrift/thrift.reading.js.map +1 -0
  202. package/dist/thrift/thrift.writing.d.ts +44 -0
  203. package/dist/thrift/thrift.writing.js +342 -0
  204. package/dist/thrift/thrift.writing.js.map +1 -0
  205. package/dist/types/index.js +285 -0
  206. package/dist/useMultiFileAuthState.js +1768 -0
  207. package/dist/utils/helper-1.js +1 -0
  208. package/dist/utils/helper-10.js +1 -0
  209. package/dist/utils/helper-11.js +1 -0
  210. package/dist/utils/helper-12.js +1 -0
  211. package/dist/utils/helper-13.js +1 -0
  212. package/dist/utils/helper-14.js +1 -0
  213. package/dist/utils/helper-15.js +1 -0
  214. package/dist/utils/helper-16.js +1 -0
  215. package/dist/utils/helper-17.js +1 -0
  216. package/dist/utils/helper-18.js +1 -0
  217. package/dist/utils/helper-19.js +1 -0
  218. package/dist/utils/helper-2.js +1 -0
  219. package/dist/utils/helper-20.js +1 -0
  220. package/dist/utils/helper-21.js +1 -0
  221. package/dist/utils/helper-22.js +1 -0
  222. package/dist/utils/helper-23.js +1 -0
  223. package/dist/utils/helper-24.js +1 -0
  224. package/dist/utils/helper-25.js +1 -0
  225. package/dist/utils/helper-26.js +1 -0
  226. package/dist/utils/helper-27.js +1 -0
  227. package/dist/utils/helper-28.js +1 -0
  228. package/dist/utils/helper-29.js +1 -0
  229. package/dist/utils/helper-3.js +1 -0
  230. package/dist/utils/helper-30.js +1 -0
  231. package/dist/utils/helper-4.js +1 -0
  232. package/dist/utils/helper-5.js +1 -0
  233. package/dist/utils/helper-6.js +1 -0
  234. package/dist/utils/helper-7.js +1 -0
  235. package/dist/utils/helper-8.js +1 -0
  236. package/dist/utils/helper-9.js +1 -0
  237. package/dist/utils/index.js +280 -0
  238. package/dist/utils/insta-mqtt-helper.js +128 -0
  239. package/examples/listen-to-messages.js +86 -0
  240. package/package.json +82 -0
@@ -0,0 +1,296 @@
1
+ const Repository = require('../core/repository');
2
+
3
+ class FriendshipRepository extends Repository {
4
+ async create(userId) {
5
+ const response = await this.client.request.send({
6
+ method: 'POST',
7
+ url: `/api/v1/friendships/create/${userId}/`,
8
+ form: this.client.request.sign({
9
+ _uid: this.client.state.cookieUserId,
10
+ _uuid: this.client.state.uuid,
11
+ user_id: userId,
12
+ }),
13
+ });
14
+ return response.body;
15
+ }
16
+
17
+ async destroy(userId) {
18
+ const response = await this.client.request.send({
19
+ method: 'POST',
20
+ url: `/api/v1/friendships/destroy/${userId}/`,
21
+ form: this.client.request.sign({
22
+ _uid: this.client.state.cookieUserId,
23
+ _uuid: this.client.state.uuid,
24
+ user_id: userId,
25
+ }),
26
+ });
27
+ return response.body;
28
+ }
29
+
30
+ async show(userId) {
31
+ const response = await this.client.request.send({
32
+ method: 'GET',
33
+ url: `/api/v1/friendships/show/${userId}/`,
34
+ });
35
+ return response.body;
36
+ }
37
+
38
+ async showMany(userIds) {
39
+ const response = await this.client.request.send({
40
+ method: 'POST',
41
+ url: '/api/v1/friendships/show_many/',
42
+ form: this.client.request.sign({
43
+ _uuid: this.client.state.uuid,
44
+ user_ids: Array.isArray(userIds) ? userIds.join(',') : userIds,
45
+ }),
46
+ });
47
+ return response.body;
48
+ }
49
+
50
+ async approve(userId) {
51
+ const response = await this.client.request.send({
52
+ method: 'POST',
53
+ url: `/api/v1/friendships/approve/${userId}/`,
54
+ form: this.client.request.sign({
55
+ _uid: this.client.state.cookieUserId,
56
+ _uuid: this.client.state.uuid,
57
+ user_id: userId,
58
+ }),
59
+ });
60
+ return response.body;
61
+ }
62
+
63
+ async ignore(userId) {
64
+ const response = await this.client.request.send({
65
+ method: 'POST',
66
+ url: `/api/v1/friendships/ignore/${userId}/`,
67
+ form: this.client.request.sign({
68
+ _uid: this.client.state.cookieUserId,
69
+ _uuid: this.client.state.uuid,
70
+ user_id: userId,
71
+ }),
72
+ });
73
+ return response.body;
74
+ }
75
+
76
+ async removeFollower(userId) {
77
+ const response = await this.client.request.send({
78
+ method: 'POST',
79
+ url: `/api/v1/friendships/remove_follower/${userId}/`,
80
+ form: this.client.request.sign({
81
+ _uid: this.client.state.cookieUserId,
82
+ _uuid: this.client.state.uuid,
83
+ user_id: userId,
84
+ }),
85
+ });
86
+ return response.body;
87
+ }
88
+
89
+ async block(userId) {
90
+ const response = await this.client.request.send({
91
+ method: 'POST',
92
+ url: `/api/v1/friendships/block/${userId}/`,
93
+ form: this.client.request.sign({
94
+ _uid: this.client.state.cookieUserId,
95
+ _uuid: this.client.state.uuid,
96
+ user_id: userId,
97
+ }),
98
+ });
99
+ return response.body;
100
+ }
101
+
102
+ async unblock(userId) {
103
+ const response = await this.client.request.send({
104
+ method: 'POST',
105
+ url: `/api/v1/friendships/unblock/${userId}/`,
106
+ form: this.client.request.sign({
107
+ _uid: this.client.state.cookieUserId,
108
+ _uuid: this.client.state.uuid,
109
+ user_id: userId,
110
+ }),
111
+ });
112
+ return response.body;
113
+ }
114
+
115
+ async mute(userId, options = {}) {
116
+ const form = {
117
+ _uid: this.client.state.cookieUserId,
118
+ _uuid: this.client.state.uuid,
119
+ user_id: userId,
120
+ };
121
+ if (options.muteStories) form.target_reel_author_id = userId;
122
+ if (options.mutePosts) form.target_posts_author_id = userId;
123
+
124
+ const response = await this.client.request.send({
125
+ method: 'POST',
126
+ url: '/api/v1/friendships/mute_posts_or_story_from_follow/',
127
+ form: this.client.request.sign(form),
128
+ });
129
+ return response.body;
130
+ }
131
+
132
+ async unmute(userId, options = {}) {
133
+ const form = {
134
+ _uid: this.client.state.cookieUserId,
135
+ _uuid: this.client.state.uuid,
136
+ user_id: userId,
137
+ };
138
+ if (options.unmuteStories) form.target_reel_author_id = userId;
139
+ if (options.unmutePosts) form.target_posts_author_id = userId;
140
+
141
+ const response = await this.client.request.send({
142
+ method: 'POST',
143
+ url: '/api/v1/friendships/unmute_posts_or_story_from_follow/',
144
+ form: this.client.request.sign(form),
145
+ });
146
+ return response.body;
147
+ }
148
+
149
+ async getPendingRequests() {
150
+ const response = await this.client.request.send({
151
+ method: 'GET',
152
+ url: '/api/v1/friendships/pending/',
153
+ });
154
+ return response.body;
155
+ }
156
+
157
+ async getFollowers(userId, maxId = null) {
158
+ const qs = {};
159
+ if (maxId) qs.max_id = maxId;
160
+ const response = await this.client.request.send({
161
+ method: 'GET',
162
+ url: `/api/v1/friendships/${userId}/followers/`,
163
+ qs,
164
+ });
165
+ return response.body;
166
+ }
167
+
168
+ async getFollowing(userId, maxId = null) {
169
+ const qs = {};
170
+ if (maxId) qs.max_id = maxId;
171
+ const response = await this.client.request.send({
172
+ method: 'GET',
173
+ url: `/api/v1/friendships/${userId}/following/`,
174
+ qs,
175
+ });
176
+ return response.body;
177
+ }
178
+
179
+ async getMutuafFollowers(userId) {
180
+ const response = await this.client.request.send({
181
+ method: 'GET',
182
+ url: `/api/v1/friendships/${userId}/mutual_followers/`,
183
+ });
184
+ return response.body;
185
+ }
186
+
187
+ async getBlockedUsers() {
188
+ const response = await this.client.request.send({
189
+ method: 'GET',
190
+ url: '/api/v1/users/blocked_list/',
191
+ });
192
+ return response.body;
193
+ }
194
+
195
+ async restrict(userId) {
196
+ const response = await this.client.request.send({
197
+ method: 'POST',
198
+ url: '/api/v1/restrict_action/restrict/',
199
+ form: this.client.request.sign({
200
+ _uid: this.client.state.cookieUserId,
201
+ _uuid: this.client.state.uuid,
202
+ target_user_id: userId,
203
+ }),
204
+ });
205
+ return response.body;
206
+ }
207
+
208
+ async unrestrict(userId) {
209
+ const response = await this.client.request.send({
210
+ method: 'POST',
211
+ url: '/api/v1/restrict_action/unrestrict/',
212
+ form: this.client.request.sign({
213
+ _uid: this.client.state.cookieUserId,
214
+ _uuid: this.client.state.uuid,
215
+ target_user_id: userId,
216
+ }),
217
+ });
218
+ return response.body;
219
+ }
220
+
221
+ async setCloseFriend(userId, add = true) {
222
+ if (add) {
223
+ const response = await this.client.request.send({
224
+ method: 'POST',
225
+ url: '/api/v1/friendships/set_besties/',
226
+ form: this.client.request.sign({
227
+ _uuid: this.client.state.uuid,
228
+ _uid: this.client.state.cookieUserId,
229
+ add: JSON.stringify([userId]),
230
+ remove: JSON.stringify([]),
231
+ }),
232
+ });
233
+ return response.body;
234
+ } else {
235
+ const response = await this.client.request.send({
236
+ method: 'POST',
237
+ url: '/api/v1/friendships/set_besties/',
238
+ form: this.client.request.sign({
239
+ _uuid: this.client.state.uuid,
240
+ _uid: this.client.state.cookieUserId,
241
+ add: JSON.stringify([]),
242
+ remove: JSON.stringify([userId]),
243
+ }),
244
+ });
245
+ return response.body;
246
+ }
247
+ }
248
+
249
+ async setBesties(addUserIds = [], removeUserIds = []) {
250
+ const response = await this.client.request.send({
251
+ method: 'POST',
252
+ url: '/api/v1/friendships/set_besties/',
253
+ form: this.client.request.sign({
254
+ _uuid: this.client.state.uuid,
255
+ _uid: this.client.state.cookieUserId,
256
+ add: JSON.stringify(addUserIds),
257
+ remove: JSON.stringify(removeUserIds),
258
+ }),
259
+ });
260
+ return response.body;
261
+ }
262
+
263
+ async getFavoriteFriends() {
264
+ const response = await this.client.request.send({
265
+ method: 'GET',
266
+ url: '/api/v1/friendships/favorites/',
267
+ });
268
+ return response.body;
269
+ }
270
+
271
+ async setFavorite(userId) {
272
+ const response = await this.client.request.send({
273
+ method: 'POST',
274
+ url: `/api/v1/friendships/favorite/${userId}/`,
275
+ form: this.client.request.sign({
276
+ _uid: this.client.state.cookieUserId,
277
+ _uuid: this.client.state.uuid,
278
+ }),
279
+ });
280
+ return response.body;
281
+ }
282
+
283
+ async unsetFavorite(userId) {
284
+ const response = await this.client.request.send({
285
+ method: 'POST',
286
+ url: `/api/v1/friendships/unfavorite/${userId}/`,
287
+ form: this.client.request.sign({
288
+ _uid: this.client.state.cookieUserId,
289
+ _uuid: this.client.state.uuid,
290
+ }),
291
+ });
292
+ return response.body;
293
+ }
294
+ }
295
+
296
+ module.exports = FriendshipRepository;
@@ -0,0 +1,49 @@
1
+ const Repository = require('../core/repository');
2
+
3
+ class FundraiserRepository extends Repository {
4
+ async standaloneFundraiserInfo(fundraiserPk) {
5
+ const response = await this.client.request.send({
6
+ method: 'GET',
7
+ url: `/api/v1/fundraiser/${fundraiserPk}/standalone_fundraiser_info/`,
8
+ });
9
+ return response.body;
10
+ }
11
+
12
+ async createCharityFundraiser(options = {}) {
13
+ const {
14
+ title = '',
15
+ description = '',
16
+ goalAmount = 0,
17
+ charityId = '',
18
+ endTime = null,
19
+ } = options;
20
+
21
+ const response = await this.client.request.send({
22
+ method: 'POST',
23
+ url: '/api/v1/fundraiser/create_fundraiser/',
24
+ form: this.client.request.sign({
25
+ _uuid: this.client.state.uuid,
26
+ title,
27
+ description,
28
+ goal_amount: String(goalAmount),
29
+ charity_id: charityId,
30
+ end_time: endTime ? String(endTime) : '',
31
+ }),
32
+ });
33
+ return response.body;
34
+ }
35
+
36
+ async donateFundraiser(fundraiserPk, amount) {
37
+ const response = await this.client.request.send({
38
+ method: 'POST',
39
+ url: `/api/v1/fundraiser/${fundraiserPk}/donate/`,
40
+ form: this.client.request.sign({
41
+ _uuid: this.client.state.uuid,
42
+ amount: String(amount),
43
+ }),
44
+ });
45
+ return response.body;
46
+ }
47
+ }
48
+
49
+ module.exports = FundraiserRepository;
@@ -0,0 +1,99 @@
1
+ const Repository = require('../core/repository');
2
+
3
+ class HashtagRepository extends Repository {
4
+ async info(hashtag) {
5
+ const response = await this.client.request.send({
6
+ method: 'GET',
7
+ url: `/api/v1/tags/${hashtag}/info/`,
8
+ });
9
+
10
+ return response.body;
11
+ }
12
+
13
+ async search(query) {
14
+ const response = await this.client.request.send({
15
+ method: 'GET',
16
+ url: '/api/v1/tags/search/',
17
+ qs: {
18
+ q: query,
19
+ count: 50,
20
+ rank_token: this.client.state.uuid,
21
+ }
22
+ });
23
+
24
+ return response.body;
25
+ }
26
+
27
+ async getFeed(hashtag, maxId = null) {
28
+ const qs = {
29
+ rank_token: this.client.state.uuid
30
+ };
31
+
32
+ if (maxId) {
33
+ qs.max_id = maxId;
34
+ }
35
+
36
+ const response = await this.client.request.send({
37
+ method: 'GET',
38
+ url: `/api/v1/feed/tag/${hashtag}/`,
39
+ qs
40
+ });
41
+
42
+ return response.body;
43
+ }
44
+
45
+ async getStories(hashtag) {
46
+ const response = await this.client.request.send({
47
+ method: 'GET',
48
+ url: `/api/v1/tags/${hashtag}/story/`,
49
+ });
50
+
51
+ return response.body;
52
+ }
53
+
54
+ async follow(hashtag) {
55
+ const response = await this.client.request.send({
56
+ method: 'POST',
57
+ url: `/api/v1/tags/follow/${hashtag}/`,
58
+ form: this.client.request.sign({
59
+ _uid: this.client.state.cookieUserId,
60
+ _uuid: this.client.state.uuid,
61
+ }),
62
+ });
63
+
64
+ return response.body;
65
+ }
66
+
67
+ async unfollow(hashtag) {
68
+ const response = await this.client.request.send({
69
+ method: 'POST',
70
+ url: `/api/v1/tags/unfollow/${hashtag}/`,
71
+ form: this.client.request.sign({
72
+ _uid: this.client.state.cookieUserId,
73
+ _uuid: this.client.state.uuid,
74
+ }),
75
+ });
76
+
77
+ return response.body;
78
+ }
79
+
80
+ async getRelated(hashtag) {
81
+ const response = await this.client.request.send({
82
+ method: 'GET',
83
+ url: `/api/v1/tags/${hashtag}/related/`,
84
+ });
85
+
86
+ return response.body;
87
+ }
88
+
89
+ async getFollowing() {
90
+ const response = await this.client.request.send({
91
+ method: 'GET',
92
+ url: '/api/v1/tags/followed/',
93
+ });
94
+
95
+ return response.body;
96
+ }
97
+ }
98
+
99
+ module.exports = HashtagRepository;
@@ -0,0 +1,121 @@
1
+ const Repository = require('../core/repository');
2
+
3
+ class HighlightsRepository extends Repository {
4
+ async getHighlightsTray(userId) {
5
+ const response = await this.client.request.send({
6
+ method: 'GET',
7
+ url: `/api/v1/highlights/${userId}/highlights_tray/`,
8
+ });
9
+
10
+ return response.body;
11
+ }
12
+
13
+ async getHighlight(highlightId) {
14
+ const response = await this.client.request.send({
15
+ method: 'GET',
16
+ url: `/api/v1/feed/reels_media/`,
17
+ qs: {
18
+ reel_ids: highlightId
19
+ }
20
+ });
21
+
22
+ return response.body;
23
+ }
24
+
25
+ async create(title, storyIds, coverMediaId = null) {
26
+ const form = {
27
+ _uuid: this.client.state.uuid,
28
+ title: title,
29
+ media_ids: JSON.stringify(storyIds),
30
+ source: 'story_viewer',
31
+ };
32
+
33
+ if (coverMediaId) {
34
+ form.cover_media_id = coverMediaId;
35
+ }
36
+
37
+ const response = await this.client.request.send({
38
+ method: 'POST',
39
+ url: '/api/v1/highlights/create_reel/',
40
+ form: this.client.request.sign(form),
41
+ });
42
+
43
+ return response.body;
44
+ }
45
+
46
+ async edit(highlightId, title, storyIds, coverMediaId = null) {
47
+ const form = {
48
+ _uuid: this.client.state.uuid,
49
+ title: title,
50
+ added_media_ids: JSON.stringify(storyIds),
51
+ source: 'story_viewer',
52
+ };
53
+
54
+ if (coverMediaId) {
55
+ form.cover_media_id = coverMediaId;
56
+ }
57
+
58
+ const response = await this.client.request.send({
59
+ method: 'POST',
60
+ url: `/api/v1/highlights/${highlightId}/edit_reel/`,
61
+ form: this.client.request.sign(form),
62
+ });
63
+
64
+ return response.body;
65
+ }
66
+
67
+ async delete(highlightId) {
68
+ const response = await this.client.request.send({
69
+ method: 'POST',
70
+ url: `/api/v1/highlights/${highlightId}/delete_reel/`,
71
+ form: this.client.request.sign({
72
+ _uuid: this.client.state.uuid,
73
+ }),
74
+ });
75
+
76
+ return response.body;
77
+ }
78
+
79
+ async addStories(highlightId, storyIds) {
80
+ const response = await this.client.request.send({
81
+ method: 'POST',
82
+ url: `/api/v1/highlights/${highlightId}/add_highlight/`,
83
+ form: this.client.request.sign({
84
+ _uuid: this.client.state.uuid,
85
+ added_media_ids: JSON.stringify(storyIds),
86
+ source: 'story_viewer',
87
+ }),
88
+ });
89
+
90
+ return response.body;
91
+ }
92
+
93
+ async removeStories(highlightId, storyIds) {
94
+ const response = await this.client.request.send({
95
+ method: 'POST',
96
+ url: `/api/v1/highlights/${highlightId}/remove_highlight/`,
97
+ form: this.client.request.sign({
98
+ _uuid: this.client.state.uuid,
99
+ removed_media_ids: JSON.stringify(storyIds),
100
+ }),
101
+ });
102
+
103
+ return response.body;
104
+ }
105
+
106
+ async updateCover(highlightId, coverMediaId) {
107
+ const response = await this.client.request.send({
108
+ method: 'POST',
109
+ url: `/api/v1/highlights/${highlightId}/edit_reel/`,
110
+ form: this.client.request.sign({
111
+ _uuid: this.client.state.uuid,
112
+ cover_media_id: coverMediaId,
113
+ source: 'story_viewer',
114
+ }),
115
+ });
116
+
117
+ return response.body;
118
+ }
119
+ }
120
+
121
+ module.exports = HighlightsRepository;
@@ -0,0 +1,82 @@
1
+ const Repository = require('../core/repository');
2
+
3
+ class InsightsRepository extends Repository {
4
+ async mediaFeedAll(options = {}) {
5
+ const {
6
+ selectedDomain = 'ACCOUNT',
7
+ timeframe = 'TWO_WEEKS',
8
+ dataOrdering = 'REACH_COUNT',
9
+ count = 15,
10
+ maxId = '',
11
+ } = options;
12
+
13
+ const response = await this.client.request.send({
14
+ method: 'POST',
15
+ url: '/api/v1/insights/media_feed_all/',
16
+ form: this.client.request.sign({
17
+ _uuid: this.client.state.uuid,
18
+ selected_domain: selectedDomain,
19
+ timeframe,
20
+ data_ordering: dataOrdering,
21
+ count: String(count),
22
+ max_id: maxId,
23
+ }),
24
+ });
25
+ return response.body;
26
+ }
27
+
28
+ async account(options = {}) {
29
+ const {
30
+ dayRange = 7,
31
+ } = options;
32
+
33
+ const response = await this.client.request.send({
34
+ method: 'GET',
35
+ url: '/api/v1/insights/account_organic_insights/',
36
+ qs: {
37
+ show_promotions_in_landing_page: 'true',
38
+ first: '0',
39
+ timezone_offset: String(this.client.state.timezoneOffset),
40
+ day_range: String(dayRange),
41
+ },
42
+ });
43
+ return response.body;
44
+ }
45
+
46
+ async media(mediaPk) {
47
+ const response = await this.client.request.send({
48
+ method: 'GET',
49
+ url: `/api/v1/insights/media_organic_insights/${mediaPk}/`,
50
+ qs: {
51
+ ig_sig_key_version: this.client.state.signatureVersion,
52
+ },
53
+ });
54
+ return response.body;
55
+ }
56
+
57
+ async reelInsights(mediaPk) {
58
+ const response = await this.client.request.send({
59
+ method: 'GET',
60
+ url: `/api/v1/insights/media_organic_insights/${mediaPk}/`,
61
+ qs: {
62
+ ig_sig_key_version: this.client.state.signatureVersion,
63
+ surface: 'clips',
64
+ },
65
+ });
66
+ return response.body;
67
+ }
68
+
69
+ async storyInsights(mediaPk) {
70
+ const response = await this.client.request.send({
71
+ method: 'GET',
72
+ url: `/api/v1/insights/media_organic_insights/${mediaPk}/`,
73
+ qs: {
74
+ ig_sig_key_version: this.client.state.signatureVersion,
75
+ surface: 'story',
76
+ },
77
+ });
78
+ return response.body;
79
+ }
80
+ }
81
+
82
+ module.exports = InsightsRepository;