public async Task <SipPeer> CreateSipPeer(SipPeer item) { using (var response = await Client.MakePostRequest(Client.ConcatAccountPath(string.Format("{0}/{1}/{2}", SitePath, Id, SipPeerPath)), item)) { return(await GetSipPeer(Client.GetIdFromLocationHeader(response.Headers.Location))); } }
public static Task<SipPeer> Create(Client client, SipPeer item) { if (item.SiteId == null) throw new ArgumentException("SiteId is required"); var site = new Site {Id = item.SiteId}; site.SetClient(client); return site.CreateSipPeer(item); }
public async Task<SipPeer> CreateSipPeer(SipPeer item) { using (var response = await Client.MakePostRequest(Client.ConcatAccountPath(string.Format("{0}/{1}/{2}", SitePath, Id, SipPeerPath)), item)) { return await GetSipPeer(Client.GetIdFromLocationHeader(response.Headers.Location)); } }
public async Task <SipPeer> UpdateSipPeer(string id, SipPeer sipPeer) { var item = (await Client.MakePutRequest <SipPeerResponse>( Client.ConcatAccountPath(string.Format("{0}/{1}/{2}/{3}", SitePath, Id, SipPeerPath, id)), sipPeer)).SipPeer; item.Client = Client; item.SiteId = Id; return(item); }
public static Task <SipPeer> Create(Client client, SipPeer item) { if (item.SiteId == null) { throw new ArgumentException("SiteId is required"); } var site = new Site { Id = item.SiteId }; site.SetClient(client); return(site.CreateSipPeer(item)); }
public static Task <SipPeer> Update(Client client, string siteId, string id, SipPeer sipPeer) { if (siteId == null) { throw new ArgumentNullException("siteId"); } if (id == null) { throw new ArgumentNullException("id"); } var site = new Site { Id = siteId }; site.SetClient(client); return(site.UpdateSipPeer(id, sipPeer)); }
public void CreateTest() { var item = new SipPeer { Name = "test", SiteId = "1", IsDefaultPeer = true }; var createdItem = new SipPeer { Id = "1", SiteId = "1", Name = "test", IsDefaultPeer = true }; using (var server = new HttpServer(new[] { new RequestHandler { EstimatedMethod = "POST", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers", Helper.AccountId), EstimatedContent = Helper.ToXmlString(item), HeadersToSend = new Dictionary<string, string> { {"Location", string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10", Helper.AccountId)} }, StatusCodeToSend = 201 }, new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10", Helper.AccountId), ContentToSend = Helper.CreateXmlContent(new SipPeerResponse{SipPeer = createdItem}) } })) { var client = Helper.CreateClient(); var r = SipPeer.Create(client, item).Result; Helper.AssertObjects(createdItem, r); if (server.Error != null) throw server.Error; } }
public static Task<SipPeer> Create(SipPeer item) { return Create(Client.GetInstance(), item); }
public void GetSipPeerTest() { var item = new SipPeer { Id = "10", SiteId = "1", Name = "test", IsDefaultPeer = true }; using (var server = new HttpServer(new[] { new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10", Helper.AccountId), ContentToSend = Helper.CreateXmlContent(new SipPeerResponse{SipPeer = item}) } })) { var client = Helper.CreateClient(); var i = new Site { Id = "1" }; i.SetClient(client); var r = i.GetSipPeer("10").Result; if (server.Error != null) throw server.Error; Helper.AssertObjects(item, r); } }
public static Task <SipPeer> Create(SipPeer item) { return(Create(Client.GetInstance(), item)); }
public static Task <SipPeer> Update(string siteId, string id, SipPeer sipPeer) { return(Update(Client.GetInstance(), siteId, id, sipPeer)); }
public void MoveTnsTest() { using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "POST", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10/movetns", Helper.AccountId), EstimatedContent = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<SipPeerTelephoneNumbers>\r\n <FullNumber>111</FullNumber>\r\n <FullNumber>222</FullNumber>\r\n</SipPeerTelephoneNumbers>" })) { var client = Helper.CreateClient(); var peer = new SipPeer { Id = "10", SiteId = "1" }; peer.SetClient(client); peer.MoveTns("111", "222").Wait(); if (server.Error != null) throw server.Error; } }
public void UpdateTnsTest() { var item = new SipPeerTelephoneNumber { FullNumber = "Number", RewriteUser = "******" }; using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "PUT", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10/tns/00", Helper.AccountId), EstimatedContent = Helper.ToXmlString(item) })) { var client = Helper.CreateClient(); var peer = new SipPeer { Id = "10", SiteId = "1" }; peer.SetClient(client); peer.UpdateTns("00", item).Wait(); if (server.Error != null) throw server.Error; } }
public void GetTns2WithXmlTest() { using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10/tns", Helper.AccountId), ContentToSend = new StringContent(TestXmlStrings.ValidSipPeerTnsResponseXml, Encoding.UTF8, "application/xml") })) { var client = Helper.CreateClient(); var peer = new SipPeer { Id = "10", SiteId = "1" }; peer.SetClient(client); var result = peer.GetTns().Result; if (server.Error != null) throw server.Error; Assert.AreEqual(17, result.Length); Assert.AreEqual("3034162216", result[0].FullNumber); Assert.AreEqual("3034162218", result[1].FullNumber); } }
public void GetTnsTest() { var item = new SipPeerTelephoneNumber { FullNumber = "Number", RewriteUser = "******" }; var response = new SipPeerTelephoneNumberResponse { SipPeerTelephoneNumber = item }; using (var server = new HttpServer(new RequestHandler { EstimatedMethod = "GET", EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/sites/1/sippeers/10/tns/00", Helper.AccountId), ContentToSend = Helper.CreateXmlContent(response) })) { var client = Helper.CreateClient(); var peer = new SipPeer { Id = "10", SiteId = "1" }; peer.SetClient(client); var result = peer.GetTns("00").Result; if (server.Error != null) throw server.Error; Helper.AssertObjects(item, result); } }