Exemple #1
0
        public async static Task <LnpOrderResponse> Create(Client client, PortIn order)
        {
            var item = await client.MakePostRequest <LnpOrderResponse>(client.ConcatAccountPath(PortInPath), order);

            item.Client = client;
            return(item);
        }
        public void CreateWithXmlTest()
        {
            var order = new PortIn
            {
                BillingTelephoneNumber = "1111",
                Subscriber = new Subscriber
                {
                    SubscriberType = "BUSINESS",
                    BusinessName = "Company",
                    ServiceAddress = new Address
                    {
                        City = "City",
                        StateCode = "State",
                        Country = "County"
                    }
                },
                SiteId = "1"
            };

            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "POST",
                EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins", Helper.AccountId),
                EstimatedContent = Helper.ToXmlString(order),
                ContentToSend = new StringContent(TestXmlStrings.ValidCreatePostInResponse, Encoding.UTF8, "application/xml")
            }))
            {
                var client = Helper.CreateClient();
                var r = PortIn.Create(client, order).Result;
                if (server.Error != null) throw server.Error;
                Assert.AreEqual("d28b36f7-fa96-49eb-9556-a40fca49f7c6", r.Id);
                Assert.AreEqual("201", r.Status.Code);
                Assert.AreEqual("Order request received. Please use the order id to check the status of your order later.", r.Status.Description);
                Assert.AreEqual("PENDING_DOCUMENTS", r.ProcessingStatus);
                Assert.AreEqual("John Doe", r.LoaAuthorizingPerson);
                Assert.AreEqual("6882015002", r.BillingTelephoneNumber);
                CollectionAssert.AreEqual(new[] { "6882015025", "6882015026" }, r.ListOfPhoneNumbers);
                Assert.IsFalse(r.Triggered);
                Assert.AreEqual("PORTIN", r.BillingType);
                
            }
        }
        static async Task PortInDemo()
        {
            var numberToCheck = "9192971001";
            var lnpResult = await LnpChecker.Check(_client, new []{numberToCheck}, true);
            if (lnpResult.PortableNumbers != null && lnpResult.PortableNumbers[0].Equals(numberToCheck))
            {
                var sites = await Site.List(_client);
                var site = sites[0];
                var sipPeers = await site.GetSipPeers();
                var sipPeer = sipPeers[0];


                var data = new PortIn
                    {
                        BillingTelephoneNumber = numberToCheck,
                        LoaAuthorizingPerson = "Joe Blow",
                        Subscriber = new Subscriber
                            {
                                SubscriberType = "BUSINESS",
                                BusinessName = "Company",
                                ServiceAddress = new Address
                                    {
                                        HouseNumber = "123",
                                        StreetName = "Anywhere St",
                                        City = "Raleigh",
                                        StateCode = "NC",
                                        Zip= "27609"

                                    }
                            },
                            ListOfPhoneNumbers = new string[]
                                {
                                    numberToCheck
                                },
                        PeerId = sipPeer.Id,
                        SiteId = site.Id
                    };
                var order = await PortIn.Create(_client, data);
                Console.WriteLine("Created PortIn Order ID: {0}", order.Id);

                var fileName = await order.CreateFile(new byte[] {0, 1, 2, 3, 4, 5}, "application/pdf");
                var metadata = await order.GetFileMetadata(fileName);
                using (var content = await order.GetFile(fileName))
                {
                    var fileContent = content.Buffer;
                }
                await order.UpdateFile(fileName, new byte[] {10, 11, 12, 13, 14, 15}, "application/pdf");
                await order.DeleteFile(fileName);
                await order.Update(new LnpOrderSupp
                    {
                        RequestedFocDate = DateTime.Parse("2015-07-18T00:00:00.000Z"),
                        WirelessInfo = new[]
                            {
                                new WirelessInfo
                                    {
                                        AccountNumber = "77129766500001",
                                        PinNumber = "0000"
                                    }
                            }
                    });
                await order.Delete();
            }
        }
Exemple #4
0
 public static Task <LnpOrderResponse> Create(PortIn order)
 {
     return(Create(Client.GetInstance(), order));
 }
 public static Task<LnpOrderResponse> Create(PortIn order)
 {
     return Create(Client.GetInstance(), order);
 }
 public async static Task<LnpOrderResponse> Create(Client client, PortIn order)
 {
     var item = await client.MakePostRequest<LnpOrderResponse>(client.ConcatAccountPath(PortInPath), order);
     item.Client = client;
     return item;
 }
 public void GetNotesTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1/notes", Helper.AccountId),
         ContentToSend = new StringContent(TestXmlStrings.NotesResponse, Encoding.UTF8, "application/xml")
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         var list = portIn.GetNotes().Result;
         if (server.Error != null) throw server.Error;
         Assert.AreEqual(2, list.Length);
         Assert.AreEqual("11299", list[0].Id);
         Assert.AreEqual("customer", list[0].UserId);
         Assert.AreEqual("Test", list[0].Description);
         Assert.AreEqual("11301", list[1].Id);
         Assert.AreEqual("customer", list[1].UserId);
         Assert.AreEqual("Test1", list[1].Description);
     }
 }
 public void AddNoteTest()
 {
     var item = new Note
     {
         UserId = "customer",
         Description = "Test"
     };
     using (var server = new HttpServer(new []{
         new RequestHandler
         {
             EstimatedMethod = "POST",
             EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1/notes", Helper.AccountId),
             EstimatedContent = Helper.ToXmlString(item),
             HeadersToSend = new Dictionary<string, string> {
                 {"Location", string.Format("/v1.0/accounts/{0}/portins/1/notes/11299", Helper.AccountId)} 
             }
         },
         new RequestHandler
         {
             EstimatedMethod = "GET",
             EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1/notes", Helper.AccountId),
             ContentToSend = new StringContent(TestXmlStrings.NotesResponse, Encoding.UTF8, "application/xml")
         }
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         var r = portIn.AddNote(item).Result;
         if (server.Error != null) throw server.Error;
         Assert.AreEqual("11299", r.Id);
         Assert.AreEqual("customer", r.UserId);
         Assert.AreEqual("Test", r.Description);
     }
 }
 public void DeleteTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "DELETE",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1", Helper.AccountId)
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         portIn.Delete().Wait();
         if (server.Error != null) throw server.Error;
     }
 }
 public void UpdateTest()
 {
     var data = new LnpOrderSupp
     {
         RequestedFocDate = DateTime.Parse("2014-11-18T00:00:00.000Z"),
         WirelessInfo = new []{new WirelessInfo
         {
             AccountNumber = "77129766500001",
             PinNumber = "0000"
         }}
     };
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "PUT",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1", Helper.AccountId),
         EstimatedContent = Helper.ToXmlString(data)
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         portIn.Update(data).Wait();
         if (server.Error != null) throw server.Error;
     }
 }
 public void GetFileMetadataTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1/loas/test/metadata", Helper.AccountId),
         ContentToSend = new StringContent(TestXmlStrings.FileMetadataResponse, Encoding.UTF8, "application/xml")
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         var r = portIn.GetFileMetadata("test").Result;
         if (server.Error != null) throw server.Error;
         Assert.AreEqual("LOA", r.DocumentType);
     }
 }
 public void GetFilesTest()
 {
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1/loas?metadata=true", Helper.AccountId),
         ContentToSend = new StringContent(TestXmlStrings.FileListResponse, Encoding.UTF8, "application/xml")
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         var list = portIn.GetFiles(true).Result;
         if (server.Error != null) throw server.Error;
         Assert.AreEqual(6, list.Length);
         Assert.AreEqual("d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416231534986.txt", list[0].FileName);
         Assert.AreEqual("LOA", list[0].FileMetadata.DocumentType);
     }
 }
 public void GetFile2Test()
 {
     const string data = "hello";
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "GET",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1/loas/test", Helper.AccountId),
         ContentToSend = new StringContent(data, Encoding.UTF8, "media/type")
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         using (var r = portIn.GetFile("test", true).Result)
         using(var reader = new StreamReader(r.Stream, Encoding.UTF8))
         {
             Assert.AreEqual("media/type", r.MediaType);
             Assert.AreEqual(data, reader.ReadToEnd());
         }
         if (server.Error != null) throw server.Error;
     }
 }
 public void UpdateFile2Test()
 {
     const string data = "hello";
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "PUT",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1/loas/test", Helper.AccountId),
         EstimatedContent = data,
         EstimatedHeaders = new Dictionary<string, string> { { "Content-Type", "media/type" } }
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         portIn.UpdateFile("test", Encoding.UTF8.GetBytes(data), "media/type").Wait();
         if (server.Error != null) throw server.Error;
     }
 }
 public void CreateFile2Test()
 {
     const string data = "hello";
     using (var server = new HttpServer(new RequestHandler
     {
         EstimatedMethod = "POST",
         EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/portins/1/loas", Helper.AccountId),
         EstimatedContent = data,
         EstimatedHeaders = new Dictionary<string, string> { { "Content-Type", "media/type" } },
         ContentToSend = Helper.CreateXmlContent(new FileResult { FileName = "test" })
     }))
     {
         var client = Helper.CreateClient();
         var portIn = new PortIn { Id = "1" };
         portIn.SetClient(client);
         var fileName = portIn.CreateFile(Encoding.UTF8.GetBytes(data), "media/type").Result;
         if (server.Error != null) throw server.Error;
         Assert.AreEqual("test", fileName);
     }
 }