require 'net/http' require 'net/https' require 'json' class AdditionalFunc attr_accessor :telegram_api_url, :telegram_chat_id, :telegram_messanger def initialize(telegram_api_url, telegram_chat_id) @telegram_api_url = telegram_api_url @telegram_chat_id = telegram_chat_id @telegram_messanger = Telegram_2.new(telegram_api_url, telegram_chat_id) end def answ_dev_query_format_process(dev_list) dataaa_ok = [] dataaa_failed = [] final_answ = {} begin if dev_list[:approved_list]!=[] for i in dev_list[:approved_list][:body] begin imei =0 imsi =0 msisdn =0 description = 'nil' note = "nil" type = "nil" profile ="nil" address ="nil" if i.key?("imei") imei=i["imei"] end if i.key?("imsi") imsi=i["imsi"] end if i.key?("msisdn") msisdn=i["msisdn"] end if i.key?("description") if i["description"] == nil description="nil" else description=i["description"] end end if i.key?("note") if i["note"] == nil note="nil" else note=i["note"] end end if i.key?("device_type") type=i["device_type"] end if i.key?("profile") profile=i["profile"] end if i.key?("address") address=i["address"] end dataaa_ok.append({:imei => imei, :imsi => imsi, :msisdn => msisdn, :description => description, :note => note, :type => type, :profile => profile, :address => address}) rescue dataaa_failed.append(i[:imei]) end end end begin for i in dev_list[:unapproved_list] dataaa_failed.append(i[:imei]) end rescue nil end final_answ = {:ok => dataaa_ok, :failed => dataaa_failed} {:code => 200, :result => "Request completed successfully", :body => final_answ} rescue {:code => 507, :result => "Unknown SDK error", :body => {}} end end def check_input_1(login, imei_list) {:code => 200, :result => "Request completed successfully", :body => "Data checked"} end def check_input_2(login, imei_list) {:code => 200, :result => "Request completed successfully", :body => "Data checked"} end def check_input_3(login, imei_list) {:code => 200, :result => "Request completed successfully", :body => "Data checked"} end def check_input_4(login, imei_list) {:code => 200, :result => "Request completed successfully", :body => "Data checked"} end def check_input_5(login, imei_list) {:code => 200, :result => "Request completed successfully", :body => "Data checked"} end def check_input_6(login, imei_list) {:code => 200, :result => "Request completed successfully", :body => "Data checked"} end def iot_query_dev_soapgw_answer(input_params, output_answer) answ = {} p output_answer begin if output_answer[:code]==200 dataaa = [] dataaa_failed = [] ddd = answ_dev_query_format_process(output_answer[:data])[:body] p ddd answ = {:code => output_answer[:code], :result => output_answer[:result], :data => ddd[:ok], :error_list => ddd[:failed] } else answ = {:code => output_answer[:code], :result => output_answer[:result], :data => [], :error_list => input_params[:imei] } end rescue answ = {:code => 500, :result => "Unknown error" } end answ end end