Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_location_by_iata iata_code
- theXml = "<IATALocationRQ><Credentials username='#{CARHIRE3000_USERNAME}' password='#{CARHIRE3000_PASSWORD}' remoteIp='#{THIS_IP}' /><Location id='#{iata_code}'/></IATALocationRQ>"
- raw_response = Carhire3000.post "/service/ServiceRequest.do", :query => {:xml => theXml}
- xml = XmlSimple.xml_in raw_response
- locationData = {}
- begin
- xml['location'].each do | location |
- locationData['country'] = location['country']
- locationData['city'] = location['city']
- locationData['location'] = location['id']
- locationData['location_name'] = location['locationName']
- end
- rescue Exception => ex
- puts "Unable to find location: #{iata_code} because of #{ex.message}"
- Rails.logger.warn "Unable to find location: #{iata_code} because of #{ex.message}"
- raise ex
- end
- get_location_by_iata = locationData
- end
Add Comment
Please, Sign In to add comment