Ejemplo n.º 1
0
        public async Task GetSupplier_ExistingCorrectPostalCode_Found()
        {
            var name       = Formatters.ToCasSupplierName("autotest-dev-first", "autotest-dev-last");
            var postalCode = "V8Z 7X9".ToCasPostalCode();
            var response   = await client.GetSupplierAsync(new GetSupplierRequest { PostalCode = postalCode, SupplierName = name }, CancellationToken.None);

            response.ShouldNotBeNull();
            response.Suppliernumber.ShouldBe("2005363");
            response.SupplierAddress.ShouldHaveSingleItem().Suppliersitecode.ShouldBe("001");
        }
Ejemplo n.º 2
0
        public async Task <(string SupplierNumber, string SiteCode)?> GetSupplier(contact contact, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(contact.address1_postalcode))
            {
                throw new ArgumentNullException($"contact {contact.contactid}", nameof(contact.address1_postalcode));
            }
            if (string.IsNullOrEmpty(contact.firstname))
            {
                throw new ArgumentNullException($"contact {contact.contactid}", nameof(contact.firstname));
            }
            if (string.IsNullOrEmpty(contact.lastname))
            {
                throw new ArgumentNullException($"contact {contact.contactid}", nameof(contact.lastname));
            }

            var response = await casWebProxy.GetSupplierAsync(new GetSupplierRequest
            {
                PostalCode   = contact.address1_postalcode.ToCasPostalCode(),
                SupplierName = Formatters.ToCasSupplierName(contact.firstname, contact.lastname)
            }, ct);

            if (response == null || !response.SupplierAddress.Any())
            {
                return(null);
            }
            return(SupplierNumber : response.Suppliernumber, SiteCode : response.SupplierAddress.First().Suppliersitecode.StripCasSiteNumberBrackets());
        }