Class: Asdawqw::RatesAndAvailabilityController
- Inherits:
-
BaseController
- Object
- BaseController
- Asdawqw::RatesAndAvailabilityController
- Defined in:
- lib/asdawqw/controllers/rates_and_availability_controller.rb
Overview
RatesAndAvailabilityController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_and_update_rates_and_availability(content_type, body) ⇒ Object
Create and update calls are the same.
-
#get_rates_and_availability_product_id(content_type, product_id) ⇒ Object
This function allows logged in users to get rates and availability for the specific product.
- #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/rates_and_availability_controller.rb', line 12 def instance @instance end |
Instance Method Details
#create_and_update_rates_and_availability(content_type, body) ⇒ Object
Create and update calls are the same. When data is sent, if the data already exists in BookingPal - that data will be updated. Otherwise it will be created (inserted). If you want to update data for some period, you should just send data for these dates. All other data (for other dates) will remain untouched. This allows you to update only changed periods and we will not delete previously sent data for other periods. In the case of a first data push, all data for one property should be sent in one request. When making updates or changes to existing data, then all changed data should be sent in one request. Note: if property is set to use LOS rates (supportedLosRates) - only field leadTime, array availableCount and availability can be updated in this API call (for MLT property). For SGL property only leadTime and availability can be updated. This API call can not be used for OWN properties. Important: Maximum allowed end date in any data type is 3 years in future. Every API call in this section should be with PM credentials. parameter: Example:
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/asdawqw/controllers/rates_and_availability_controller.rb', line 74 def create_and_update_rates_and_availability(content_type, body) # Prepare query url. _path_url = '/ra' _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) RatesAvailabilityResponse.from_hash(decoded) end |
#get_rates_and_availability_product_id(content_type, product_id) ⇒ Object
This function allows logged in users to get rates and availability for the specific product. Every API call in this section should be with PM credentials.
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 51 52 53 |
# File 'lib/asdawqw/controllers/rates_and_availability_controller.rb', line 25 def get_rates_and_availability_product_id(content_type, product_id) # Prepare query url. _path_url = '/ra/{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, 'Content-Type' => content_type } # 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) RatesAvailabilityResponse.from_hash(decoded) end |
#instance ⇒ Object
15 16 17 |
# File 'lib/asdawqw/controllers/rates_and_availability_controller.rb', line 15 def instance self.class.instance end |