class Elong::API::Static::Hotel
Public Class Methods
brands()
click to toggle source
Get the brands of hotel
@return [Hash]
# File lib/elong/api/static.rb, line 57 def brands xml = open "http://api.elong.com/xml/v2.0/hotel/brand_cn.xml" Hash.from_xml(xml)['ArrayOfHotelBrand']['HotelBrand'] end
detail(hotel_id)
click to toggle source
Get the detail info of one hotel
@return [Hash]
# File lib/elong/api/static.rb, line 44 def detail(hotel_id) raise "hotel_id should be String" unless hotel_id.class == String begin xml = open "http://api.elong.com/xml/v2.0/hotel/cn/#{hotel_id[-2,2]}/#{hotel_id}.xml" rescue OpenURI::HTTPError return false end Hash.from_xml(xml)['Hotel']['Detail'] end
geo()
click to toggle source
List All Geo Data
@return [Hash]
# File lib/elong/api/static.rb, line 36 def geo xml = open "http://api.elong.com/xml/v2.0/hotel/geo_cn.xml" Hash.from_xml(xml)['HotelGeos']['HotelGeoList']['HotelGeo'] end
list(status = nil)
click to toggle source
List all hotel 8-bit ids
@return [Array]
# File lib/elong/api/static.rb, line 22 def list(status = nil) raise "status must be 0 or 1 or nil" unless [0,1,nil].include?status noko = Nokogiri::XML(open('http://api.elong.com/xml/v2.0/hotel/hotellist.xml')) results = noko.xpath("/HotelIndex/Hotels/Hotel") if status results.map{|node|node["HotelId"] if node['Status'] == status.to_s}.delete_if{|node|node.nil?} else results.map{|node|node["HotelId"]} end end