class NgiAPI

This is the main class, holding all of the functions and checks. The instance it’s built with a hash of arguments.

Public Class Methods

MyNGIAccess = NgiAPI.new(arguments) click to toggle source

Initialize the class instance with a hash of arguments. The hash is mandatory and must not be empty. There’s a test mode and a production live mode.

Test mode

arguments[:test] = true

Puts any operation in test mode, with standard login and password and a different wsdl.

arguments[:debug] = true

The :debug can be set to true for improved stdout logging.

Production mode

arguments[:partnerLogin] = "13243546"
arguments[:partnerPassword] = "randomsaltprovidedbyNGI"
# File lib/ngi_api.rb, line 28
def initialize(args)
raise ArgumentError, "no arguments provided, no idea what to do" if args.empty?
raise ArgumentError, "\"test\" option provided with login and/or password - can't do that" if args[:test] && (!!args[:partnerLogin] || !!args[:partnerPassword])
raise ArgumentError, "you must give both a login and a password." if !!args[:partnerLogin] ^ !!args[:partnerPassword]
        @partnerLogin = !!args[:test] ? "12345678" : parameter_to_string(args[:partnerLogin])
        @partnerPassword = !!args[:test] ? "517fc7b578767ebfa6bb5252252653d2" : parameter_to_string(args[:partnerPassword])
fetch_cacert unless File.exist?('cacert.pem')
@soapClient = Savon.client do
  wsdl !!args[:test] ? "https://www.eolo.it/ws/wsdl/?test" : "https://www.eolo.it/ws/wsdl/"
  ssl_ca_cert_file "cacert.pem"
  if !!args[:debug]
    log true 
    log_level :debug 
    pretty_print_xml true
  end
end
end

Available Operations

↑ top

Constants

VERSION

gem version

Public Instance Methods

infoBts(btsID) → {...} click to toggle source

Obtain the exact informations about a specific BTS. btsID is a non-negative integer, number or string

# File lib/ngi_api.rb, line 89
def infoBts(btsID)
    raise ArgumentError, "btsID value not allowed" unless btsID.to_i > 0 && btsID.to_s[/\A[-+]?\d+\z/] === btsID.to_s # kudos to http://stackoverflow.com/a/1235990/2513430
    build_and_send_query(:info_bts,
        {
            btsID: parameter_to_string(btsID)
        }
    )
end
infoCoverage(via,civico,istat) → {...} click to toggle source

Gets the coverage for the specified address. The address is composed of

  • via the street location

  • civico the number

  • istat the istat code for the town, gathered from listComuni

# File lib/ngi_api.rb, line 105
def infoCoverage(via,civico,istat)
    build_and_send_query(:info_coverage, 
        {
            via: parameter_to_string(via), 
            civico: parameter_to_string(civico), 
            istat: parameter_to_string(istat)
        }
    )
end
infoRadio(macAddresses_clientLogins) → {...} click to toggle source

Status of a radio, obtained as a string or an array of a client login/mac address.

# File lib/ngi_api.rb, line 56
def infoRadio(macAddresses_clientLogins)
    
    macAddressArray = []
    clientLoginArray = []

    case macAddresses_clientLogins.class.to_s
    when "Array"
        raise ArgumentError,"array exceeds 20 elements" if macAddresses_clientLogins.size > 20
        macAddresses_clientLogins.each_with_index do |element,index|
                raise ArgumentError, "value #{element} at position #{index} is not a valid mac address or a login" unless is_valid_mac(element) || is_valid_login(element)
                macAddressArray.push(fix_mac_address(element)) if is_valid_mac(element)
                clientLoginArray.push(fix_login(element)) if is_valid_login(element)
        end
    when "String"
        raise ArgumentError,"the single value to check is not a valid mac address or customer login" unless is_valid_mac(macAddresses_clientLogins) || is_valid_login(macAddresses_clientLogins)
        macAddressArray.push(fix_mac_address(macAddresses_clientLogins)) if is_valid_mac(macAddresses_clientLogins)
        clientLoginArray.push(fix_login(macAddresses_clientLogins)) if is_valid_login(macAddresses_clientLogins)
    else
        raise ArgumentError,"unsupported data type: a single mac address or login string or an array of them are the only allowed types."
    end 
    
    build_and_send_query(:info_radio,
        {
            macAddressList: macAddressArray,
            clientLoginList: clientLoginArray
        }
    )
end
listBts → {} click to toggle source

Obtain a hash of active BTSes with their details. No input needed, lots of output to be expected.

# File lib/ngi_api.rb, line 119
def listBts
    build_and_send_query(:list_bts)
end
listComuni(comune) → {} click to toggle source

Obtain the istat code for the town.

# File lib/ngi_api.rb, line 127
def listComuni(comune)
    raise ArgumentError, "comune is not >= 2 and <= 35 in length, or has not allowed characters" unless is_valid_comune(parameter_to_string(comune))
    build_and_send_query(:list_comuni,
        {
            comune: parameter_to_string(comune)
        }
    )
end
rebootRadio(macAddress) → {esito: true} click to toggle source

Reboot a customer’s radio.

# File lib/ngi_api.rb, line 155
def rebootRadio(macAddress)
    raise ArgumentError, "specified mac address is wrong or in an invalid format" unless is_valid_mac(macAddress)
    build_and_send_query(:reboot_radio,
        {
            macAddress: fix_mac_address(parameter_to_string(macAddress))
        }
    )
end
setEthernet(macAddress,statoEthernet) => {:stato_ethernet→true} click to toggle source

Set the ethernet adapter of a customer’s radio.

# File lib/ngi_api.rb, line 140
def setEthernet(macAddress,statoEthernet)
    raise ArgumentError, "specified mac address is wrong or in an invalid format" unless is_valid_mac(macAddress)
    raise ArgumentError, "stato ethernet is wrong on in an invalid format" unless ["0","1"].include? parameter_to_string(statoEthernet)
    build_and_send_query(:set_ethernet,
        {
            macAddress: fix_mac_address(parameter_to_string(macAddress)),
            statoEthernet: parameter_to_string(statoEthernet)
        }
    )
end