Class: Locate

Inherits:
Object
  • Object
show all
Defined in:
lib/location/Locate.rb

Instance Method Summary collapse

Constructor Details

#initialize(endpoints, username, password) ⇒ Locate

Returns a new instance of Locate.



16
17
18
19
20
# File 'lib/location/Locate.rb', line 16

def initialize(endpoints, username, password)
  @endpoints=endpoints
  @username=username
  @password=password
end

Instance Method Details

#getEndpointsObject



21
22
23
# File 'lib/location/Locate.rb', line 21

def getEndpoints
  @endpoints
end

#getPasswordObject



37
38
39
# File 'lib/location/Locate.rb', line 37

def getPassword
  @password
end

#getUsernameObject



29
30
31
# File 'lib/location/Locate.rb', line 29

def getUsername
  @username
end

#locateMultipleTerminals(address, requestedAccuracy) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 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) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 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) ⇒ Object



25
26
27
# File 'lib/location/Locate.rb', line 25

def setEndpoints(endpoints)
  @endpoints=endpoints
end

#setPassword(password) ⇒ Object



41
42
43
# File 'lib/location/Locate.rb', line 41

def setPassword(password)
  @password=password
end

#setUsername(username) ⇒ Object



33
34
35
# File 'lib/location/Locate.rb', line 33

def setUsername(username)
  @username=username
end