stream-chat-ruby 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f33905fc20d905b773d08de0596be91bdf399031
4
- data.tar.gz: 3f68209a47f4a0c6f78ec39be3322515e85855b8
2
+ SHA256:
3
+ metadata.gz: 0a7fe7381fe903fe6c875649624173564234d61a561c42852b2e00d39af597fb
4
+ data.tar.gz: cdfb06d0a7f43b3e49423148abf29a654d31de8f1f7246218fe1c69740813d15
5
5
  SHA512:
6
- metadata.gz: dad5cb157613c0c83cf1f9db5acdb8d42882ae5cf7a8831b99afe48434b0bd598e0d73a942a0aeb25d9b0d3ae6f99fe9fb12b7de971b7c5c48496a59b4fc95ed
7
- data.tar.gz: 4ffa4e56a649e549e5b2b88a92949e727648d183b23e53afe06b5e5e5bf3a4fb9da46c2a4bf5fd4a583e6b80057544df2113370179fe621fb55901dff2126965
6
+ metadata.gz: ef7720d01eca5f1b3a66198cfdf23834d4e81100a780992dc0737343d32d23b39d50b8019811da02796f568fe08e542ec602c3b51eeaa55d6d2efd3502d024d8
7
+ data.tar.gz: 9e64bef129d028ab0d9757794662b3106bec83b1a6730e2a1941e767a97ab455d3fd2e0939c6ed635445e8400f2d54a67ba620dd521025e1e2916efd33800a76
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## next release
2
+
3
+ ## Oct 27th, 2019 - 1.1.0
4
+
5
+ - Mark gems use for testing as development dependencies
6
+ - Added `send_file`, `send_image`, `delete_file`, `delete_image`
7
+ - Added `invite_members`
8
+
1
9
  ## Oct 19th, 2019 - 1.0.0
2
10
 
3
11
  - Added `channel.hide` and `channel.show`
@@ -82,6 +82,10 @@ module StreamChat
82
82
  @client.post(url, data: {"add_members": user_ids})
83
83
  end
84
84
 
85
+ def invite_members(user_ids)
86
+ @client.post(url, data: {"invites": user_ids})
87
+ end
88
+
85
89
  def add_moderators(user_ids)
86
90
  @client.post(url, data: {"add_moderators": user_ids})
87
91
  end
@@ -123,6 +127,22 @@ module StreamChat
123
127
  @client.post("#{url}/show", data: {user_id: user_id})
124
128
  end
125
129
 
130
+ def send_file(url, user, content_type = nil)
131
+ @client.send_file("#{self.url}/file", url, user, content_type)
132
+ end
133
+
134
+ def send_image(url, user, content_type = nil)
135
+ @client.send_file("#{self.url}/image", url, user, content_type)
136
+ end
137
+
138
+ def delete_file(url)
139
+ @client.delete("#{self.url}/file", params: {"url": url})
140
+ end
141
+
142
+ def delete_image(url)
143
+ @client.delete("#{self.url}/image", params: {"url": url})
144
+ end
145
+
126
146
  private
127
147
 
128
148
  def add_user_id(payload, user_id)
@@ -1,4 +1,5 @@
1
1
  # lib/client.rb
2
+ require 'open-uri'
2
3
  require 'faraday'
3
4
  require 'jwt'
4
5
  require 'stream-chat/channel'
@@ -34,7 +35,8 @@ module StreamChat
34
35
  @conn = Faraday.new(url: @base_url) do |faraday|
35
36
  faraday.options[:open_timeout] = @timeout
36
37
  faraday.options[:timeout] = @timeout
37
- faraday.adapter Faraday.default_adapter
38
+ faraday.request :multipart
39
+ faraday.adapter :net_http
38
40
  end
39
41
  end
40
42
 
@@ -264,6 +266,25 @@ module StreamChat
264
266
  make_http_request(:patch, relative_url, params: params, data: data)
265
267
  end
266
268
 
269
+ def send_file(relative_url, file_url, user, content_type = 'application/octet-stream')
270
+ url = [@base_url, relative_url].join('/')
271
+
272
+ file = open(file_url)
273
+ body = {user: user.to_json}
274
+
275
+ body[:file] = Faraday::UploadIO.new(file, content_type)
276
+
277
+ response = @conn.post url do |req|
278
+ req.headers["X-Stream-Client"] = get_user_agent
279
+ req.headers['Authorization'] = @auth_token
280
+ req.headers["stream-auth-type"] = "jwt"
281
+ req.params = get_default_params
282
+ req.body = body
283
+ end
284
+
285
+ parse_response(response)
286
+ end
287
+
267
288
  private
268
289
 
269
290
  def get_default_params
@@ -301,7 +322,10 @@ module StreamChat
301
322
  params = params != nil ? params : {}
302
323
  params = Hash[get_default_params.merge(params).sort_by { |k, v| k.to_s }]
303
324
  url = "#{url}?#{URI.encode_www_form(params)}"
304
- body = data.to_json if %w[patch post put].include? method.to_s
325
+
326
+ if %w[patch post put].include? method.to_s
327
+ body = data.to_json
328
+ end
305
329
 
306
330
  response = @conn.run_request(
307
331
  method,
@@ -1,5 +1,5 @@
1
1
  # lib/version.rb
2
2
 
3
3
  module StreamChat
4
- VERSION = "1.0.0".freeze
4
+ VERSION = "1.1.0".freeze
5
5
  end
data/stream-chat.gemspec CHANGED
@@ -14,10 +14,10 @@ Gem::Specification.new do |gem|
14
14
  gem.files = Dir.chdir(File.expand_path('..', __FILE__)) do
15
15
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
16
  end
17
-
17
+
18
18
  gem.add_dependency 'faraday'
19
19
  gem.add_dependency 'jwt'
20
- gem.add_dependency 'rake'
21
- gem.add_dependency 'rspec'
22
- gem.add_dependency 'simplecov'
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec'
22
+ gem.add_development_dependency 'simplecov'
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream-chat-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mircea Cosbuc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-19 00:00:00.000000000 Z
11
+ date: 2019-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -45,7 +45,7 @@ dependencies:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :runtime
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- type: :runtime
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -73,7 +73,7 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
- type: :runtime
76
+ type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
@@ -118,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.4.7
121
+ rubygems_version: 3.0.6
123
122
  signing_key:
124
123
  specification_version: 4
125
124
  summary: The low level client for serverside calls for Stream Chat.