repltalk 1.0.0 → 1.4.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 +84 -0
- data/lib/repltalk.rb +114 -0
- metadata +18 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65d203ef3528fe101026800562c7f63088f16ce6e92fc90227bb023cb4d7301c
|
4
|
+
data.tar.gz: a26cbd197e3268b40375a8eb435593792b9cabcbf99f560e06a44b5b25af85f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d77c7ca647951ca694e23786038c1df339d946b80fe9dee70c3897d2c67a4e85616558e9ce941c107c24b49587d896b28553c211e78bd86d524d81aca335497
|
7
|
+
data.tar.gz: 85e91cdb4b8f7c72951e03dc6de860ac3179635298db19cb7d263256343b76796e3af03f2831f9c4f329c8a95549bc4750881a8bc99f66013b6c1614f2d3f21b
|
data/lib/queries.rb
CHANGED
@@ -298,6 +298,14 @@ class Queries
|
|
298
298
|
}"
|
299
299
|
end
|
300
300
|
|
301
|
+
def Queries.get_board
|
302
|
+
"query boardBySlug($slug: String!) {
|
303
|
+
board: boardBySlug(slug: $slug) {
|
304
|
+
#{@@board}
|
305
|
+
}
|
306
|
+
}"
|
307
|
+
end
|
308
|
+
|
301
309
|
def Queries.get_posts
|
302
310
|
"query PostsFeed($order: String, $after: String, $searchQuery: String, $languages: [String!], $count: Int, $boardSlugs: [String!], $pinAnnouncements: Boolean, $pinPinned: Boolean) {
|
303
311
|
posts(order: $order, after: $after, searchQuery: $searchQuery, languages: $languages, count: $count, boardSlugs: $boardSlugs, pinAnnouncements: $pinAnnouncements, pinPinned: $pinPinned) {
|
@@ -318,4 +326,80 @@ class Queries
|
|
318
326
|
}
|
319
327
|
}"
|
320
328
|
end
|
329
|
+
end
|
330
|
+
|
331
|
+
|
332
|
+
class Mutations < Queries
|
333
|
+
def Mutations.create_post
|
334
|
+
"mutation createPost($input: CreatePostInput!) {
|
335
|
+
createPost(input: $input) {
|
336
|
+
post {
|
337
|
+
#{@@post}
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}"
|
341
|
+
end
|
342
|
+
|
343
|
+
def Mutations.edit_post
|
344
|
+
"mutation updatePost($input: UpdatePostInput!) {
|
345
|
+
updatePost(input: $input) {
|
346
|
+
post {
|
347
|
+
#{@@post}
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
"
|
352
|
+
end
|
353
|
+
|
354
|
+
def Mutations.delete_post
|
355
|
+
"mutation deletePost($id: Int!) {
|
356
|
+
deletePost(id: $id) {
|
357
|
+
id
|
358
|
+
}
|
359
|
+
}"
|
360
|
+
end
|
361
|
+
|
362
|
+
def Mutations.create_comment
|
363
|
+
"mutation createComment($input: CreateCommentInput!) {
|
364
|
+
createComment(input: $input) {
|
365
|
+
comment {
|
366
|
+
#{@@comment}
|
367
|
+
}
|
368
|
+
}
|
369
|
+
}"
|
370
|
+
end
|
371
|
+
|
372
|
+
def Mutations.edit_comment
|
373
|
+
"mutation updateComment($input: UpdateCommentInput!) {
|
374
|
+
updateComment(input: $input) {
|
375
|
+
comment {
|
376
|
+
#{@@comment}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}"
|
380
|
+
end
|
381
|
+
|
382
|
+
def Mutations.delete_comment
|
383
|
+
"mutation deleteComment($id: Int!) {
|
384
|
+
deleteComment(id: $id) {
|
385
|
+
id
|
386
|
+
}
|
387
|
+
}"
|
388
|
+
end
|
389
|
+
|
390
|
+
def Mutations.report_post
|
391
|
+
"mutation createBoardReport($id: Int!, $reason: String!) {
|
392
|
+
createBoardReport(postId: $id, reason: $reason) {
|
393
|
+
id
|
394
|
+
}
|
395
|
+
}"
|
396
|
+
end
|
397
|
+
|
398
|
+
def Mutations.report_comment
|
399
|
+
"mutation createBoardReport($id: Int!, $reason: String!) {
|
400
|
+
createBoardReport(commentId: $id, reason: $reason) {
|
401
|
+
id
|
402
|
+
}
|
403
|
+
}"
|
404
|
+
end
|
321
405
|
end
|
data/lib/repltalk.rb
CHANGED
@@ -208,6 +208,50 @@ class Comment
|
|
208
208
|
c["comment"]["parentComment"] == nil ? nil : Comment.new(@client, c["comment"]["parentComment"])
|
209
209
|
end
|
210
210
|
|
211
|
+
def create_comment(content)
|
212
|
+
c = @client.graphql(
|
213
|
+
"createComment",
|
214
|
+
Mutations.create_comment,
|
215
|
+
input: {
|
216
|
+
postId: @post_id,
|
217
|
+
commentId: @id,
|
218
|
+
body: content
|
219
|
+
}
|
220
|
+
)
|
221
|
+
Comment.new(@client, c["createComment"]["comment"])
|
222
|
+
end
|
223
|
+
|
224
|
+
def edit(content)
|
225
|
+
c = @client.graphql(
|
226
|
+
"updateComment",
|
227
|
+
Mutations.edit_comment,
|
228
|
+
input: {
|
229
|
+
id: @id,
|
230
|
+
body: content
|
231
|
+
}
|
232
|
+
)
|
233
|
+
Comment.new(@client, c["updateComment"]["comment"])
|
234
|
+
end
|
235
|
+
|
236
|
+
def delete
|
237
|
+
@client.graphql(
|
238
|
+
"deleteComment",
|
239
|
+
Mutations.delete_comment,
|
240
|
+
id: @id
|
241
|
+
)
|
242
|
+
nil
|
243
|
+
end
|
244
|
+
|
245
|
+
def report(reason)
|
246
|
+
@client.graphql(
|
247
|
+
"createBoardReport",
|
248
|
+
Mutations.report_comment,
|
249
|
+
id: @id,
|
250
|
+
reason: reason
|
251
|
+
)
|
252
|
+
nil
|
253
|
+
end
|
254
|
+
|
211
255
|
def to_s
|
212
256
|
@content
|
213
257
|
end
|
@@ -270,6 +314,52 @@ class Post
|
|
270
314
|
u["post"]["votes"]["items"].map { |vote| User.new(@client, vote["user"]) }
|
271
315
|
end
|
272
316
|
|
317
|
+
def create_comment(content)
|
318
|
+
c = @client.graphql(
|
319
|
+
"createComment",
|
320
|
+
Mutations.create_comment,
|
321
|
+
input: {
|
322
|
+
postId: @id,
|
323
|
+
body: content
|
324
|
+
}
|
325
|
+
)
|
326
|
+
Comment.new(@client, c["createComment"]["comment"])
|
327
|
+
end
|
328
|
+
|
329
|
+
def edit(title: @title, content: @content, repl_id: @repl.id, show_hosted: false)
|
330
|
+
p = @client.graphql(
|
331
|
+
"updatePost",
|
332
|
+
Mutations.edit_post,
|
333
|
+
input: {
|
334
|
+
id: @id,
|
335
|
+
title: title,
|
336
|
+
body: content,
|
337
|
+
replId: repl_id,
|
338
|
+
showHosted: show_hosted
|
339
|
+
}
|
340
|
+
)
|
341
|
+
Post.new(@client, p["updatePost"]["post"])
|
342
|
+
end
|
343
|
+
|
344
|
+
def delete
|
345
|
+
@client.graphql(
|
346
|
+
"deletePost",
|
347
|
+
Mutations.delete_post,
|
348
|
+
id: @id
|
349
|
+
)
|
350
|
+
nil
|
351
|
+
end
|
352
|
+
|
353
|
+
def report(reason)
|
354
|
+
@client.graphql(
|
355
|
+
"createBoardReport",
|
356
|
+
Mutations.report_post,
|
357
|
+
id: @id,
|
358
|
+
reason: reason
|
359
|
+
)
|
360
|
+
nil
|
361
|
+
end
|
362
|
+
|
273
363
|
def to_s
|
274
364
|
@title
|
275
365
|
end
|
@@ -438,6 +528,15 @@ class Client
|
|
438
528
|
Repl.new(self, r["repl"])
|
439
529
|
end
|
440
530
|
|
531
|
+
def get_board(name)
|
532
|
+
b = graphql(
|
533
|
+
"boardBySlug",
|
534
|
+
Queries.get_board,
|
535
|
+
slug: name
|
536
|
+
)
|
537
|
+
Board.new(b["board"])
|
538
|
+
end
|
539
|
+
|
441
540
|
def get_leaderboard(count: nil, since: nil, after: nil)
|
442
541
|
u = graphql(
|
443
542
|
"LeaderboardQuery",
|
@@ -462,4 +561,19 @@ class Client
|
|
462
561
|
)
|
463
562
|
p["posts"]["items"].map { |post| Post.new(self, post) }
|
464
563
|
end
|
564
|
+
|
565
|
+
def create_post(board_name, title, content, repl_id: nil, show_hosted: false)
|
566
|
+
p = graphql(
|
567
|
+
"createPost",
|
568
|
+
Mutations.create_post,
|
569
|
+
input: {
|
570
|
+
boardId: get_board(board_name).id,
|
571
|
+
title: title,
|
572
|
+
body: content,
|
573
|
+
replId: repl_id,
|
574
|
+
showHosted: show_hosted
|
575
|
+
}
|
576
|
+
)
|
577
|
+
Post.new(self, p["createPost"]["post"])
|
578
|
+
end
|
465
579
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repltalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CodingCactus
|
@@ -14,30 +14,42 @@ dependencies:
|
|
14
14
|
name: http
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.4'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 4.4.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.4'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 4.4.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: json
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.5'
|
31
40
|
- - ">="
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
42
|
+
version: 2.5.1
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.5'
|
38
50
|
- - ">="
|
39
51
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
52
|
+
version: 2.5.1
|
41
53
|
description: With the repltalk gem, you can easily interect with the repltalk graphql
|
42
54
|
api. See https://github.com/Coding-Cactus/repltalk for documentation
|
43
55
|
email: codingcactus.cc@gmail.com
|
@@ -47,7 +59,7 @@ extra_rdoc_files: []
|
|
47
59
|
files:
|
48
60
|
- lib/queries.rb
|
49
61
|
- lib/repltalk.rb
|
50
|
-
homepage:
|
62
|
+
homepage: https://github.com/Coding-Cactus/repltalk
|
51
63
|
licenses:
|
52
64
|
- MIT
|
53
65
|
metadata:
|