melissa_data 0.2.14 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/melissa_data.rb +1 -2
- data/lib/melissa_data/geo_lookup/geocoder.rb +1 -1
- data/lib/melissa_data/version.rb +1 -1
- data/lib/melissa_data/web_smart/client.rb +6 -4
- data/lib/melissa_data/web_smart/property_api.rb +50 -25
- data/lib/melissa_data/web_smart/response_processor.rb +2 -2
- data/melissa_data.gemspec +9 -8
- metadata +27 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ad99ffda47a41ab5769c579eb119ffae8353114
|
4
|
+
data.tar.gz: 5f88c441fc21210d7b458d31cfcb38443956c76f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20a2f54106674585fcc5ca4aa1bb9ec479e6d2fb3806985b06cc8b0a812d3df6f90857c84058904ea5e15accb52553faa02d4eb3e13d99e51e5d674e8be4e719
|
7
|
+
data.tar.gz: c53bbde3abc59944433c42c495778cf6e2e6a0f13d58abf48c2d3b68f86e8dc5b7c64032086f3489e609933ef13eb98b85dc01759e5c8041d136196b195ccb9e
|
data/lib/melissa_data.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "active_support/core_ext/hash"
|
1
2
|
require "melissa_data/version"
|
2
3
|
require "melissa_data/web_smart/xml"
|
3
4
|
require "melissa_data/web_smart/response_processor"
|
@@ -6,8 +7,6 @@ require "melissa_data/web_smart/property_api"
|
|
6
7
|
require "melissa_data/config"
|
7
8
|
require "melissa_data/geo_lookup/geocoder"
|
8
9
|
|
9
|
-
require 'rest-client'
|
10
|
-
require 'nokogiri'
|
11
10
|
require 'geokit'
|
12
11
|
|
13
12
|
module MelissaData
|
@@ -14,7 +14,7 @@ module MelissaData
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def coordinates?(response)
|
17
|
-
if !response[:errors]
|
17
|
+
if !response[:errors] && !response[:property_address]&.empty?
|
18
18
|
lat = response.fetch(:property_address)[:latitude]
|
19
19
|
long =response.fetch(:property_address)[:longitude]
|
20
20
|
lat != nil && long != nil
|
data/lib/melissa_data/version.rb
CHANGED
@@ -24,7 +24,7 @@ module MelissaData
|
|
24
24
|
|
25
25
|
def resolve_response
|
26
26
|
return @response unless success?
|
27
|
-
add_coordinates(@response) unless MelissaData::GeoLookup::Geocoder.coordinates? @response
|
27
|
+
add_coordinates(@response[:records].first) unless MelissaData::GeoLookup::Geocoder.coordinates? @response[:records].first
|
28
28
|
@response
|
29
29
|
end
|
30
30
|
|
@@ -42,9 +42,11 @@ module MelissaData
|
|
42
42
|
city = response.dig(:property_address, :city)
|
43
43
|
state = response.dig(:property_address, :state)
|
44
44
|
zip = response.dig(:property_address, :zip)
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
|
46
|
+
if addr && city && state && zip
|
47
|
+
full_address = "#{addr}, #{city}, #{state}, #{zip}"
|
48
|
+
MelissaData::GeoLookup::Geocoder.address_to_coordinates(full_address)
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
@@ -1,40 +1,65 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'faraday'
|
2
|
+
require 'typhoeus'
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module MelissaData
|
6
6
|
module WebSmart
|
7
7
|
class PropertyAPI
|
8
|
+
USER_AGENT = "MelissaData-Rubygem/#{MelissaData::VERSION}"
|
9
|
+
BASE_URL = 'https://property.melissadata.net'
|
10
|
+
|
11
|
+
def default_connection(url = BASE_URL, json_headers: false)
|
12
|
+
Faraday.new(url: url) do |conn|
|
13
|
+
conn.response :logger
|
14
|
+
conn.headers[:user_agent] = USER_AGENT
|
15
|
+
|
16
|
+
if json_headers
|
17
|
+
conn.headers['Content-Type'] = 'application/json'
|
18
|
+
conn.headers['Accept'] = 'application/json'
|
19
|
+
end
|
20
|
+
|
21
|
+
conn.adapter :typhoeus
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
8
25
|
def property_by_apn(fips:, apn:)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
26
|
+
raw = default_connection(BASE_URL).get '/v4/WEB/LookupProperty/', {
|
27
|
+
id: MelissaData.web_smart_id,
|
28
|
+
fips: fips,
|
29
|
+
apn: apn,
|
30
|
+
format: 'json'
|
31
|
+
}
|
32
|
+
|
33
|
+
res = JSON.parse(raw.body).deep_transform_keys(&:underscore)
|
34
|
+
res&.with_indifferent_access
|
15
35
|
end
|
16
36
|
|
17
37
|
def property_by_address_key(address_key:)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
38
|
+
raw = default_connection(BASE_URL).get '/v4/WEB/LookupProperty/', {
|
39
|
+
id: MelissaData.web_smart_id,
|
40
|
+
AddressKey: address_key,
|
41
|
+
format: 'json'
|
42
|
+
}
|
43
|
+
|
44
|
+
res = JSON.parse(raw.body).deep_transform_keys(&:underscore)
|
45
|
+
res&.with_indifferent_access
|
23
46
|
end
|
24
47
|
|
25
48
|
def address(address:, city:, state:, zip:, country:)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
49
|
+
raw = default_connection(BASE_URL, json_headers: true)
|
50
|
+
.get '/v3/WEB/ContactVerify/doContactVerify', {
|
51
|
+
id: MelissaData.web_smart_id,
|
52
|
+
Actions: 'Check',
|
53
|
+
a1: address,
|
54
|
+
city: city,
|
55
|
+
state: state,
|
56
|
+
postal: zip,
|
57
|
+
ctry: country,
|
58
|
+
AdvancedAddressCorrection: 'on'
|
59
|
+
}
|
60
|
+
|
61
|
+
res = JSON.parse(raw.body).deep_transform_keys(&:underscore)
|
62
|
+
res&.with_indifferent_access[:records]&.first
|
38
63
|
end
|
39
64
|
end
|
40
65
|
end
|
@@ -31,9 +31,9 @@ module MelissaData
|
|
31
31
|
def codes(response, resp_type)
|
32
32
|
case resp_type
|
33
33
|
when 'property'
|
34
|
-
response[:
|
34
|
+
response[:records].first[:results].split(',')
|
35
35
|
when 'address'
|
36
|
-
response[:results].split(
|
36
|
+
response[:records].first[:results].split(',')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/melissa_data.gemspec
CHANGED
@@ -20,13 +20,14 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
spec.required_ruby_version = '>= 2.3'
|
22
22
|
|
23
|
-
spec.add_runtime_dependency
|
24
|
-
spec.add_runtime_dependency
|
25
|
-
spec.add_runtime_dependency
|
23
|
+
spec.add_runtime_dependency 'geokit'
|
24
|
+
spec.add_runtime_dependency 'activesupport', '~> 4.2.2'
|
25
|
+
spec.add_runtime_dependency 'faraday', '~> 0.15.0'
|
26
|
+
spec.add_runtime_dependency 'typhoeus', '~> 1.3.0'
|
26
27
|
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.3'
|
31
|
+
spec.add_development_dependency 'pry'
|
32
|
+
spec.add_development_dependency 'webmock'
|
32
33
|
end
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Grayson
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: geokit
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
@@ -26,33 +26,47 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: activesupport
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 4.2.2
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 4.2.2
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: faraday
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 0.15.0
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 0.15.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: typhoeus
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.3.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.3.0
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: bundler
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|