diff --git a/src/Stripe.net/Services/_base/Service.cs b/src/Stripe.net/Services/_base/Service.cs index efe4af981b..e5f48a434a 100644 --- a/src/Stripe.net/Services/_base/Service.cs +++ b/src/Stripe.net/Services/_base/Service.cs @@ -231,7 +231,6 @@ protected async Task RequestAsync( CancellationToken cancellationToken = default(CancellationToken)) where T : IStripeEntity { - options = this.SetupOptions(options, IsStripeList()); requestOptions = this.SetupRequestOptions(requestOptions); return await this.Client.RequestAsync( method, @@ -287,29 +286,6 @@ protected IEnumerable ListRequestAutoPaging( } } - protected BaseOptions SetupOptions(BaseOptions options, bool isListMethod) - { - var serviceExpansions = this.Expansions(isListMethod); - if (!serviceExpansions.Any()) - { - return options; - } - - options = options ?? new BaseOptions(); - - if (options.Expand == null) - { - options.Expand = new List(); - } - - // Compute the union instead of using `AddRangeExpand` to avoid adding duplicate - // values in the list, in case `SetupOptions` has already been called on this options - // instance. - options.Expand = options.Expand.Union(serviceExpansions).ToList(); - - return options; - } - protected RequestOptions SetupRequestOptions(RequestOptions requestOptions) { if (requestOptions == null) @@ -345,21 +321,5 @@ private static bool IsStripeList() return typeInfo.IsGenericType && typeInfo.GetGenericTypeDefinition() == typeof(StripeList<>); } - - /// - /// Returns the list of attributes to expand in requests sent by the service. - /// - /// Whether the request is a list request or not. - /// The list of attributes to expand. - public List Expansions(bool isListMethod) - { - return this.GetType() - .GetRuntimeProperties() - .Where(p => p.Name.StartsWith("Expand") && p.PropertyType == typeof(bool)) - .Where(p => (bool)p.GetValue(this, null)) - .Select(p => StringUtils.ToSnakeCase(p.Name.Substring("Expand".Length))) - .Select(i => isListMethod ? $"data.{i}" : i) - .ToList(); - } } }