public bool Parse(ref string requestString, JsonPropertyAttribute attribute, PropertyInfo property, object propertyValue, object propertyParent) { if (attribute.PropertyName != "legal_entity[additional_owners]") { return(false); } List <StripeAccountAdditionalOwner> list = (List <StripeAccountAdditionalOwner>)property.GetValue(propertyParent, null); if (list == null) { return(true); } int num = 0; foreach (StripeAccountAdditionalOwner item in list) { IEnumerable <PropertyInfo> runtimeProperties = item.GetType().GetRuntimeProperties(); foreach (PropertyInfo item2 in runtimeProperties) { object value = item2.GetValue(item, null); if (value != null) { JsonPropertyAttribute jsonPropertyAttribute = item2.GetCustomAttributes <JsonPropertyAttribute>().SingleOrDefault(); if (jsonPropertyAttribute != null) { RequestStringBuilder.ApplyParameterToRequestString(ref requestString, $"{attribute.PropertyName}[{num}]{jsonPropertyAttribute.PropertyName}", value.ToString()); } } } num++; } return(true); }
public static void CreateQuery(ref string requestString, INestedOptions options) { List <Parameter> list = FlattenParams(options); foreach (Parameter item in list) { RequestStringBuilder.ApplyParameterToRequestString(ref requestString, item.Key, item.Value); } }
public static string ApplyAllParameters <T>(this Service <T> service, BaseOptions obj, string url, bool isListMethod = false) where T : IStripeEntity { string requestString = url; if (obj != null) { RequestStringBuilderObj.CreateQuery(ref requestString, obj); foreach (KeyValuePair <string, string> extraParam in obj.ExtraParams) { string argument = WebUtility.UrlEncode(extraParam.Key); RequestStringBuilder.ApplyParameterToRequestString(ref requestString, argument, extraParam.Value); } foreach (string item in obj.Expand) { RequestStringBuilder.ApplyParameterToRequestString(ref requestString, "expand[]", item); } } if (service != null) { IEnumerable <string> enumerable = from p in service.GetType().GetRuntimeProperties() where p.Name.StartsWith("Expand") && p.PropertyType == typeof(bool) where (bool)p.GetValue(service, null) select p.Name; foreach (string item2 in enumerable) { string input = item2.Substring("Expand".Length); input = Regex.Replace(input, "([a-z])([A-Z])", "$1_$2").ToLower(); if (isListMethod) { input = "data." + input; } requestString = ApplyParameterToUrl(requestString, "expand[]", input); } } return(requestString); }
public static string ApplyParameterToUrl(string url, string argument, string value) { RequestStringBuilder.ApplyParameterToRequestString(ref url, argument, value); return(url); }