Sha256: b1dd29ae746ab966c2b8ad9a90ae4543a36166996aaf62d3de224ec2c2fa2449
Contents?: true
Size: 1.93 KB
Versions: 4
Compression:
Stored size: 1.93 KB
Contents
require 'imperituroard/projects/iot/internal_functions' class Crm_2 attr_accessor :crm_callback_url, :crm_login, :crm_password, :internal_func, :telegram_connector, :log_level def initialize(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id, log_level) @crm_callback_url = crm_callback_url @crm_login = crm_login @log_level = log_level @crm_password = crm_password @internal_func = InternalFunc.new @telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id) end def crm_status_2(crm_payload) input_params = {:crm_payload => crm_payload} output_params = {} request_message = {} begin thr_crm_status_2 = Thread.new do uri = URI(crm_callback_url) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth crm_login, crm_password req["Content-Type"] = "application/json" req["Accept"] = "application/json" req.body = crm_payload.to_json res = https.request(req) output_params = {:code => 200, :result => "Crm_2.crm_status_2: Request processed", :body => {:request_message => crm_payload, :res_code => res.code, :res_body => JSON.parse(res.body.to_s)}} #p res.body end thr_crm_status_2.join rescue output_params = {:code => 500, :result => "Crm_2.crm_status_2: Something wrong", :body => {:request_message => request_message}} telegram_connector.telegram_message(output_params) end internal_func.printer_texter({:input => input_params, :output => output_params, :procedure => "Crm_2.crm_status_2"}, log_level) output_params end end
Version data entries
4 entries across 4 versions & 1 rubygems