public void IntegrationTests_AccountStatus_Get()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            var account = phaxio.GetAccountStatus();
        }
Example #2
0
        public void IntegrationTests_Numbers_GetAreaCodes()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            var areaCodes = phaxio.ListAreaCodes(state:"HI");

            Assert.Greater(areaCodes.Count(), 0, "There should be some area codes");
        }
        public void IntegrationTests_SupportedCountries()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            var countries = phaxio.ListSupportedCountries();

            Assert.Greater(countries.Count(), 0, "There should be some countries");
        }
Example #4
0
        public void IntegrationTests_PhaxCode_GetCodeBytes()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            var code = phaxio.DownloadPhaxCodePng();

            Assert.IsNotEmpty(code);
        }
Example #5
0
        public void IntegrationTests_PhaxCode_GetCodeUrl()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            var code = phaxio.CreatePhaxCode();

            Assert.IsNotEmpty(code.AbsoluteUri);
        }
        public void IntegrationTests_GetHostedDocument()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            var filename = "hostedoc.pdf";

            Assert.Throws(typeof(ApplicationException), () => phaxio.GetHostedDocument(filename));
        }
Example #7
0
        public void IntegrationTests_Fax_Send()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            var testPdf = BinaryFixtures.getTestPdfFile();

            var faxId = phaxio.SendFax("8088675309", testPdf);

            Assert.IsNotEmpty(faxId);
        }
Example #8
0
        public void IntegrationTests_PhaxCode_AttachCodeAndGetBytes()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            var testPdf = BinaryFixtures.getTestPdfFile();

            var code = phaxio.AttachPhaxCodeToPdf(0, 0, testPdf);

            Assert.IsNotEmpty(code);
        }
Example #9
0
        public void IntegrationTests_Numbers_BasicScenario()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            // Find area codes to provision a number in
            var areaCodes = phaxio.ListAreaCodes(state: "DE");

            Assert.Greater(areaCodes.Count(), 0, "There should be some area codes");

            var areaCode = areaCodes.First();

            // Provision a number
            var provisionedNumber = phaxio.ProvisionNumber(areaCode.Key);

            // Check to see if the number's listed on the account
            var accountNumbers = phaxio.ListNumbers();

            if (!accountNumbers.Any(n => n.Number == provisionedNumber.Number))
            {
                throw new AssertionException("ListNumbers should return newly provisioned number.");
            }

            Thread.Sleep(1000);

            // Release the number
            phaxio.ReleaseNumber(provisionedNumber.Number);

            Thread.Sleep(1000);

            // Check to see if the number's still listed on the account
            accountNumbers = phaxio.ListNumbers();

            if (accountNumbers.Any(n => n.Number == provisionedNumber.Number))
            {
                throw new AssertionException("ListNumbers should not return released number.");
            }
        }
Example #10
0
        // This is test runs faily long since Phaxio rate limits
        public void IntegrationTests_Fax_BasicScenario()
        {
            var config = new KeyManager();

            var phaxio = new PhaxioClient(config["api_key"], config["api_secret"]);

            // Create a phax code
            var metadata = StringHelpers.Random(10);

            var phaxCodePng = phaxio.DownloadPhaxCodePng(metadata);

            var phaxCodeFilename = metadata + ".png";

            filesToCleanup.Add(phaxCodeFilename);

            File.WriteAllBytes(phaxCodeFilename, phaxCodePng);

            // Attach phax code to pdf
            var testPdf = BinaryFixtures.getTestPdfFile();

            var testPdfWithCodeBytes = phaxio.AttachPhaxCodeToPdf(0, 0, testPdf, metadata: metadata);

            var testPdfWithCodeFilename = metadata + ".pdf";

            filesToCleanup.Add(testPdfWithCodeFilename);

            File.WriteAllBytes(testPdfWithCodeFilename, testPdfWithCodeBytes);

            var testPdfWithCode = new FileInfo(testPdfWithCodeFilename);

            // Send phax using pdf with phax code
            var faxId = phaxio.SendFax("8088675309", testPdfWithCode);

            // Phaxio rate limits, so we need to wait a second.
            Thread.Sleep(100);

            // Download a thumbnail of the sent fax
            // It takes a little while for a fax to show up
            int retries = 0;
            bool downloadSuccess = false;
            while (retries < 20 && !downloadSuccess)
            {
                try
                {
                    var thumbnailBytes = phaxio.DownloadFax(faxId, "s");
                    var thumbnailFilename = metadata + ".jpg";

                    filesToCleanup.Add(thumbnailFilename);

                    File.WriteAllBytes(thumbnailFilename, thumbnailBytes);

                    downloadSuccess = true;
                }
                catch (Exception)
                {
                    retries++;
                    Thread.Sleep(1000);
                }
            }

            Assert.IsTrue(downloadSuccess, "DownloadFax should've worked");

            // Resend fax
            var resendResult = phaxio.ResendFax(faxId);

            Assert.True(resendResult.Success, "ResendFax should return success.");

            Thread.Sleep(500);

            // Cancel a fax
            var cancelResult = phaxio.CancelFax(faxId);

            Assert.IsFalse(cancelResult.Success, "CancelFax should not be successful.");

            Thread.Sleep(500);

            // Delete a fax
            var deleteResult = phaxio.DeleteFax(faxId);

            Assert.True(resendResult.Success, "DeleteResult should return success.");
        }