Skip to content

binary-com/perl-WebService-Async-SmartyStreets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

WebService::Async::SmartyStreets - calls the SmartyStreets API and checks for the validity of the address

SYNOPSIS

my $ss = WebService::Async::SmartyStreets->new(
    # Obtain these from your SmartyStreets account page.
    # These will be used for US lookups
    us_auth_id => '...',
    us_token   => '...',
    # For non-US address lookups, you would also need an international token
    international_auth_id => '...',
    international_token   => '...',
);
IO::Async::Loop->new->add($ss);

print $ss->verify(
    city => 'Atlanta',
    country => 'US',
    geocode => 1
)->get->status;

DESCRIPTION

This module provides basic support for the SmartyStreets API.

Note that this module uses Future::AsyncAwait.

verify

Makes connection to SmartyStreets API and parses the response into WebService::Async::SmartyStreets::Address.

my $addr = $ss->verify(%address_to_check)->get;

Takes the following named parameters:

  • country - country (required)
  • address1 - address line 1
  • address2 - address line 2
  • organization - name of organization (usually building names)
  • locality - city
  • administrative_area - state
  • postal_code - post code
  • geocode - true or false

Returns a Future which should resolve to a valid WebService::Async::SmartyStreets::Address instance.

METHODS - Accessors

METHODS - Internal

get_decoded_data

Calls the SmartyStreets API then decode and parses the response give by SmartyStreets

my $decoded = await get_decoded_data($self, $uri)

Takes the following parameters:

  • $uri - URI for endpoint

More information on the response can be seen in SmartyStreets Documentation .

Returns a Future which resolves to an arrayref of WebService::Async::SmartyStreets::Address instances.

configure

Configures the instance.

Takes the following named parameters:

  • international_auth_id - auth_id obtained from SmartyStreet
  • international_token - token obtained from SmartyStreet
  • us_auth_id - auth_id obtained from SmartyStreet
  • us_token - token obtained from SmartyStreet

Note that you can provide US, international or both API tokens - if an API token is not available for a "verify" call, then it will return a failed Future.

ua

Accessor for the Net::Async::HTTP instance which will be used for SmartyStreets API requests.

About

Address lookup and verification API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published