Ejemplo n.º 1
0
        public async Task <SupplierInvoice> Get(string entityNumber, SupplierDocumentType documentType = SupplierDocumentType.Invoice)
        {
            SupplierInvoice rsp;

            if (documentType == SupplierDocumentType.Invoice) // documentType = invoice use default endpoint.
            {
                rsp = await VismaNetApiHelper.Get <SupplierInvoice>(entityNumber, ApiControllerUri, Authorization);
            }
            else
            {
                rsp = await VismaNetApiHelper.Get <SupplierInvoice>(entityNumber, ApiControllerUri, Authorization, $"{documentType.ToString()}/{entityNumber}");
            }
            rsp.InternalPrepareForUpdate();
            return(rsp);
        }
Ejemplo n.º 2
0
 public async Task <string> AddAttachmentToInvoice(string invoiceNumber, byte[] byteArray, string fileName, SupplierDocumentType documentType = SupplierDocumentType.Invoice)
 {
     if (byteArray == default(byte[]))
     {
         throw new ArgumentNullException(nameof(byteArray), "ByteArray is missing");
     }
     if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(Path.GetExtension(fileName)))
     {
         throw new ArgumentNullException(nameof(fileName), "File name must be provided and have an extention");
     }
     if (documentType != SupplierDocumentType.Invoice)
     {
         invoiceNumber = $"documentType/{documentType}/{invoiceNumber}";
     }
     return(await VismaNetApiHelper.AddAttachmentToSupplierInvoice(Authorization, invoiceNumber, byteArray, fileName));
 }
Ejemplo n.º 3
0
        public async Task <string> AddAttachmentToInvoice(string invoiceNumber, Stream stream, string fileName, SupplierDocumentType documentType = SupplierDocumentType.Invoice)
        {
            if (stream == default(Stream))
            {
                throw new ArgumentNullException(nameof(stream), "Stream is missing");
            }
            if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(Path.GetExtension(fileName)))
            {
                throw new ArgumentNullException(nameof(fileName), "File name must be provided and have an extention");
            }

            using (var memoryStream = new MemoryStream())
            {
                stream.CopyTo(memoryStream);
                if (documentType != SupplierDocumentType.Invoice)
                {
                    invoiceNumber = $"documentType/{documentType}/{invoiceNumber}";
                }
                return(await VismaNetApiHelper.AddAttachmentToSupplierInvoice(Authorization, invoiceNumber, memoryStream.ToArray(), fileName));
            }
        }
Ejemplo n.º 4
0
 public async Task <string> AddAttachmentToInvoice(string invoiceNumber, string content, string fileName, SupplierDocumentType documentType = SupplierDocumentType.Invoice)
 {
     return(await AddAttachmentToInvoice(invoiceNumber, Encoding.UTF8.GetBytes(content), fileName, documentType));
 }