Class: OracleOWS::ResvAdvanced

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

Overview

Instance Attribute Summary

Attributes included from Common

#namespaces, #password, #url, #username

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ResvAdvanced

initialize the object

Parameters:

  • base (OracleOws::Base)

    parameters



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

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

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

Instance Method Details

#checkin(options = {}) ⇒ Hash

CheckIn

Parameters:

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

    for API call

Options Hash (options):

  • :hotel_code (String)

    to identify the hotel

  • :key_1 (String)

    Key #1

  • :key_2 (String)

    Key #2

  • :key_3 (String)

    Key #3

  • :key_4 (String)

    Key #4

Returns:

  • (Hash)

    result hash from deeply nested XML Response



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
70
# File 'lib/oracle_ows/resv_advanced.rb', line 44

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

  response = soap_client.call(
    :check_in,
    message: {
      'ReservationRequest' => {
        'HotelReference' => { '@hotelCode' => options[:hotel_code] },
        'KeyTrack' => {
          '@Key1Track' => options[:key_1],
          '@Key2Track' => options[:key_2],
          '@Key3Track' => options[:key_3],
          '@Key4Track' => options[:key_4]
        }
      }
    }
  )

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

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

#checkout(options = {}) ⇒ Hash

CheckOut

Parameters:

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

    for API call

Options Hash (options):

  • :hotel_code (String)

    to identify the hotel

  • :key_1 (String)

    Key #1

  • :key_2 (String)

    Key #2

  • :key_3 (String)

    Key #3

  • :key_4 (String)

    Key #4

Returns:

  • (Hash)

    result hash from deeply nested XML Response



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/oracle_ows/resv_advanced.rb', line 84

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

  response = soap_client.call(
    :check_out,
    message: {
      'ReservationRequest' => {
        'HotelReference' => { '@hotelCode' => options[:hotel_code] },
        'KeyTrack' => {
          '@Key1Track' => options[:key_1],
          '@Key2Track' => options[:key_2],
          '@Key3Track' => options[:key_3],
          '@Key4Track' => options[:key_4]
        }
      }
    }
  )

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

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