pusher-chatkit-server 1.9.0 → 1.9.1
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.
- checksums.yaml +4 -4
- data/lib/chatkit/client.rb +35 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc311446ce1ca48d7be2f562a6159e4f5de7ed54
|
4
|
+
data.tar.gz: ff32422a40b5f39959c0c08ec04a4b4a5edee7cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5d653ce1d9153d8f369388dc42be3694fbb91b2034b9d231fe9daa41398ad0642e63bfbdd5b614ce73b75f5d16bc4b4d516949fafc830d82e69e8858f9c98dc
|
7
|
+
data.tar.gz: 86920abf2d1a6e123d9cc36c515d15d0b3b7a8ccf2ee97d51d34e64ba7e4d4c92b28b215cfa09f901b5de55bfb740646f1466e927fc3c699dbaed57b61e36121
|
data/lib/chatkit/client.rb
CHANGED
@@ -88,6 +88,13 @@ module Chatkit
|
|
88
88
|
generate_access_token({ su: true }.merge(options))
|
89
89
|
end
|
90
90
|
|
91
|
+
# This helper should be used to encode parameters that appear in path segments.
|
92
|
+
# CGI::escape should NOT be used as it treats the string as if it appears in a query string.
|
93
|
+
# E.G. We want "user name" to be encoded as "user%20name" rather than "user+name"
|
94
|
+
def url_encode_path_segment(s)
|
95
|
+
ERB::Util.url_encode(s)
|
96
|
+
end
|
97
|
+
|
91
98
|
# User API
|
92
99
|
|
93
100
|
def create_user(options)
|
@@ -145,7 +152,7 @@ module Chatkit
|
|
145
152
|
|
146
153
|
api_request({
|
147
154
|
method: "PUT",
|
148
|
-
path: "/users/#{
|
155
|
+
path: "/users/#{url_encode_path_segment options[:id]}",
|
149
156
|
body: payload,
|
150
157
|
jwt: generate_su_token({ user_id: options[:id] })[:token]
|
151
158
|
})
|
@@ -158,7 +165,7 @@ module Chatkit
|
|
158
165
|
|
159
166
|
scheduler_request({
|
160
167
|
method: "PUT",
|
161
|
-
path: "/users/#{
|
168
|
+
path: "/users/#{url_encode_path_segment options[:id]}",
|
162
169
|
jwt: generate_su_token[:token]
|
163
170
|
})
|
164
171
|
end
|
@@ -170,7 +177,7 @@ module Chatkit
|
|
170
177
|
|
171
178
|
scheduler_request({
|
172
179
|
method: "GET",
|
173
|
-
path: "/status/#{
|
180
|
+
path: "/status/#{url_encode_path_segment options[:id]}",
|
174
181
|
jwt: generate_su_token[:token]
|
175
182
|
})
|
176
183
|
end
|
@@ -182,7 +189,7 @@ module Chatkit
|
|
182
189
|
|
183
190
|
api_request({
|
184
191
|
method: "GET",
|
185
|
-
path: "/users/#{
|
192
|
+
path: "/users/#{url_encode_path_segment options[:id]}",
|
186
193
|
jwt: generate_su_token[:token]
|
187
194
|
})
|
188
195
|
end
|
@@ -267,7 +274,7 @@ module Chatkit
|
|
267
274
|
|
268
275
|
api_request({
|
269
276
|
method: "PUT",
|
270
|
-
path: "/rooms/#{
|
277
|
+
path: "/rooms/#{url_encode_path_segment options[:id]}",
|
271
278
|
body: payload,
|
272
279
|
jwt: generate_su_token[:token]
|
273
280
|
})
|
@@ -280,7 +287,7 @@ module Chatkit
|
|
280
287
|
|
281
288
|
scheduler_request({
|
282
289
|
method: "PUT",
|
283
|
-
path: "/rooms/#{
|
290
|
+
path: "/rooms/#{url_encode_path_segment options[:id]}",
|
284
291
|
jwt: generate_su_token[:token]
|
285
292
|
})
|
286
293
|
end
|
@@ -292,7 +299,7 @@ module Chatkit
|
|
292
299
|
|
293
300
|
api_request({
|
294
301
|
method: "GET",
|
295
|
-
path: "/rooms/#{
|
302
|
+
path: "/rooms/#{url_encode_path_segment options[:id]}",
|
296
303
|
jwt: generate_su_token[:token]
|
297
304
|
})
|
298
305
|
end
|
@@ -337,7 +344,7 @@ module Chatkit
|
|
337
344
|
|
338
345
|
api_request({
|
339
346
|
method: "PUT",
|
340
|
-
path: "/rooms/#{
|
347
|
+
path: "/rooms/#{url_encode_path_segment options[:room_id]}/users/add",
|
341
348
|
body: { user_ids: options[:user_ids] },
|
342
349
|
jwt: generate_su_token[:token]
|
343
350
|
})
|
@@ -354,7 +361,7 @@ module Chatkit
|
|
354
361
|
|
355
362
|
api_request({
|
356
363
|
method: "PUT",
|
357
|
-
path: "/rooms/#{
|
364
|
+
path: "/rooms/#{url_encode_path_segment options[:room_id]}/users/remove",
|
358
365
|
body: { user_ids: options[:user_ids] },
|
359
366
|
jwt: generate_su_token[:token]
|
360
367
|
})
|
@@ -370,7 +377,7 @@ module Chatkit
|
|
370
377
|
|
371
378
|
api_request({
|
372
379
|
method: "GET",
|
373
|
-
path: "/rooms/#{
|
380
|
+
path: "/rooms/#{url_encode_path_segment options[:room_id]}/messages/#{options[:message_id]}",
|
374
381
|
jwt: generate_su_token[:token]
|
375
382
|
})
|
376
383
|
end
|
@@ -392,7 +399,7 @@ module Chatkit
|
|
392
399
|
|
393
400
|
api_request({
|
394
401
|
method: "GET",
|
395
|
-
path: "/rooms/#{
|
402
|
+
path: "/rooms/#{url_encode_path_segment options[:room_id]}/messages",
|
396
403
|
query: query_params,
|
397
404
|
jwt: generate_su_token[:token]
|
398
405
|
})
|
@@ -410,7 +417,7 @@ module Chatkit
|
|
410
417
|
|
411
418
|
api_v2_request({
|
412
419
|
method: "GET",
|
413
|
-
path: "/rooms/#{
|
420
|
+
path: "/rooms/#{url_encode_path_segment options[:room_id]}/messages",
|
414
421
|
query: query_params,
|
415
422
|
jwt: generate_su_token[:token]
|
416
423
|
})
|
@@ -467,7 +474,7 @@ module Chatkit
|
|
467
474
|
|
468
475
|
api_request({
|
469
476
|
method: "POST",
|
470
|
-
path: "/rooms/#{
|
477
|
+
path: "/rooms/#{url_encode_path_segment options[:room_id]}/messages",
|
471
478
|
body: {parts: request_parts},
|
472
479
|
jwt: token
|
473
480
|
})
|
@@ -509,7 +516,7 @@ module Chatkit
|
|
509
516
|
|
510
517
|
api_v2_request({
|
511
518
|
method: "POST",
|
512
|
-
path: "/rooms/#{
|
519
|
+
path: "/rooms/#{url_encode_path_segment options[:room_id]}/messages",
|
513
520
|
body: payload,
|
514
521
|
jwt: generate_su_token({ user_id: options[:sender_id] })[:token]
|
515
522
|
})
|
@@ -591,7 +598,7 @@ module Chatkit
|
|
591
598
|
|
592
599
|
api_request({
|
593
600
|
method: "PUT",
|
594
|
-
path: "/rooms/#{
|
601
|
+
path: "/rooms/#{url_encode_path_segment room_id}/messages/#{message_id}",
|
595
602
|
body: {parts: request_parts},
|
596
603
|
jwt: token
|
597
604
|
})
|
@@ -645,7 +652,7 @@ module Chatkit
|
|
645
652
|
|
646
653
|
api_v2_request({
|
647
654
|
method: "PUT",
|
648
|
-
path: "/rooms/#{
|
655
|
+
path: "/rooms/#{url_encode_path_segment room_id}/messages/#{message_id}",
|
649
656
|
body: payload,
|
650
657
|
jwt: generate_su_token({ user_id: options[:sender_id] })[:token]
|
651
658
|
})
|
@@ -700,7 +707,7 @@ module Chatkit
|
|
700
707
|
|
701
708
|
authorizer_request({
|
702
709
|
method: "GET",
|
703
|
-
path: "/users/#{
|
710
|
+
path: "/users/#{url_encode_path_segment options[:user_id]}/roles",
|
704
711
|
jwt: generate_su_token[:token]
|
705
712
|
})
|
706
713
|
end
|
@@ -750,7 +757,7 @@ module Chatkit
|
|
750
757
|
|
751
758
|
cursors_request({
|
752
759
|
method: "GET",
|
753
|
-
path: "/cursors/0/rooms/#{
|
760
|
+
path: "/cursors/0/rooms/#{url_encode_path_segment options[:room_id]}/users/#{url_encode_path_segment options[:user_id]}",
|
754
761
|
jwt: generate_su_token[:token]
|
755
762
|
})
|
756
763
|
end
|
@@ -770,7 +777,7 @@ module Chatkit
|
|
770
777
|
|
771
778
|
cursors_request({
|
772
779
|
method: "PUT",
|
773
|
-
path: "/cursors/0/rooms/#{
|
780
|
+
path: "/cursors/0/rooms/#{url_encode_path_segment options[:room_id]}/users/#{url_encode_path_segment options[:user_id]}",
|
774
781
|
body: { position: options[:position] },
|
775
782
|
jwt: generate_su_token[:token]
|
776
783
|
})
|
@@ -783,7 +790,7 @@ module Chatkit
|
|
783
790
|
|
784
791
|
cursors_request({
|
785
792
|
method: "GET",
|
786
|
-
path: "/cursors/0/users/#{
|
793
|
+
path: "/cursors/0/users/#{url_encode_path_segment options[:user_id]}",
|
787
794
|
jwt: generate_su_token[:token]
|
788
795
|
})
|
789
796
|
end
|
@@ -795,7 +802,7 @@ module Chatkit
|
|
795
802
|
|
796
803
|
cursors_request({
|
797
804
|
method: "GET",
|
798
|
-
path: "/cursors/0/rooms/#{
|
805
|
+
path: "/cursors/0/rooms/#{url_encode_path_segment options[:room_id]}",
|
799
806
|
jwt: generate_su_token[:token]
|
800
807
|
})
|
801
808
|
end
|
@@ -852,7 +859,7 @@ module Chatkit
|
|
852
859
|
|
853
860
|
request_options = {
|
854
861
|
method: "GET",
|
855
|
-
path: "/users/#{
|
862
|
+
path: "/users/#{url_encode_path_segment options[:id]}/rooms",
|
856
863
|
jwt: generate_su_token[:token]
|
857
864
|
}
|
858
865
|
|
@@ -891,7 +898,7 @@ module Chatkit
|
|
891
898
|
|
892
899
|
authorizer_request({
|
893
900
|
method: "DELETE",
|
894
|
-
path: "/roles/#{
|
901
|
+
path: "/roles/#{url_encode_path_segment options[:name]}/scope/#{options[:scope]}",
|
895
902
|
jwt: generate_su_token[:token]
|
896
903
|
})
|
897
904
|
end
|
@@ -913,7 +920,7 @@ module Chatkit
|
|
913
920
|
|
914
921
|
authorizer_request({
|
915
922
|
method: "PUT",
|
916
|
-
path: "/users/#{
|
923
|
+
path: "/users/#{url_encode_path_segment options[:user_id]}/roles",
|
917
924
|
body: body,
|
918
925
|
jwt: generate_su_token[:token]
|
919
926
|
})
|
@@ -926,7 +933,7 @@ module Chatkit
|
|
926
933
|
|
927
934
|
request_options = {
|
928
935
|
method: "DELETE",
|
929
|
-
path: "/users/#{
|
936
|
+
path: "/users/#{url_encode_path_segment options[:user_id]}/roles",
|
930
937
|
jwt: generate_su_token[:token]
|
931
938
|
}
|
932
939
|
|
@@ -944,7 +951,7 @@ module Chatkit
|
|
944
951
|
|
945
952
|
authorizer_request({
|
946
953
|
method: "GET",
|
947
|
-
path: "/roles/#{
|
954
|
+
path: "/roles/#{url_encode_path_segment options[:name]}/scope/#{options[:scope]}/permissions",
|
948
955
|
jwt: generate_su_token[:token]
|
949
956
|
})
|
950
957
|
end
|
@@ -967,7 +974,7 @@ module Chatkit
|
|
967
974
|
|
968
975
|
authorizer_request({
|
969
976
|
method: "PUT",
|
970
|
-
path: "/roles/#{
|
977
|
+
path: "/roles/#{url_encode_path_segment options[:name]}/scope/#{options[:scope]}/permissions",
|
971
978
|
body: body,
|
972
979
|
jwt: generate_su_token[:token]
|
973
980
|
})
|
@@ -992,7 +999,7 @@ module Chatkit
|
|
992
999
|
|
993
1000
|
attachment_response = api_request({
|
994
1001
|
method: "POST",
|
995
|
-
path: "/rooms/#{
|
1002
|
+
path: "/rooms/#{url_encode_path_segment room_id}/attachments",
|
996
1003
|
body: attachment_req,
|
997
1004
|
jwt: token
|
998
1005
|
})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher-chatkit-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pusher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pusher-platform
|