imperituroard 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c14a6e4b874b88dee7fcb385a9bdc1a3421171c
|
4
|
+
data.tar.gz: e0db9b2f11a898a8eda22a0075da8f88c5902f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c01ba2b79798b63b81137c34d410834b0d1814101c4b70dfb788b974b6835a07954c36e30f70a0dbc28d2aa46c3857542502527daf8fb978f0915ed953648e0
|
7
|
+
data.tar.gz: 013d5fa3179ac944216c3c7ae87e96bbc54c3c65d03c069a45fa21b03bbb558ecf3a35725ef9704b74e132601e68ad718871fb44b4f3524c4e8449e49a793340
|
@@ -213,6 +213,7 @@ class HuaIot
|
|
213
213
|
request['Authorization'] = 'Bearer ' + token
|
214
214
|
request['app_key'] = app_id
|
215
215
|
res = https.request(request)
|
216
|
+
p "res.code"
|
216
217
|
p res.code
|
217
218
|
p res.body
|
218
219
|
if res.body != nil
|
@@ -509,7 +510,6 @@ class HuaIot
|
|
509
510
|
p uri.port
|
510
511
|
p uri.path
|
511
512
|
|
512
|
-
|
513
513
|
cert_file = "/Users/imperituroard/Desktop/cert.crt"
|
514
514
|
key_file = "/Users/imperituroard/Desktop/key.pem"
|
515
515
|
|
@@ -526,7 +526,6 @@ class HuaIot
|
|
526
526
|
:secret => "ppeMsOq6zdb2fSUH4GoRooS_FgEa"
|
527
527
|
}
|
528
528
|
|
529
|
-
|
530
529
|
#request['app_key'] = 'ppeMsOq6zdb2fSUH4GoRooS_FgEa'
|
531
530
|
#request['Authorization'] = 'Bearer ppeMsOq6zdb2fSUH4GoRooS_FgEa'
|
532
531
|
request.content_type = 'application/x-www-form-urlencoded'
|
@@ -535,9 +534,7 @@ class HuaIot
|
|
535
534
|
res = https.request(request)
|
536
535
|
p res.code
|
537
536
|
p res.message
|
538
|
-
|
539
537
|
p parse_token(res.body)
|
540
|
-
|
541
538
|
end
|
542
539
|
|
543
540
|
# App ID
|
@@ -135,8 +135,25 @@ class InternalFunc
|
|
135
135
|
end
|
136
136
|
|
137
137
|
|
138
|
+
#procedure for check input imei
|
139
|
+
def imei_validate(imei)
|
138
140
|
|
141
|
+
input = {:imei => imei}
|
139
142
|
|
143
|
+
answer = {}
|
144
|
+
if imei.is_a? Integer
|
145
|
+
|
146
|
+
if imei.to_s.length>=14 && imei.to_s.length<=17
|
147
|
+
answer = {:code => 200, :result => "IMEI correct.", :checked => true}
|
148
|
+
else
|
149
|
+
answer = {:code => 401, :result => "invalid IMEI length.", :checked => false}
|
150
|
+
end
|
151
|
+
else
|
152
|
+
answer = {:code => 400, :result => "Invalid IMEI. Data is not integer", :checked => false}
|
153
|
+
end
|
154
|
+
printer_texter({:answer => answer, :input => input}, "debug")
|
155
|
+
answer
|
156
|
+
end
|
140
157
|
|
141
158
|
def test()
|
142
159
|
p "eeeeeeeeeeeeeeeeeeeeeeee"
|
@@ -72,27 +72,37 @@ class IotFunctions_2
|
|
72
72
|
processed_list = []
|
73
73
|
|
74
74
|
for ii in imei_list
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
valid_resp = internal_func.imei_validate(ii["imei"])
|
76
|
+
if valid_resp[:checked]
|
77
|
+
list1[ii["imei"]] = ii
|
78
|
+
imei.append(ii["imei"])
|
79
|
+
else
|
80
|
+
not_processed_list.append({:imei => ii["imei"], :error => valid_resp[:result]})
|
81
|
+
end
|
81
82
|
end
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
if imei != []
|
85
|
+
list_checked = mongo_client.check_imei_exists(imei)
|
86
|
+
|
87
|
+
for ss in list_checked[:body][:exists]
|
88
|
+
not_processed_list.append({:imei => ss, :error => "Device exists in database"})
|
89
|
+
end
|
90
|
+
|
91
|
+
for jj in list_checked[:body][:not_exists]
|
92
|
+
begin
|
93
|
+
get_login_info = mongo_client.check_login_prof_perm_id_one(login, list1[jj]["profile"])[:code]
|
94
|
+
if get_login_info==200
|
95
|
+
for_insert.append(list1[jj])
|
96
|
+
else
|
97
|
+
not_processed_list.append({:imei => list1[jj], :error => "Permission denied for this profile"})
|
98
|
+
end
|
99
|
+
rescue
|
100
|
+
not_processed_list.append({:imei => list1[jj], :error => "Unknown error"})
|
90
101
|
end
|
91
|
-
rescue
|
92
|
-
not_processed_list.append({:imei => list1[jj], :error => "Unknown error"})
|
93
102
|
end
|
94
103
|
end
|
95
104
|
|
105
|
+
|
96
106
|
begin
|
97
107
|
added_on_iot_platf = []
|
98
108
|
if for_insert!=[]
|
@@ -433,8 +443,12 @@ class IotFunctions_2
|
|
433
443
|
|
434
444
|
imei_data = mongo_client.get_imei_info_from_db([imei])
|
435
445
|
if imei_data[:body]!=[]
|
436
|
-
ans =
|
437
|
-
|
446
|
+
ans = {}
|
447
|
+
if imei_data[:body][0]["huadata"]["body"]["deviceId"] != nil
|
448
|
+
ans = hua_aceanconnect_connector.remove_one_device_from_iot(credentials[:body][:app_id], credentials[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"])
|
449
|
+
else
|
450
|
+
ans = {:code => "204", :result => "Not processed by iot platform. deviceId not found in mongoDB"}
|
451
|
+
end
|
438
452
|
if ans[:code]=="204" or ans[:code]=="200"
|
439
453
|
resp = mongo_client.device_remove_single_mongo(imei)
|
440
454
|
else
|