Class: Asdawqw::FeeAndTaxController
- Inherits:
-
BaseController
- Object
- BaseController
- Asdawqw::FeeAndTaxController
- Defined in:
- lib/asdawqw/controllers/fee_and_tax_controller.rb
Overview
FeeAndTaxController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_fee_and_tax(content_type, body) ⇒ Object
This function allows the logged in user to set fees (i.e. cleaning fee, damage waiver, extra bed, extra person etc.) and taxes for the specific product.
-
#get_fee_and_tax_list_by_product_id(product_id) ⇒ Object
This function allows the logged in user to get a fee list 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/fee_and_tax_controller.rb', line 12 def instance @instance end |
Instance Method Details
#create_fee_and_tax(content_type, body) ⇒ Object
This function allows the logged in user to set fees (i.e. cleaning fee, damage waiver, extra bed, extra person etc.) and taxes for the specific product. Here, you always need to send all fees and taxes for one property. All fees or taxes which were in our system for that property and which are not in the new request will be deleted. Taxes in the BookingPal system will always have percent value. If you want to delete all fees and/or taxes for one property (if you do not have fees and taxes in your system for one property) send an empty list of fees and.or taxes. In short when you use this request you need to always send us a full list of fees and taxes per property, since we will do a full update.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/asdawqw/controllers/fee_and_tax_controller.rb', line 65 def create_fee_and_tax(content_type, body) # Prepare query url. _path_url = '/taxfee' _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) FeeTaxResponse.from_hash(decoded) end |
#get_fee_and_tax_list_by_product_id(product_id) ⇒ Object
This function allows the logged in user to get a fee list 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/fee_and_tax_controller.rb', line 23 def get_fee_and_tax_list_by_product_id(product_id) # Prepare query url. _path_url = '/taxfee/{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) FeeTaxResponse.from_hash(decoded) end |
#instance ⇒ Object
15 16 17 |
# File 'lib/asdawqw/controllers/fee_and_tax_controller.rb', line 15 def instance self.class.instance end |