UNPKG

smartystreets-javascript-sdk

Version:
2 lines (1 loc) 3.06 kB
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 m}from"./StatusCodeSender.mjs";import{__require as u}from"./LicenseSender.mjs";import{__require as a}from"./Errors.mjs";import l from"./RetrySender.mjs";import h from"./util/Sleeper.mjs";import{__require as p}from"./us_street/Client.mjs";import{__require as d}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 C}from"./international_street/Client.mjs";import{__require as b}from"./us_reverse_geo/Client.mjs";import{__require as f}from"./international_address_autocomplete/Client.mjs";import{__require as w}from"./us_enrichment/Client.mjs";var S,j;function x(){if(j)return S;j=1;const x=t(),y=e,q=r,U=i,g=s,v=o,R=n,H=m(),k=u(),A=a().BadCredentialsError,E=l,T=h,B=p(),z=d(),I=c(),L=_(),M=C(),P=b(),D=f(),G=w();return S=class{constructor(t){if(!t instanceof g||!t instanceof v)throw new A;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=[]}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}buildSender(){if(this.httpSender)return this.httpSender;const t=new x(this.maxTimeout,this.proxy,this.debug),e=new H(t),r=new y(e,this.signer);let i=new U(r);if(this.maxRetries>0){const t=new E(this.maxRetries,r,new T);i=new U(t)}const s=new R(i,this.customHeaders),o=new q(s,this.baseUrl);return new k(o,this.licenses)}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",B)}buildUsZipcodeClient(){return this.buildClient("https://us-zipcode.api.smarty.com/lookup",z)}buildUsAutocompleteProClient(){return this.buildClient("https://us-autocomplete-pro.api.smarty.com/lookup",I)}buildUsExtractClient(){return this.buildClient("https://us-extract.api.smarty.com/",L)}buildInternationalStreetClient(){return this.buildClient("https://international-street.api.smarty.com/verify",M)}buildUsReverseGeoClient(){return this.buildClient("https://us-reverse-geo.api.smarty.com/lookup",P)}buildInternationalAddressAutocompleteClient(){return this.buildClient("https://international-autocomplete.api.smarty.com/v2/lookup",D)}buildUsEnrichmentClient(){return this.buildClient("https://us-enrichment.api.smarty.com/lookup",G)}}}export{x as __require};