Class: OracleOWS::GuestServices

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

Overview

Instance Attribute Summary

Attributes included from Common

#namespaces, #password, #url, #username

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ GuestServices

Initialize

Parameters:

  • object (Hash)

    with connection parameters



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

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

  # we need these for API calls
  more_namespaces = {
    'xmlns:gue' => 'http://webservices.micros.com/og/4.3/GuestServices/',
    'xmlns:hot' => 'http://webservices.micros.com/og/4.3/HotelCommon/'
  }
  # merge base + additional namespaces
  @namespaces.merge!(more_namespaces)
end

Instance Method Details

#update_room_status(options = {}) ⇒ Hash

Update Room Status

Parameters:

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

    to update the room status

Options Hash (options):

  • :hotel_code (String)

    code of the hotel

  • :room (Numeric, String)

    number to update

Returns:

  • (Hash)

    result hash extracted from the deply nested XML



41
42
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/guest_services.rb', line 41

def update_room_status(options = {})
  # save resources if we have nothing to do
  return {} if options.blank?

  # make the SOAP API call
  response = soap_client.call(
    # endpoint action
    :update_room_status,
    # payload
    message: {
      'HotelReference' => {
        '@hotelCode' => options[:hotel_code]
      },
      'RoomNumber' => options[:room],
      'RoomStatus' => 'Clean',
      'TurnDownStatus' => 'Completed',
      'GuestServiceStatus' => 'DoNotDisturb'
    }
  )

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

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

#wake_up_call(options = {}) ⇒ Hash

Wake Up Call

Parameters:

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

    parameters

Options Hash (options):

  • :hotel_code (String)

    is the code of the hotel

  • :room (Numeric, String)

    number

Returns:

  • (Hash)

    result hash from the deeply nested XML response



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/oracle_ows/guest_services.rb', line 80

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

  response = soap_client.call(
    :wake_up_call,
    message: {
      'HotelReference' => { '@hotelCode' => options[:hotel_code] },
      'RoomNumber' => options[:room]
    }
  )

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

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