예제 #1
0
        public Result Send(string toNumber, byte[] file, string filename, FaxOptions options = null)
        {
            var result = client.SendFax(toNumber, file, filename, options);

            Id = result.Id;
            return(result);
        }
예제 #2
0
 public Result Send(string toNumber, FileInfo file, FaxOptions options = null)
 {
     return(Send(new List <string> {
         toNumber
     }, new List <FileInfo> {
         file
     }, options));
 }
예제 #3
0
        public void IntegrationTests_FaxClass_SendSingleFileOptions()
        {
            var testToNumber = "8088675309";
            var testOptions = new FaxOptions
            {
                HeaderText = "headertext",
                StringData = "somedata",
                StringDataType = "html",
                IsBatch = true,
                BatchDelaySeconds = 10,
                AvoidBatchCollision = true,
                CallbackUrl = "https://example.com/callback",
                CancelTimeoutAfter = 20,
                CallerId = "3213214321",
                FailureErrorType = "failure_type"
            };

            Action<IRestRequest> requestAsserts = req =>
            {
                var parameters = ParametersHelper.ToDictionary(req.Parameters);

                Assert.AreEqual(testToNumber, parameters["to[]"]);

                var props = typeof(FaxOptions).GetProperties();
                foreach (var prop in props)
                {
                    var serializeAs = prop.GetCustomAttributes(false)
                        .OfType<SerializeAsAttribute>()
                        .FirstOrDefault();

                    if (serializeAs != null)
                    {
                        object expectedValue = prop.GetValue(testOptions, null);

                        Assert.AreEqual(expectedValue, parameters[serializeAs.Value]);
                    }   
                }
            };

            var clientBuilder = new IRestClientBuilder { Op = "send", RequestAsserts = requestAsserts };
            var phaxio = new PhaxioClient(IRestClientBuilder.TEST_KEY, IRestClientBuilder.TEST_SECRET, clientBuilder.Build());

            var testFile = BinaryFixtures.getTestPdfFile();

            var fax = phaxio.CreateFax();

            fax.Send(testToNumber, testFile, testOptions);

            Assert.AreEqual("1234", fax.Id, "FaxId should be the same.");
        }
예제 #4
0
파일: Fax.cs 프로젝트: phaxio/phaxio-dotnet
 public void Send(IEnumerable<string> toNumbers, IEnumerable<FileInfo> files, FaxOptions options = null)
 {
     Id = client.SendFax(toNumbers, files, options);
 }
예제 #5
0
파일: Fax.cs 프로젝트: phaxio/phaxio-dotnet
 public void Send(string toNumber, IEnumerable<FileInfo> files, FaxOptions options = null)
 {
     Send(new List<string> { toNumber }, files, options);
 }
예제 #6
0
파일: Fax.cs 프로젝트: phaxio/phaxio-dotnet
 public void Send(IEnumerable<string> toNumbers, FileInfo file, FaxOptions options = null)
 {
     Send(toNumbers, new List<FileInfo> { file }, options);
 }
예제 #7
0
파일: Fax.cs 프로젝트: phaxio/phaxio-dotnet
 public void Send(string toNumber, FileInfo file, FaxOptions options = null)
 {
     Send(new List<string> { toNumber }, new List<FileInfo> { file }, options);
 }
예제 #8
0
        public void UnitTests_Fax_SendSingleFileSomeOptions()
        {
            var testToNumber = "8088675309";
            var testOptions = new FaxOptions
            {
                HeaderText = "headertext",
                StringData = "somedata",
                StringDataType = "html",
                IsBatch = true
            };

            Action<IRestRequest> requestAsserts = req =>
            {
                var parameters = ParametersHelper.ToDictionary(req.Parameters);

                Assert.AreEqual(testToNumber, parameters["to[]"]);

                var props = typeof(FaxOptions).GetProperties();
                foreach (var prop in props)
                {
                    var serializeAs = prop.GetCustomAttributes(false)
                        .OfType<SerializeAsAttribute>()
                        .FirstOrDefault();

                    if (serializeAs != null)
                    {
                        object expectedValue = prop.GetValue(testOptions, null);

                        if (expectedValue == null)
                        {
                            Assert.False(parameters.ContainsKey(serializeAs.Value));
                        }
                        else
                        {
                            Assert.AreEqual(expectedValue, parameters[serializeAs.Value]);
                        }
                    }
                }
            };

            var clientBuilder = new IRestClientBuilder { Op = "send", RequestAsserts = requestAsserts };
            var phaxio = new PhaxioClient(IRestClientBuilder.TEST_KEY, IRestClientBuilder.TEST_SECRET, clientBuilder.Build());

            var testFile = BinaryFixtures.getTestPdfFile();

            var faxId = phaxio.SendFax(testToNumber, testFile, testOptions);

            Assert.AreEqual("1234", faxId, "FaxId should be the same.");
        }
예제 #9
0
        public void UnitTests_Fax_SendSingleWithTags()
        {
            var testToNumber = "8088675309";
            var testOptions = new FaxOptions
            {
                Tags = new Dictionary<string, string> { { "key1", "value1" }, { "key2", "value2" } }
            };

            Action<IRestRequest> requestAsserts = req =>
            {
                var parameters = ParametersHelper.ToDictionary(req.Parameters);

                Assert.AreEqual(testToNumber, parameters["to[]"]);

                foreach (var pair in testOptions.Tags)
                {
                    var tagKey = "tag[" + pair.Key + "]";
                    Assert.IsTrue(parameters.ContainsKey(tagKey));
                    Assert.AreEqual(pair.Value, parameters[tagKey]);
                }
            };

            var clientBuilder = new IRestClientBuilder { Op = "send", RequestAsserts = requestAsserts };
            var phaxio = new PhaxioClient(IRestClientBuilder.TEST_KEY, IRestClientBuilder.TEST_SECRET, clientBuilder.Build());

            var testFile = BinaryFixtures.getTestPdfFile();

            var faxId = phaxio.SendFax(testToNumber, testFile, testOptions);

            Assert.AreEqual("1234", faxId, "FaxId should be the same.");
        }
예제 #10
0
        public Result Send(IEnumerable <string> toNumbers, IEnumerable <FileInfo> files, FaxOptions options = null)
        {
            var result = client.SendFax(toNumbers, files, options);

            Id = result.Id;
            return(result);
        }
예제 #11
0
 public Result Send(string toNumber, IEnumerable <FileInfo> files, FaxOptions options = null)
 {
     return(Send(new List <string> {
         toNumber
     }, files, options));
 }
예제 #12
0
 public Result Send(IEnumerable <string> toNumbers, FileInfo file, FaxOptions options = null)
 {
     return(Send(toNumbers, new List <FileInfo> {
         file
     }, options));
 }