public void FromJsonAutoNoObject() { var json = "{\"id\": \"ch_123\"}"; var o = StripeEntity.FromJson(json); Assert.Null(o); }
public void FromJsonAutoUnknownObject() { var json = "{\"id\": \"ch_123\", \"object\": \"foo\"}"; var o = StripeEntity.FromJson(json); Assert.Null(o); }
public void FromJsonGeneric() { var json = "{\"integer\": 234, \"string\": \"String!\"}"; var o = StripeEntity.FromJson <TestEntity>(json); Assert.NotNull(o); Assert.Equal(234, o.Integer); Assert.Equal("String!", o.String); }
public void FromJsonAuto() { var json = "{\"id\": \"ch_123\", \"object\": \"charge\"}"; var o = StripeEntity.FromJson(json); Assert.NotNull(o); Assert.IsType <Charge>(o); Assert.Equal("ch_123", ((Charge)o).Id); }
private static T ProcessResponse <T>(StripeResponse response) where T : IStripeEntity { if (response.StatusCode != HttpStatusCode.Created) { throw BuildStripeException(response); } T obj; try { obj = StripeEntity.FromJson <T>(response.Content); } catch (Newtonsoft.Json.JsonException) { throw BuildInvalidResponseException(response); } obj.StripeResponse = response; return(obj); }