basket-get.sh Script Documentation
This document describes the functionality and usage of the basket-get.sh script found in the cruiseappy/scripts folder.
Purpose
This script retrieves basket information for a given search ID, processes the data, and updates the database accordingly.
Usage
./basket-get.sh <search_id>
Arguments
search_id: The ID of the search for which to retrieve basket information.
Description
The script performs the following steps:
1. Sources the functions.sh script for additional functions.
2. Retrieves the search ID from the first argument.
3. Generates a timestamp and constructs the file path for the XML response.
4. Fetches hotel result number, flight result number, and session key from the database.
5. Prepares the XML request to get the basket and sends it to the endpoint.
6. Saves the XML response to a file.
7. Modifies the XML response using xmlstarlet.
8. If hotel result number is present, fetches room group number and item booking terms.
9. If flight result number is present, fetches item booking terms.
10. Loads the XML response into the database.
11. Removes duplicate entries from the database.
12. Updates commission and basket reservation in the basket searches table.
13. Processes each basket item and updates the database accordingly based on item type (hotel, flight, car hire, car park, transfer).
14. Checks the basket status and adjusts flight prices if necessary.
15. Updates deposit details for flights and hotels in the database.
16. Ensures no past deposit due dates are shown.
17. Checks if there are any items in the basket; if not, updates the basket status to error.
Environment Variables
ca_db_name: The name of the database to use.ca_tt_username: The username for authentication.ca_tt_password: The password for authentication.ca_tt_endpoint: The endpoint URL for API requests.ca_tt_language: The language parameter for API requests.
Dependencies
functions.sh: A script containing utility functions.xmlstarlet: A command-line XML toolkit.mysql: A command-line client for MySQL.curl: A command-line tool for transferring data with URLs.
For further details, refer to the comments in the script or contact the development team.