Formatters
The formatters.py
module provides utility functions for formatting filter values, phone numbers, and service instance profiles. These functions ensure consistency when handling formatted data within the API.
Functions
format_filter_value
Formats a filter value according to the specified filter type by adding the appropriate wildcards.
Function Signature
Parameters
filter_type
(str): The type of filter operation ("equal to"
,"contains"
,"starts with"
).filter_value
(str): The value to filter for.
Raises
OAUnsupportedFilter
: Raised when an unsupported filter type (e.g.,"ends with"
) is requested.
Returns
(str): The formatted filter value with the appropriate wildcard(s).
Example Usage
format_int_list_of_numbers
Formats a list of integer phone numbers by prepending a specified country code.
Function Signature
Parameters
country_code
(int): The country code to prepend to each number.numbers
(List[int]): A list of phone numbers (integers) without a country code.
Returns
(List[str]): A list of formatted phone numbers with the country code prepended.
Example Usage
format_service_instance_profile
Ensures that the serviceInstanceProfile
key exists in the given dictionary, initializing it as an empty dictionary if absent.
Function Signature
Parameters
data
(Dict): The input dictionary to check for theserviceInstanceProfile
key.
Returns
(Dict[str, Any]): The original dictionary with
serviceInstanceProfile
ensured as a key.
Example Usage
This module ensures that formatted values adhere to expected structures, reducing the likelihood of errors when interacting with the API.
Last updated
Was this helpful?