public Attachment AddOrReplace(Attachment attachment, AttachmentEndpointType type, Guid parent)
        {
            var mimeType = MimeTypes.GetMimeType(attachment.FileName);

            return Client.Post<Attachment, AttachmentsResponse>(string.Format("/api.xro/2.0/{0}/{1}/Attachments/{2}",
                type, parent.ToString("D"), attachment.FileName),
                attachment.Content, mimeType).FirstOrDefault();
        }
Beispiel #2
0
        public void adding_attachment_to_invoice()
        {
            var invoiceId = Given_invoice_with_no_attachments();

            var newAttachment = new Attachment(new FileInfo(ImagePath));
            var attachment = Api.Attachments.AddOrReplace(newAttachment, AttachmentEndpointType.Invoices, invoiceId);

            Assert.IsTrue(attachment.Id != Guid.Empty);
        }
        public Attachment AddOrReplace(Attachment attachment, AttachmentEndpointType type, Guid parent, bool includeOnline = false)
        {
            var mimeType = MimeTypes.GetMimeType(attachment.FileName);

            var url = string.Format("/api.xro/2.0/{0}/{1}/Attachments/{2}", type, parent.ToString("D"), attachment.FileName);

            if (SupportsOnline(type) && includeOnline)
            {
                Client.Parameters.Add("IncludeOnline", true);
            }

            return Client.Post<Attachment, AttachmentsResponse>(url, attachment.Content, mimeType).FirstOrDefault();
        }