wialon 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wialon.rb +51 -7
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36654cb91e1206daa424c26f13f67e53419d33a0ed351153aea5e74fd1fdf67a
|
4
|
+
data.tar.gz: 5bdf4a446e3056c3c1ebbccbc94f2ee10bdc95732413a03a4217f3db5d44f69c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a7149e8f8c12b07db044ab2008c679cd60ddc4b176e841ef1b80999ca254c357bc826dc4584f2ec86a41527eef9fc3194a8da20d5f3e902cca9688b22c7d5c1
|
7
|
+
data.tar.gz: 414da12ec731d120474ed170b75f6f2d0ad901de1d52c5d9d97756e32c5d97dda6f6eff26d34b9c17fccf8408a2c84cdd5682a118c89e93437e8ce9beff2d5e9
|
data/lib/wialon.rb
CHANGED
@@ -125,20 +125,33 @@ class Wialon
|
|
125
125
|
http.request(request)
|
126
126
|
end
|
127
127
|
|
128
|
-
response = JSON.parse(response.body)
|
128
|
+
response = JSON.parse(response.body, symbolize_names: true)
|
129
|
+
|
130
|
+
if response.class == Hash
|
131
|
+
if !response[:error].nil?
|
132
|
+
return {
|
133
|
+
status: 400,
|
134
|
+
reason: self.parse_errors(response[:error]),
|
135
|
+
result: response
|
136
|
+
}
|
137
|
+
end
|
138
|
+
end
|
129
139
|
|
130
|
-
return
|
140
|
+
return {
|
141
|
+
status: 200,
|
142
|
+
result: response
|
143
|
+
}
|
131
144
|
end
|
132
145
|
|
133
146
|
def login(token)
|
134
147
|
result = self.token_login({token: token})
|
135
|
-
if !result[
|
136
|
-
self.sid = result[
|
148
|
+
if !result[:eid].nil?
|
149
|
+
self.sid = result[:eid]
|
137
150
|
end
|
138
151
|
|
139
152
|
begin
|
140
|
-
if !result[
|
141
|
-
self.uid = result[
|
153
|
+
if !result[:user][:id].nil?
|
154
|
+
self.uid = result[:user][:id]
|
142
155
|
end
|
143
156
|
rescue Exception => e
|
144
157
|
if self.debug
|
@@ -150,7 +163,7 @@ class Wialon
|
|
150
163
|
|
151
164
|
def logout
|
152
165
|
result = self.core_logout()
|
153
|
-
if result.empty? && result[
|
166
|
+
if result.empty? && result[:error] == 0
|
154
167
|
self.sid = ""
|
155
168
|
end
|
156
169
|
return result
|
@@ -166,6 +179,37 @@ class Wialon
|
|
166
179
|
end
|
167
180
|
|
168
181
|
private
|
182
|
+
def parse_errors(code)
|
183
|
+
errors = {
|
184
|
+
'1' => "Invalid session",
|
185
|
+
'2' => "Invalid service name",
|
186
|
+
'3' => "Invalid result",
|
187
|
+
'4' => "Invalid input",
|
188
|
+
'5' => "Error performing request",
|
189
|
+
'6' => "Unknown error",
|
190
|
+
'7' => "Access denied",
|
191
|
+
'8' => "Invalid user name or password",
|
192
|
+
'9' => "Authorization server is unavailable",
|
193
|
+
'10' => "Reached limit of concurrent requests",
|
194
|
+
'11' => "Password reset error",
|
195
|
+
'14' => "Billing error",
|
196
|
+
'1001' => "No messages for selected interval",
|
197
|
+
'1002' => "Item with such unique property already exists or Item cannot be created according to billing restrictions",
|
198
|
+
'1003' => "Only one request is allowed at the moment",
|
199
|
+
'1004' => "Limit of messages has been exceeded",
|
200
|
+
'1005' => "Execution time has exceeded the limit",
|
201
|
+
'1006' => "Exceeding the limit of attempts to enter a two-factor authorization code",
|
202
|
+
'1011' => "Your IP has changed or session has expired",
|
203
|
+
'2014' => "Selected user is a creator for some system objects, thus this user cannot be bound to a new account",
|
204
|
+
'2015' => "Sensor deleting is forbidden because of using in another sensor or advanced properties of the unit"
|
205
|
+
}
|
206
|
+
|
207
|
+
if errors[code.to_s].nil?
|
208
|
+
return "Unknown error"
|
209
|
+
else
|
210
|
+
return errors[code.to_s]
|
211
|
+
end
|
212
|
+
end
|
169
213
|
# SID setter
|
170
214
|
def set_sid(sid)
|
171
215
|
self.sid = sid
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wialon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Golden M Software
|
8
|
+
- Kenny Mochizuki
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2019-
|
12
|
+
date: 2019-08-01 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: Wialon gem wrapper for Remote API
|
14
15
|
email: software@goldenmcorp.com
|
@@ -36,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: '0'
|
38
39
|
requirements: []
|
39
|
-
rubygems_version: 3.0.
|
40
|
+
rubygems_version: 3.0.3
|
40
41
|
signing_key:
|
41
42
|
specification_version: 4
|
42
43
|
summary: Wialon gem wrapper for Remote API
|