Generate State Workflow
Overview
User Code: com.finmars.standard-workflow:generate-state
This script is designed to generate state files for state managers. It processes input data to create a structured state file that includes information about workers and their respective states.
Workflow Function
The main workflow function is a task that generates the state file based on the provided payload.
Parameters:
-
payload: A dictionary containing the necessary information for state generation.
Process:
- Validates the presence of a payload
- Retrieves the input data from the specified path
input_file - Generates a new state file using the
generate_state_filefunction - Saves the generated state file
- Updates the status of the operation in the state file
Helper Functions
-
get_first_transaction_date: Retrieves the earliest transaction date from the API. -
get_next_date: Calculates the next date based on the given periodicity. -
get_period_end_date: Calculates the end date of a period based on the start date and periodicity. -
build_url: Constructs the full API URL for a given endpoint. -
get_headers: Generates headers with authorization token for HTTP requests. -
log_message: Logs a message with a timestamp. -
save_file: Saves data to a specified file path in JSON format. -
get_files: Lists files in the specified directory. -
get_folders: Lists directories in the specified path. -
get_data: Reads data from a JSON file.