zquickblox 1.0.3 → 1.0.4

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
2
  SHA1:
3
- metadata.gz: 4d87d086e7ff68a648ccaec293158490b2d2068c
4
- data.tar.gz: 8b1cb38892190918442f443d5f1c740b138bbd82
3
+ metadata.gz: 5ae4c356cd3ca377dc9fe3a08b6f101bdd538a8f
4
+ data.tar.gz: f1dfedf7c9449ea121945f26a075c68440a8aa02
5
5
  SHA512:
6
- metadata.gz: f23d329dfadb9b413e6cf684f4997a0e8ec8355dbf456559d4ad6731ec283905bdb76009fd6bdf883074d7ed87ed67b850076dd1d58aaa9570d90943c341a076
7
- data.tar.gz: 98754acef0e9b4e43ae1eef30a77825f21dfe1349ef9bf82096cb3f5ffaa678c4690e7a3e429298c2403188e36a32c5d8067c047b9922bf722b1ebe5719c7a5a
6
+ metadata.gz: bf3ae1dc543b1ff18525cb00b70a5016a5d7e3666a8cf85568774521d7c2e415db9aa40cf393ac4a69094de1b6565b3706ee58cc63a6656474f77e2895e3fcb0
7
+ data.tar.gz: 8a5440679e7e1722e8664006b64edb8056edb299aed74abd5e567ac7cc86fee689f4d9ef6b9ec220dcc5c17c39499835b65c9f4dc46d262fe6d36f277c4ae3df
@@ -34,10 +34,14 @@ module ZQuickblox
34
34
  put if @method == :put
35
35
  delete if @method == :delete
36
36
 
37
- @response_body = JSON.parse(@response.body) if @response.status != 404
37
+ if @response.status != 404 && @response.body.length > 1
38
+ @response_body = JSON.parse(@response.body)
39
+ else
40
+ @response_body = {}
41
+ end
38
42
 
39
43
  @errors = @response_body["errors"] if @response.status != 404
40
- if @errors
44
+ if @errors
41
45
  if @errors.kind_of?(Hash)
42
46
  raise ZQuickblox::Error.new(messages: @errors["base"]) if !@errors["base"].nil?
43
47
  message = ""
@@ -45,7 +49,7 @@ module ZQuickblox
45
49
  message += "; " + key
46
50
  message += " " + value.join(", ")
47
51
  end
48
- raise ZQuickblox::Error.new(messages: message)
52
+ raise ZQuickblox::Error.new(messages: message)
49
53
  end
50
54
  end
51
55
 
@@ -1,5 +1,6 @@
1
1
  require_relative "user/create_user_request"
2
2
  require_relative "user/find_user_request"
3
+ require_relative "user/delete_user_request"
3
4
 
4
5
  module ZQuickblox
5
6
  module User
@@ -16,13 +17,20 @@ module ZQuickblox
16
17
  def find(login)
17
18
  request = ZQuickblox::User::FindUserRequest.new(login)
18
19
  run_request(request)
19
- return nil if request.response.status == 404
20
+ return nil if request.response.status == 404
20
21
  user = User.new(ZQuickblox::Util.symbolize_keys(request.response_body["user"]))
21
22
  return user
22
23
  end
23
24
 
24
- def run_request(request)
25
- session = ZQuickblox::Session.create
25
+ def delete(login, password, id)
26
+ request = ZQuickblox::User::DeleteUserRequest.new(id)
27
+ run_request(request, login, password)
28
+ return nil if request.response.status != 200
29
+ return {}
30
+ end
31
+
32
+ def run_request(request, login=nil, password=nil)
33
+ session = ZQuickblox::Session.create(login, password)
26
34
  request.header("QB-Token", session.token)
27
35
  request.execute
28
36
  end
@@ -0,0 +1,11 @@
1
+ module ZQuickblox
2
+ module User
3
+ class DeleteUserRequest < Request
4
+ def initialize(id)
5
+ super()
6
+ @uri = "/users/#{id}.json"
7
+ @method = :delete
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module ZQuickblox
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zquickblox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thuong Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-09 00:00:00.000000000 Z
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,10 +110,25 @@ files:
110
110
  - lib/zquickblox/signature.rb
111
111
  - lib/zquickblox/user.rb
112
112
  - lib/zquickblox/user/create_user_request.rb
113
+ - lib/zquickblox/user/delete_user_request.rb
113
114
  - lib/zquickblox/user/find_user_request.rb
114
115
  - lib/zquickblox/user/login_user_request.rb
115
116
  - lib/zquickblox/util.rb
116
117
  - lib/zquickblox/version.rb
118
+ - zquickblox-0.1.0.gem
119
+ - zquickblox-0.1.1.gem
120
+ - zquickblox-0.1.2.gem
121
+ - zquickblox-0.1.3.gem
122
+ - zquickblox-0.1.4.gem
123
+ - zquickblox-0.1.5.gem
124
+ - zquickblox-0.1.6.gem
125
+ - zquickblox-0.1.7.gem
126
+ - zquickblox-0.1.8.gem
127
+ - zquickblox-0.1.9.gem
128
+ - zquickblox-1.0.0.gem
129
+ - zquickblox-1.0.1.gem
130
+ - zquickblox-1.0.2.gem
131
+ - zquickblox-1.0.3.gem
117
132
  - zquickblox.gemspec
118
133
  homepage: https://github.com/zelic91/zquickblox
119
134
  licenses: