Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ff187f5
tom/smartystreets_basic_api
tom-binary Feb 27, 2019
79c8c09
Initial import
tom-binary Feb 27, 2019
f4152e6
initial version
Mar 14, 2019
57a0095
changes settings
Mar 14, 2019
c3cb854
first unit test
Mar 19, 2019
1be66d7
changed implementation
Mar 20, 2019
3b38cfd
Forgotten make file
Mar 20, 2019
0ea4673
added readme
Mar 20, 2019
9df21d3
added comments for Address.pm
Mar 20, 2019
9775dd1
added comments in smarty Street pm
Mar 20, 2019
a46548a
added makefile
Mar 21, 2019
2d49627
small changes
Mar 21, 2019
fe1c37e
added descriptons
Mar 21, 2019
59dd689
added doc
Mar 21, 2019
11fc915
change comments
Mar 21, 2019
403c2e7
test
Mar 21, 2019
5ac1263
test
chengyang-binary Mar 25, 2019
964afd9
Update lib/WebService/Async/SmartyStreets/Address.pm
code4pay Mar 26, 2019
93311ae
deleted unnecessary file
Mar 29, 2019
15b6b1a
changes comments
Mar 29, 2019
9963432
experiment
Mar 29, 2019
d2c3347
as per commented, moved verify_international and verify_usa into diff…
Mar 29, 2019
284dfa9
removed do
Mar 29, 2019
97985d1
moved sypsnosis inline
Apr 1, 2019
f95bc45
added comments
Apr 1, 2019
c92679a
removed dumper
Apr 1, 2019
cf5a793
added comments, removed builds
Apr 1, 2019
ec5e0f4
Update README.md
chengyang-binary Apr 1, 2019
35ed5be
changed comments
Apr 1, 2019
2f88afb
Merge branch 'limchengyang/add_smartystreet_address_check' of github.…
Apr 1, 2019
a81ef0e
comments
Apr 1, 2019
9422468
comments
Apr 1, 2019
614a863
Update Changes
tom-binary Apr 2, 2019
aa84ddc
first 2 comments
Apr 2, 2019
e58bcaa
Merge branch 'limchengyang/add_smartystreet_address_check' of github.…
Apr 2, 2019
fad6ca7
changed comments
Apr 2, 2019
6dc3482
removed unused
Apr 2, 2019
692662f
Update lib/WebService/Async/SmartyStreets.pm
tom-binary Apr 3, 2019
f061322
Removed International and USA module as it adds on confusions
Apr 4, 2019
e023812
remove build file
Apr 4, 2019
118380b
changes sequence and added comments
Apr 5, 2019
2b53f12
fix test
Apr 5, 2019
ddcb4cb
changed implementation
Apr 5, 2019
7cb4072
updated readme
Apr 5, 2019
d3542a7
fix test
Apr 5, 2019
ae94575
fix comments
Apr 5, 2019
b3ba2b4
adds default api_token choice
Apr 5, 2019
5bc9dd1
comments
Apr 5, 2019
a20d289
handled error
Apr 8, 2019
ed50a16
Clear up the doc formatting slightly
tom-binary Apr 9, 2019
0b3a62c
Fix incorrect parameter documentation
tom-binary Apr 9, 2019
a891471
Fix up documentation
tom-binary Apr 9, 2019
0b417d6
Drop the api_choice concept
tom-binary Apr 9, 2019
3dc7d2e
Token and auth ID lookup for US/international
tom-binary Apr 9, 2019
52d4f59
More cleanup
tom-binary Apr 9, 2019
8525f5b
Update testcase
tom-binary Apr 9, 2019
50ac347
Replace list with headers so we can link to them
tom-binary Apr 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Revision history for {{$dist->name}}

{{$NEXT}}

Pre-release version. Released as a proof of concept.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
dzil test

73 changes: 73 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012.
use strict;
use warnings;

use 5.014000;

use ExtUtils::MakeMaker 6.48;

my %WriteMakefileArgs = (
"ABSTRACT" => "Access SmartyStreet API",
"AUTHOR" => "binary.com <BINARY\@cpan.org>",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => "6.64"
},
"DISTNAME" => "WebService-Async-SmartyStreets",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.014000",
"NAME" => "WebService::Async::SmartyStreets",
"PREREQ_PM" => {
"Future::AsyncAwait" => "0.21",
"IO::Async::SSL" => 0,
"Net::Async::HTTP" => "0.44",
"indirect" => 0,
"mro" => 0,
"parent" => 0
},
"TEST_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Test::CheckDeps" => "0.010",
"Test::FailWarnings" => 0,
"Test::Fatal" => 0,
"Test::More" => "0.94",
"Test::Warn" => 0
},
"VERSION" => "0.001",
"test" => {
"TESTS" => "t/*.t"
}
);


my %FallbackPrereqs = (
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"Future::AsyncAwait" => "0.21",
"IO::Async::SSL" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Net::Async::HTTP" => "0.44",
"Test::CheckDeps" => "0.010",
"Test::FailWarnings" => 0,
"Test::Fatal" => 0,
"Test::More" => "0.94",
"Test::Warn" => 0,
"indirect" => 0,
"mro" => 0,
"parent" => 0
);


unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}

delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };

WriteMakefile(%WriteMakefileArgs);
237 changes: 235 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,235 @@
# perl-WebService-Async-SmartyStreets
Address lookup and verification API
# NAME

WebService::Async::SmartyStreets::Address - parses the response from SmartyStreets API

# VERSION

version 0.001

# SYNOPSIS

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);

# DESCRIPTION

This module parses the response by SmartyStreets API into an object to access them.

## Construction

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",
});

## Sample SmartyStreets API response

[
{
"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"
}
}
]

# Attributes

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](https://smartystreets.com/docs/cloud/international-street-api)

# Methods

## status_at_least

Checks if the returned response at least hits a certain level (in terms of score).

## accuracy_at_least

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'.

# Attributes

## input_id

Returns the input_id parsed.

## organization

Returns the organization parsed.

## latitude

Returns the latitude parsed.

## longitude

Returns the latitude parsed.

## geocode_precision

Returns the geocode_precision parsed.

## max_geocode_precision

Returns the max_geocode_precision parsed.

## address_format

Returns the value of address_format parsed.

## status

Returns the value of verification_status parsed.

The value returned should be either:

- none
- ambiguous
- partial
- verified

## address_precision

Returns the value of address_precision parsed.

## max_address_precision

Returns the value of max_address_precision parsed.

---

# NAME

WebService::Async::SmartyStreets;

# SYNOPSIS

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;

# DESCRIPTION

This class calls the SmartyStreets API and parse the response to `WebService::Async::SmartyStreets::Address`

# METHODS

## verify

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

## get_decoded_data

Parses the response give by SmartyStreets

More information of the resposne can be seen in [SmartyStreets Documentation](https://smartystreets.com/docs/cloud/international-street-api)

Returns an arrayref of hashrefs which the keys corresponds to `WebService::Async::SmartyStreets::Address`

## configure

configures the class with auth_id and token.

## auth_id

Returns auth_id.

## token

Returns token.

## api_choice

Returns api_choice.

## ua

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

# AUTHOR

Binary.com

17 changes: 17 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
requires 'mro', 0;
requires 'indirect', 0;
requires 'parent', 0;
requires 'Net::Async::HTTP', '>= 0.44';
requires 'IO::Async::SSL', 0;
requires 'Future::AsyncAwait', '>= 0.21';

on configure => sub {
requires 'ExtUtils::MakeMaker', '6.64';
};

on test => sub {
requires 'Test::More';
requires 'Test::Warn';
requires 'Test::FailWarnings';
requires 'Test::Fatal';
};
Loading