Class: Asdawqw::RequestToBookController
- Inherits:
-
BaseController
- Object
- BaseController
- Asdawqw::RequestToBookController
- Defined in:
- lib/asdawqw/controllers/request_to_book_controller.rb
Overview
RequestToBookController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_request_to_book_answer_from_pms(content_type, body) ⇒ Object
This is an API call which you should use for accepting on avoiding requests to book.
-
#create_request_to_book_cancel_request(body) ⇒ Object
This will be a request which we will send to PMS when we get a request to book from the channel.
-
#create_request_to_book_request(body) ⇒ Object
This will be a request which we will send to PMS when we get a request to book from the channel.
-
#create_request_to_book_test(body) ⇒ Object
Since you can not get the request to book on our test environment (since this first needs to be created on the channel) We provide the possibility for PMS to test this request with some random filled data in our system.
- #instance ⇒ Object
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/request_to_book_controller.rb', line 12 def instance @instance end |
Instance Method Details
#create_request_to_book_answer_from_pms(content_type, body) ⇒ Object
This is an API call which you should use for accepting on avoiding requests to book. Example:
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 50 |
# File 'lib/asdawqw/controllers/request_to_book_controller.rb', line 25 def create_request_to_book_answer_from_pms(content_type, body) # Prepare query url. _path_url = '/requestToBook' _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, 'Content-Type' => content_type } # Prepare and execute HttpRequest. _request = @http_client.post( _query_url, headers: _headers, parameters: body.to_json ) CustomQueryAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) APIResponseWithoutData.from_hash(decoded) end |
#create_request_to_book_cancel_request(body) ⇒ Object
This will be a request which we will send to PMS when we get a request to book from the channel. So when BookingPal gets a new request to book request - we will push this POST request to the link which you set in BookingPal for your PMS (in Push Notification section - “requestToBook”). 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:
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/asdawqw/controllers/request_to_book_controller.rb', line 131 def create_request_to_book_cancel_request(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 |
#create_request_to_book_request(body) ⇒ Object
This will be a request which we will send to PMS when we get a request to book from the channel. So when BookingPal gets a new request to book request - we will push this POST request to the link which you set in BookingPal for your PMS (in Push Notification section - “requestToBook”). 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.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/asdawqw/controllers/request_to_book_controller.rb', line 94 def create_request_to_book_request(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 |
#create_request_to_book_test(body) ⇒ Object
Since you can not get the request to book on our test environment (since this first needs to be created on the channel) We provide the possibility for PMS to test this request with some random filled data in our system. So when you call this API function - we will send you push notification for the request to book for a provided property ID.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/asdawqw/controllers/request_to_book_controller.rb', line 59 def create_request_to_book_test(body) # Prepare query url. _path_url = '/requestToBookTest' _query_builder = Configuration.get_base_uri _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 ) CustomQueryAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) APIResponseWithoutData.from_hash(decoded) end |
#instance ⇒ Object
15 16 17 |
# File 'lib/asdawqw/controllers/request_to_book_controller.rb', line 15 def instance self.class.instance end |