imperituroard 0.2.8 → 0.2.9

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: aeca304c427cdbe347a566fc39138f8a58da945d
4
- data.tar.gz: 4708274c23856b68e63d040d1a66b784840a5933
3
+ metadata.gz: b9caa5ad1572dee6c98500f3f462d24b1e33c380
4
+ data.tar.gz: ad4f914e0ecaa6d3d2ad289af39d72d8d17d6b2a
5
5
  SHA512:
6
- metadata.gz: 224628db3fef071736cc068fda2310dc0d5c47131387148481060f3bcd6de8ff1eb8cc4c66324ca6fd00ed62d36b2f7d1031fa145ae4af6012f14cc154a3245d
7
- data.tar.gz: af0d5294b40f4149d1260136549804e610c4259f3ae16b92cba39a523c9ed8c2b17e292b9bf35260ed004f4f46c8404b1f0aa2fae0dbedf58b7034dde1dac010
6
+ metadata.gz: d25801d9cebc2a5ac5f1e4c80939f98187b9021424a3818a7ebd89f5b27e30cb74c4b0f01dff9a268c5489a5dbe9e628abdda7aac21edcde7f74419fe3c5f96d
7
+ data.tar.gz: 1761bc8bd8a6fea80075c0de0616e3c3777a9f9b333cce4e38176e7ebb3307b392abf03d7693134412f84efb84ec89fdac5b3b8681223250abf509b3ff5aacf2
@@ -90,6 +90,7 @@ class HuaIot
90
90
 
91
91
  #2.2.4 Registering a Directly Connected Device (Password Mode) (V2)
92
92
  def dev_register_passw_code_mode2(app_id, secret, node_id, name_p, description_p, device_type, profile)
93
+ out_resp = {}
93
94
  token = get_token(app_id, secret)[:body]["accessToken"]
94
95
  path = "/iocm/app/reg/v2.0.0/deviceCredentials?appId=" + app_id
95
96
  url_string = "https://" + platformip + ":" + platformport + path
@@ -106,13 +107,16 @@ class HuaIot
106
107
  request.body = {deviceInfo: {nodeId: node_id, name: name_p, description: description_p, deviceType: device_type}}.to_json
107
108
  res = https.request(request)
108
109
  p res.body.to_s
109
- {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
110
+ out_resp = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
111
+ p out_resp
112
+ out_resp
110
113
  end
111
114
 
112
115
 
113
116
 
114
117
  #2.2.12 Deleting a Directly Connected Device
115
118
  def dev_delete(app_id, secret, dev_id)
119
+ out_resp = {}
116
120
  token = get_token(app_id, secret)[:body]["accessToken"]
117
121
  path = "/iocm/app/dm/v1.1.0/devices/" + dev_id + "?app_Id=" + app_id + "&cascade=true"
118
122
  url_string = "https://" + platformip + ":" + platformport + path
@@ -130,11 +134,14 @@ class HuaIot
130
134
  p res.code
131
135
  p res.body
132
136
  if res.body != nil
133
- {:code => res.code, :message => res.message, :body => {:answ => JSON.parse(res.body.to_s)}}
137
+ out_resp = {:code => res.code, :message => res.message, :body => {:answ => JSON.parse(res.body.to_s)}}
134
138
  else
135
- {:code => res.code, :message => res.message, :body => {:answ => "no data"}}
139
+ out_resp = {:code => res.code, :message => res.message, :body => {:answ => "no data"}}
136
140
  end
137
141
 
142
+ p out_resp
143
+ out_resp
144
+
138
145
  end
139
146
 
140
147
 
@@ -19,6 +19,7 @@ class MongoIot
19
19
  end
20
20
 
21
21
  def audit_logger(proc_name, src_ip, input_json, output_json, real_ip)
22
+ out_resp = {}
22
23
  begin
23
24
  d = DateTime.now
24
25
  current = d.strftime("%d/%m/%Y %H:%M:%S")
@@ -31,15 +32,18 @@ class MongoIot
31
32
  :output_params => output_json
32
33
  }
33
34
  result = collection.insert_one(doc)
34
- return {:code => 200, :result => "Request completed successfully", :body => result}
35
+ out_resp = {:code => 200, :result => "audit_logger: Request completed successfully", :body => result}
35
36
  rescue
36
- return {:code => 507, :result => "Unknown SDK error"}
37
+ out_resp = {:code => 507, :result => "audit_logger: Unknown SDK error"}
37
38
  end
39
+ p out_resp
40
+ out_resp
38
41
  end
39
42
 
40
43
  #:code => 507, :result => "Unknown SDK error"
41
44
  #{:code => 200, :result => "Request completed successfully", :body => result_ps}
42
45
  def get_profiles_by_login(login)
46
+ out_resp = {}
43
47
  begin
44
48
  p "get_profiles_by_login get_profiles_by_login"
45
49
  login_profiles = []
@@ -58,17 +62,20 @@ class MongoIot
58
62
  collection2.find({:$or => req2}, {:_id => 0}).each {|row|
59
63
  result_ps.append(row)
60
64
  }
61
- return {:code => 200, :result => "Request completed successfully", :body => result_ps}
65
+ out_resp = {:code => 200, :result => "get_profiles_by_login: Request completed successfully", :body => result_ps}
62
66
  else
63
- return {:code => 404, :result => "Access denied. Incorrect login"}
67
+ out_resp = {:code => 404, :result => "get_profiles_by_login: Access denied. Incorrect login"}
64
68
  end
65
69
 
66
70
  rescue
67
- return {:code => 507, :result => "Unknown SDK error"}
71
+ out_resp = {:code => 507, :result => "get_profiles_by_login: Unknown SDK error"}
68
72
  end
73
+ p out_resp
74
+ out_resp
69
75
  end
70
76
 
71
77
  def get_imei_info_from_db(imeilist)
78
+ out_resp = {}
72
79
  p imeilist
73
80
  p "imeilist"
74
81
  begin
@@ -81,10 +88,12 @@ class MongoIot
81
88
  collection.find({:$or => req2}, {:_id => 0}).each {|row|
82
89
  result_ps.append(row)
83
90
  }
84
- return {:code => 200, :result => "Request completed successfully", :body => result_ps}
91
+ out_resp = {:code => 200, :result => "get_imei_info_from_db: Request completed successfully", :body => result_ps}
85
92
  rescue
86
- return {:code => 507, :result => "Unknown SDK error"}
93
+ out_resp = {:code => 507, :result => "get_imei_info_from_db: Unknown SDK error"}
87
94
  end
95
+ p out_resp
96
+ out_resp
88
97
  end
89
98
 
90
99
  def get_profile_id_by_name(profile_name)
@@ -114,6 +123,7 @@ class MongoIot
114
123
  end
115
124
 
116
125
  def check_login_profile_permiss(login, profile)
126
+ out_resp = {}
117
127
  p "profile"
118
128
  p profile
119
129
  get_login_info = get_profiles_by_login(login)
@@ -123,38 +133,40 @@ class MongoIot
123
133
  if get_login_info[:code]==200
124
134
 
125
135
 
126
-
127
- dst_profile = get_profile_id_by_name(profile)
128
- p "dst_profile"
129
- p dst_profile
130
- access=1
131
- if get_login_info[:body]!=[]
132
- if dst_profile!=[]
133
- p "sgsgsd"
134
- for j in get_login_info[:body]
135
- p j
136
- if j["profile_id"].to_i==dst_profile["profile_id"].to_i
137
- access=0
138
- end
139
- if access==0
140
- return {:code => 200, :result => "Permission granted"}
141
- else
142
- return {:code => 400, :result => "Access denied. This incident will be reported."}
136
+ dst_profile = get_profile_id_by_name(profile)
137
+ p "dst_profile"
138
+ p dst_profile
139
+ access=1
140
+ if get_login_info[:body]!=[]
141
+ if dst_profile!=[]
142
+ p "sgsgsd"
143
+ for j in get_login_info[:body]
144
+ p j
145
+ if j["profile_id"].to_i==dst_profile["profile_id"].to_i
146
+ access=0
147
+ end
148
+ if access==0
149
+ out_resp = {:code => 200, :result => "check_login_profile_permiss: Permission granted"}
150
+ else
151
+ out_resp = {:code => 400, :result => "check_login_profile_permiss: Access denied. This incident will be reported."}
152
+ end
143
153
  end
154
+ else
155
+ out_resp = {:code => 501, :result => "check_login_profile_permiss: Profile not found"}
144
156
  end
145
157
  else
146
- return {:code => 501, :result => "Profile not found"}
158
+ out_resp = {:code => 500, :result => "check_login_profile_permiss: Access denied. Login not found"}
147
159
  end
148
160
  else
149
- return {:code => 500, :result => "Access denied. Login not found"}
150
- end
151
- else
152
- {:code => 500, :result => "Access denied. Login not found"}
161
+ out_resp = {:code => 500, :result => "check_login_profile_permiss: Access denied. Login not found"}
153
162
  end
163
+ p out_resp
164
+ out_resp
154
165
  end
155
166
 
156
167
 
157
168
  def check_login_prof_perm_id_one(login, profile_id)
169
+ out_resp = {}
158
170
  p "profile"
159
171
  p profile_id
160
172
  get_login_info = get_profiles_by_login(login)
@@ -169,17 +181,20 @@ class MongoIot
169
181
  access=0
170
182
  end
171
183
  if access==0
172
- return {:code => 200, :result => "Permission granted"}
184
+ out_resp = {:code => 200, :result => "check_login_prof_perm_id_one: Permission granted"}
173
185
  else
174
- return {:code => 400, :result => "Access denied. This incident will be reported."}
186
+ out_resp = {:code => 400, :result => "check_login_prof_perm_id_one: Access denied. This incident will be reported."}
175
187
  end
176
188
  end
177
189
  else
178
- {:code => 500, :result => "Login not found"}
190
+ out_resp = {:code => 500, :result => "check_login_prof_perm_id_one: Login not found"}
179
191
  end
192
+ p out_resp
193
+ out_resp
180
194
  end
181
195
 
182
196
  def check_imei_exists(imei_list)
197
+ out_resp = {}
183
198
  res_exists = []
184
199
  imei_list_res = get_imei_info_from_db(imei_list)
185
200
  p imei_list_res
@@ -195,8 +210,11 @@ class MongoIot
195
210
  p "not_ex"
196
211
  p not_ex
197
212
  p res_exists
198
- {:code => 200, :result => "check_imei_exists: Request completed successfully",
213
+ out_resp = {:code => 200, :result => "check_imei_exists: Request completed successfully",
199
214
  :body => {:exists => res_exists, :not_exists => not_ex}}
215
+
216
+ p out_resp
217
+ out_resp
200
218
  end
201
219
 
202
220
 
@@ -248,47 +266,52 @@ class MongoIot
248
266
  end
249
267
 
250
268
  def get_profile_name_from_imei(imei)
269
+ out_resp = {}
251
270
  begin
271
+ id = ""
252
272
  begin
253
273
  info = get_imei_info_from_db([imei])
254
274
  if info[:body]==[]
255
- return {:code => 505, :result => "get_profile_name_from_imei: get_imei_info_from_db returned empty list from database. IMEIS not found"}
275
+ out_resp = {:code => 505, :result => "get_profile_name_from_imei: get_imei_info_from_db returned empty list from database. IMEIS not found"}
256
276
  else
257
277
  p "fshhsdf"
258
278
  p info
259
279
  id = info[:body][0]["profile"]
260
280
  end
261
281
  rescue
262
- return {:code => 506, :result => "get_profile_name_from_imei: Function get_imei_info_from_db not processed correctly and returned: #{info.to_s}"}
282
+ out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_imei_info_from_db not processed correctly and returned: #{info.to_s}"}
263
283
  end
264
284
  begin
265
285
  res = get_profile_name_by_id(id)
266
286
  if res.key?("profile")
267
287
  res=res
268
288
  else
269
- return {:code => 505, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not returned profile. Invalid data in database and returned: #{res.to_s}"}
289
+ out_resp = {:code => 505, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not returned profile. Invalid data in database and returned: #{res.to_s}"}
270
290
  end
271
291
 
272
292
  rescue
273
- return {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
293
+ out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
274
294
 
275
295
  end
276
296
  begin
277
297
  if res["profile"]!=nil
278
- return {:code => 200, :result => "get_profile_name_from_imei: Request completed successfully", :body => res}
298
+ out_resp = {:code => 200, :result => "get_profile_name_from_imei: Request completed successfully", :body => res}
279
299
  end
280
300
  rescue
281
- return {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
301
+ out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
282
302
  end
283
303
  rescue
284
- return {:code => 507, :result => "get_profile_name_from_imei: Unknown SDK error"}
304
+ out_resp = {:code => 507, :result => "get_profile_name_from_imei: Unknown SDK error"}
285
305
  end
286
306
 
307
+ p out_resp
308
+ out_resp
309
+
287
310
  end
288
311
 
289
312
 
290
313
  def device_remove_single_mongo(imei)
291
-
314
+ out_resp = {}
292
315
  begin
293
316
  collection = client[:device_imei]
294
317
  doc = {
@@ -296,14 +319,17 @@ class MongoIot
296
319
  }
297
320
  result = collection.delete_many(doc)
298
321
  p result
299
- return {:code => 200, :result => "device_remove_single_mongo: Request completed successfully"}
322
+ out_resp = {:code => 200, :result => "device_remove_single_mongo: Request completed successfully"}
300
323
  rescue
301
- return {:code => 507, :result => "device_remove_single_mongo: Unknown SDK error"}
324
+ out_resp = {:code => 507, :result => "device_remove_single_mongo: Unknown SDK error"}
302
325
  end
326
+ p out_resp
327
+ out_resp
303
328
 
304
329
  end
305
330
 
306
331
  def device_modify_attr_mongo(imei, address)
332
+ out_resp = {}
307
333
  begin
308
334
  collection = client[:device_imei]
309
335
  doc = {
@@ -311,13 +337,16 @@ class MongoIot
311
337
  }
312
338
  sett = {'$set' => {address: address}}
313
339
  result = collection.update_one(doc, sett)
314
- return {:code => 200, :result => "device_modify_attr_mongo: Request completed successfully"}
340
+ out_resp = {:code => 200, :result => "device_modify_attr_mongo: Request completed successfully"}
315
341
  rescue
316
- return {:code => 507, :result => "device_remove_single_mongo: Unknown SDK error"}
342
+ out_resp = {:code => 507, :result => "device_modify_attr_mongo: Unknown SDK error"}
317
343
  end
344
+ p out_resp
345
+ out_resp
318
346
  end
319
347
 
320
348
  def device_modify_any_attr_mongo(imei, attr_list)
349
+ out_resp = {}
321
350
  begin
322
351
  collection = client[:device_imei]
323
352
  doc = {
@@ -333,6 +362,7 @@ class MongoIot
333
362
 
334
363
 
335
364
  def get_iot_oceanconnect_credent(login)
365
+ out_resp = {}
336
366
  begin
337
367
  result_ps = []
338
368
  collection = client[:users]
@@ -342,12 +372,14 @@ class MongoIot
342
372
  p result_ps[0]
343
373
  app_id = result_ps[0][:iot_data][:app_id]
344
374
  secret = result_ps[0][:iot_data][:secret]
345
- return {:code => 200, :result => "get_iot_oceanconnect_credent: Request completed successfully", :body => {:app_id => app_id, :secret => secret}}
375
+ out_resp = {:code => 200, :result => "get_iot_oceanconnect_credent: Request completed successfully", :body => {:app_id => app_id, :secret => secret}}
346
376
  rescue
347
- {:code => 500, :result => "get_iot_oceanconnect_credent: Process failed"}
377
+ out_resp = {:code => 500, :result => "get_iot_oceanconnect_credent: Process failed"}
348
378
  end
379
+ p out_resp
380
+ out_resp
349
381
 
350
- end
382
+ end
351
383
 
352
384
 
353
385
  def ttt
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy