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); }
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); }
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))); }
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); }
/// <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)); }