Class: BookingAutomation::XMLClient

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/booking_automation/xml_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ XMLClient

Returns a new instance of XMLClient.



9
10
11
12
# File 'lib/booking_automation/xml_client.rb', line 9

def initialize(username, password)
  @username = username
  @password = password
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/booking_automation/xml_client.rb', line 7

def password
  @password
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/booking_automation/xml_client.rb', line 7

def username
  @username
end

Instance Method Details

#get_bookings(opts = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/booking_automation/xml_client.rb', line 21

def get_bookings(opts = {})
  valid_opts = opts.slice(*Constants::VALID_XML_BOOKING_OPTS)
  response = self.class.post('/getBookings', body: xmlize(valid_opts))
  parse! response
rescue APIError => e
  e.response
end

#get_properties(opts = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/booking_automation/xml_client.rb', line 14

def get_properties(opts = {})
  response = self.class.post('/getProperties', body: xmlize(opts.slice(:propid)))
  parse! response
rescue APIError => e
  e.response
end

#modify_booking(id, attrs = {}) ⇒ Object



29
30
31
32
33
34
# File 'lib/booking_automation/xml_client.rb', line 29

def modify_booking(id, attrs = {})
  response = self.class.post('/putBookings', body: modify_payload(id, attrs))
  parse! response
rescue APIError => e
  e.response
end