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);
        }
Пример #2
0
 protected async Task <T> DeleteRequestAsync <T>(string url, BaseOptions options, StripeRequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(Mapper <T> .MapFromJson(await Requestor.DeleteAsync(this.ApplyAllParameters(options, url), SetupRequestOptions(requestOptions), cancellationToken).ConfigureAwait(continueOnCapturedContext: false)));
 }
Пример #3
0
 protected T GetRequest <T>(string url, BaseOptions options, StripeRequestOptions requestOptions, bool isListMethod)
 {
     return(Mapper <T> .MapFromJson(Requestor.GetString(this.ApplyAllParameters(options, url, isListMethod), SetupRequestOptions(requestOptions))));
 }
Пример #4
0
 protected Task <EntityReturned> UpdateEntityAsync(string id, BaseOptions options, StripeRequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(PostRequestAsync <EntityReturned>(InstanceUrl(id), options, requestOptions, cancellationToken));
 }
Пример #5
0
 protected T DeleteRequest <T>(string url, BaseOptions options, StripeRequestOptions requestOptions)
 {
     return(Mapper <T> .MapFromJson(Requestor.Delete(this.ApplyAllParameters(options, url), SetupRequestOptions(requestOptions))));
 }
Пример #6
0
 protected EntityReturned UpdateEntity(string id, BaseOptions options, StripeRequestOptions requestOptions)
 {
     return(PostRequest <EntityReturned>(InstanceUrl(id), options, requestOptions));
 }
Пример #7
0
 protected Task <EntityReturned> GetEntityAsync(string id, BaseOptions options, StripeRequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(GetRequestAsync <EntityReturned>(InstanceUrl(id), options, requestOptions, isListMethod: false, cancellationToken));
 }
Пример #8
0
 protected EntityReturned GetEntity(string id, BaseOptions options, StripeRequestOptions requestOptions)
 {
     return(GetRequest <EntityReturned>(InstanceUrl(id), options, requestOptions, isListMethod: false));
 }
Пример #9
0
 protected Task <EntityReturned> CreateEntityAsync(BaseOptions options, StripeRequestOptions requestOptions, CancellationToken cancellationToken)
 {
     return(PostRequestAsync <EntityReturned>(ClassUrl(), options, requestOptions, cancellationToken));
 }
Пример #10
0
 protected EntityReturned CreateEntity(BaseOptions options, StripeRequestOptions requestOptions)
 {
     return(PostRequest <EntityReturned>(ClassUrl(), options, requestOptions));
 }