/// <summary> /// Performs address validation on an address /// </summary> /// <param name="address"> /// The address. /// </param> /// <returns> /// The <see cref="AddressValidationResult"/>. /// </returns> public AddressValidationResult ValidateTaxAddress(IValidatableAddress address) { var requestUrl = string.Format("{0}?{1}", GetApiUrl("address", "validate"), address.AsApiQueryString()); var json = GetResponse(requestUrl); return(JsonConvert.DeserializeObject <AddressValidationResult>(json)); }
/// <summary> /// Performs address validation on an address /// </summary> /// <param name="address"> /// The address. /// </param> /// <returns> /// The <see cref="AddressValidationResult"/>. /// </returns> public AddressValidationResult ValidateTaxAddress(IValidatableAddress address) { var requestUrl = string.Format("{0}?{1}", GetApiUrl("address", "validate"), address.AsApiQueryString()); var json = GetResponse(requestUrl); return JsonConvert.DeserializeObject<AddressValidationResult>(json); }
/// <summary> /// Maps a <see cref="IValidatableAddress"/> to an <see cref="IAddress"/>. /// </summary> /// <param name="validatableAddress"> /// The verifiable address. /// </param> /// <returns> /// The <see cref="IAddress"/>. /// </returns> public static IAddress ToAddress(this IValidatableAddress validatableAddress) { return(new Address() { Address1 = validatableAddress.Line1, Address2 = string.Format("{0} {1}", validatableAddress.Line2, validatableAddress.Line3).Trim(), Locality = validatableAddress.City, Region = validatableAddress.Region, PostalCode = validatableAddress.PostalCode, CountryCode = validatableAddress.Country }); }
/// <summary> /// Maps a <see cref="IValidatableAddress"/> to an API usable query string. /// </summary> /// <param name="taxAddress"> /// The tax address. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public static string AsApiQueryString(this IValidatableAddress taxAddress) { return(string.Format( "{0}&{1}&{2}&{3}&{4}&{5}&{6}", GetQsValue("Line1", taxAddress.Line1), GetQsValue("Line2", taxAddress.Line2), GetQsValue("Line3", taxAddress.Line3), GetQsValue("City", taxAddress.City), GetQsValue("Region", taxAddress.Region), GetQsValue("PostalCode", taxAddress.PostalCode), GetQsValue("Country", taxAddress.Country))); }
/// <summary> /// Maps a <see cref="IValidatableAddress"/> to a <see cref="ITaxAddress"/>. /// </summary> /// <param name="address"> /// The address. /// </param> /// <returns> /// The <see cref="ITaxAddress"/>. /// </returns> public static ITaxAddress ToTaxAddress(this IValidatableAddress address) { return(AutoMapper.Mapper.Map <TaxAddress>(address)); }