예제 #1
0
        /// <summary>
        /// Gets all adjustments for this account
        /// </summary>
        /// <param name="filter">Optional filter criteria</param>
        /// <param name="type">Adjustment type to retrieve. Optional, default: All.</param>
        /// <param name="state">State of the Adjustments to retrieve. Optional, default: Any.</param>
        /// <returns></returns>
        public RecurlyList <Adjustment> GetAdjustments(FilterCriteria filter, Adjustment.AdjustmentType type = Adjustment.AdjustmentType.All,
                                                       Adjustment.AdjustmentState state = Adjustment.AdjustmentState.Any)
        {
            var adjustments = new AdjustmentList();

            filter = filter ?? FilterCriteria.Instance;
            var parameters = filter.ToNamedValueCollection();

            if (type != Adjustment.AdjustmentType.All)
            {
                parameters["type"] = type.ToString().EnumNameToTransportCase();
            }
            if (state != Adjustment.AdjustmentState.Any)
            {
                parameters["state"] = state.ToString().EnumNameToTransportCase();
            }


            var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Get,
                                                            UrlPrefix + Uri.EscapeDataString(AccountCode) + "/adjustments/"
                                                            + "?" + parameters.ToString()
                                                            , adjustments.ReadXmlList);

            return(statusCode == HttpStatusCode.NotFound ? null : adjustments);
        }
예제 #2
0
        /// <summary>
        /// Gets all adjustments for this account, by type
        /// </summary>
        /// <param name="type">Adjustment type to retrieve. Optional, default: All.</param>
        /// <param name="state">State of the Adjustments to retrieve. Optional, default: Any.</param>
        /// <returns></returns>
        public RecurlyList <Adjustment> GetAdjustments(Adjustment.AdjustmentType type   = Adjustment.AdjustmentType.All,
                                                       Adjustment.AdjustmentState state = Adjustment.AdjustmentState.Any)
        {
            var adjustments = new AdjustmentList();
            var statusCode  = Client.Instance.PerformRequest(Client.HttpRequestMethod.Get,
                                                             UrlPrefix + Uri.EscapeUriString(AccountCode) + "/adjustments/"
                                                             + Build.QueryStringWith(Adjustment.AdjustmentState.Any == state ? "" : "state=" + state.ToString().EnumNameToTransportCase())
                                                             .AndWith(Adjustment.AdjustmentType.All == type ? "" : "type=" + type.ToString().EnumNameToTransportCase())
                                                             , adjustments.ReadXmlList);

            return(statusCode == HttpStatusCode.NotFound ? null : adjustments);
        }
예제 #3
0
        /// <summary>
        /// Gets all adjustments for this account, by type
        /// </summary>
        /// <param name="type">Adjustment type to retrieve. Optional, default: All.</param>
        /// <param name="state">State of the Adjustments to retrieve. Optional, default: Any.</param>
        /// <returns></returns>
        public RecurlyList <Adjustment> GetAdjustments(Adjustment.AdjustmentType type   = Adjustment.AdjustmentType.All,
                                                       Adjustment.AdjustmentState state = Adjustment.AdjustmentState.Any, DateTime beginTime = new DateTime(), int perPage = 50)
        {
            beginTime = DateTime.SpecifyKind(beginTime, DateTimeKind.Utc);

            var adjustments = new AdjustmentList();
            var statusCode  = Client.Instance.PerformRequest(Client.HttpRequestMethod.Get,
                                                             UrlPrefix + Uri.EscapeDataString(AccountCode) + "/adjustments/"
                                                             + Build.QueryStringWith(Adjustment.AdjustmentState.Any == state ? "" : "state=" + state.ToString().EnumNameToTransportCase())
                                                             .AndWith(Adjustment.AdjustmentType.All == type ? "" : "type=" + type.ToString().EnumNameToTransportCase())
                                                             .AndWith("per_Page=" + perPage)
                                                             .AndWith(beginTime == DateTime.MinValue ? "" : "begin_time=" + beginTime.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ssK"))
                                                             , adjustments.ReadXmlList);

            return(statusCode == HttpStatusCode.NotFound ? null : adjustments);
        }