pusher-chatkit-server 0.4.2 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chatkit/client.rb +22 -18
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5491da27b0ce38e9b13058a838ff48589270d777
4
- data.tar.gz: b008fb29fcbab25b7b634ed266d34c998e5e66bb
3
+ metadata.gz: c3a7278828c729e0a89fde04edb9e75b94b72b91
4
+ data.tar.gz: 8715360652c89f7a70e1058951012410cf35ea22
5
5
  SHA512:
6
- metadata.gz: 3e96e39a8294dc267859d01980e611213fcac3ac11991d2acaa1e71afd0b4893fd66639e75609c9607d5b96267a9cc6a294e46b0d260737c407eaad3572283de
7
- data.tar.gz: d9f7b95a1ac47ee483f7c2be7246c822228e6365de63209ec52838c5d51053dc397356e47e116b8c77f581f70e87fe27852fbeb2cdee3d37eaa4c8c88db0f7b0
6
+ metadata.gz: dfcf2fb6fbbfbcc4d6f78349175dc4eceda2741c051acc174e39383450cbb452f0a9a6ad765770895c9cbb704892483855aaa08ba69dcf5adaf63704e1c58f25
7
+ data.tar.gz: 9c33e178b6551a7d1cbd95cb68d5d9a0fd58da2c542aaf15820aa2b0d6880bb2d043031697adb2c94bec3b2f11e4191a4bec320a9c2a139b3a2234dfe7c926c5
@@ -42,9 +42,13 @@ module Chatkit
42
42
  @api_instance.generate_access_token(options)
43
43
  end
44
44
 
45
+ def generate_su_token(options = {})
46
+ generate_access_token({ su: true }.merge(options))[:token]
47
+ end
48
+
45
49
  # User API
46
50
 
47
- def create_user(id, name, avatar_url, custom_data)
51
+ def create_user(id, name, avatar_url = nil, custom_data = nil)
48
52
  body = {
49
53
  id: id,
50
54
  name: name
@@ -65,7 +69,7 @@ module Chatkit
65
69
  "Content-Type": "application/json",
66
70
  },
67
71
  body: body,
68
- jwt: generate_access_token(su: true)
72
+ jwt: generate_su_token
69
73
  )
70
74
  end
71
75
 
@@ -73,7 +77,7 @@ module Chatkit
73
77
  @api_instance.request(
74
78
  method: "DELETE",
75
79
  path: "/users/#{id}",
76
- jwt: generate_access_token(su: true)
80
+ jwt: generate_su_token
77
81
  )
78
82
  end
79
83
 
@@ -81,7 +85,7 @@ module Chatkit
81
85
  request_options = {
82
86
  method: "GET",
83
87
  path: "/users",
84
- jwt: generate_access_token(su: true)
88
+ jwt: generate_su_token
85
89
  }
86
90
 
87
91
  unless from_id == nil && from_id == ""
@@ -98,7 +102,7 @@ module Chatkit
98
102
  query: {
99
103
  user_ids: user_ids.join(",")
100
104
  },
101
- jwt: generate_access_token(su: true)
105
+ jwt: generate_su_token
102
106
  )
103
107
  end
104
108
 
@@ -108,11 +112,11 @@ module Chatkit
108
112
  @api_instance.request(
109
113
  method: "GET",
110
114
  path: "/rooms/#{room_id}",
111
- jwt: generate_access_token(su: true)
115
+ jwt: generate_su_token
112
116
  )
113
117
  end
114
118
 
115
- def get_room_messages(room_id, initial_id, direction, limit)
119
+ def get_room_messages(user_id, room_id, initial_id = nil, direction = nil, limit = nil)
116
120
  query_params = {}
117
121
 
118
122
  query_params[:initial_id] = initial_id unless initial_id.nil?
@@ -123,15 +127,15 @@ module Chatkit
123
127
  method: "GET",
124
128
  path: "/rooms/#{room_id}/messages",
125
129
  query: query_params,
126
- jwt: @api_instance.generate_access_token(su: true)
130
+ jwt: generate_su_token({ user_id: user_id })
127
131
  )
128
132
  end
129
133
 
130
- def get_rooms(from_id)
134
+ def get_rooms(user_id, from_id = nil)
131
135
  request_options = {
132
136
  method: "GET",
133
137
  path: "/rooms",
134
- jwt: @api_instance.generate_access_token(su: true)
138
+ jwt: generate_su_token({ user_id: user_id })
135
139
  }
136
140
 
137
141
  unless from_id == nil && from_id == ""
@@ -171,7 +175,7 @@ module Chatkit
171
175
  resp = @authorizer_instance.request(
172
176
  method: "GET",
173
177
  path: "/roles",
174
- jwt: generate_access_token(su: true)
178
+ jwt: generate_su_token
175
179
  )
176
180
 
177
181
  JSON.parse(resp.body)
@@ -181,7 +185,7 @@ module Chatkit
181
185
  resp = @authorizer_instance.request(
182
186
  method: "GET",
183
187
  path: "/users/#{user_id}/roles",
184
- jwt: generate_access_token(su: true)
188
+ jwt: generate_su_token
185
189
  )
186
190
 
187
191
  JSON.parse(resp.body)
@@ -221,7 +225,7 @@ module Chatkit
221
225
  "Content-Type": "application/json"
222
226
  },
223
227
  body: body,
224
- jwt: generate_access_token(su: true)
228
+ jwt: generate_su_token
225
229
  )
226
230
  end
227
231
 
@@ -241,7 +245,7 @@ module Chatkit
241
245
  name: name,
242
246
  permissions: permissions,
243
247
  },
244
- jwt: generate_access_token(su: true)
248
+ jwt: generate_su_token
245
249
  )
246
250
  end
247
251
 
@@ -249,7 +253,7 @@ module Chatkit
249
253
  @authorizer_instance.request(
250
254
  method: "DELETE",
251
255
  path: "/roles/#{role_name}/scope/#{scope}",
252
- jwt: generate_access_token(su: true)
256
+ jwt: generate_su_token
253
257
  )
254
258
  end
255
259
 
@@ -267,7 +271,7 @@ module Chatkit
267
271
  "Content-Type": "application/json",
268
272
  },
269
273
  body: body,
270
- jwt: generate_access_token(su: true)
274
+ jwt: generate_su_token
271
275
  )
272
276
  end
273
277
 
@@ -279,7 +283,7 @@ module Chatkit
279
283
  "Content-Type": "application/json",
280
284
  },
281
285
  query: { room_id: room_id },
282
- jwt: generate_access_token(su: true)
286
+ jwt: generate_su_token
283
287
  }
284
288
 
285
289
  unless room_id.nil?
@@ -293,7 +297,7 @@ module Chatkit
293
297
  resp = @authorizer_instance.request(
294
298
  method: "GET",
295
299
  path: "/roles/#{role_name}/scope/#{scope}/permissions",
296
- jwt: generate_access_token(su: true)
300
+ jwt: generate_su_token
297
301
  )
298
302
 
299
303
  JSON.parse(resp.body)
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: 0.4.2
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pusher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-11 00:00:00.000000000 Z
11
+ date: 2018-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pusher-platform