smartystreets-javascript-sdk
Version:
Quick and easy Smarty address validation.
2 lines (1 loc) • 3.82 kB
JavaScript
import{__require as t}from"./HttpSender.mjs";import e from"./SigningSender.mjs";import r from"./BaseUrlSender.mjs";import i from"./AgentSender.mjs";import s from"./StaticCredentials.mjs";import o from"./SharedCredentials.mjs";import n from"./CustomHeaderSender.mjs";import{__require as u}from"./StatusCodeSender.mjs";import{__require as m}from"./LicenseSender.mjs";import a from"./CustomQuerySender.mjs";import{__require as l}from"./Errors.mjs";import h from"./RetrySender.mjs";import p from"./util/Sleeper.mjs";import{__require as d}from"./us_street/Client.mjs";import{__require as c}from"./us_zipcode/Client.mjs";import{__require as C}from"./us_autocomplete_pro/Client.mjs";import{__require as _}from"./us_extract/Client.mjs";import{__require as f}from"./international_street/Client.mjs";import{__require as w}from"./us_reverse_geo/Client.mjs";import{__require as b}from"./international_address_autocomplete/Client.mjs";import{__require as S}from"./us_enrichment/Client.mjs";import{__require as y}from"./international_postal_code/Client.mjs";var j,x;function q(){if(x)return j;x=1;const q=t(),U=e,g=r,Q=i,v=s,H=o,R=n,k=u(),A=m(),E=a,T=l().BadCredentialsError,B=h,I=p,M=d(),P=c(),z=C(),F=_(),L=f(),D=w(),G=b(),O=S(),Z=y();return j=class{constructor(t){if(!(t instanceof v||t instanceof H))throw new T;this.signer=t,this.httpSender=void 0,this.maxRetries=5,this.maxTimeout=1e4,this.baseUrl=void 0,this.proxy=void 0,this.customHeaders={},this.debug=void 0,this.licenses=[],this.customQueries=new Map}withMaxRetries(t){return this.maxRetries=t,this}withMaxTimeout(t){return this.maxTimeout=t,this}withSender(t){return this.httpSender=t,this}withBaseUrl(t){return this.baseUrl=t,this}withProxy(t,e,r,i,s){return this.proxy={host:t,port:e,protocol:r},i&&s&&(this.proxy.auth={username:i,password:s}),this}withCustomHeaders(t){return this.customHeaders=t,this}withDebug(){return this.debug=!0,this}withLicenses(t){return this.licenses=t,this}withCustomQuery(t,e){return this.customQueries.set(t,e),this}withCustomCommaSeperatedQuery(t,e){let r=this.customQueries.get(t);return""===r?r=e:r+=","+e,this.customQueries.set(t,r),this}withFeatureComponentAnalysis(){return this.withCustomCommaSeperatedQuery("features","component-analysis")}withFinancialHistory(){return this.withCustomCommaSeperatedQuery("features","financial")}withOccupantUse(){return this.withCustomCommaSeperatedQuery("features","occupant-use")}buildSender(){if(this.httpSender)return this.httpSender;const t=new q(this.maxTimeout,this.proxy,this.debug),e=new k(t),r=new U(e,this.signer);let i=new Q(r);if(this.maxRetries>0){const t=new B(this.maxRetries,r,new I);i=new Q(t)}const s=new R(i,this.customHeaders),o=new g(s,this.baseUrl),n=new A(o,this.licenses);return new E(n,this.customQueries)}buildClient(t,e){return this.baseUrl||(this.baseUrl=t),new e(this.buildSender())}buildUsStreetApiClient(){return this.buildClient("https://us-street.api.smarty.com/street-address",M)}buildUsZipcodeClient(){return this.buildClient("https://us-zipcode.api.smarty.com/lookup",P)}buildInternationalPostalCodeClient(){return this.buildClient("https://international-postal-code.api.smarty.com/lookup",Z)}buildUsAutocompleteProClient(){return this.buildClient("https://us-autocomplete-pro.api.smarty.com/lookup",z)}buildUsExtractClient(){return this.buildClient("https://us-extract.api.smarty.com/",F)}buildInternationalStreetClient(){return this.buildClient("https://international-street.api.smarty.com/verify",L)}buildUsReverseGeoClient(){return this.buildClient("https://us-reverse-geo.api.smarty.com/lookup",D)}buildInternationalAddressAutocompleteClient(){return this.buildClient("https://international-autocomplete.api.smarty.com/v2/lookup",G)}buildUsEnrichmentClient(){return this.buildClient("https://us-enrichment.api.smarty.com/lookup",O)}}}export{q as __require};