imperituroard 0.3.0 → 0.3.1

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: 5dd10455562230533ca66925146fc6277ad59e8d
4
- data.tar.gz: da05bfe279194071153aa51c7fe9071051e4a8ef
3
+ metadata.gz: af60b151480d6a1c71cd84d689e423bccf2ed941
4
+ data.tar.gz: 409d6e0c73cde93cb4af935a149dc73cd394ca7c
5
5
  SHA512:
6
- metadata.gz: b5ba1bb0d2403d224fc8e96ab1a7ceb36815c4340b35174a3b7211161ae8090e7a64c38f09c34d577bb2ea66de20e4f25d098a1769b3de65a3a5a6e1c06ad34e
7
- data.tar.gz: 5ac36913151dd8637caf0aec3723e0f327e54d336e1c0387ff263f9d8ad2e74c74df41a222c06e83b57e161eff6a19fac2f7a3be79984cf9de7e67ae1e9f88b1
6
+ metadata.gz: 6853486f866d2cbf9890a573dc940d9be819b243a45c55c6f31f1710800427a52b0262faa0bf27876a8615a9774e4487856c40cb177b0fb88ba22d600d26c35e
7
+ data.tar.gz: 0c8a055f4998cfa4edb4f23a443f9b6cd599e0d722962587ce628e248fe09461703d23926f9ce97497a2690e15c84d580543bfdce6fc954daa5132537790f7f3
@@ -5,11 +5,12 @@ require 'json'
5
5
  require 'rubygems'
6
6
  require 'nokogiri'
7
7
  require 'rails'
8
+ require "imperituroard/projects/iot/internal_functions"
8
9
 
9
10
 
10
11
  class HuaIot
11
12
 
12
- attr_accessor :platformip, :platformport, :client, :database, :cert_file, :key_file
13
+ attr_accessor :platformip, :platformport, :client, :database, :cert_file, :key_file, :internal_func
13
14
 
14
15
  def initialize(platformip, platformport, cert_file, key_file)
15
16
  @database = database
@@ -19,6 +20,7 @@ class HuaIot
19
20
  @key_file = key_file
20
21
  #client_host = [mongoip + ":" + mongoport]
21
22
  #@client = Mongo::Client.new(client_host, :database => database)
23
+ @internal_func = InternalFunc.new
22
24
  end
23
25
 
24
26
  def parse_token(str)
@@ -48,6 +50,7 @@ class HuaIot
48
50
  end
49
51
 
50
52
  def get_token(app_id, secret)
53
+ internal_func.test
51
54
  out_resp = {}
52
55
  begin
53
56
  path = "/iocm/app/sec/v1.1.0/login"
@@ -70,15 +73,15 @@ class HuaIot
70
73
  rescue
71
74
  out_resp = {:code => 500, :message => "failed get token"}
72
75
  end
73
- p jjj = {:procedure => "get_token", :answ => out_resp}
76
+ jjj = {:procedure => "get_token", :answ => out_resp}
77
+ internal_func.printer_texter(jjj)
74
78
  out_resp
75
79
  end
76
80
 
77
81
 
78
82
  def token_logout(token)
79
83
 
80
- p "token_logout token: #{token}"
81
-
84
+ internal_func.printer_texter("token_logout token: #{token}")
82
85
  out_resp = {}
83
86
  begin
84
87
  path = "/iocm/app/sec/v1.1.0/logout"
@@ -100,7 +103,8 @@ class HuaIot
100
103
  rescue
101
104
  out_resp = {:code => 500, :message => "failed logout token"}
102
105
  end
103
- p jjj = {:procedure => "token_logout", :answ => out_resp}
106
+ jjj = {:procedure => "token_logout", :answ => out_resp}
107
+ internal_func.printer_texter(jjj)
104
108
  out_resp
105
109
  end
106
110
 
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift File.expand_path("../projects/iot", __dir__)
2
+
3
+ class InternalFunc
4
+
5
+
6
+ def printer_texter(text)
7
+ mess = {:sdk=> "imperituroard", :sdk_version=> "0.3.1", :message => text}
8
+ p mess
9
+ end
10
+
11
+
12
+ def test()
13
+ p "eeeeeeeeeeeeeeeeeeeeeeee"
14
+ end
15
+ end
@@ -4,11 +4,12 @@ require 'json'
4
4
  require 'rubygems'
5
5
  require 'nokogiri'
6
6
  require 'rails'
7
+ require "imperituroard/projects/iot/internal_functions"
7
8
 
8
9
  #class for communication with mongo database for iot API
9
10
  class MongoIot
10
11
 
11
- attr_accessor :mongo_ip, :mongo_port, :client, :mongo_database
12
+ attr_accessor :mongo_ip, :mongo_port, :client, :mongo_database, :internal_func
12
13
 
13
14
  def initialize(mongo_ip, mongo_port, mongo_database)
14
15
  @mongo_database = mongo_database
@@ -16,6 +17,7 @@ class MongoIot
16
17
  @mongo_port = mongo_port
17
18
  client_host = [mongo_ip + ":" + mongo_port]
18
19
  @client = Mongo::Client.new(client_host, :database => mongo_database)
20
+ @internal_func = InternalFunc.new
19
21
  end
20
22
 
21
23
  def audit_logger(proc_name, src_ip, input_json, output_json, real_ip)
@@ -36,7 +38,7 @@ class MongoIot
36
38
  rescue
37
39
  out_resp = {:code => 507, :result => "audit_logger: Unknown SDK error"}
38
40
  end
39
- p out_resp
41
+ internal_func.printer_texter(out_resp)
40
42
  out_resp
41
43
  end
42
44
 
@@ -70,7 +72,7 @@ class MongoIot
70
72
  rescue
71
73
  out_resp = {:code => 507, :result => "get_profiles_by_login: Unknown SDK error"}
72
74
  end
73
- p out_resp
75
+ internal_func.printer_texter(out_resp)
74
76
  out_resp
75
77
  end
76
78
 
@@ -92,7 +94,7 @@ class MongoIot
92
94
  rescue
93
95
  out_resp = {:code => 507, :result => "get_imei_info_from_db: Unknown SDK error"}
94
96
  end
95
- p out_resp
97
+ internal_func.printer_texter(out_resp)
96
98
  out_resp
97
99
  end
98
100
 
@@ -160,7 +162,7 @@ class MongoIot
160
162
  else
161
163
  out_resp = {:code => 500, :result => "check_login_profile_permiss: Access denied. Login not found"}
162
164
  end
163
- p out_resp
165
+ internal_func.printer_texter(out_resp)
164
166
  out_resp
165
167
  end
166
168
 
@@ -189,7 +191,7 @@ class MongoIot
189
191
  else
190
192
  out_resp = {:code => 500, :result => "check_login_prof_perm_id_one: Login not found"}
191
193
  end
192
- p out_resp
194
+ internal_func.printer_texter(out_resp)
193
195
  out_resp
194
196
  end
195
197
 
@@ -212,8 +214,7 @@ class MongoIot
212
214
  p res_exists
213
215
  out_resp = {:code => 200, :result => "check_imei_exists: Request completed successfully",
214
216
  :body => {:exists => res_exists, :not_exists => not_ex}}
215
-
216
- p out_resp
217
+ internal_func.printer_texter(out_resp)
217
218
  out_resp
218
219
  end
219
220
 
@@ -291,7 +292,6 @@ class MongoIot
291
292
  else
292
293
  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}"}
293
294
  end
294
-
295
295
  rescue
296
296
  out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
297
297
 
@@ -303,8 +303,6 @@ class MongoIot
303
303
  rescue
304
304
  out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_profile_name_by_id not processed correctly and returned: #{res.to_s}"}
305
305
  end
306
-
307
-
308
306
  end
309
307
  rescue
310
308
  out_resp = {:code => 506, :result => "get_profile_name_from_imei: Function get_imei_info_from_db not processed correctly and returned: #{info.to_s}"}
@@ -313,10 +311,8 @@ class MongoIot
313
311
  rescue
314
312
  out_resp = {:code => 507, :result => "get_profile_name_from_imei: Unknown SDK error"}
315
313
  end
316
-
317
- p out_resp
314
+ internal_func.printer_texter(out_resp)
318
315
  out_resp
319
-
320
316
  end
321
317
 
322
318
 
@@ -333,9 +329,8 @@ class MongoIot
333
329
  rescue
334
330
  out_resp = {:code => 507, :result => "device_remove_single_mongo: Unknown SDK error"}
335
331
  end
336
- p out_resp
332
+ internal_func.printer_texter(out_resp)
337
333
  out_resp
338
-
339
334
  end
340
335
 
341
336
  def device_modify_attr_mongo(imei, address)
@@ -351,7 +346,7 @@ class MongoIot
351
346
  rescue
352
347
  out_resp = {:code => 507, :result => "device_modify_attr_mongo: Unknown SDK error"}
353
348
  end
354
- p out_resp
349
+ internal_func.printer_texter(out_resp)
355
350
  out_resp
356
351
  end
357
352
 
@@ -386,9 +381,8 @@ class MongoIot
386
381
  rescue
387
382
  out_resp = {:code => 500, :result => "get_iot_oceanconnect_credent: Process failed"}
388
383
  end
389
- p out_resp
384
+ internal_func.printer_texter(out_resp)
390
385
  out_resp
391
-
392
386
  end
393
387
 
394
388
 
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/imperituroard.rb CHANGED
@@ -7,6 +7,7 @@ require "imperituroard/phpipamcps"
7
7
  require "imperituroard/projects/iot/mongoconnector"
8
8
  require "imperituroard/projects/iot/hua_oceanconnect_adapter"
9
9
  require "imperituroard/projects/iot/add_functions"
10
+ require "imperituroard/projects/iot/internal_functions"
10
11
  require 'json'
11
12
  require 'ipaddr'
12
13
 
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
@@ -162,6 +162,7 @@ files:
162
162
  - lib/imperituroard/phpipamdb.rb
163
163
  - lib/imperituroard/projects/iot/add_functions.rb
164
164
  - lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb
165
+ - lib/imperituroard/projects/iot/internal_functions.rb
165
166
  - lib/imperituroard/projects/iot/mongoconnector.rb
166
167
  - lib/imperituroard/projects/wttx/updatepostcps.rb
167
168
  - lib/imperituroard/version.rb