Class: Asdawqw::ReservationNotificationsController
- Inherits:
-
BaseController
- Object
- BaseController
- Asdawqw::ReservationNotificationsController
- Defined in:
- lib/asdawqw/controllers/reservation_notifications_controller.rb
Overview
ReservationNotificationsController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_reservation_cancellation_notification_push(body) ⇒ Object
This function sends the request to the provided link about the reservation cancellation.
-
#get_reservation_by_pm ⇒ Object
This API call will return a list of reservations that belong to the current user.
-
#get_reservation_by_product(product_id) ⇒ Object
This function allows logged-in users to get all reservations for the specific product.
- #instance ⇒ Object
-
#new_reservation_notification_push(body) ⇒ Object
This function sends the request to the provided link about a new reservation.
Methods inherited from BaseController
#execute_request, #initialize, #validate_parameters, #validate_response
Constructor Details
This class inherits a constructor from Asdawqw::BaseController
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
12 13 14 |
# File 'lib/asdawqw/controllers/reservation_notifications_controller.rb', line 12 def instance @instance end |
Instance Method Details
#create_reservation_cancellation_notification_push(body) ⇒ Object
This function sends the request to the provided link about the reservation cancellation. So when BookingPal gets a cancel reservation request from the channel - we will push this POST request to the link which you set in BookingPal for your PMS (in Push Notification section). Important note: In this doc to be able to test this - you need to set a full URL on the Configure button in the right section. Example:
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/asdawqw/controllers/reservation_notifications_controller.rb', line 133 def create_reservation_cancellation_notification_push(body) # Prepare query url. _path_url = '/' _query_builder = Configuration.get_base_uri( Configuration::Server::PUSH_MESSAGES_URL ) _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8', 'x-api-key' => Configuration.x_api_key } # Prepare and execute HttpRequest. _request = @http_client.post( _query_url, headers: _headers, parameters: body.to_json ) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) ReservationPushResponse.from_hash(decoded) end |
#get_reservation_by_pm ⇒ Object
This API call will return a list of reservations that belong to the current user.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/asdawqw/controllers/reservation_notifications_controller.rb', line 54 def get_reservation_by_pm # Prepare query url. _path_url = '/reservation' _query_builder = Configuration.get_base_uri _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'x-api-key' => Configuration.x_api_key } # Prepare and execute HttpRequest. _request = @http_client.get( _query_url, headers: _headers ) CustomQueryAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) ReservationGetResponse.from_hash(decoded) end |
#get_reservation_by_product(product_id) ⇒ Object
This function allows logged-in users to get all reservations for the specific product.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/asdawqw/controllers/reservation_notifications_controller.rb', line 23 def get_reservation_by_product(product_id) # Prepare query url. _path_url = '/reservation/{productId}' _path_url = APIHelper.append_url_with_template_parameters( _path_url, 'productId' => product_id ) _query_builder = Configuration.get_base_uri _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'x-api-key' => Configuration.x_api_key } # Prepare and execute HttpRequest. _request = @http_client.get( _query_url, headers: _headers ) CustomQueryAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) ReservationGetResponse.from_hash(decoded) end |
#instance ⇒ Object
15 16 17 |
# File 'lib/asdawqw/controllers/reservation_notifications_controller.rb', line 15 def instance self.class.instance end |
#new_reservation_notification_push(body) ⇒ Object
This function sends the request to the provided link about a new reservation. So when BookingPal gets a new reservation - we will push this POST request to the link which you set in BookingPal for your PMS (in Push Notification section). Important note: In this doc to be able to test this - you need to set a full URL on the Configure button in the right section. Note: Credit card data will be sent only if PMS should process payment in their system. Also, data that will be passed to PMS depends on channels - and do we get all of this data. So we have column ‘Mandatory’ to be aware that some data will be missing if we do not get them from a channel (like some guest address data). Additional note: Some channels support modification. At this moment we will process modification first by canceling the current reservation and then we will process the new regular reservation. In these cases for tracking purposes, you can use channel reservation ID (confirmationID) which should be the same in these cases.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/asdawqw/controllers/reservation_notifications_controller.rb', line 97 def new_reservation_notification_push(body) # Prepare query url. _path_url = '/' _query_builder = Configuration.get_base_uri( Configuration::Server::PUSH_MESSAGES_URL ) _query_builder << _path_url _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8', 'x-api-key' => Configuration.x_api_key } # Prepare and execute HttpRequest. _request = @http_client.post( _query_url, headers: _headers, parameters: body.to_json ) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) ReservationPushResponse.from_hash(decoded) end |