class Locate

Public Class Methods

new(endpoints, username, password) click to toggle source
# File lib/location/Locate.rb, line 16
def initialize(endpoints, username, password)
  @endpoints=endpoints
  @username=username
  @password=password
end

Public Instance Methods

getEndpoints() click to toggle source
# File lib/location/Locate.rb, line 21
def getEndpoints
  @endpoints
end
getPassword() click to toggle source
# File lib/location/Locate.rb, line 37
def getPassword
  @password
end
getUsername() click to toggle source
# File lib/location/Locate.rb, line 29
def getUsername
  @username
end
locateMultipleTerminals(address,requestedAccuracy) click to toggle source
# File lib/location/Locate.rb, line 71
def locateMultipleTerminals(address,requestedAccuracy)
  baseurl=@endpoints.getLocationEndpoint()
  requestProcessor=JSONRequest.new()
  if address!=nil
    for item in address
      baseurl=requestProcessor.addQueryParameter(baseurl,'address',item)
    end
  end
  baseurl=requestProcessor.addQueryParameter(baseurl,'requestedAccuracy', requestedAccuracy)
  rawresponse=requestProcessor.get(baseurl,'application/json', @username, @password)
  response=LocationResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['terminalLocationList']!=nil) then
      response.setTerminalLocationListJSON(jsondata['terminalLocationList'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end
locateTerminal(address,requestedAccuracy) click to toggle source
# File lib/location/Locate.rb, line 46
def locateTerminal(address,requestedAccuracy)
  baseurl=@endpoints.getLocationEndpoint()
  requestProcessor=JSONRequest.new()
  baseurl=requestProcessor.addQueryParameter(baseurl,'address', address)
  baseurl=requestProcessor.addQueryParameter(baseurl,'requestedAccuracy', requestedAccuracy)
  rawresponse=requestProcessor.get(baseurl,'application/json', @username, @password)
  response=LocationResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['terminalLocationList']!=nil) then
      response.setTerminalLocationListJSON(jsondata['terminalLocationList'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end
setEndpoints(endpoints) click to toggle source
# File lib/location/Locate.rb, line 25
def setEndpoints(endpoints)
  @endpoints=endpoints
end
setPassword(password) click to toggle source
# File lib/location/Locate.rb, line 41
def setPassword(password)
  @password=password
end
setUsername(username) click to toggle source
# File lib/location/Locate.rb, line 33
def setUsername(username)
  @username=username
end