예제 #1
0
        public void CheckWithXmlTest()
        {
            var request = new NumberPortabilityRequest
            {
                TnList = new[] { "1111", "2222", "3333" }
            };

            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "POST",
                EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lnpchecker?fullCheck=true", Helper.AccountId),
                EstimatedContent = Helper.ToXmlString(request),
                ContentToSend = new StringContent(TestXmlStrings.LnpCheckResponse, Encoding.UTF8, "application/xml")
            }))
            {
                var client = Helper.CreateClient();
                var result = LnpChecker.Check(client, new[] { "1111", "2222", "3333" }, true).Result;
                if (server.Error != null)
                {
                    throw server.Error;
                }
                CollectionAssert.AreEqual(new[] { "9195551212", "9195551213" }, result.PortableNumbers);
                Assert.AreEqual("NC", result.SupportedRateCenters[0].State);
                CollectionAssert.AreEqual(new[] { "9195551212", "9195551213" }, result.SupportedLosingCarriers.LosingCarrierTnList.TnList);
            }
        }
예제 #2
0
        public void CheckThrowsErrorTest()
        {
            var request = new NumberPortabilityRequest
            {
                TnList = new[] { "1111" }
            };
            var response = new BandwidthIrisException(
                "170",
                "error thrown",
                System.Net.HttpStatusCode.ExpectationFailed
                );

            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "POST",
                EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lnpchecker?fullCheck=true", Helper.AccountId),
                EstimatedContent = Helper.ToXmlString(request),
                ContentToSend = new StringContent("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><NumberPortabilityResponse><PortableNumbers><Tn>9192202164</Tn><Tn>9197891146</Tn></PortableNumbers><PortabilityErrors><Error><Code>7331</Code><Description>Rate Center Not Present in Bandwidth Dashboard</Description><TelephoneNumbers><Tn>5555555555</Tn></TelephoneNumbers></Error></PortabilityErrors><SupportedRateCenters><RateCenterGroup><RateCenter>DURHAM</RateCenter><City>DURHAM</City><State>NC</State><LATA>426</LATA><Tiers><Tier>0</Tier></Tiers><TnList><Tn>9192202164</Tn></TnList></RateCenterGroup><RateCenterGroup><RateCenter>RALEIGH</RateCenter><City>RALEIGH</City><State>NC</State><LATA>426</LATA><Tiers><Tier>0</Tier></Tiers><TnList><Tn>9197891146</Tn></TnList></RateCenterGroup></SupportedRateCenters><UnsupportedRateCenters/></NumberPortabilityResponse>", Encoding.UTF8, "application/xml")
            }))
            {
                var client = Helper.CreateClient();
                try
                {
                    var result = LnpChecker.Check(client, new[] { "1111" }, true).Result;
                } catch (BandwidthIrisException e)
                {
                    return;
                }
                catch (AggregateException e)
                {
                    Exception innerEx = e;
                    while (innerEx != null)
                    {
                        string mesg = innerEx.Message;
                        innerEx = innerEx.InnerException;
                        Console.WriteLine(mesg);
                    }
                    return;
                }
                catch (Exception e)
                {
                    return;
                }
                Assert.Fail("The exception was not thrown");
            }
        }
예제 #3
0
        public void CheckTest()
        {
            var request = new NumberPortabilityRequest
            {
                TnList = new[] { "1111", "2222", "3333" }
            };
            var response = new NumberPortabilityResponse
            {
                SupportedRateCenters = new[]
                {
                    new RateCenterGroup
                    {
                        RateCenter = "Center1",
                        City       = "City1",
                        State      = "State1",
                        Lata       = "11",
                        Tiers      = new [] { "111", "222", "333" },
                        TnList     = new [] { "1111", "2222", "3333" }
                    },
                },
                UnsupportedRateCenters = new RateCenterGroup[0]
            };

            using (var server = new HttpServer(new RequestHandler
            {
                EstimatedMethod = "POST",
                EstimatedPathAndQuery = string.Format("/v1.0/accounts/{0}/lnpchecker?fullCheck=true", Helper.AccountId),
                EstimatedContent = Helper.ToXmlString(request),
                ContentToSend = Helper.CreateXmlContent(response)
            }))
            {
                var client = Helper.CreateClient();
                var result = LnpChecker.Check(client, new[] { "1111", "2222", "3333" }, true).Result;
                if (server.Error != null)
                {
                    throw server.Error;
                }
                Helper.AssertObjects(response, result);
            }
        }
예제 #4
0
        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();
            }
        }