/// <summary>Condense filter.</summary>
        /// <param name="filter">Specifies the filter.</param>
        /// <param name="value"> [out] The value.</param>
        /// <returns>True if it succeeds, false if it fails.</returns>
        private static bool TryCondenseFilter(r5.Subscription.FilterByComponent filter, out string value)
        {
            if ((filter == null) ||
                (filter.SearchParamName == null))
            {
                value = null;
                return(false);
            }

            if ((filter.SearchModifier == null) ||
                (filter.SearchModifier.Value == r5.SubscriptionSearchModifier.Eq) ||
                (filter.SearchModifier.Value == r5.SubscriptionSearchModifier.Equal))
            {
                value = $"{filter.SearchParamName}={filter.Value}";
                return(true);
            }

            string modifier = filter.SearchModifier.Value.ToString().ToLowerInvariant();

            switch (filter.SearchModifier.Value)
            {
            case r5.SubscriptionSearchModifier.Above:
            case r5.SubscriptionSearchModifier.Below:
            case r5.SubscriptionSearchModifier.In:
                value = $"{filter.SearchParamName}:{modifier}={filter.Value}";
                break;

            case r5.SubscriptionSearchModifier.NotIn:
                value = $"{filter.SearchParamName}:not-in={filter.Value}";
                break;

            case r5.SubscriptionSearchModifier.OfType:
                value = $"{filter.SearchParamName}:of-type={filter.Value}";
                break;

            default:
                value = $"{filter.SearchParamName}={modifier}{filter.Value}";
                break;
            }

            return(true);
        }
        /// <summary>
        /// Attempts to expand filter a r5.Subscription.FilterByComponent from the given string.
        /// </summary>
        /// <param name="filter">Specifies the filter.</param>
        /// <param name="value"> [out] The value.</param>
        /// <returns>True if it succeeds, false if it fails.</returns>
        private static bool TryExpandFilter(string filter, out r5.Subscription.FilterByComponent value)
        {
            if (string.IsNullOrEmpty(filter))
            {
                value = null;
                return(false);
            }

            string[] components = filter.Split('=');
            if (components.Length != 2)
            {
                Console.WriteLine($"Failed to parse filter: {filter}");
                value = null;
                return(false);
            }

            string searchParam = components[0];
            string searchValue = components[1];
            string modifier    = string.Empty;

            r5.SubscriptionSearchModifier searchModifier;

            if (searchParam.Contains(':', StringComparison.Ordinal))
            {
                string[] parts = searchParam.Split(':');
                searchParam = parts[0];
                modifier    = parts[1];
            }

            if (string.IsNullOrEmpty(modifier) && (searchValue.Length > 2))
            {
                modifier = searchValue.Substring(0, 2);
            }

            switch (modifier)
            {
            case "equal":
                searchModifier = r5.SubscriptionSearchModifier.Equal;
                break;

            case "above":
                searchModifier = r5.SubscriptionSearchModifier.Above;
                break;

            case "below":
                searchModifier = r5.SubscriptionSearchModifier.Below;
                break;

            case "in":
                searchModifier = r5.SubscriptionSearchModifier.In;
                break;

            case "not-in":
                searchModifier = r5.SubscriptionSearchModifier.NotIn;
                break;

            case "of-type":
                searchModifier = r5.SubscriptionSearchModifier.OfType;
                break;

            case "eq":
                searchModifier = r5.SubscriptionSearchModifier.Eq;
                searchValue    = searchValue.Substring(2);
                break;

            case "ne":
                searchModifier = r5.SubscriptionSearchModifier.Ne;
                searchValue    = searchValue.Substring(2);
                break;

            case "gt":
                searchModifier = r5.SubscriptionSearchModifier.Gt;
                searchValue    = searchValue.Substring(2);
                break;

            case "lt":
                searchModifier = r5.SubscriptionSearchModifier.Lt;
                searchValue    = searchValue.Substring(2);
                break;

            case "ge":
                searchModifier = r5.SubscriptionSearchModifier.Ge;
                searchValue    = searchValue.Substring(2);
                break;

            case "le":
                searchModifier = r5.SubscriptionSearchModifier.Le;
                searchValue    = searchValue.Substring(2);
                break;

            case "sa":
                searchModifier = r5.SubscriptionSearchModifier.Sa;
                searchValue    = searchValue.Substring(2);
                break;

            case "eb":
                searchModifier = r5.SubscriptionSearchModifier.Eb;
                searchValue    = searchValue.Substring(2);
                break;

            case "ap":
                searchModifier = r5.SubscriptionSearchModifier.Ap;
                searchValue    = searchValue.Substring(2);
                break;

            default:
                searchModifier = r5.SubscriptionSearchModifier.Equal;
                break;
            }

            value = new r5.Subscription.FilterByComponent()
            {
                SearchParamName = searchParam,
                SearchModifier  = searchModifier,
                Value           = searchValue,
            };

            return(true);
        }