Guest User

Untitled

a guest
Jul 7th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. def get_location_by_iata iata_code
  2. theXml = "<IATALocationRQ><Credentials username='#{CARHIRE3000_USERNAME}' password='#{CARHIRE3000_PASSWORD}' remoteIp='#{THIS_IP}' /><Location id='#{iata_code}'/></IATALocationRQ>"
  3. raw_response = Carhire3000.post "/service/ServiceRequest.do", :query => {:xml => theXml}
  4. xml = XmlSimple.xml_in raw_response
  5. locationData = {}
  6. begin
  7. xml['location'].each do | location |
  8. locationData['country'] = location['country']
  9. locationData['city'] = location['city']
  10. locationData['location'] = location['id']
  11. locationData['location_name'] = location['locationName']
  12. end
  13. rescue Exception => ex
  14. puts "Unable to find location: #{iata_code} because of #{ex.message}"
  15. Rails.logger.warn "Unable to find location: #{iata_code} because of #{ex.message}"
  16. raise ex
  17. end
  18. get_location_by_iata = locationData
  19. end
Add Comment
Please, Sign In to add comment