class InternalFunc_1

Public Instance Methods

ap_hostname_generator(company, tunnel_id) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/freewifi/additional/additional_functions.rb, line 15
def telegram_message_1(message, 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: message}
    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