Пример #1
0
        public void Cancel()
        {
            var req = new BillomatRequest
            {
                Verb     = "PUT",
                Resource = GetResource().ResourceName,
                Id       = Id,
                Method   = "cancel"
            };

            req.GetResponse();
        }
Пример #2
0
        /// <summary>
        /// Returns image date containing a thumbnail of the first page of the template
        /// </summary>
        /// <param name="type">Type of the image to be returned</param>
        /// <returns>Byte array containing image data of the thumbnail</returns>
        public byte[] Thumb(BillomatTemplateThumbType type = BillomatTemplateThumbType.Png)
        {
            var req = new BillomatRequest
            {
                Resource = "templates",
                Id       = Id,
                Method   = "thumb"
            };

            req.Params.Add("type", type.ToString().ToLower());

            return(req.GetResponse());
        }
Пример #3
0
        public Stream GetPdfDocument()
        {
            var req = new BillomatRequest
            {
                Resource = GetResource().ResourceName,
                Id       = Id,
                Method   = "pdf"
            };

            req.Params.Add("format", "pdf");

            return(new MemoryStream(req.GetResponse()));
        }
Пример #4
0
        public void SendMail(string toEMail, string fromEMail = null, string ccEMail = null,
                             string bccEMail = null, string subject = null, string body = null, string filename = null)
        {
            string[] tos  = (toEMail ?? "").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string[] ccs  = (ccEMail ?? "").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string[] bccs = (bccEMail ?? "").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (tos.Length == 0)
            {
                throw new BillomatException("No recipient specified!", new ArgumentException("toEMail must not be null or empty", "toEMail"));
            }

            var req = new BillomatRequest
            {
                Verb     = "POST",
                Resource = GetResource().ResourceName,
                Id       = Id,
                Method   = "email"
            };

            var elRecipients = new XElement("recipients");

            elRecipients.Add(tos.Select(to => new XElement("to", to)).ToArray());
            elRecipients.Add(ccs.Select(cc => new XElement("cc", cc)).ToArray());
            elRecipients.Add(bccs.Select(bcc => new XElement("bcc", bcc)).ToArray());

            var xml = new XElement("email", elRecipients);

            if (!string.IsNullOrEmpty(fromEMail))
            {
                xml.Add(new XElement("from", fromEMail));
            }

            if (!string.IsNullOrEmpty(subject))
            {
                xml.Add(new XElement("subject", subject));
            }

            if (!string.IsNullOrEmpty(body))
            {
                xml.Add(new XElement("body", body));
            }

            if (!string.IsNullOrEmpty(filename))
            {
                xml.Add(new XElement("filename", filename));
            }

            req.Body = xml.ToString(SaveOptions.DisableFormatting);
            req.GetResponse();
        }
Пример #5
0
        /// <summary>
        /// Uploads a signed PDF file for this invoice
        /// </summary>
        /// <param name="file"></param>
        public void UploadSignature(Stream file)
        {
            string base64File = BillomatHelper.Base64File(file);

            var req = new BillomatRequest
            {
                Verb     = "PUT",
                Resource = GetResource().ResourceName,
                Id       = Id,
                Method   = "upload-signature"
            };

            var xml = new XElement("signature", new XElement("base64file", base64File));

            req.Body = xml.ToString(SaveOptions.DisableFormatting);
            req.GetResponse();
        }
Пример #6
0
        /// <summary>
        /// Downloads the PDF document of this invoice
        /// </summary>
        /// <param name="signed">Specify true to retrieve a signed PDF</param>
        /// <returns></returns>
        public MemoryStream GetPdfDocument(bool signed)
        {
            var req = new BillomatRequest
            {
                Resource = GetResource().ResourceName,
                Id       = Id,
                Method   = "pdf"
            };

            req.Params.Add("format", "pdf");

            if (signed)
            {
                req.Params.Add("type", "signed");
            }

            return(new MemoryStream(req.GetResponse()));
        }
Пример #7
0
        public void Complete(int?templateId = null)
        {
            var req = new BillomatRequest
            {
                Verb     = "PUT",
                Resource = GetResource().ResourceName,
                Id       = Id,
                Method   = "complete"
            };

            var xml = new XElement("complete");

            if (templateId.HasValue)
            {
                xml.Add(new XElement("template_id", templateId.Value.ToString(CultureInfo.InvariantCulture)));
            }

            req.Body = xml.ToString(SaveOptions.DisableFormatting);
            req.GetResponse();
        }