WebService::Async::SmartyStreets::Address - parses the response from SmartyStreets API
version 0.001
use WebService::Async::SmartyStreets::Address;
# Mocking a simple response from SmartyStreets API and parses it with WebService::Async::SmartyStreets::Address
my $response = WebService::Async::SmartyStreets::Address->new(
metadata => {
latitude => 101.2131,
longitude => 180.1223,
geocode_precision => "Premise",
},
analysis => {
verification_status => "Partial",
address_precision => "Premise",
});
# Accessing the attributes
print ($response->status);
This module parses the response by SmartyStreets API into an object to access them.
WebService::Async::SmartyStreets::Address->new(
input_id => 12345,
organization => 'Beenary',
metadata => {
latitude => 101.2131,
longitude => 180.1223,
geocode_precision => "Premise",
},
analysis => {
verification_status => "Partial",
address_precision => "Premise",
});
[
{
"address1": "Hainichener Str. 64",
"address2": "09599 Freiberg",
"components": {
"administrative_area": "Sachsen",
"sub_administrative_area": "Früher: Direktionsbezirk Chemnitz",
"country_iso_3": "DEU",
"locality": "Freiberg",
"postal_code": "09599",
"postal_code_short": "09599",
"premise": "64",
"premise_number": "64",
"thoroughfare": "Hainichener Str.",
"thoroughfare_name": "Hainichenerstr.",
"thoroughfare_trailing_type": "Str."
},
"metadata": {
"latitude": 50.92221,
"longitude": 13.32259,
"geocode_precision": "Premise",
"max_geocode_precision": "DeliveryPoint",
"address_format": "thoroughfare premise|postal_code locality"
},
"analysis": {
"verification_status": "Verified",
"address_precision": "Premise",
"max_address_precision": "DeliveryPoint"
}
}
]
All attributes that is parsed includes:
- input_id
- organization
- latitude
- longitude
- geocode_precision
- max_geocode_precision
- address_format
- verification_status
- address_precision
- max_address_precision
For more information about the attributes, click here
Checks if the returned response at least hits a certain level (in terms of score).
Checks if the returned response at least hits a certain accuracy (in terms of score). Instantly returns 0 if the status is lower than 'partial'.
Returns the input_id parsed.
Returns the organization parsed.
Returns the latitude parsed.
Returns the latitude parsed.
Returns the geocode_precision parsed.
Returns the max_geocode_precision parsed.
Returns the value of address_format parsed.
Returns the value of verification_status parsed.
The value returned should be either:
- none
- ambiguous
- partial
- verified
Returns the value of address_precision parsed.
Returns the value of max_address_precision parsed.
WebService::Async::SmartyStreets;
my $loop = IO::Async::Loop->new;
$loop->add(
my $ss = WebService::Async::SmartyStreets->new(
# International token
auth_id => '...',
token => '...',
api_choice => '...',
)
);
async sub {
my $addr = await $ss->verify(
# insert address here
);
}->get;
This class calls the SmartyStreets API and parse the response to WebService::Async::SmartyStreets::Address
Makes connection to SmartyStreets API and parses the response into WebService::Async::SmartyStreets::Address
.
Takes the following named parameters:
- args - address parameters in hash (See
WebService::Async::SmartyStreets/verify_international
)
args consists of the following parameters:
- country - country [COMPULSORY]
- 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
- api_choice - [OPTIONAL] will overide the api_choice in config
Parses the response give by SmartyStreets
More information of the resposne can be seen in SmartyStreets Documentation
Returns an arrayref of hashrefs which the keys corresponds to WebService::Async::SmartyStreets::Address
configures the class with auth_id and token.
Returns auth_id.
Returns token.
Returns api_choice.
Accessor for the Net::Async::HTTP
instance which will be used for SmartyStreets API requests.
Binary.com