lib/imperituroard.rb in imperituroard-0.3.5 vs lib/imperituroard.rb in imperituroard-0.3.7
- old
+ new
@@ -1,18 +1,23 @@
$LOAD_PATH.unshift File.expand_path("../projects/iot", __dir__)
$LOAD_PATH.unshift File.expand_path("../projects/wttx", __dir__)
+$LOAD_PATH.unshift File.expand_path("../projects/mhub", __dir__)
require "imperituroard/version"
require "imperituroard/phpipamdb"
require "imperituroard/phpipamcps"
require "imperituroard/projects/iot/mongoconnector"
require "imperituroard/projects/iot/hua_oceanconnect_adapter"
require "imperituroard/projects/iot/add_functions"
require "imperituroard/projects/iot/internal_functions"
+require 'imperituroard/projects/mhub/infobip'
+require 'imperituroard/projects/mhub/sk'
require 'json'
require 'ipaddr'
require 'date'
+require 'net/http'
+require 'uri'
module Imperituroard
class Error < StandardError;
end
@@ -782,9 +787,83 @@
#p ddd.get_profile_id_by_name("1341241")
#p ddd.get_device_type_info_by_model("BGT_PPMC11")
#fff = HuaIot.new("134.17.93.4", "443", "/Users/imperituroard/Desktop/cert.crt", "/Users/imperituroard/Desktop/key.pem")
- #p fff.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "eWllZpHgXgvgDAQlJjWs4QXaR94a", [91234])
+ p hua_aceanconnect_connector.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "eWllZpHgXgvgDAQlJjWs4QXaR94a", "91234")
end
end
+
+
+class Mhub_2
+
+ attr_accessor :sk_url, :sk_login, :sk_password, :mhub_connector
+
+ def initialize(sk_url, sk_login, sk_password, telegram_api_url, telegram_chat_id)
+ @sk_url = sk_url
+ @sk_login = sk_login
+ @sk_password = sk_password
+ @internal_func = InternalFunc.new
+ @mhub_connector = Sksk_1.new(sk_url, sk_login, sk_password)
+ @internal_func = InternalFunc.new
+ @add_functions_connector = AdditionalFunc.new(telegram_api_url, telegram_chat_id)
+ end
+
+
+ #{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}],
+ # "scenarioKey"=>"1", "viber"=>nil, "sms"=>{"text"=>"карточка готова"},
+ # "sendAt"=>"2019-08-15T08:40:00.000", "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports",
+ # "notifyContentType"=>"application/json", "controller"=>"bank", "action"=>"api",
+ # "bank"=>{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}], "scenarioKey"=>"1",
+ # "viber"=>nil, "sms"=>{"text"=>"карточка готова"}, "sendAt"=>"2019-08-15T08:40:00.000",
+ # "notifyUrl"=>"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports",
+ # "notifyContentType"=>"application/json"}}
+
+
+ def get_send_message(params)
+
+ input_params = {:params => params}
+
+ p input_params
+
+ output_params = {}
+
+ begin
+
+ msisdn = params["destinations"][0]["to"]["phoneNumber"]
+
+
+ if params["viber"] == nil && params["sms"] != nil
+
+ mhub_connector.sk_send_sms(msisdn, params["notifyUrl"], params["sms"]["text"], "TEST")
+
+ elsif params["viber"] != nil && params["sms"] == nil
+
+ mhub_connector.sk_send_viber(msisdn, params["notifyUrl"], params["viber"]["text"])
+
+ elsif params["viber"] != nil && params["sms"] != nil
+
+ mhub_connector.sk_send_viber_sms(msisdn, params["notifyUrl"], params["sms"]["text"], params["viber"]["text"], "TEST")
+
+ else
+
+ output_params = {:code => 501, :result => "Invalid input data"}
+
+ end
+
+ rescue
+ output_params = {:code => 500, :result => "Invalid input data"}
+ end
+
+ internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Mhub_2.get_send_message"}, "debug")
+
+
+ end
+
+
+ def test2
+ hh = Infobip_1.new
+ hh.test
+ end
+
+end
\ No newline at end of file