melissa_data 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2976f5d997bb1045a542a18aef357cadf47eee77
4
- data.tar.gz: c05bbaaf4cfaedd203dc8c1197743e5169d480ab
3
+ metadata.gz: b45cd57a7506db6b7878611cb74c9f68593a3e2e
4
+ data.tar.gz: 32ce7c1ff706ee8346c05164784cb1cefc979e32
5
5
  SHA512:
6
- metadata.gz: dfd63be631a5f800469e1d8b1b8a2ffcf396c04553d0da8f316033e8ff0fb3d59565551b823117cefa2962ac0c28a03e4b504a9139cc27fe7d32d4daf69727fa
7
- data.tar.gz: 004292d3662a372759005640f37da7f0b71ab3838f12ab0d1a48d957de45352ff8a46c601dc5217c38d8c0e6b5930886c3a9e480a52181a7d7465b94c1080237
6
+ metadata.gz: 3d622bc34471c75ad69409846ee1c1af69faecc6736eac47a66fb1bcfdc656be0dd6870ce325a9d591a82b59e1b230db2c50c42195c3726eb5aa178ff6b8a721
7
+ data.tar.gz: 176521fa39987ed20af5bc32d1eebee100c30a536fee01e00c52086d9a1471789b1aa8d402ffb265d26d7cb01207a8b2ea2c9760904d723cd9f3ad3b661e224a
@@ -1,3 +1,3 @@
1
1
  module MelissaData
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -1,8 +1,21 @@
1
1
  module MelissaData
2
2
  module WebSmart
3
3
  class Client
4
- def property(fips:, apn:)
5
- MelissaData::WebSmart::PropertyAPI.new.property(fips: fips, apn: apn)
4
+ def initialize
5
+ @client = MelissaData::WebSmart::PropertyAPI.new
6
+ end
7
+
8
+ def property_by_apn(fips:, apn:)
9
+ @client.property_by_apn(fips: fips, apn: apn)
10
+ end
11
+
12
+ def property_by_address_key(address_key:)
13
+ @client.property_by_address_key(address_key: address_key)
14
+ end
15
+
16
+ def address(address:, city:, state:, zip:, country: "USA")
17
+ @client.address(address: address, city: city, state: state,
18
+ zip: zip, country: country)
6
19
  end
7
20
  end
8
21
  end
@@ -4,13 +4,31 @@ require 'nokogiri'
4
4
  module MelissaData
5
5
  module WebSmart
6
6
  class PropertyAPI
7
- def property(fips:, apn:)
7
+ def property_by_apn(fips:, apn:)
8
8
  resp = RestClient.get('https://property.melissadata.net/v3/REST/Service.svc/doLookup',
9
9
  { params: { id: MelissaData.web_smart_id,
10
10
  fips: fips,
11
11
  apn: apn } })
12
12
  PropertyXMLParser.new(Nokogiri::XML(resp)).parse
13
13
  end
14
+
15
+ def property_by_address_key(address_key:)
16
+ resp = RestClient.get('https://property.melissadata.net/v3/REST/Service.svc/doLookup',
17
+ { params: { id: MelissaData.web_smart_id,
18
+ AddressKey: address_key } })
19
+ PropertyXMLParser.new(Nokogiri::XML(resp)).parse
20
+ end
21
+
22
+ def address(address:, city:, state:, zip:, country:)
23
+ resp = RestClient.get('https://address.melissadata.net/v3/WEB/GlobalAddress/doGlobalAddress',
24
+ { params: { id: MelissaData.web_smart_id,
25
+ a1: address,
26
+ loc: city,
27
+ admarea: state,
28
+ postal: zip,
29
+ ctry: country} })
30
+ AddressXMLParser.new(Nokogiri::XML(resp)).parse
31
+ end
14
32
  end
15
33
  end
16
34
  end
@@ -26,6 +26,26 @@ module MelissaData
26
26
  end
27
27
  end
28
28
 
29
+ class AddressXMLParser < XMLParser
30
+ def parse
31
+ viperize_hash(Hash[retrieved_fields.zip(field_details)])
32
+ end
33
+
34
+ def field_details
35
+ xml_children.first.children.last.children.first.children
36
+ .map(&:children)
37
+ .map(&:text)
38
+ end
39
+
40
+ def retrieved_fields
41
+ xml_children.first.children.last.children.first.children.map(&:name)
42
+ end
43
+
44
+ def xml_children
45
+ xml_document.children
46
+ end
47
+ end
48
+
29
49
  class PropertyXMLParser < XMLParser
30
50
  def parse
31
51
  parsed_hash = {}
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Grayson