예제 #1
0
 /// <summary>
 /// Lists usages by status and/or time. Defaults to all.
 /// </summary>
 /// <param name="billingState"></param>
 /// <param name="dateTimeType"></param>
 /// <param name="startDateTime"></param>
 /// <param name="endDateTime"></param>
 /// <returns></returns>
 public static RecurlyList <Usage> List(string subscriptionUuid,
                                        string subscriptionAddOnCode,
                                        UsageList.UsageBillingState billingState = UsageList.UsageBillingState.All,
                                        UsageList.UsageDateTimeType dateTimeType = UsageList.UsageDateTimeType.All,
                                        DateTime?startDateTime = null,
                                        DateTime?endDateTime   = null)
 {
     return(new UsageList("/subscriptions/" + Uri.EscapeUriString(subscriptionUuid) +
                          "/add_ons/" + Uri.EscapeUriString(subscriptionAddOnCode) +
                          "/usage" +
                          Build.QueryStringWith("billing_status=" + billingState.ToString().EnumNameToTransportCase())
                          .AndWith(dateTimeType != UsageList.UsageDateTimeType.All ? "datetime_type=" + dateTimeType.ToString().EnumNameToTransportCase() : "")
                          .AndWith(startDateTime != null ? "start_datetime=" + Uri.EscapeUriString(startDateTime.Value.ToString("s")) : "")
                          .AndWith(endDateTime != null ? "end_datetime=" + Uri.EscapeUriString(endDateTime.Value.ToString("s")) : "")
                          ));
 }
예제 #2
0
        public static RecurlyList <Usage> List(string subscriptionUuid, string subscriptionAddOnCode, FilterCriteria filter,
                                               UsageList.UsageBillingState billingState = UsageList.UsageBillingState.All,
                                               UsageList.UsageDateTimeType dateTimeType = UsageList.UsageDateTimeType.All)
        {
            filter = filter ?? FilterCriteria.Instance;
            var parameters = filter.ToNamedValueCollection();

            if (billingState != UsageList.UsageBillingState.All)
            {
                parameters["billing_status"] = billingState.ToString().EnumNameToTransportCase();
            }
            if (dateTimeType != UsageList.UsageDateTimeType.All)
            {
                parameters["datetime_type"] = dateTimeType.ToString().EnumNameToTransportCase();
            }

            return(new UsageList(UrlPrefix(subscriptionUuid, subscriptionAddOnCode) + "?" + parameters.ToString()));
        }