Class: OracleOWS::HouseKeeping

Inherits:
Base
  • Object
show all
Defined in:
lib/oracle_ows/house_keeping.rb

Overview

Instance Attribute Summary

Attributes included from Common

#namespaces, #password, #url, #username

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HouseKeeping

Initialize

Parameters:

  • object (Hash)

    with connection parameters



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/oracle_ows/house_keeping.rb', line 19

def initialize(options = {})
  # call the parent method, all arguments passed
  super

  # we need these for API calls
  more_namespaces = {
    'xmlns:hkeep' => 'http://webservices.micros.com/ows/5.1/HouseKeeping.wsdl',
    'xmlns:room' => 'http://webservices.micros.com/og/4.3/HouseKeeping/'
  }
  # merge base + additional namespaces
  @namespaces.merge!(more_namespaces)
end

Instance Method Details

#room_status(options = {}) ⇒ Hash

FetchHouseKeepingRoomStatus

Parameters:

  • options (Hash) (defaults to: {})

    with parameters

Options Hash (options):

  • :hotel_code (String)

    is the identifier for the hotel

  • :room (Hash)

    a hash of :from and :to parameters

  • :from (Symbol)

    parameter in :room => { :from => 1 }

  • :to (Symbol)

    parameter in :room => { :to => 1 }

Returns:

  • (Hash)

    of the result from deeply nested XML response



43
44
45
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/oracle_ows/house_keeping.rb', line 43

def room_status(options = {})
  return {} if options.blank?

  response = soap_client.call(
    :fetch_house_keeping_room_status,
    message: {
      'HotelReference' => { '@hotelCode' => options[:hotel_code] },
      'Criteria' => {
        'FromRoom' => options[:room][:from],
        'ToRoom' => options[:room][:to],
        'RoomStatusList' => { 'Code' => 'CLEAN' },
        'HKStatusList' => { 'Code' => 'VACANT' },
        'FOStatusList' => { 'Code' => 'VACANT' },
        'ReservationStatusList' => { 'Code' => 'STAYOVER' }
      }
    }
  )

  # fetch the response safely (without exception or too many conditional blocks)
  response.body.dig(:fetch_house_keeping_room_status_response, :result)

# handle exceptions gracefully
rescue OracleOWS::Error => e
  # handle exception gracefully
ensure
  {} # at least return a blank hash
end