Class: InternalFunc_1
- Inherits:
-
Object
- Object
- InternalFunc_1
- Defined in:
- lib/freewifi/additional/additional_functions.rb
Instance Method Summary collapse
- #ap_hostname_generator(company, tunnel_id) ⇒ Object
- #company_check_wifi_1(compname) ⇒ Object
- #datetimenow_1 ⇒ Object
- #hub_tunnelname_generator_1(tunnel_id, company_name) ⇒ Object
- #prep_comp_name_for_config_1(company_name) ⇒ Object
- #prep_ssid_for_config_1(ssid) ⇒ Object
- #printer_texter_wifi_1(text, log_level) ⇒ Object
- #telegram_message_1(message, telegram_api_url, telegram_chat_id) ⇒ Object
Instance Method Details
#ap_hostname_generator(company, tunnel_id) ⇒ Object
73 74 75 |
# File 'lib/freewifi/additional/additional_functions.rb', line 73 def ap_hostname_generator(company, tunnel_id) "#{self.prep_comp_name_for_config_1(company)}_#{tunnel_id.to_s}" end |
#company_check_wifi_1(compname) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/freewifi/additional/additional_functions.rb', line 51 def company_check_wifi_1(compname) compname2="" if compname.include?(" ") compname2 = compname.gsub(" ", "") else compname2 = compname end compname2 end |
#datetimenow_1 ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/freewifi/additional/additional_functions.rb', line 6 def datetimenow_1() d_curr = DateTime.now time_zone = 'Europe/Minsk' # DateTime.new # .in_time_zone(time_zone) # .change(year: d_curr.year, month: d_curr.month, day: d_curr.day, hour: d_curr.hour, min: d_curr.min, sec: d_curr.sec) d_curr.to_s end |
#hub_tunnelname_generator_1(tunnel_id, company_name) ⇒ Object
46 47 48 49 |
# File 'lib/freewifi/additional/additional_functions.rb', line 46 def hub_tunnelname_generator_1(tunnel_id, company_name) comp_name = company_name "#{tunnel_id.to_s}_eoip_hub_auto_#{comp_name}" end |
#prep_comp_name_for_config_1(company_name) ⇒ Object
61 62 63 64 65 |
# File 'lib/freewifi/additional/additional_functions.rb', line 61 def prep_comp_name_for_config_1(company_name) res = company_name.gsub(" ", "") res1 = Translit.convert(res, :english) res1.slice(0..14) end |
#prep_ssid_for_config_1(ssid) ⇒ Object
67 68 69 70 71 |
# File 'lib/freewifi/additional/additional_functions.rb', line 67 def prep_ssid_for_config_1(ssid) res = ssid.gsub(" ", "_") res1 = Translit.convert(res, :english) res1.slice(0..14) end |
#printer_texter_wifi_1(text, log_level) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/freewifi/additional/additional_functions.rb', line 34 def printer_texter_wifi_1(text, log_level) begin if log_level == "debug" && Freewifi_1::LOGLEVEL_1 == "debug" mess = {:datetime => datetimenow_1, :sdk => "freewifi", :sdk_version => Freewifi_1::VERSION, :message => text} p mess end rescue p "Failed print message" end end |
#telegram_message_1(message, telegram_api_url, telegram_chat_id) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/freewifi/additional/additional_functions.rb', line 15 def (, telegram_api_url, telegram_chat_id) begin uri = URI.parse(telegram_api_url) https_connector = Net::HTTP.new(uri.host, uri.port) https_connector.use_ssl = true data = {chat_id: telegram_chat_id, text: } request_mess = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/json'}) request_mess.body = data.to_json response_mess = https_connector.request(request_mess) body = response_mess.body return {:code => 200, :result => "Request completed successfully", :body => {:telegram_resp => JSON.parse(body.to_s), :description => "Telegram message to telegram_chat_id: #{telegram_chat_id.to_s}"}} rescue return {:code => 507, :result => 'Unknown SDK error'} end end |