public static async Task<Subscription> Create(Client client, Subscription item) { using (var response = await client.MakePostRequest(client.ConcatAccountPath(SubscriptionPath), item)) { return await Get(client, client.GetIdFromLocationHeader(response.Headers.Location)); } }
public void GetWithDefaultClientTest() { var item = new Subscription { Id = "1", OrderType = "orders", OrderId = "100", EmailSubscription = new EmailSubscription { Email = "test@test", DigestRequested = "NONE" } }; using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/subscriptions/1", Helper.AccountId), ContentToSend = Helper.CreateXmlContent(new SubscriptionsResponse { Subscriptions = new[] { item } }) })) { var result = Subscription.Get("1").Result; if (server.Error != null) throw server.Error; Helper.AssertObjects(item, result); } }
public void DeleteTest() { using (var server = new HttpServer(new[] { new RequestHandler { EstimatedMethod = "DELETE", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/subscriptions/1", Helper.AccountId), } })) { var client = Helper.CreateClient(); var i = new Subscription { Id = "1" }; i.SetClient(client); i.Delete().Wait(); if (server.Error != null) throw server.Error; } }
public void UpdateTest() { var item = new Subscription { OrderType = "orders", OrderId = "100", EmailSubscription = new EmailSubscription { Email = "test@test", DigestRequested = "NONE" } }; using (var server = new HttpServer(new[] { new RequestHandler { EstimatedMethod = "PUT", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/subscriptions/1", Helper.AccountId), EstimatedContent = Helper.ToXmlString(item) } })) { var client = Helper.CreateClient(); var i = new Subscription {Id = "1"}; i.SetClient(client); i.Update(item).Wait(); if (server.Error != null) throw server.Error; } }
public void CreateWithDefaultClientTest() { var item = new Subscription { OrderType = "orders", OrderId = "100", EmailSubscription = new EmailSubscription { Email = "test@test", DigestRequested = "NONE" } }; using (var server = new HttpServer(new[] { new RequestHandler { EstimatedMethod = "POST", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/subscriptions", Helper.AccountId), EstimatedContent = Helper.ToXmlString(item), HeadersToSend = new Dictionary<string, string> { {"Location", string.Format("/v1.0/accounts/{0}/subscriptions/1", Helper.AccountId)} } }, new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/subscriptions/1", Helper.AccountId), ContentToSend = Helper.CreateXmlContent(new SubscriptionsResponse{Subscriptions = new []{new Subscription {Id = "1"}}}) } })) { var i = Subscription.Create(item).Result; if (server.Error != null) throw server.Error; Assert.AreEqual("1", i.Id); } }
public Task Update(Subscription site) { return Client.MakePutRequest(Client.ConcatAccountPath(string.Format("{0}/{1}", SubscriptionPath, Id)), site, true); }
public static Task<Subscription> Create(Subscription item) { return Create(Client.GetInstance(), item); }