nodejs-insta-private-api-mqtt 1.0.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 (210) hide show
  1. package/README.md +1650 -0
  2. package/dist/constants/constants.js +280 -0
  3. package/dist/constants/index.js +41 -0
  4. package/dist/core/client.js +243 -0
  5. package/dist/core/repository.js +7 -0
  6. package/dist/core/request.js +212 -0
  7. package/dist/core/state.js +1456 -0
  8. package/dist/core/utils.js +786 -0
  9. package/dist/downloadMedia.js +381 -0
  10. package/dist/errors/index.d.ts +16 -0
  11. package/dist/errors/index.js +30 -0
  12. package/dist/errors/index.js.map +1 -0
  13. package/dist/fbns/fbns.client.d.ts +32 -0
  14. package/dist/fbns/fbns.client.events.d.ts +41 -0
  15. package/dist/fbns/fbns.client.events.js +3 -0
  16. package/dist/fbns/fbns.client.events.js.map +1 -0
  17. package/dist/fbns/fbns.client.js +179 -0
  18. package/dist/fbns/fbns.client.js.map +1 -0
  19. package/dist/fbns/fbns.device-auth.d.ts +17 -0
  20. package/dist/fbns/fbns.device-auth.js +54 -0
  21. package/dist/fbns/fbns.device-auth.js.map +1 -0
  22. package/dist/fbns/fbns.types.d.ts +83 -0
  23. package/dist/fbns/fbns.types.js +3 -0
  24. package/dist/fbns/fbns.types.js.map +1 -0
  25. package/dist/fbns/fbns.utilities.d.ts +2 -0
  26. package/dist/fbns/fbns.utilities.js +79 -0
  27. package/dist/fbns/fbns.utilities.js.map +1 -0
  28. package/dist/fbns/index.d.ts +4 -0
  29. package/dist/fbns/index.js +21 -0
  30. package/dist/fbns/index.js.map +1 -0
  31. package/dist/index.js +39 -0
  32. package/dist/mqttot/index.d.ts +4 -0
  33. package/dist/mqttot/index.js +21 -0
  34. package/dist/mqttot/index.js.map +1 -0
  35. package/dist/mqttot/mqttot.client.d.ts +39 -0
  36. package/dist/mqttot/mqttot.client.js +120 -0
  37. package/dist/mqttot/mqttot.client.js.map +1 -0
  38. package/dist/mqttot/mqttot.connect.request.packet.d.ts +7 -0
  39. package/dist/mqttot/mqttot.connect.request.packet.js +9 -0
  40. package/dist/mqttot/mqttot.connect.request.packet.js.map +1 -0
  41. package/dist/mqttot/mqttot.connect.response.packet.d.ts +7 -0
  42. package/dist/mqttot/mqttot.connect.response.packet.js +24 -0
  43. package/dist/mqttot/mqttot.connect.response.packet.js.map +1 -0
  44. package/dist/mqttot/mqttot.connection.d.ts +57 -0
  45. package/dist/mqttot/mqttot.connection.js +56 -0
  46. package/dist/mqttot/mqttot.connection.js.map +1 -0
  47. package/dist/package.json +59 -0
  48. package/dist/realtime/commands/commands.d.ts +15 -0
  49. package/dist/realtime/commands/commands.js +21 -0
  50. package/dist/realtime/commands/commands.js.map +1 -0
  51. package/dist/realtime/commands/direct.commands.d.ts +75 -0
  52. package/dist/realtime/commands/direct.commands.js +186 -0
  53. package/dist/realtime/commands/direct.commands.js.map +1 -0
  54. package/dist/realtime/commands/enhanced.direct.commands.js +987 -0
  55. package/dist/realtime/commands/index.d.ts +2 -0
  56. package/dist/realtime/commands/index.js +19 -0
  57. package/dist/realtime/commands/index.js.map +1 -0
  58. package/dist/realtime/delta-sync.manager.js +293 -0
  59. package/dist/realtime/features/dm-sender.js +88 -0
  60. package/dist/realtime/features/error-handler.js +73 -0
  61. package/dist/realtime/features/gap-handler.js +61 -0
  62. package/dist/realtime/features/presence.manager.js +66 -0
  63. package/dist/realtime/index.js +30 -0
  64. package/dist/realtime/messages/app-presence.event.d.ts +9 -0
  65. package/dist/realtime/messages/app-presence.event.js +3 -0
  66. package/dist/realtime/messages/app-presence.event.js.map +1 -0
  67. package/dist/realtime/messages/index.d.ts +3 -0
  68. package/dist/realtime/messages/index.js +20 -0
  69. package/dist/realtime/messages/index.js.map +1 -0
  70. package/dist/realtime/messages/message-sync.message.d.ts +222 -0
  71. package/dist/realtime/messages/message-sync.message.js +43 -0
  72. package/dist/realtime/messages/message-sync.message.js.map +1 -0
  73. package/dist/realtime/messages/realtime-sub.direct.data.d.ts +11 -0
  74. package/dist/realtime/messages/realtime-sub.direct.data.js +3 -0
  75. package/dist/realtime/messages/realtime-sub.direct.data.js.map +1 -0
  76. package/dist/realtime/messages/thread-update.message.d.ts +68 -0
  77. package/dist/realtime/messages/thread-update.message.js +3 -0
  78. package/dist/realtime/messages/thread-update.message.js.map +1 -0
  79. package/dist/realtime/mixins/index.d.ts +3 -0
  80. package/dist/realtime/mixins/index.js +20 -0
  81. package/dist/realtime/mixins/index.js.map +1 -0
  82. package/dist/realtime/mixins/message-sync.mixin.d.ts +8 -0
  83. package/dist/realtime/mixins/message-sync.mixin.js +381 -0
  84. package/dist/realtime/mixins/message-sync.mixin.js.map +1 -0
  85. package/dist/realtime/mixins/mixin.d.ts +19 -0
  86. package/dist/realtime/mixins/mixin.js +41 -0
  87. package/dist/realtime/mixins/mixin.js.map +1 -0
  88. package/dist/realtime/mixins/presence-typing.mixin.js +33 -0
  89. package/dist/realtime/mixins/realtime-sub.mixin.d.ts +8 -0
  90. package/dist/realtime/mixins/realtime-sub.mixin.js +55 -0
  91. package/dist/realtime/mixins/realtime-sub.mixin.js.map +1 -0
  92. package/dist/realtime/parsers/graphql-parser.js +43 -0
  93. package/dist/realtime/parsers/graphql.parser.d.ts +15 -0
  94. package/dist/realtime/parsers/graphql.parser.js +22 -0
  95. package/dist/realtime/parsers/graphql.parser.js.map +1 -0
  96. package/dist/realtime/parsers/index.d.ts +6 -0
  97. package/dist/realtime/parsers/index.js +23 -0
  98. package/dist/realtime/parsers/index.js.map +1 -0
  99. package/dist/realtime/parsers/iris-parser.js +43 -0
  100. package/dist/realtime/parsers/iris.parser.d.ts +17 -0
  101. package/dist/realtime/parsers/iris.parser.js +10 -0
  102. package/dist/realtime/parsers/iris.parser.js.map +1 -0
  103. package/dist/realtime/parsers/json-parser.js +43 -0
  104. package/dist/realtime/parsers/json.parser.d.ts +6 -0
  105. package/dist/realtime/parsers/json.parser.js +10 -0
  106. package/dist/realtime/parsers/json.parser.js.map +1 -0
  107. package/dist/realtime/parsers/parser.d.ts +9 -0
  108. package/dist/realtime/parsers/parser.js +3 -0
  109. package/dist/realtime/parsers/parser.js.map +1 -0
  110. package/dist/realtime/parsers/region-hint-parser.js +43 -0
  111. package/dist/realtime/parsers/region-hint.parser.d.ts +12 -0
  112. package/dist/realtime/parsers/region-hint.parser.js +15 -0
  113. package/dist/realtime/parsers/region-hint.parser.js.map +1 -0
  114. package/dist/realtime/parsers/skywalker-parser.js +43 -0
  115. package/dist/realtime/parsers/skywalker.parser.d.ts +12 -0
  116. package/dist/realtime/parsers/skywalker.parser.js +15 -0
  117. package/dist/realtime/parsers/skywalker.parser.js.map +1 -0
  118. package/dist/realtime/parsers-advanced.js +158 -0
  119. package/dist/realtime/proto/common.proto +38 -0
  120. package/dist/realtime/proto/direct.proto +65 -0
  121. package/dist/realtime/proto/ig-messages.proto +83 -0
  122. package/dist/realtime/proto/iris.proto +188 -0
  123. package/dist/realtime/proto-parser.js +195 -0
  124. package/dist/realtime/protocols/iris.handshake.js +74 -0
  125. package/dist/realtime/protocols/proto-definitions.js +80 -0
  126. package/dist/realtime/protocols/skywalker.protocol.js +91 -0
  127. package/dist/realtime/realtime.client.events.js +3 -0
  128. package/dist/realtime/realtime.client.js +449 -0
  129. package/dist/realtime/realtime.service.js +462 -0
  130. package/dist/realtime/reconnect.manager.js +94 -0
  131. package/dist/realtime/session.manager.js +121 -0
  132. package/dist/realtime/subscriptions/graphql.subscription.d.ts +47 -0
  133. package/dist/realtime/subscriptions/graphql.subscription.js +99 -0
  134. package/dist/realtime/subscriptions/graphql.subscription.js.map +1 -0
  135. package/dist/realtime/subscriptions/index.d.ts +2 -0
  136. package/dist/realtime/subscriptions/index.js +19 -0
  137. package/dist/realtime/subscriptions/index.js.map +1 -0
  138. package/dist/realtime/subscriptions/skywalker.subscription.d.ts +4 -0
  139. package/dist/realtime/subscriptions/skywalker.subscription.js +13 -0
  140. package/dist/realtime/subscriptions/skywalker.subscription.js.map +1 -0
  141. package/dist/realtime/topic-map.js +71 -0
  142. package/dist/realtime/topic.js +80 -0
  143. package/dist/repositories/account.repository.js +261 -0
  144. package/dist/repositories/direct-thread.repository.js +247 -0
  145. package/dist/repositories/direct.repository.js +153 -0
  146. package/dist/repositories/feed.repository.js +233 -0
  147. package/dist/repositories/friendship.repository.js +190 -0
  148. package/dist/repositories/hashtag.repository.js +101 -0
  149. package/dist/repositories/highlights.repository.js +127 -0
  150. package/dist/repositories/location.repository.js +84 -0
  151. package/dist/repositories/media.repository.js +165 -0
  152. package/dist/repositories/story.repository.js +156 -0
  153. package/dist/repositories/upload.repository.js +167 -0
  154. package/dist/repositories/user.repository.js +94 -0
  155. package/dist/sendmedia/index.js +11 -0
  156. package/dist/sendmedia/sendFile.js +154 -0
  157. package/dist/sendmedia/sendPhoto.js +145 -0
  158. package/dist/sendmedia/uploadPhoto.js +175 -0
  159. package/dist/sendmedia/uploadfFile.js +264 -0
  160. package/dist/services/live.service.js +147 -0
  161. package/dist/services/search.service.js +116 -0
  162. package/dist/shared/index.js +35 -0
  163. package/dist/shared/shared.js +86 -0
  164. package/dist/thrift/index.d.ts +3 -0
  165. package/dist/thrift/index.js +20 -0
  166. package/dist/thrift/index.js.map +1 -0
  167. package/dist/thrift/thrift.d.ts +59 -0
  168. package/dist/thrift/thrift.js +101 -0
  169. package/dist/thrift/thrift.js.map +1 -0
  170. package/dist/thrift/thrift.reading.d.ts +41 -0
  171. package/dist/thrift/thrift.reading.js +327 -0
  172. package/dist/thrift/thrift.reading.js.map +1 -0
  173. package/dist/thrift/thrift.writing.d.ts +44 -0
  174. package/dist/thrift/thrift.writing.js +342 -0
  175. package/dist/thrift/thrift.writing.js.map +1 -0
  176. package/dist/types/index.js +285 -0
  177. package/dist/useMultiFileAuthState.js +437 -0
  178. package/dist/utils/helper-1.js +1 -0
  179. package/dist/utils/helper-10.js +1 -0
  180. package/dist/utils/helper-11.js +1 -0
  181. package/dist/utils/helper-12.js +1 -0
  182. package/dist/utils/helper-13.js +1 -0
  183. package/dist/utils/helper-14.js +1 -0
  184. package/dist/utils/helper-15.js +1 -0
  185. package/dist/utils/helper-16.js +1 -0
  186. package/dist/utils/helper-17.js +1 -0
  187. package/dist/utils/helper-18.js +1 -0
  188. package/dist/utils/helper-19.js +1 -0
  189. package/dist/utils/helper-2.js +1 -0
  190. package/dist/utils/helper-20.js +1 -0
  191. package/dist/utils/helper-21.js +1 -0
  192. package/dist/utils/helper-22.js +1 -0
  193. package/dist/utils/helper-23.js +1 -0
  194. package/dist/utils/helper-24.js +1 -0
  195. package/dist/utils/helper-25.js +1 -0
  196. package/dist/utils/helper-26.js +1 -0
  197. package/dist/utils/helper-27.js +1 -0
  198. package/dist/utils/helper-28.js +1 -0
  199. package/dist/utils/helper-29.js +1 -0
  200. package/dist/utils/helper-3.js +1 -0
  201. package/dist/utils/helper-30.js +1 -0
  202. package/dist/utils/helper-4.js +1 -0
  203. package/dist/utils/helper-5.js +1 -0
  204. package/dist/utils/helper-6.js +1 -0
  205. package/dist/utils/helper-7.js +1 -0
  206. package/dist/utils/helper-8.js +1 -0
  207. package/dist/utils/helper-9.js +1 -0
  208. package/dist/utils/index.js +280 -0
  209. package/examples/listen-to-messages.js +86 -0
  210. package/package.json +79 -0
@@ -0,0 +1,190 @@
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
+ _csrftoken: this.client.state.cookieCsrfToken,
10
+ _uid: this.client.state.cookieUserId,
11
+ _uuid: this.client.state.uuid,
12
+ user_id: userId,
13
+ }),
14
+ });
15
+
16
+ return response.body;
17
+ }
18
+
19
+ async destroy(userId) {
20
+ const response = await this.client.request.send({
21
+ method: 'POST',
22
+ url: `/api/v1/friendships/destroy/${userId}/`,
23
+ form: this.client.request.sign({
24
+ _csrftoken: this.client.state.cookieCsrfToken,
25
+ _uid: this.client.state.cookieUserId,
26
+ _uuid: this.client.state.uuid,
27
+ user_id: userId,
28
+ }),
29
+ });
30
+
31
+ return response.body;
32
+ }
33
+
34
+ async show(userId) {
35
+ const response = await this.client.request.send({
36
+ method: 'GET',
37
+ url: `/api/v1/friendships/show/${userId}/`,
38
+ });
39
+
40
+ return response.body;
41
+ }
42
+
43
+ async showMany(userIds) {
44
+ const response = await this.client.request.send({
45
+ method: 'POST',
46
+ url: '/api/v1/friendships/show_many/',
47
+ form: this.client.request.sign({
48
+ _csrftoken: this.client.state.cookieCsrfToken,
49
+ _uuid: this.client.state.uuid,
50
+ user_ids: userIds.join(','),
51
+ }),
52
+ });
53
+
54
+ return response.body;
55
+ }
56
+
57
+ async approve(userId) {
58
+ const response = await this.client.request.send({
59
+ method: 'POST',
60
+ url: `/api/v1/friendships/approve/${userId}/`,
61
+ form: this.client.request.sign({
62
+ _csrftoken: this.client.state.cookieCsrfToken,
63
+ _uid: this.client.state.cookieUserId,
64
+ _uuid: this.client.state.uuid,
65
+ user_id: userId,
66
+ }),
67
+ });
68
+
69
+ return response.body;
70
+ }
71
+
72
+ async ignore(userId) {
73
+ const response = await this.client.request.send({
74
+ method: 'POST',
75
+ url: `/api/v1/friendships/ignore/${userId}/`,
76
+ form: this.client.request.sign({
77
+ _csrftoken: this.client.state.cookieCsrfToken,
78
+ _uid: this.client.state.cookieUserId,
79
+ _uuid: this.client.state.uuid,
80
+ user_id: userId,
81
+ }),
82
+ });
83
+
84
+ return response.body;
85
+ }
86
+
87
+ async removeFollower(userId) {
88
+ const response = await this.client.request.send({
89
+ method: 'POST',
90
+ url: `/api/v1/friendships/remove_follower/${userId}/`,
91
+ form: this.client.request.sign({
92
+ _csrftoken: this.client.state.cookieCsrfToken,
93
+ _uid: this.client.state.cookieUserId,
94
+ _uuid: this.client.state.uuid,
95
+ user_id: userId,
96
+ }),
97
+ });
98
+
99
+ return response.body;
100
+ }
101
+
102
+ async block(userId) {
103
+ const response = await this.client.request.send({
104
+ method: 'POST',
105
+ url: `/api/v1/friendships/block/${userId}/`,
106
+ form: this.client.request.sign({
107
+ _csrftoken: this.client.state.cookieCsrfToken,
108
+ _uid: this.client.state.cookieUserId,
109
+ _uuid: this.client.state.uuid,
110
+ user_id: userId,
111
+ }),
112
+ });
113
+
114
+ return response.body;
115
+ }
116
+
117
+ async unblock(userId) {
118
+ const response = await this.client.request.send({
119
+ method: 'POST',
120
+ url: `/api/v1/friendships/unblock/${userId}/`,
121
+ form: this.client.request.sign({
122
+ _csrftoken: this.client.state.cookieCsrfToken,
123
+ _uid: this.client.state.cookieUserId,
124
+ _uuid: this.client.state.uuid,
125
+ user_id: userId,
126
+ }),
127
+ });
128
+
129
+ return response.body;
130
+ }
131
+
132
+ async mute(userId, options = {}) {
133
+ const form = {
134
+ _csrftoken: this.client.state.cookieCsrfToken,
135
+ _uid: this.client.state.cookieUserId,
136
+ _uuid: this.client.state.uuid,
137
+ user_id: userId,
138
+ };
139
+
140
+ if (options.muteStories !== undefined) {
141
+ form.target_reel_author_id = userId;
142
+ }
143
+ if (options.mutePosts !== undefined) {
144
+ form.target_posts_author_id = userId;
145
+ }
146
+
147
+ const response = await this.client.request.send({
148
+ method: 'POST',
149
+ url: `/api/v1/friendships/mute_posts_or_story_from_follow/`,
150
+ form: this.client.request.sign(form),
151
+ });
152
+
153
+ return response.body;
154
+ }
155
+
156
+ async unmute(userId, options = {}) {
157
+ const form = {
158
+ _csrftoken: this.client.state.cookieCsrfToken,
159
+ _uid: this.client.state.cookieUserId,
160
+ _uuid: this.client.state.uuid,
161
+ user_id: userId,
162
+ };
163
+
164
+ if (options.unmuteStories !== undefined) {
165
+ form.target_reel_author_id = userId;
166
+ }
167
+ if (options.unmutePosts !== undefined) {
168
+ form.target_posts_author_id = userId;
169
+ }
170
+
171
+ const response = await this.client.request.send({
172
+ method: 'POST',
173
+ url: `/api/v1/friendships/unmute_posts_or_story_from_follow/`,
174
+ form: this.client.request.sign(form),
175
+ });
176
+
177
+ return response.body;
178
+ }
179
+
180
+ async getPendingRequests() {
181
+ const response = await this.client.request.send({
182
+ method: 'GET',
183
+ url: '/api/v1/friendships/pending/',
184
+ });
185
+
186
+ return response.body;
187
+ }
188
+ }
189
+
190
+ module.exports = FriendshipRepository;
@@ -0,0 +1,101 @@
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
+ _csrftoken: this.client.state.cookieCsrfToken,
60
+ _uid: this.client.state.cookieUserId,
61
+ _uuid: this.client.state.uuid,
62
+ }),
63
+ });
64
+
65
+ return response.body;
66
+ }
67
+
68
+ async unfollow(hashtag) {
69
+ const response = await this.client.request.send({
70
+ method: 'POST',
71
+ url: `/api/v1/tags/unfollow/${hashtag}/`,
72
+ form: this.client.request.sign({
73
+ _csrftoken: this.client.state.cookieCsrfToken,
74
+ _uid: this.client.state.cookieUserId,
75
+ _uuid: this.client.state.uuid,
76
+ }),
77
+ });
78
+
79
+ return response.body;
80
+ }
81
+
82
+ async getRelated(hashtag) {
83
+ const response = await this.client.request.send({
84
+ method: 'GET',
85
+ url: `/api/v1/tags/${hashtag}/related/`,
86
+ });
87
+
88
+ return response.body;
89
+ }
90
+
91
+ async getFollowing() {
92
+ const response = await this.client.request.send({
93
+ method: 'GET',
94
+ url: '/api/v1/tags/followed/',
95
+ });
96
+
97
+ return response.body;
98
+ }
99
+ }
100
+
101
+ module.exports = HashtagRepository;
@@ -0,0 +1,127 @@
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
+ _csrftoken: this.client.state.cookieCsrfToken,
28
+ _uuid: this.client.state.uuid,
29
+ title: title,
30
+ media_ids: JSON.stringify(storyIds),
31
+ source: 'story_viewer',
32
+ };
33
+
34
+ if (coverMediaId) {
35
+ form.cover_media_id = coverMediaId;
36
+ }
37
+
38
+ const response = await this.client.request.send({
39
+ method: 'POST',
40
+ url: '/api/v1/highlights/create_reel/',
41
+ form: this.client.request.sign(form),
42
+ });
43
+
44
+ return response.body;
45
+ }
46
+
47
+ async edit(highlightId, title, storyIds, coverMediaId = null) {
48
+ const form = {
49
+ _csrftoken: this.client.state.cookieCsrfToken,
50
+ _uuid: this.client.state.uuid,
51
+ title: title,
52
+ added_media_ids: JSON.stringify(storyIds),
53
+ source: 'story_viewer',
54
+ };
55
+
56
+ if (coverMediaId) {
57
+ form.cover_media_id = coverMediaId;
58
+ }
59
+
60
+ const response = await this.client.request.send({
61
+ method: 'POST',
62
+ url: `/api/v1/highlights/${highlightId}/edit_reel/`,
63
+ form: this.client.request.sign(form),
64
+ });
65
+
66
+ return response.body;
67
+ }
68
+
69
+ async delete(highlightId) {
70
+ const response = await this.client.request.send({
71
+ method: 'POST',
72
+ url: `/api/v1/highlights/${highlightId}/delete_reel/`,
73
+ form: this.client.request.sign({
74
+ _csrftoken: this.client.state.cookieCsrfToken,
75
+ _uuid: this.client.state.uuid,
76
+ }),
77
+ });
78
+
79
+ return response.body;
80
+ }
81
+
82
+ async addStories(highlightId, storyIds) {
83
+ const response = await this.client.request.send({
84
+ method: 'POST',
85
+ url: `/api/v1/highlights/${highlightId}/add_highlight/`,
86
+ form: this.client.request.sign({
87
+ _csrftoken: this.client.state.cookieCsrfToken,
88
+ _uuid: this.client.state.uuid,
89
+ added_media_ids: JSON.stringify(storyIds),
90
+ source: 'story_viewer',
91
+ }),
92
+ });
93
+
94
+ return response.body;
95
+ }
96
+
97
+ async removeStories(highlightId, storyIds) {
98
+ const response = await this.client.request.send({
99
+ method: 'POST',
100
+ url: `/api/v1/highlights/${highlightId}/remove_highlight/`,
101
+ form: this.client.request.sign({
102
+ _csrftoken: this.client.state.cookieCsrfToken,
103
+ _uuid: this.client.state.uuid,
104
+ removed_media_ids: JSON.stringify(storyIds),
105
+ }),
106
+ });
107
+
108
+ return response.body;
109
+ }
110
+
111
+ async updateCover(highlightId, coverMediaId) {
112
+ const response = await this.client.request.send({
113
+ method: 'POST',
114
+ url: `/api/v1/highlights/${highlightId}/edit_reel/`,
115
+ form: this.client.request.sign({
116
+ _csrftoken: this.client.state.cookieCsrfToken,
117
+ _uuid: this.client.state.uuid,
118
+ cover_media_id: coverMediaId,
119
+ source: 'story_viewer',
120
+ }),
121
+ });
122
+
123
+ return response.body;
124
+ }
125
+ }
126
+
127
+ module.exports = HighlightsRepository;
@@ -0,0 +1,84 @@
1
+ const Repository = require('../core/repository');
2
+
3
+ class LocationRepository extends Repository {
4
+ async info(locationId) {
5
+ const response = await this.client.request.send({
6
+ method: 'GET',
7
+ url: `/api/v1/locations/${locationId}/info/`,
8
+ });
9
+
10
+ return response.body;
11
+ }
12
+
13
+ async search(query, lat, lng) {
14
+ const qs = {
15
+ search_query: query,
16
+ rank_token: this.client.state.uuid,
17
+ };
18
+
19
+ if (lat && lng) {
20
+ qs.latitude = lat;
21
+ qs.longitude = lng;
22
+ }
23
+
24
+ const response = await this.client.request.send({
25
+ method: 'GET',
26
+ url: '/api/v1/location_search/',
27
+ qs
28
+ });
29
+
30
+ return response.body;
31
+ }
32
+
33
+ async searchByCoordinates(lat, lng) {
34
+ const response = await this.client.request.send({
35
+ method: 'GET',
36
+ url: '/api/v1/location_search/',
37
+ qs: {
38
+ latitude: lat,
39
+ longitude: lng,
40
+ rank_token: this.client.state.uuid,
41
+ }
42
+ });
43
+
44
+ return response.body;
45
+ }
46
+
47
+ async getFeed(locationId, maxId = null) {
48
+ const qs = {
49
+ rank_token: this.client.state.uuid
50
+ };
51
+
52
+ if (maxId) {
53
+ qs.max_id = maxId;
54
+ }
55
+
56
+ const response = await this.client.request.send({
57
+ method: 'GET',
58
+ url: `/api/v1/feed/location/${locationId}/`,
59
+ qs
60
+ });
61
+
62
+ return response.body;
63
+ }
64
+
65
+ async getStories(locationId) {
66
+ const response = await this.client.request.send({
67
+ method: 'GET',
68
+ url: `/api/v1/locations/${locationId}/story/`,
69
+ });
70
+
71
+ return response.body;
72
+ }
73
+
74
+ async getRelated(locationId) {
75
+ const response = await this.client.request.send({
76
+ method: 'GET',
77
+ url: `/api/v1/locations/${locationId}/related/`,
78
+ });
79
+
80
+ return response.body;
81
+ }
82
+ }
83
+
84
+ module.exports = LocationRepository;
@@ -0,0 +1,165 @@
1
+ const Repository = require('../core/repository');
2
+
3
+ class MediaRepository extends Repository {
4
+ async info(mediaId) {
5
+ const response = await this.client.request.send({
6
+ url: `/api/v1/media/${mediaId}/info/`,
7
+ method: 'GET',
8
+ form: this.client.request.sign({
9
+ igtv_feed_preview: false,
10
+ media_id: mediaId,
11
+ _csrftoken: this.client.state.cookieCsrfToken,
12
+ _uid: this.client.state.cookieUserId,
13
+ _uuid: this.client.state.uuid,
14
+ }),
15
+ });
16
+
17
+ return response.body;
18
+ }
19
+
20
+ async like(mediaId, moduleInfo = { module_name: 'feed_timeline' }) {
21
+ const response = await this.client.request.send({
22
+ url: `/api/v1/media/${mediaId}/like/`,
23
+ method: 'POST',
24
+ form: this.client.request.sign({
25
+ media_id: mediaId,
26
+ _csrftoken: this.client.state.cookieCsrfToken,
27
+ _uid: this.client.state.cookieUserId,
28
+ _uuid: this.client.state.uuid,
29
+ radio_type: this.client.state.radioType,
30
+ module_name: moduleInfo.module_name,
31
+ }),
32
+ });
33
+
34
+ return response.body;
35
+ }
36
+
37
+ async unlike(mediaId, moduleInfo = { module_name: 'feed_timeline' }) {
38
+ const response = await this.client.request.send({
39
+ url: `/api/v1/media/${mediaId}/unlike/`,
40
+ method: 'POST',
41
+ form: this.client.request.sign({
42
+ media_id: mediaId,
43
+ _csrftoken: this.client.state.cookieCsrfToken,
44
+ _uid: this.client.state.cookieUserId,
45
+ _uuid: this.client.state.uuid,
46
+ radio_type: this.client.state.radioType,
47
+ module_name: moduleInfo.module_name,
48
+ }),
49
+ });
50
+
51
+ return response.body;
52
+ }
53
+
54
+ async comment(mediaId, commentText) {
55
+ const response = await this.client.request.send({
56
+ url: `/api/v1/media/${mediaId}/comment/`,
57
+ method: 'POST',
58
+ form: this.client.request.sign({
59
+ media_id: mediaId,
60
+ comment_text: commentText,
61
+ _csrftoken: this.client.state.cookieCsrfToken,
62
+ _uid: this.client.state.cookieUserId,
63
+ _uuid: this.client.state.uuid,
64
+ radio_type: this.client.state.radioType,
65
+ module_name: 'feed_timeline',
66
+ }),
67
+ });
68
+
69
+ return response.body;
70
+ }
71
+
72
+ async deleteComment(mediaId, commentId) {
73
+ const response = await this.client.request.send({
74
+ url: `/api/v1/media/${mediaId}/comment/${commentId}/delete/`,
75
+ method: 'POST',
76
+ form: this.client.request.sign({
77
+ _csrftoken: this.client.state.cookieCsrfToken,
78
+ _uid: this.client.state.cookieUserId,
79
+ _uuid: this.client.state.uuid,
80
+ }),
81
+ });
82
+
83
+ return response.body;
84
+ }
85
+
86
+ async delete(mediaId, mediaType = 'PHOTO') {
87
+ const response = await this.client.request.send({
88
+ url: `/api/v1/media/${mediaId}/delete/`,
89
+ method: 'POST',
90
+ qs: {
91
+ media_type: mediaType,
92
+ },
93
+ form: this.client.request.sign({
94
+ igtv_feed_preview: false,
95
+ media_id: mediaId,
96
+ _csrftoken: this.client.state.cookieCsrfToken,
97
+ _uid: this.client.state.cookieUserId,
98
+ _uuid: this.client.state.uuid,
99
+ }),
100
+ });
101
+
102
+ return response.body;
103
+ }
104
+
105
+ async edit(mediaId, captionText) {
106
+ const response = await this.client.request.send({
107
+ url: `/api/v1/media/${mediaId}/edit_media/`,
108
+ method: 'POST',
109
+ form: this.client.request.sign({
110
+ igtv_feed_preview: false,
111
+ media_id: mediaId,
112
+ _csrftoken: this.client.state.cookieCsrfToken,
113
+ _uid: this.client.state.cookieUserId,
114
+ _uuid: this.client.state.uuid,
115
+ caption_text: captionText,
116
+ }),
117
+ });
118
+
119
+ return response.body;
120
+ }
121
+
122
+ async seen(reels) {
123
+ const response = await this.client.request.send({
124
+ url: '/api/v1/media/seen/',
125
+ method: 'POST',
126
+ form: this.client.request.sign({
127
+ reels: JSON.stringify(reels),
128
+ live_vods: JSON.stringify([]),
129
+ nf_token: '',
130
+ _csrftoken: this.client.state.cookieCsrfToken,
131
+ _uid: this.client.state.cookieUserId,
132
+ _uuid: this.client.state.uuid,
133
+ container_module: 'feed_short_url',
134
+ }),
135
+ });
136
+
137
+ return response.body;
138
+ }
139
+
140
+ async likers(mediaId) {
141
+ const response = await this.client.request.send({
142
+ url: `/api/v1/media/${mediaId}/likers/`,
143
+ method: 'GET',
144
+ });
145
+
146
+ return response.body;
147
+ }
148
+
149
+ async comments(mediaId, maxId = null) {
150
+ const qs = {};
151
+ if (maxId) {
152
+ qs.max_id = maxId;
153
+ }
154
+
155
+ const response = await this.client.request.send({
156
+ url: `/api/v1/media/${mediaId}/comments/`,
157
+ method: 'GET',
158
+ qs
159
+ });
160
+
161
+ return response.body;
162
+ }
163
+ }
164
+
165
+ module.exports = MediaRepository;