예제 #1
0
 public void EncodeSubscriptionUpdate()
 {
     UrlEncoder urlEncoder = new UrlEncoder();
     Subscription subscription = new Subscription();
     subscription.Id = "sub_569df922b4506cd73030";
     subscription.Offer = new Offer() { Id = "sub_569df922b4506cd73030" };
     string expected = "offer=sub_569df922b4506cd73030";
     string reply = urlEncoder.EncodeUpdate(subscription);
     Assert.AreEqual(expected, reply);
 }
예제 #2
0
 public void EncodeTransactionUpdate()
 {
     UrlEncoder urlEncoder = new UrlEncoder();
     Transaction transaction = new Transaction();
     transaction.Token = "098f6bcd4621d373cade4e832627b4f6";
     transaction.Amount = 3500;
     transaction.Currency = "EUR";
     transaction.Description = "Test";
     string expected = "description=Test";
     string reply = urlEncoder.EncodeUpdate(transaction);
     Assert.AreEqual(expected, reply);
 }
예제 #3
0
        public virtual async Task <Offer> UpdateAsync(Offer obj, Boolean updateSubscriptions)
        {
            var    encoder = new UrlEncoder();
            String param   = encoder.EncodeObject(new
            {
                update_subscriptions = updateSubscriptions.ToString().ToLower()
            });
            var content = encoder.EncodeUpdate(obj);

            return(await updateWithContentAsync(obj.Id,
                                                String.Format("{0}&{1}", content, param)));
        }
예제 #4
0
        public void EncodeSubscriptionUpdate()
        {
            UrlEncoder urlEncoder = new UrlEncoder();

            Subscription subscription = new Subscription();

            subscription.CancelAtPeriodEnd = true;
            subscription.Id = "sub_569df922b4506cd73030";
            string expected = "cancel_at_period_end=true";
            string reply    = urlEncoder.EncodeUpdate(subscription);

            Assert.AreEqual(expected, reply);
        }
예제 #5
0
        /// <summary>
        /// Updates the asynchronous.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns></returns>
        public virtual async Task <T> UpdateAsync(T obj)
        {
            String resourceId = GetResourceId(obj);
            var    encoder    = new UrlEncoder();
            var    content    = new StringContent(encoder.EncodeUpdate(obj));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
            string requestUri            = _apiUrl + "/" + _resource.ToString().ToLower() + "/" + resourceId;
            HttpResponseMessage response = httpClient.PutAsync(requestUri, content).Result;
            String data = await readReponseMessage(response);

            return(ReadResult <T>(data));
        }
예제 #6
0
        public void EncodeTransactionUpdate()
        {
            UrlEncoder  urlEncoder  = new UrlEncoder();
            Transaction transaction = new Transaction();

            transaction.Token       = "098f6bcd4621d373cade4e832627b4f6";
            transaction.Amount      = 3500;
            transaction.Currency    = "EUR";
            transaction.Description = "Test";
            string expected = "description=Test";
            string reply    = urlEncoder.EncodeUpdate(transaction);

            Assert.AreEqual(expected, reply);
        }
예제 #7
0
        public void EncodeSubscriptionUpdate()
        {
            UrlEncoder   urlEncoder   = new UrlEncoder();
            Subscription subscription = new Subscription();

            subscription.Id    = "sub_569df922b4506cd73030";
            subscription.Offer = new Offer()
            {
                Id = "sub_569df922b4506cd73030"
            };
            string expected = "offer=sub_569df922b4506cd73030";
            string reply    = urlEncoder.EncodeUpdate(subscription);

            Assert.AreEqual(expected, reply);
        }