static id TNLURLEncodableValue()

in Source/TNLURLCoding.m [360:382]


static id TNLURLEncodableValue(id value,
                               TNLURLEncodableDictionaryOptions options,
                               NSString * __nullable contextKey)
{
    id returnValue;
    if (TNL_BITMASK_HAS_SUBSET_FLAGS(options, TNLURLEncodableDictionaryOptionReplaceArraysWithArraysOfEncodableStrings) && [value isKindOfClass:[NSArray class]]) {
        returnValue = TNLURLConvertArrayToArrayOfEncodableStrings(value, options, contextKey);
    } else if (TNL_BITMASK_HAS_SUBSET_FLAGS(options, TNLURLEncodableDictionaryOptionReplaceDictionariesWithDictionariesOfEncodableStrings) && [value isKindOfClass:[NSDictionary class]]) {
        returnValue = TNLURLConvertDictionaryToDictionaryOfEncodableStrings(value, options);
    } else if ([value isKindOfClass:[NSNumber class]]) {
        // NSNumbers are always OK
        returnValue = value;
    } else {
        const TNLURLEncodingOptions encodingOptions = (options & (TNLURLEncodingOptionDiscardEmptyValues |  TNLURLEncodingOptionIgnoreUnsupportedValues | TNLURLEncodingOptionTreatUnsupportedValuesAsEmpty));

        NSString *valueString = TNLStringValue(value, encodingOptions, contextKey);
        if (TNL_BITMASK_HAS_SUBSET_FLAGS(options, TNLURLEncodableDictionaryOptionDiscardEmptyValues) && (valueString.length == 0)) {
            valueString = nil;
        }
        returnValue = valueString;
    }
    return returnValue;
}