示例#1
0
        /// <summary>
        /// Preview the changes associated with the current subscription
        /// </summary>
        /// <param name="uuid">The uuid of the subscription to be changed</param>
        /// <param name="change">A subscription change object listing what to change about the subscription</param>
        public static Subscription PreviewChange(String uuid, SubscriptionChange change)
        {
            if (uuid.IsNullOrEmpty())
            {
                throw new Recurly.RecurlyException("Must have an existing subscription to preview changes.");
            }

            var previewSubscription = new Subscription();

            var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Post,
                                                            UrlPrefix + Uri.EscapeDataString(uuid) + "/preview",
                                                            change.WriteChangeSubscriptionXml,
                                                            previewSubscription.ReadPreviewXml);

            return(statusCode == HttpStatusCode.NotFound ? null : previewSubscription);
        }
示例#2
0
        /// <summary>
        /// Request that an update to a subscription take place
        /// </summary>
        /// <param name="uuid">The uuid of the subscription to be changed</param>
        /// <param name="change">A subscription change object listing what to change about the subscription</param>
        public static Subscription ChangeSubscription(String uuid, SubscriptionChange change)
        {
            if (uuid.IsNullOrEmpty())
            {
                throw new ArgumentException("uuid cannot be null or empty");
            }

            if (change == null)
            {
                throw new ArgumentException("change cannot be null or empty");
            }

            var subscription = new Subscription();

            var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Put,
                                                            UrlPrefix + Uri.EscapeDataString(uuid),
                                                            change.WriteChangeSubscriptionXml,
                                                            subscription.ReadXml);

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