repltalk 0.0.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/queries.rb +539 -2
- data/lib/repltalk.rb +199 -23
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e8d796ec5d9532272e6ffb20cfa6881e49a38990c13ec58b0f6126974c7d2b
|
4
|
+
data.tar.gz: 2a9f9217d0af746f6dcec692e498c248480d68a8f8e1c2851eefa50a07933326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 449d1a9f1f3a0af88d2d4ab6c316f73f437db0f6fca7d521fdc46b66ad783a2f305fc62ea5f72e2b9624a8a0529e026a8ca590f2ca39a161dc0e8ae41daa0aeb
|
7
|
+
data.tar.gz: b37f383cb86062cf2f1a9788e4f2c6456d0f155fb9eb49932fbcbb7c5e55f8caa319549dcff10cf25dad845ddc0b06ade7f760c558995aa2c72492e52dad2daa
|
data/lib/queries.rb
CHANGED
@@ -1,9 +1,546 @@
|
|
1
1
|
class Queries
|
2
2
|
def Queries.get_user
|
3
|
-
"query userByUsername($username: String!) {
|
3
|
+
"query userByUsername($username: String!) {
|
4
|
+
user: userByUsername(username: $username) {
|
5
|
+
id
|
6
|
+
username
|
7
|
+
fullName
|
8
|
+
image
|
9
|
+
url
|
10
|
+
...ProfileHeaderUser
|
11
|
+
__typename
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
fragment ProfileHeaderUser on User {
|
16
|
+
id
|
17
|
+
fullName
|
18
|
+
username
|
19
|
+
image
|
20
|
+
bio
|
21
|
+
karma
|
22
|
+
isHacker
|
23
|
+
timeCreated
|
24
|
+
roles {
|
25
|
+
id
|
26
|
+
name
|
27
|
+
key
|
28
|
+
tagline
|
29
|
+
__typename
|
30
|
+
}
|
31
|
+
organization {
|
32
|
+
id
|
33
|
+
name
|
34
|
+
__typename
|
35
|
+
}
|
36
|
+
languages {
|
37
|
+
id
|
38
|
+
key
|
39
|
+
displayName
|
40
|
+
tagline
|
41
|
+
icon
|
42
|
+
__typename
|
43
|
+
}
|
44
|
+
__typename
|
45
|
+
}"
|
4
46
|
end
|
5
47
|
|
6
48
|
def Queries.get_user_by_id
|
7
|
-
"query user($user_id: Int!) {
|
49
|
+
"query user($user_id: Int!) {
|
50
|
+
user: user(id: $user_id) {
|
51
|
+
id
|
52
|
+
username
|
53
|
+
fullName
|
54
|
+
image
|
55
|
+
url
|
56
|
+
...ProfileHeaderUser
|
57
|
+
__typename
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
fragment ProfileHeaderUser on User {
|
62
|
+
id
|
63
|
+
fullName
|
64
|
+
username
|
65
|
+
image
|
66
|
+
bio
|
67
|
+
karma
|
68
|
+
isHacker
|
69
|
+
timeCreated
|
70
|
+
roles {
|
71
|
+
id
|
72
|
+
name
|
73
|
+
key
|
74
|
+
tagline
|
75
|
+
__typename
|
76
|
+
}
|
77
|
+
organization {
|
78
|
+
id
|
79
|
+
name
|
80
|
+
__typename
|
81
|
+
}
|
82
|
+
languages {
|
83
|
+
id
|
84
|
+
key
|
85
|
+
displayName
|
86
|
+
tagline
|
87
|
+
icon
|
88
|
+
__typename
|
89
|
+
}
|
90
|
+
__typename
|
91
|
+
}"
|
92
|
+
end
|
93
|
+
|
94
|
+
def Queries.get_user_posts
|
95
|
+
"query ProfilePosts($username: String!, $after: String, $order: String, $count: Int) {
|
96
|
+
user: userByUsername(username: $username) {
|
97
|
+
id
|
98
|
+
displayName
|
99
|
+
posts(after: $after, order: $order, count: $count) {
|
100
|
+
items {
|
101
|
+
id
|
102
|
+
isHidden
|
103
|
+
...PostsFeedItemPost
|
104
|
+
board {
|
105
|
+
id
|
106
|
+
name
|
107
|
+
url
|
108
|
+
color
|
109
|
+
__typename
|
110
|
+
}
|
111
|
+
__typename
|
112
|
+
}
|
113
|
+
pageInfo {
|
114
|
+
nextCursor
|
115
|
+
__typename
|
116
|
+
}
|
117
|
+
__typename
|
118
|
+
}
|
119
|
+
__typename
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
fragment PostsFeedItemPost on Post {
|
124
|
+
id
|
125
|
+
title
|
126
|
+
body
|
127
|
+
preview(removeMarkdown: true, length: 150)
|
128
|
+
url
|
129
|
+
commentCount
|
130
|
+
isPinned
|
131
|
+
isLocked
|
132
|
+
isAnnouncement
|
133
|
+
timeCreated
|
134
|
+
isAnswered
|
135
|
+
isAnswerable
|
136
|
+
...PostVoteControlPost
|
137
|
+
...PostLinkPost
|
138
|
+
user {
|
139
|
+
id
|
140
|
+
username
|
141
|
+
isHacker
|
142
|
+
image
|
143
|
+
...UserLabelUser
|
144
|
+
...UserLinkUser
|
145
|
+
__typename
|
146
|
+
}
|
147
|
+
repl {
|
148
|
+
id
|
149
|
+
url
|
150
|
+
title
|
151
|
+
description
|
152
|
+
isPrivate
|
153
|
+
isAlwaysOn
|
154
|
+
lang {
|
155
|
+
id
|
156
|
+
icon
|
157
|
+
key
|
158
|
+
displayName
|
159
|
+
tagline
|
160
|
+
__typename
|
161
|
+
}
|
162
|
+
__typename
|
163
|
+
}
|
164
|
+
board {
|
165
|
+
id
|
166
|
+
name
|
167
|
+
color
|
168
|
+
__typename
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
fragment PostVoteControlPost on Post {
|
173
|
+
id
|
174
|
+
voteCount
|
175
|
+
canVote
|
176
|
+
hasVoted
|
177
|
+
__typename
|
178
|
+
}
|
179
|
+
|
180
|
+
fragment PostLinkPost on Post {
|
181
|
+
id
|
182
|
+
url
|
183
|
+
__typename
|
184
|
+
}
|
185
|
+
|
186
|
+
fragment UserLabelUser on User {
|
187
|
+
id
|
188
|
+
username
|
189
|
+
karma
|
190
|
+
...UserLinkUser
|
191
|
+
__typename
|
192
|
+
}
|
193
|
+
|
194
|
+
fragment UserLinkUser on User {
|
195
|
+
id
|
196
|
+
url
|
197
|
+
username
|
198
|
+
timeCreated
|
199
|
+
roles {
|
200
|
+
id
|
201
|
+
name
|
202
|
+
key
|
203
|
+
tagline
|
204
|
+
__typename
|
205
|
+
}
|
206
|
+
organization {
|
207
|
+
id
|
208
|
+
name
|
209
|
+
__typename
|
210
|
+
}
|
211
|
+
languages {
|
212
|
+
id
|
213
|
+
key
|
214
|
+
displayName
|
215
|
+
tagline
|
216
|
+
icon
|
217
|
+
__typename
|
218
|
+
}
|
219
|
+
__typename
|
220
|
+
}"
|
221
|
+
end
|
222
|
+
|
223
|
+
def Queries.get_user_comments
|
224
|
+
"query ProfileComments($username: String!, $after: String, $order: String, $count: Int) {
|
225
|
+
user: userByUsername(username: $username) {
|
226
|
+
id
|
227
|
+
displayName
|
228
|
+
comments(after: $after, order: $order, count: $count) {
|
229
|
+
items {
|
230
|
+
id
|
231
|
+
...ProfileCommentsComment
|
232
|
+
__typename
|
233
|
+
}
|
234
|
+
pageInfo {
|
235
|
+
nextCursor
|
236
|
+
__typename
|
237
|
+
}
|
238
|
+
__typename
|
239
|
+
}
|
240
|
+
__typename
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
fragment ProfileCommentsComment on Comment {
|
245
|
+
id
|
246
|
+
body
|
247
|
+
timeCreated
|
248
|
+
url
|
249
|
+
isAnswer
|
250
|
+
...CommentVoteControlComment
|
251
|
+
user {
|
252
|
+
id
|
253
|
+
fullName
|
254
|
+
username
|
255
|
+
image
|
256
|
+
bio
|
257
|
+
karma
|
258
|
+
isHacker
|
259
|
+
timeCreated
|
260
|
+
roles {
|
261
|
+
id
|
262
|
+
name
|
263
|
+
key
|
264
|
+
tagline
|
265
|
+
__typename
|
266
|
+
}
|
267
|
+
organization {
|
268
|
+
id
|
269
|
+
name
|
270
|
+
__typename
|
271
|
+
}
|
272
|
+
languages {
|
273
|
+
id
|
274
|
+
key
|
275
|
+
displayName
|
276
|
+
tagline
|
277
|
+
icon
|
278
|
+
__typename
|
279
|
+
}
|
280
|
+
}
|
281
|
+
post {
|
282
|
+
id
|
283
|
+
title
|
284
|
+
url
|
285
|
+
user {
|
286
|
+
id
|
287
|
+
username
|
288
|
+
url
|
289
|
+
__typename
|
290
|
+
}
|
291
|
+
board {
|
292
|
+
id
|
293
|
+
name
|
294
|
+
url
|
295
|
+
slug
|
296
|
+
__typename
|
297
|
+
}
|
298
|
+
__typename
|
299
|
+
}
|
300
|
+
__typename
|
301
|
+
}
|
302
|
+
|
303
|
+
fragment CommentVoteControlComment on Comment {
|
304
|
+
id
|
305
|
+
voteCount
|
306
|
+
canVote
|
307
|
+
hasVoted
|
308
|
+
__typename
|
309
|
+
}"
|
310
|
+
end
|
311
|
+
|
312
|
+
def Queries.get_post
|
313
|
+
"query post($id: Int!) {
|
314
|
+
post(id: $id) {
|
315
|
+
id
|
316
|
+
title
|
317
|
+
preview(removeMarkdown: true, length: 150)
|
318
|
+
body
|
319
|
+
isAnnouncement
|
320
|
+
url
|
321
|
+
isAnswerable
|
322
|
+
isHidden
|
323
|
+
answeredBy {
|
324
|
+
id
|
325
|
+
...PostAnsweredCardUser
|
326
|
+
__typename
|
327
|
+
}
|
328
|
+
answer {
|
329
|
+
id
|
330
|
+
...PostAnsweredCardComment
|
331
|
+
__typename
|
332
|
+
}
|
333
|
+
board {
|
334
|
+
id
|
335
|
+
url
|
336
|
+
description
|
337
|
+
slug
|
338
|
+
__typename
|
339
|
+
}
|
340
|
+
...PostDetailPost
|
341
|
+
__typename
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
fragment PostDetailPost on Post {
|
346
|
+
id
|
347
|
+
title
|
348
|
+
body
|
349
|
+
timeCreated
|
350
|
+
canReport
|
351
|
+
hasReported
|
352
|
+
isAnnouncement
|
353
|
+
isPinned
|
354
|
+
isLocked
|
355
|
+
isHidden
|
356
|
+
commentCount
|
357
|
+
isAnswered
|
358
|
+
isAnswerable
|
359
|
+
...PostVoteControlPost
|
360
|
+
user {
|
361
|
+
id
|
362
|
+
timeCreated
|
363
|
+
roles {
|
364
|
+
id
|
365
|
+
name
|
366
|
+
key
|
367
|
+
tagline
|
368
|
+
__typename
|
369
|
+
}
|
370
|
+
organization {
|
371
|
+
id
|
372
|
+
name
|
373
|
+
__typename
|
374
|
+
}
|
375
|
+
languages {
|
376
|
+
id
|
377
|
+
key
|
378
|
+
displayName
|
379
|
+
tagline
|
380
|
+
icon
|
381
|
+
__typename
|
382
|
+
}
|
383
|
+
...UserPostHeaderUser
|
384
|
+
__typename
|
385
|
+
}
|
386
|
+
repl {
|
387
|
+
id
|
388
|
+
url
|
389
|
+
title
|
390
|
+
description
|
391
|
+
isPrivate
|
392
|
+
isAlwaysOn
|
393
|
+
lang {
|
394
|
+
id
|
395
|
+
icon
|
396
|
+
key
|
397
|
+
displayName
|
398
|
+
tagline
|
399
|
+
__typename
|
400
|
+
}
|
401
|
+
__typename
|
402
|
+
}
|
403
|
+
board {
|
404
|
+
id
|
405
|
+
name
|
406
|
+
color
|
407
|
+
__typename
|
408
|
+
}
|
409
|
+
__typename
|
410
|
+
}
|
411
|
+
|
412
|
+
fragment PostVoteControlPost on Post {
|
413
|
+
id
|
414
|
+
voteCount
|
415
|
+
canVote
|
416
|
+
hasVoted
|
417
|
+
__typename
|
418
|
+
}
|
419
|
+
|
420
|
+
fragment UserPostHeaderUser on User {
|
421
|
+
id
|
422
|
+
image
|
423
|
+
isHacker
|
424
|
+
isModerator: hasRole(role: MODERATOR)
|
425
|
+
isAdmin: hasRole(role: ADMIN)
|
426
|
+
...DepreciatedUserLabelUser
|
427
|
+
...UserLinkUser
|
428
|
+
__typename
|
429
|
+
}
|
430
|
+
|
431
|
+
fragment UserLinkUser on User {
|
432
|
+
id
|
433
|
+
url
|
434
|
+
username
|
435
|
+
__typename
|
436
|
+
}
|
437
|
+
|
438
|
+
fragment DepreciatedUserLabelUser on User {
|
439
|
+
id
|
440
|
+
image
|
441
|
+
username
|
442
|
+
url
|
443
|
+
karma
|
444
|
+
__typename
|
445
|
+
}
|
446
|
+
|
447
|
+
fragment PostAnsweredCardUser on User {
|
448
|
+
id
|
449
|
+
username
|
450
|
+
...DepreciatedUserLabelUser
|
451
|
+
__typename
|
452
|
+
}
|
453
|
+
|
454
|
+
fragment PostAnsweredCardComment on Comment {
|
455
|
+
id
|
456
|
+
url
|
457
|
+
__typename
|
458
|
+
}"
|
459
|
+
end
|
460
|
+
|
461
|
+
def Queries.get_comment
|
462
|
+
"query comment ($id: Int!) {
|
463
|
+
comment(id: $id) {
|
464
|
+
id
|
465
|
+
url
|
466
|
+
isAnswer
|
467
|
+
...CommentDetailComment
|
468
|
+
comments {
|
469
|
+
id
|
470
|
+
url
|
471
|
+
isAnswer
|
472
|
+
...CommentDetailComment
|
473
|
+
__typename
|
474
|
+
}
|
475
|
+
__typename
|
476
|
+
}
|
477
|
+
}
|
478
|
+
|
479
|
+
fragment DepreciatedUserLabelUser on User {
|
480
|
+
id
|
481
|
+
fullName
|
482
|
+
username
|
483
|
+
image
|
484
|
+
bio
|
485
|
+
karma
|
486
|
+
isHacker
|
487
|
+
timeCreated
|
488
|
+
roles {
|
489
|
+
id
|
490
|
+
name
|
491
|
+
key
|
492
|
+
tagline
|
493
|
+
__typename
|
494
|
+
}
|
495
|
+
organization {
|
496
|
+
id
|
497
|
+
name
|
498
|
+
__typename
|
499
|
+
}
|
500
|
+
languages {
|
501
|
+
id
|
502
|
+
key
|
503
|
+
displayName
|
504
|
+
tagline
|
505
|
+
icon
|
506
|
+
__typename
|
507
|
+
}
|
508
|
+
__typename
|
509
|
+
}
|
510
|
+
|
511
|
+
fragment CommentDetailComment on Comment {
|
512
|
+
id
|
513
|
+
body
|
514
|
+
timeCreated
|
515
|
+
url
|
516
|
+
isAnswer
|
517
|
+
...CommentVoteControlComment
|
518
|
+
user {
|
519
|
+
id
|
520
|
+
username
|
521
|
+
...DepreciatedUserLabelWithImageUser
|
522
|
+
__typename
|
523
|
+
}
|
524
|
+
post {
|
525
|
+
id
|
526
|
+
__typename
|
527
|
+
}
|
528
|
+
__typename
|
529
|
+
}
|
530
|
+
|
531
|
+
fragment DepreciatedUserLabelWithImageUser on User {
|
532
|
+
id
|
533
|
+
image
|
534
|
+
...DepreciatedUserLabelUser
|
535
|
+
__typename
|
536
|
+
}
|
537
|
+
|
538
|
+
fragment CommentVoteControlComment on Comment {
|
539
|
+
id
|
540
|
+
voteCount
|
541
|
+
canVote
|
542
|
+
hasVoted
|
543
|
+
__typename
|
544
|
+
}"
|
8
545
|
end
|
9
546
|
end
|
data/lib/repltalk.rb
CHANGED
@@ -16,6 +16,23 @@ class Role
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
|
20
|
+
|
21
|
+
class Organization
|
22
|
+
attr_reader :id, :name
|
23
|
+
|
24
|
+
def initialize(organization)
|
25
|
+
@id = organization["id"]
|
26
|
+
@name = organization["name"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
@name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
19
36
|
class Language
|
20
37
|
attr_reader :id, :key, :name, :tagline, :icon
|
21
38
|
|
@@ -32,10 +49,126 @@ class Language
|
|
32
49
|
end
|
33
50
|
end
|
34
51
|
|
52
|
+
|
53
|
+
|
54
|
+
class Repl
|
55
|
+
attr_reader :id, :url, :title, :description, :language, :is_private, :is_always_on
|
56
|
+
|
57
|
+
def initialize(repl)
|
58
|
+
@id = repl["id"]
|
59
|
+
@url = repl["url"]
|
60
|
+
@title = repl["title"]
|
61
|
+
@description = repl["description"]
|
62
|
+
@language = Language.new(repl["lang"])
|
63
|
+
|
64
|
+
@is_private = repl["isPrivate"]
|
65
|
+
@is_always_on = repl["isAlwaysOn"]
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
@title
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
class Board
|
76
|
+
attr_reader :id, :name, :color
|
77
|
+
|
78
|
+
def initialize(board)
|
79
|
+
@id = board["id"]
|
80
|
+
@name = board["name"]
|
81
|
+
@color = board["color"]
|
82
|
+
end
|
83
|
+
|
84
|
+
def to_s
|
85
|
+
@name
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
class Comment
|
92
|
+
attr_reader :id, :url, :author, :content, :post_id, :is_answer, :vote_count, :timestamp, :comments, :can_vote, :has_voted
|
93
|
+
|
94
|
+
def initialize(client, comment)
|
95
|
+
@client = client
|
96
|
+
|
97
|
+
@id = comment["id"]
|
98
|
+
@url = comment["url"]
|
99
|
+
@author = comment["user"] == nil ? "[deleted user]" : User.new(@client, comment["user"])
|
100
|
+
@content = comment["body"]
|
101
|
+
@post_id = comment["post"]["id"]
|
102
|
+
@is_answer = comment["isAnswer"]
|
103
|
+
@vote_count = comment["voteCount"]
|
104
|
+
@timestamp = comment["timeCreated"]
|
105
|
+
@comments = comment.include?("comments") ? comment["comments"].map { |c| Comment.new(@client, c)} : Array.new
|
106
|
+
|
107
|
+
@can_vote = comment["canVote"]
|
108
|
+
@has_voted = comment["hasVoted"]
|
109
|
+
end
|
110
|
+
|
111
|
+
def get_post
|
112
|
+
p = @client.graphql(
|
113
|
+
"post",
|
114
|
+
Queries.get_post,
|
115
|
+
id: @post_id
|
116
|
+
)
|
117
|
+
Post.new(self, p["post"])
|
118
|
+
end
|
119
|
+
|
120
|
+
def to_s
|
121
|
+
@content
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
class Post
|
128
|
+
attr_reader :id, :url, :repl, :board, :title, :author, :content, :preview, :timestamp, :vote_count, :comment_count, :can_vote, :has_voted, :is_answered, :is_answerable, :is_hidden, :is_pinned, :is_locked, :is_announcement
|
129
|
+
|
130
|
+
def initialize(client, post)
|
131
|
+
@client = client
|
132
|
+
|
133
|
+
@id = post["id"]
|
134
|
+
@url = post["url"]
|
135
|
+
@title = post["title"]
|
136
|
+
@content = post["body"]
|
137
|
+
@preview = post["preview"]
|
138
|
+
@timestamp = post["timeCreated"]
|
139
|
+
|
140
|
+
@board = Board.new(post["board"])
|
141
|
+
@repl = post["repl"] == nil ? nil : Repl.new(post["repl"])
|
142
|
+
@author = post["user"] == nil ? "[deleted user]" : User.new(@client, post["user"])
|
143
|
+
|
144
|
+
@vote_count = post["voteCount"]
|
145
|
+
@comment_count = post["commentCount"]
|
146
|
+
|
147
|
+
@can_vote = post["canVote"]
|
148
|
+
@has_voted = post["hasVoted"]
|
149
|
+
|
150
|
+
@is_answered = post["isAnswered"]
|
151
|
+
@is_answerable = post["isAnswerable"]
|
152
|
+
|
153
|
+
@is_hidden = post["isHidden"]
|
154
|
+
@is_pinned = post["isPinned"]
|
155
|
+
@is_locked = post["isLocked"]
|
156
|
+
@is_announcement = post["isAnnouncement"]
|
157
|
+
end
|
158
|
+
|
159
|
+
def to_s
|
160
|
+
@title
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
|
35
166
|
class User
|
36
|
-
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :roles, :languages
|
167
|
+
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :roles, :organization, :languages
|
168
|
+
|
169
|
+
def initialize(client, user)
|
170
|
+
@client = client
|
37
171
|
|
38
|
-
def initialize(user)
|
39
172
|
@id = user["id"]
|
40
173
|
@username = user["username"]
|
41
174
|
@name = user["fullName"]
|
@@ -43,15 +176,43 @@ class User
|
|
43
176
|
@bio = user["bio"]
|
44
177
|
@cycles = user["karma"]
|
45
178
|
@is_hacker = user["isHacker"]
|
179
|
+
@timestamp = user["timeCreated"]
|
46
180
|
@roles = user["roles"].map { |role| Role.new(role) }
|
181
|
+
@organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
|
47
182
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
48
183
|
end
|
49
184
|
|
185
|
+
def get_posts(order: "new", count: nil, after: nil)
|
186
|
+
p = @client.graphql(
|
187
|
+
"ProfilePosts",
|
188
|
+
Queries.get_user_posts,
|
189
|
+
username: @username,
|
190
|
+
order: order,
|
191
|
+
count: count,
|
192
|
+
after: after
|
193
|
+
)
|
194
|
+
p["user"]["posts"]["items"].map { |post| Post.new(@client, post) }
|
195
|
+
end
|
196
|
+
|
197
|
+
def get_comments(order: "new", count: nil, after: nil)
|
198
|
+
c = @client.graphql(
|
199
|
+
"ProfileComments",
|
200
|
+
Queries.get_user_comments,
|
201
|
+
username: @username,
|
202
|
+
order: order,
|
203
|
+
count: count,
|
204
|
+
after: after
|
205
|
+
)
|
206
|
+
c["user"]["comments"]["items"].map { |comment| Comment.new(@client, comment) }
|
207
|
+
end
|
208
|
+
|
50
209
|
def to_s
|
51
210
|
@username
|
52
211
|
end
|
53
212
|
end
|
54
213
|
|
214
|
+
|
215
|
+
|
55
216
|
class Client
|
56
217
|
attr_writer :sid
|
57
218
|
|
@@ -59,27 +220,6 @@ class Client
|
|
59
220
|
@sid = sid
|
60
221
|
end
|
61
222
|
|
62
|
-
def get_user(name)
|
63
|
-
u = graphql(
|
64
|
-
"userByUsername",
|
65
|
-
Queries.get_user,
|
66
|
-
username: name
|
67
|
-
)
|
68
|
-
User.new(u["user"])
|
69
|
-
end
|
70
|
-
|
71
|
-
def get_user_by_id(id)
|
72
|
-
u = graphql(
|
73
|
-
"user",
|
74
|
-
Queries.get_user_by_id,
|
75
|
-
user_id: id
|
76
|
-
)
|
77
|
-
User.new(u["user"])
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
|
-
private
|
82
|
-
|
83
223
|
def graphql(name, query, **variables)
|
84
224
|
payload = {
|
85
225
|
operationName: name,
|
@@ -106,4 +246,40 @@ class Client
|
|
106
246
|
data = data["data"] if data.include?("data")
|
107
247
|
data
|
108
248
|
end
|
249
|
+
|
250
|
+
def get_user(name)
|
251
|
+
u = graphql(
|
252
|
+
"userByUsername",
|
253
|
+
Queries.get_user,
|
254
|
+
username: name
|
255
|
+
)
|
256
|
+
User.new(self, u["user"])
|
257
|
+
end
|
258
|
+
|
259
|
+
def get_user_by_id(id)
|
260
|
+
u = graphql(
|
261
|
+
"user",
|
262
|
+
Queries.get_user_by_id,
|
263
|
+
user_id: id
|
264
|
+
)
|
265
|
+
User.new(self, u["user"])
|
266
|
+
end
|
267
|
+
|
268
|
+
def get_post(id)
|
269
|
+
p = graphql(
|
270
|
+
"post",
|
271
|
+
Queries.get_post,
|
272
|
+
id: id
|
273
|
+
)
|
274
|
+
Post.new(self, p["post"])
|
275
|
+
end
|
276
|
+
|
277
|
+
def get_comment(id)
|
278
|
+
c = graphql(
|
279
|
+
"comment",
|
280
|
+
Queries.get_comment,
|
281
|
+
id: id
|
282
|
+
)
|
283
|
+
Comment.new(self, c["comment"])
|
284
|
+
end
|
109
285
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repltalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CodingCactus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: With the repltalk gem, you can easily interect with the repltalk graphql
|
42
|
-
api.
|
42
|
+
api. See https://github.com/Coding-Cactus/repltalk for documentation
|
43
43
|
email: codingcactus.cc@gmail.com
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
homepage:
|
51
51
|
licenses: []
|
52
52
|
metadata:
|
53
|
-
source_code_uri: https://github.com/
|
53
|
+
source_code_uri: https://github.com/Coding-Cactus/repltalk
|
54
54
|
post_install_message:
|
55
55
|
rdoc_options: []
|
56
56
|
require_paths:
|