Class: OracleOWS::Reservation

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

Overview

Instance Attribute Summary

Attributes included from Common

#namespaces, #password, #url, #username

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Reservation

initialize

Parameters:

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

    for connection



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

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

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

Instance Method Details

#fetch_booked_inventory_items(options = {}) ⇒ Object

Usage:

method({ hotel_code: 'ABC', type: 'ABC', source: 'ABC' })


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/oracle_ows/reservation.rb', line 66

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

  response = soap_client.call(
    :fetch_booked_inventory_items,
    message: {
      'HotelReference' => { '@hotelCode' => options[:hotel_code] } #,
      # 'ConfirmationNumber' => { '@type' => options[:type], '@source' => options[:source] }
    }
  )

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

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

#pre_checkin(options = {}) ⇒ Hash

PreCheckin

Parameters:

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

    of parameters for the API call

Options Hash (options):

  • :hotel_code (String)

    to identify the hotel

  • :chain_code (String)

    to identify the chain of hotels it belongs to

  • :confirmation (String)

    number of the check in

Returns:

  • (Hash)

    result hash from the deeply nested XML response



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/oracle_ows/reservation.rb', line 40

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

  response = soap_client.call(
    :pre_checkin,
    message: {
      'HotelReference' => {
        '@hotelCode' => options[:hotel_code],
        '@chainCode' => options[:chain_code]
      },
      'ConfirmationNumber' => options[:confirmation]
    }
  )

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

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