melissa_data 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -0
- data/config/address_error_codes.yml +16 -0
- data/config/address_success_codes.yml +13 -0
- data/config/error_codes.yml +22 -0
- data/config/property_error_codes.yml +5 -0
- data/config/property_success_codes.yml +4 -0
- data/lib/melissa_data/version.rb +1 -1
- data/lib/melissa_data/web_smart/client.rb +9 -4
- data/lib/melissa_data/web_smart/property_api.rb +17 -10
- data/lib/melissa_data/web_smart/response_processor.rb +21 -20
- data/lib/melissa_data/web_smart/xml.rb +9 -24
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac91c5646b2bec4d4c6c267d8285e32131cf5109
|
4
|
+
data.tar.gz: 6d83ffef11d3f0bc8c94eecb4b78043787a10265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df18e37db9072c6ddf9644e96222b31247615af5609ecd0a0198fddb0f9dcd19feb9bb110b35592efe7700fbc5799cbd26b0d797f0ee06daa29669aa99c4271f
|
7
|
+
data.tar.gz: 118eb045520fe3c3362384c6fdb6f9daf66f6e2964e6fbbde7643cdd84ed7b499ff25bdcc1a8e6e933d731f4e14b0c8aabd5999b346ee3284b12d9bb7e04c0e0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Melissa Data
|
2
2
|
|
3
3
|
[](https://travis-ci.org/cometaworks/melissa_data)
|
4
|
+
[](https://codeclimate.com/github/cometaworks/melissa_data)
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"address_error_codes":
|
2
|
+
"AE01": "Zip/Postal code does not exist or is improperly formatted."
|
3
|
+
"AE02": "Unknown Street. Either no match or too many."
|
4
|
+
"AE03": "Component mismatch. Combination of directions + suffix incorrect."
|
5
|
+
"AE04": "Undeliverable address. Plot exists but is not deliverable."
|
6
|
+
"AE05": "Multiple match. This adderss matched too many records to return a result"
|
7
|
+
"AE06": "Early Warning System. This address vant be verified but may be on a new road"
|
8
|
+
"AE07": "Missing minimum address. Must have atleast a1, postal code, and locality"
|
9
|
+
"AE08": "Subpremise number invalid. Suite missing"
|
10
|
+
"AE09": "Subpremise number missing."
|
11
|
+
"AE10": "Premise number invalid"
|
12
|
+
"AE11": "Premise number missing"
|
13
|
+
"AE12": "PO Box number invalid"
|
14
|
+
"AE13": "PO Box number missing"
|
15
|
+
"AE14": "Private mailbox number missing"
|
16
|
+
"AE17": "Sub premise number entered but premise has none"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"address_success_codes":
|
2
|
+
"AS01": "Address is valid and deliverable per postal agency guidelines."
|
3
|
+
"AS02": "Street address verified but suite number not valid or missing."
|
4
|
+
"AS03": "Non-USPS match, exists but may not receive mail."
|
5
|
+
"AS09": "Address is in foreign country."
|
6
|
+
"AS10": "Address is commercial mail receiving agency (PO box, mailbox)."
|
7
|
+
"AS13": "Rural address converted to city-style address."
|
8
|
+
"AS14": "Suite appended. A suite was appended using the address."
|
9
|
+
"AS15": "Apartment appended. An apartment was appended."
|
10
|
+
"AS16": "Vacant. Address unoccupied > 90 days."
|
11
|
+
"AS17": "No mail delivery to address."
|
12
|
+
"AS20": "Deliverable to only via USPS."
|
13
|
+
"AS23": "Unnecessary extraneous information received and discarded."
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"property_error_codes":
|
2
|
+
"YS04": "Detailed information returned"
|
3
|
+
"YE01": "No FIPS/APN or AddressKey provided"
|
4
|
+
"YE02": "No match found"
|
5
|
+
"YE03": "Invalid FIPS/APN or AddressKey provided"
|
6
|
+
|
7
|
+
"address_error_codes":
|
8
|
+
"AE01": "Zip/Postal code does not exist or is improperly formatted."
|
9
|
+
"AE02": "Unknown Street. Either no match or too many."
|
10
|
+
"AE03": "Component mismatch. Combination of directions + suffix incorrect."
|
11
|
+
"AE04": "Undeliverable address. Plot exists but is not deliverable."
|
12
|
+
"AE05": "Multiple match. This adderss matched too many records to return a result"
|
13
|
+
"AE06": "Early Warning System. This address vant be verified but may be on a new road"
|
14
|
+
"AE07": "Missing minimum address. Must have atleast a1, postal code, and locality"
|
15
|
+
"AE08": "Subpremise number invalid. Suite missing"
|
16
|
+
"AE09": "Subpremise number missing."
|
17
|
+
"AE10": "Premise number invalid"
|
18
|
+
"AE11": "Premise number missing"
|
19
|
+
"AE12": "PO Box number invalid"
|
20
|
+
"AE13": "PO Box number missing"
|
21
|
+
"AE14": "Private mailbox number missing"
|
22
|
+
"AE17": "Sub premise number entered but premise has none"
|
data/lib/melissa_data/version.rb
CHANGED
@@ -2,22 +2,27 @@ module MelissaData
|
|
2
2
|
module WebSmart
|
3
3
|
class Client
|
4
4
|
include MelissaData::WebSmart::ResponseProcessor
|
5
|
+
include MelissaData::WebSmart::Formatters
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@client = MelissaData::WebSmart::PropertyAPI.new
|
8
9
|
end
|
9
10
|
|
10
11
|
def property_by_apn(fips:, apn:)
|
11
|
-
|
12
|
+
process(@client.property_by_apn(fips: fips, apn: apn), 'property')
|
12
13
|
end
|
13
14
|
|
14
15
|
def property_by_address_key(address_key:)
|
15
|
-
|
16
|
+
process(@client.property_by_address_key(address_key: address_key), 'property')
|
16
17
|
end
|
17
18
|
|
18
19
|
def address(address:, city:, state:, zip:, country: "USA")
|
19
|
-
@client.address(address: address,
|
20
|
-
|
20
|
+
resp = viperize_hash(@client.address(address: address,
|
21
|
+
city: city,
|
22
|
+
state: state,
|
23
|
+
zip: zip,
|
24
|
+
country: country))
|
25
|
+
process(resp, 'address')
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'nokogiri'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
module MelissaData
|
5
6
|
module WebSmart
|
@@ -8,26 +9,32 @@ module MelissaData
|
|
8
9
|
resp = RestClient.get('https://property.melissadata.net/v3/REST/Service.svc/doLookup',
|
9
10
|
{ params: { id: MelissaData.web_smart_id,
|
10
11
|
fips: fips,
|
11
|
-
apn: apn
|
12
|
+
apn: apn,
|
13
|
+
OptPropertyDetail: "1" } })
|
12
14
|
PropertyXMLParser.new(Nokogiri::XML(resp)).parse
|
13
15
|
end
|
14
16
|
|
15
17
|
def property_by_address_key(address_key:)
|
16
18
|
resp = RestClient.get('https://property.melissadata.net/v3/REST/Service.svc/doLookup',
|
17
19
|
{ params: { id: MelissaData.web_smart_id,
|
18
|
-
AddressKey: address_key
|
20
|
+
AddressKey: address_key,
|
21
|
+
OptPropertyDetail: "1" } })
|
19
22
|
PropertyXMLParser.new(Nokogiri::XML(resp)).parse
|
20
23
|
end
|
21
24
|
|
22
25
|
def address(address:, city:, state:, zip:, country:)
|
23
|
-
resp = RestClient.get(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
resp = JSON.parse(RestClient.get("https://personator.melissadata.net/v3/WEB/ContactVerify/doContactVerify",
|
27
|
+
{ params: { id: MelissaData.web_smart_id,
|
28
|
+
Actions: "Check",
|
29
|
+
a1: address,
|
30
|
+
city: city,
|
31
|
+
state: state,
|
32
|
+
postal: zip,
|
33
|
+
ctry: country,
|
34
|
+
AdvancedAddressCorrection: "on",},
|
35
|
+
accept: :json,
|
36
|
+
content_type: :json }))
|
37
|
+
resp["Records"].first
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
@@ -1,39 +1,40 @@
|
|
1
1
|
module MelissaData
|
2
2
|
module WebSmart
|
3
3
|
module ResponseProcessor
|
4
|
-
|
5
|
-
|
4
|
+
require 'yaml'
|
5
|
+
CODE_TYPES = [:property, :address]
|
6
6
|
|
7
|
+
def process(response, resp_type)
|
8
|
+
codes = codes(response, resp_type)
|
7
9
|
if has_error_codes?(codes)
|
8
|
-
{ errors: codes_for(codes, 'error') }
|
10
|
+
{ errors: codes_for(codes, resp_type, 'error') }
|
9
11
|
else
|
10
|
-
response.merge!(success: codes_for(codes, 'success'))
|
12
|
+
response.merge!(success: codes_for(codes, resp_type, 'success'))
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
def codes_for(codes,
|
15
|
-
codes.map
|
16
|
+
def codes_for(codes, resp_type, code_type)
|
17
|
+
codes.map do |code|
|
18
|
+
YAML.load(File.read("config/#{resp_type}_#{code_type}_codes.yml")).values.first[code.to_s]
|
19
|
+
end.compact
|
16
20
|
end
|
17
21
|
|
18
|
-
def codes(response)
|
19
|
-
|
22
|
+
def codes(response, resp_type)
|
23
|
+
case resp_type
|
24
|
+
when 'property'
|
25
|
+
response[:result][:code].split(",")
|
26
|
+
when 'address'
|
27
|
+
response[:results].split(",")
|
28
|
+
end
|
20
29
|
end
|
21
30
|
|
22
31
|
def has_error_codes?(codes)
|
23
|
-
!codes.select { |
|
24
|
-
end
|
25
|
-
|
26
|
-
def property_success_codes
|
27
|
-
{ YS01: "FIPS/APN Match found",
|
28
|
-
YS02: "AddressKey Match found",
|
29
|
-
YS03: "Basic information returned",
|
30
|
-
YS04: "Detailed information returned" }
|
32
|
+
!codes.select { |code| error_codes.include? code.to_sym }.empty?
|
31
33
|
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
YE03: "Invalid FIPS/APN or AddressKey provided" }
|
35
|
+
def error_codes
|
36
|
+
error_code_strings = CODE_TYPES.map { |t| File.read("config/#{t}_error_codes.yml") }
|
37
|
+
error_code_strings.map { |c| YAML.load(c) }.flat_map { |code| code.values.first.keys.map(&:to_sym) }
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
@@ -1,16 +1,6 @@
|
|
1
1
|
module MelissaData
|
2
2
|
module WebSmart
|
3
|
-
|
4
|
-
attr_accessor :xml_document
|
5
|
-
|
6
|
-
def initialize(xml)
|
7
|
-
@xml_document = xml
|
8
|
-
end
|
9
|
-
|
10
|
-
def children?(xml_node)
|
11
|
-
xml_node.children.empty?
|
12
|
-
end
|
13
|
-
|
3
|
+
module Formatters
|
14
4
|
def viperize_hash hash
|
15
5
|
hash.map { |key, value| { viperize(key.to_s) => value } }.reduce(:merge)
|
16
6
|
end
|
@@ -26,27 +16,22 @@ module MelissaData
|
|
26
16
|
end
|
27
17
|
end
|
28
18
|
|
29
|
-
class
|
30
|
-
|
31
|
-
|
32
|
-
end
|
19
|
+
class XMLParser
|
20
|
+
include MelissaData::WebSmart::Formatters
|
21
|
+
attr_accessor :xml_document
|
33
22
|
|
34
|
-
def
|
35
|
-
|
36
|
-
.map(&:children)
|
37
|
-
.map(&:text)
|
23
|
+
def initialize(xml)
|
24
|
+
@xml_document = xml
|
38
25
|
end
|
39
26
|
|
40
|
-
def
|
41
|
-
|
27
|
+
def children?(xml_node)
|
28
|
+
xml_node.children.empty?
|
42
29
|
end
|
43
30
|
|
44
|
-
def xml_children
|
45
|
-
xml_document.children
|
46
|
-
end
|
47
31
|
end
|
48
32
|
|
49
33
|
class PropertyXMLParser < XMLParser
|
34
|
+
include MelissaData::WebSmart::Formatters
|
50
35
|
def parse
|
51
36
|
parsed_hash = {}
|
52
37
|
if expected_retrieved?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: melissa_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Grayson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -128,6 +128,11 @@ files:
|
|
128
128
|
- Rakefile
|
129
129
|
- bin/console
|
130
130
|
- bin/setup
|
131
|
+
- config/address_error_codes.yml
|
132
|
+
- config/address_success_codes.yml
|
133
|
+
- config/error_codes.yml
|
134
|
+
- config/property_error_codes.yml
|
135
|
+
- config/property_success_codes.yml
|
131
136
|
- lib/melissa_data.rb
|
132
137
|
- lib/melissa_data/config.rb
|
133
138
|
- lib/melissa_data/version.rb
|