melissa_data 0.2.2 → 0.2.3

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: b45cd57a7506db6b7878611cb74c9f68593a3e2e
4
- data.tar.gz: 32ce7c1ff706ee8346c05164784cb1cefc979e32
3
+ metadata.gz: df41fc02a5604e66a5f2ea498c71a7573fe063b2
4
+ data.tar.gz: 87ff0bd7e79330ccb429ed3546270ab4e6065ea7
5
5
  SHA512:
6
- metadata.gz: 3d622bc34471c75ad69409846ee1c1af69faecc6736eac47a66fb1bcfdc656be0dd6870ce325a9d591a82b59e1b230db2c50c42195c3726eb5aa178ff6b8a721
7
- data.tar.gz: 176521fa39987ed20af5bc32d1eebee100c30a536fee01e00c52086d9a1471789b1aa8d402ffb265d26d7cb01207a8b2ea2c9760904d723cd9f3ad3b661e224a
6
+ metadata.gz: c45cb95cd51bd4e6d13d7d84c4454f4d27750d9a0a77ea424d9a0c8c912d9a28c460e542b45344317aa244d68371271ae1ef605062e8c32fc6f75ef092202477
7
+ data.tar.gz: c497b841a773eb15ed9e664cc3b4d5a65689866463351951f0a045b0a1b95e854c2d1c1ed43cbf426c9cad8b05a253db76a97d88c64aed71aa966177048c9e57
data/.travis.yml CHANGED
@@ -2,3 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - 2.2.1
4
4
  before_install: gem install bundler -v 1.10.6
5
+
6
+ script: bundle exec rspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Melissa Data
2
2
 
3
+ [![Build Status](https://travis-ci.org/cometaworks/melissa_data.svg)](https://travis-ci.org/cometaworks/melissa_data)
4
+
3
5
  ## Installation
4
6
 
5
7
  Add this line to your application's Gemfile:
@@ -16,6 +18,23 @@ Or install it yourself as:
16
18
 
17
19
  $ gem install melissa_data
18
20
 
21
+ ## Configuration
22
+
23
+ There are two ways to configure the gem.
24
+
25
+ ### Block configuration
26
+
27
+ ```ruby
28
+ MelissaData.configure do |config|
29
+ config.web_smart_id = ENV['MELISSA_DATA_WEB_SMART_ID']
30
+ end
31
+ ```
32
+
33
+ ### One-liner
34
+
35
+ ```ruby
36
+ MelissaData.web_smart_id = ENV['MELISSA_DATA_WEB_SMART_ID']
37
+ ```
19
38
  ## Usage
20
39
 
21
40
  ### Smart Web APIs
@@ -23,229 +42,262 @@ Or install it yourself as:
23
42
  #### Property
24
43
  There is a client included for the property API on Melissa. This requires very little.
25
44
  You will need a `MelissaData Web Smart ID`.
45
+
46
+ #### Quick Use
26
47
  Once you have these, you may use the following client. To instantiate a client:
27
48
 
28
49
  ```ruby
29
50
  irb> MelissaData.web_smart_id = ENV['MELISSA_DATA_WEB_SMART_ID']
30
51
  irb> client = MelissaData::WebSmart::Client.new
31
- irb> client.property(fips: some_fips_code, apn: some_apn)
52
+ irb> client.property_by_apn(fips: some_fips_code, apn: some_apn)
32
53
  # => your property data
33
54
  # since it uses keyword arguments, order does not matter
34
- irb> client.property(apn: some_apn, fips: some_fips_code)
55
+ irb> client.property_by_apn(apn: some_apn, fips: some_fips_code)
56
+ # => your property data
57
+
58
+ # You can also look up an address code and get its `address_key` instead of using
59
+ # an apn and fips code
60
+ irb> key = client.address(address: "158 Thomas Dr", city: "Fremont", state: "Ohio", zip: "43420")[:address_key]
61
+ irb> client.property_by_address_key(key)
35
62
  # => your property data
36
63
  ```
37
64
 
38
- Data comes in the following form:
39
-
40
- ```json
41
- {
42
- "record_id": null,
43
- "result": {
44
- "code": "YS01,YS03,YC01,GS05",
45
- "description": "FIPS/APN Match Found. Basic information returned."
46
- },
47
- "parcel": {
48
- "fips_code": "12071",
49
- "fips_sub_code": null,
50
- "unformatted_apn": null,
51
- "apn_sequence_no": null,
52
- "formatted_apn": "24-43-24-03-00022.0040",
53
- "original_apn": null,
54
- "census_tract": null,
55
- "zoning": null,
56
- "range": null,
57
- "township": null,
58
- "section": null,
59
- "quarter_section": null,
60
- "homestead_exempt": null,
61
- "absentee_owner_code": null,
62
- "land_use_code": null,
63
- "county_land_use1": null,
64
- "county_land_use2": null,
65
- "property_indicator_code": null,
66
- "municipality_name": null,
67
- "view_code": null,
68
- "location_influence_code": null,
69
- "number_of_buildings": null
70
- },
71
- "property_address": {
72
- "address": "8351 Bartholomew Dr",
73
- "city": "North Fort Myers",
74
- "state": "FL",
75
- "zip": "33917-1758",
76
- "address_key": "33917175851",
77
- "latitude": "26.72156",
78
- "longitude": "-81.85911"
79
- },
80
- "parsed_property_address": {
81
- "range": "8351",
82
- "pre_directional": null,
83
- "street_name": "Bartholomew",
84
- "suffix": "Dr",
85
- "post_directional": null,
86
- "suite_name": null,
87
- "suite_range": null
88
- },
89
- "owner": {
90
- "corporate_owner": null,
91
- "name": "EDWARDS JOHN V",
92
- "name2": null,
93
- "unparsed_name1": null,
94
- "unparsed_name2": null,
95
- "phone": null,
96
- "phone_opt_out": null
97
- },
98
- "owner_address": {
99
- "address": null,
100
- "suite": null,
101
- "city": null,
102
- "state": null,
103
- "zip": null,
104
- "carrier_route": null,
105
- "matchcode": null,
106
- "mail_opt_out": null
107
- },
108
- "values": {
109
- "calculated_total_value": "17300",
110
- "calculated_land_value": null,
111
- "calculated_improvement_value": null,
112
- "calculated_total_value_code": null,
113
- "calculated_land_value_code": null,
114
- "calculated_improvement_value_code": null,
115
- "assessed_total_value": "17300",
116
- "assessed_land_value": null,
117
- "assessed_improvement_value": null,
118
- "market_total_value": null,
119
- "market_land_value": null,
120
- "market_improvement_value": null,
121
- "appraised_total_value": null,
122
- "appraised_land_value": null,
123
- "appraised_improvement_value": null,
124
- "tax_amount": "235.82",
125
- "tax_year": null
126
- },
127
- "current_sale": {
128
- "transaction_id": null,
129
- "document_year": null,
130
- "deed_category_code": null,
131
- "recording_date": null,
132
- "sale_date": "19920109",
133
- "sale_price": "69000",
134
- "sale_code": null,
135
- "seller_name": null,
136
- "multi_apn_code": null,
137
- "multi_apn_count": null,
138
- "residental_model": null
139
- },
140
- "current_deed": {
141
- "mortgage_amount": "68900",
142
- "mortgage_date": null,
143
- "mortgage_loan_type_code": null,
144
- "mortgage_deed_type_code": null,
145
- "mortgage_term_code": null,
146
- "mortgage_term": null,
147
- "mortgage_due_date": null,
148
- "mortgage_assumption_amount": null,
149
- "lender_code": null,
150
- "lender_name": null,
151
- "second_mortgage_amount": null,
152
- "second_mortgage_loan_type_code": null,
153
- "second_mortgage_deed_type_code": null
154
- },
155
- "prior_sale": {
156
- "transaction_id": null,
157
- "document_year": null,
158
- "deed_category_code": null,
159
- "recording_date": null,
160
- "sale_date": null,
161
- "sale_price": null,
162
- "sale_code": null,
163
- "transaction_code": null,
164
- "multi_apn_code": null,
165
- "multi_apn_count": null,
166
- "mortgage_amount": null,
167
- "deed_type_code": null
168
- },
169
- "lot": {
170
- "front_footage": null,
171
- "depth_footage": null,
172
- "acreage": "2.1491",
173
- "square_footage": "93615"
174
- },
175
- "square_footage": {
176
- "universal_building": null,
177
- "building_area_code": null,
178
- "building_area": null,
179
- "living_space": null,
180
- "ground_floor": null,
181
- "gross": null,
182
- "adjusted_gross": null,
183
- "basement": null,
184
- "garage_or_parking": null
185
- },
186
- "building": {
187
- "year_built": null,
188
- "effective_year_built": null,
189
- "bed_rooms": "0",
190
- "total_rooms": "0",
191
- "total_baths_calculated": null,
192
- "total_baths": "0.00",
193
- "full_baths": null,
194
- "half_baths": null,
195
- "one_quarter_baths": null,
196
- "three_quarter_baths": null,
197
- "bath_fixtures": null,
198
- "air_conditioning_code": null,
199
- "basement_code": null,
200
- "building_code": null,
201
- "improvement_code": null,
202
- "condition_code": null,
203
- "construction_code": null,
204
- "exterior_wall_code": null,
205
- "fireplace": null,
206
- "fireplaces": null,
207
- "fireplace_code": null,
208
- "foundation_code": null,
209
- "flooring_code": null,
210
- "roof_framing_code": null,
211
- "garage_code": null,
212
- "heating_code": null,
213
- "mobile_home": null,
214
- "parking_spaces": null,
215
- "parking_code": null,
216
- "pool": null,
217
- "pool_code": null,
218
- "quality_code": null,
219
- "roof_cover_code": null,
220
- "roof_type_code": null,
221
- "stories_code": null,
222
- "stories": null,
223
- "building_style_code": null,
224
- "units": null,
225
- "electricity_code": null,
226
- "fuel_code": null,
227
- "sewer_code": null,
228
- "water_code": null
229
- }
230
- }
65
+ #### Property Client
66
+
67
+ The following are the main keys returned by the client for a property request:
68
+
69
+ ```
70
+ record_id
71
+ result
72
+ parcel
73
+ property_address
74
+ parsed_property_address
75
+ owner
76
+ owner_address
77
+ values
78
+ current_sale
79
+ current_deed
80
+ prior_sale
81
+ lot
82
+ square_footage
83
+ building
84
+ success
231
85
  ```
232
86
 
233
- ## Configuration
87
+ To request a property's information, you must go through one of two processes. In order to request a property
88
+ by address, there are two steps.
234
89
 
235
- There are two ways to configure the gem.
90
+ Prepare a client
236
91
 
237
- ### Block configuration
92
+ ```ruby
93
+ irb> client = MelissaData::WebSmart::Client.new
94
+ ```
95
+
96
+ And next, we call `Client#address` with the keys `address`, `city`, `state`, `zip`, and optionally `country`,
97
+ which defaults to `US` in order to get an address key. If we do not have a `FIPS` and `APN` for the property,
98
+ we must go through this step in order to get the key to pass to the `Client#property` method.
238
99
 
239
100
  ```ruby
240
- MelissaData.configure do |config|
241
- config.web_smart_id = ENV['MELISSA_DATA_WEB_SMART_ID']
242
- end
101
+ irb. address_key = client.address(address: '158 thomas dr', city: 'fremont', state: 'ohio', zip: '43420')
243
102
  ```
244
103
 
245
- ### One-liner
104
+ And now we can call the regular `Client#property` method to get the enriched data for the parcel.
246
105
 
247
106
  ```ruby
248
- MelissaData.web_smart_id = ENV['MELISSA_DATA_WEB_SMART_ID']
107
+ irb> client.property_by_address_key(address_key: address_key)
108
+ # =>
109
+ {:record_id=>nil,
110
+ :result=>
111
+ {:code=>"YS01,YS03,YC01,GS05",
112
+ :description=> "FIPS/APN Match Found. Basic information returned."},
113
+ :parcel=>
114
+ {:fips_code=>"12071",
115
+ :fips_sub_code=>nil,
116
+ :unformatted_apn=>nil,
117
+ :apn_sequence_no=>nil,
118
+ :formatted_apn=>"24-43-24-03-00022.0040",
119
+ :original_apn=>nil,
120
+ :census_tract=>nil,
121
+ :zoning=>nil,
122
+ :range=>nil,
123
+ :township=>nil,
124
+ :section=>nil,
125
+ :quarter_section=>nil,
126
+ :homestead_exempt=>nil,
127
+ :absentee_owner_code=>nil,
128
+ :land_use_code=>nil,
129
+ :county_land_use1=>nil,
130
+ :county_land_use2=>nil,
131
+ :property_indicator_code=>nil,
132
+ :municipality_name=>nil,
133
+ :view_code=>nil,
134
+ :location_influence_code=>nil,
135
+ :number_of_buildings=>nil},
136
+ :property_address=>
137
+ {:address=>"8351 Bartholomew Dr",
138
+ :city=>"North Fort Myers",
139
+ :state=>"FL",
140
+ :zip=>"33917-1758",
141
+ :address_key=>"33917175851",
142
+ :latitude=>"26.72156",
143
+ :longitude=>"-81.85911"},
144
+ :parsed_property_address=>
145
+ {:range=>"8351",
146
+ :pre_directional=>nil,
147
+ :street_name=>"Bartholomew",
148
+ :suffix=>"Dr",
149
+ :post_directional=>nil,
150
+ :suite_name=>nil,
151
+ :suite_range=>nil},
152
+ :owner=>
153
+ {:corporate_owner=>nil,
154
+ :name=>"EDWARDS JOHN V",
155
+ :name2=>nil,
156
+ :unparsed_name1=>nil,
157
+ :unparsed_name2=>nil,
158
+ :phone=>nil,
159
+ :phone_opt_out=>nil},
160
+ :owner_address=>
161
+ {:address=>nil,
162
+ :suite=>nil,
163
+ :city=>nil,
164
+ :state=>nil,
165
+ :zip=>nil,
166
+ :carrier_route=>nil,
167
+ :matchcode=>nil,
168
+ :mail_opt_out=>nil},
169
+ :values=>
170
+ {:calculated_total_value=>"17300",
171
+ :calculated_land_value=>nil,
172
+ :calculated_improvement_value=>nil,
173
+ :calculated_total_value_code=>nil,
174
+ :calculated_land_value_code=>nil,
175
+ :calculated_improvement_value_code=>nil,
176
+ :assessed_total_value=>"17300",
177
+ :assessed_land_value=>nil,
178
+ :assessed_improvement_value=>nil,
179
+ :market_total_value=>nil,
180
+ :market_land_value=>nil,
181
+ :market_improvement_value=>nil,
182
+ :appraised_total_value=>nil,
183
+ :appraised_land_value=>nil,
184
+ :appraised_improvement_value=>nil,
185
+ :tax_amount=>"235.82",
186
+ :tax_year=>nil},
187
+ :current_sale=>
188
+ {:transaction_id=>nil,
189
+ :document_year=>nil,
190
+ :deed_category_code=>nil,
191
+ :recording_date=>nil,
192
+ :sale_date=>"19920109",
193
+ :sale_price=>"69000",
194
+ :sale_code=>nil,
195
+ :seller_name=>nil,
196
+ :multi_apn_code=>nil,
197
+ :multi_apn_count=>nil,
198
+ :residental_model=>nil},
199
+ :current_deed=>
200
+ {:mortgage_amount=>"68900",
201
+ :mortgage_date=>nil,
202
+ :mortgage_loan_type_code=>nil,
203
+ :mortgage_deed_type_code=>nil,
204
+ :mortgage_term_code=>nil,
205
+ :mortgage_term=>nil,
206
+ :mortgage_due_date=>nil,
207
+ :mortgage_assumption_amount=>nil,
208
+ :lender_code=>nil,
209
+ :lender_name=>nil,
210
+ :second_mortgage_amount=>nil,
211
+ :second_mortgage_loan_type_code=>nil,
212
+ :second_mortgage_deed_type_code=>nil},
213
+ :prior_sale=>
214
+ {:transaction_id=>nil,
215
+ :document_year=>nil,
216
+ :deed_category_code=>nil,
217
+ :recording_date=>nil,
218
+ :sale_date=>nil,
219
+ :sale_price=>nil,
220
+ :sale_code=>nil,
221
+ :transaction_code=>nil,
222
+ :multi_apn_code=>nil,
223
+ :multi_apn_count=>nil,
224
+ :mortgage_amount=>nil,
225
+ :deed_type_code=>nil},
226
+ :lot=>
227
+ {:front_footage=>nil,
228
+ :depth_footage=>nil,
229
+ :acreage=>"2.1491",
230
+ :square_footage=>"93615"},
231
+ :square_footage=>
232
+ {:universal_building=>nil,
233
+ :building_area_code=>nil,
234
+ :building_area=>nil,
235
+ :living_space=>nil,
236
+ :ground_floor=>nil,
237
+ :gross=>nil,
238
+ :adjusted_gross=>nil,
239
+ :basement=>nil,
240
+ :garage_or_parking=>nil},
241
+ :building=>
242
+ {:year_built=>nil,
243
+ :effective_year_built=>nil,
244
+ :bed_rooms=>"0",
245
+ :total_rooms=>"0",
246
+ :total_baths_calculated=>nil,
247
+ :total_baths=>"0.00",
248
+ :full_baths=>nil,
249
+ :half_baths=>nil,
250
+ :one_quarter_baths=>nil,
251
+ :three_quarter_baths=>nil,
252
+ :bath_fixtures=>nil,
253
+ :air_conditioning_code=>nil,
254
+ :basement_code=>nil,
255
+ :building_code=>nil,
256
+ :improvement_code=>nil,
257
+ :condition_code=>nil,
258
+ :construction_code=>nil,
259
+ :exterior_wall_code=>nil,
260
+ :fireplace=>nil,
261
+ :fireplaces=>nil,
262
+ :fireplace_code=>nil,
263
+ :foundation_code=>nil,
264
+ :flooring_code=>nil,
265
+ :roof_framing_code=>nil,
266
+ :garage_code=>nil,
267
+ :heating_code=>nil,
268
+ :mobile_home=>nil,
269
+ :parking_spaces=>nil,
270
+ :parking_code=>nil,
271
+ :pool=>nil,
272
+ :pool_code=>nil,
273
+ :quality_code=>nil,
274
+ :roof_cover_code=>nil,
275
+ :roof_type_code=>nil,
276
+ :stories_code=>nil,
277
+ :stories=>nil,
278
+ :building_style_code=>nil,
279
+ :units=>nil,
280
+ :electricity_code=>nil,
281
+ :fuel_code=>nil,
282
+ :sewer_code=>nil,
283
+ :water_code=>nil},
284
+ :success=>
285
+ ["FIPS/APN Match found", "Basic information returned"]}
286
+ }
287
+ ```
288
+
289
+ The alternative method is used if you have a `FIPS` and `APN` available. This is `Client#property_by_apn`.
290
+
291
+ ```ruby
292
+ irb> client.property_by_apn(apn: 'my_apn', fips: 'my_fips')
293
+ # => see above return format, it is identical
294
+ ```
295
+
296
+ There is an `error` key returned in a hash with the reasons for the failure if an error occurs.
297
+ If there is not an error, there is a `success` key added with some basic logging and information such as:
298
+
299
+ ```
300
+ ["FIPS/APN Match found", "Basic information returned"]
249
301
  ```
250
302
 
251
303
  ## Development
@@ -1,3 +1,3 @@
1
1
  module MelissaData
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -1,20 +1,22 @@
1
1
  module MelissaData
2
2
  module WebSmart
3
3
  class Client
4
+ include MelissaData::WebSmart::ResponseProcessor
5
+
4
6
  def initialize
5
7
  @client = MelissaData::WebSmart::PropertyAPI.new
6
8
  end
7
9
 
8
10
  def property_by_apn(fips:, apn:)
9
- @client.property_by_apn(fips: fips, apn: apn)
11
+ process_property(@client.property_by_apn(fips: fips, apn: apn))
10
12
  end
11
13
 
12
14
  def property_by_address_key(address_key:)
13
- @client.property_by_address_key(address_key: address_key)
15
+ process_property(@client.property_by_address_key(address_key: address_key))
14
16
  end
15
17
 
16
18
  def address(address:, city:, state:, zip:, country: "USA")
17
- @client.address(address: address, city: city, state: state,
19
+ resp = @client.address(address: address, city: city, state: state,
18
20
  zip: zip, country: country)
19
21
  end
20
22
  end
@@ -0,0 +1,43 @@
1
+ module MelissaData
2
+ module WebSmart
3
+ module ResponseProcessor
4
+ def process_property(response)
5
+ codes = codes(response)
6
+ if has_error_codes?(codes)
7
+ { errors: codes_for(codes, 'error') }
8
+ else
9
+ response.merge!(success: codes_for(codes, 'success'))
10
+ end
11
+ end
12
+
13
+ def codes_for(codes, type)
14
+ codes.map { |c| method("property_#{type}_codes").call[c.to_sym] }.compact
15
+ end
16
+
17
+ def codes(response)
18
+ codes = response[:result][:code].split(",")
19
+ end
20
+
21
+ def has_error_codes? codes
22
+ error_codes?(codes) ? false : true
23
+ end
24
+
25
+ def error_codes?(codes)
26
+ codes.map { |c| c if property_error_codes.keys.include? c }.compact.empty?
27
+ end
28
+
29
+ def property_success_codes
30
+ { YS01: "FIPS/APN Match found",
31
+ YS02: "AddressKey Match found",
32
+ YS03: "Basic information returned",
33
+ YS04: "Detailed information returned" }
34
+ end
35
+
36
+ def property_error_codes
37
+ { YE01: "No FIPS/APN or AddressKey provided",
38
+ YE02: "No match found",
39
+ YE03: "Invalid FIPS/APN or AddressKey provided" }
40
+ end
41
+ end
42
+ end
43
+ end
data/lib/melissa_data.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "melissa_data/version"
2
2
  require "melissa_data/web_smart/xml"
3
+ require "melissa_data/web_smart/response_processor"
3
4
  require "melissa_data/web_smart/client"
4
5
  require "melissa_data/web_smart/property_api"
5
6
  require "melissa_data/config"
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.2
4
+ version: 0.2.3
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-15 00:00:00.000000000 Z
12
+ date: 2015-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -133,6 +133,7 @@ files:
133
133
  - lib/melissa_data/version.rb
134
134
  - lib/melissa_data/web_smart/client.rb
135
135
  - lib/melissa_data/web_smart/property_api.rb
136
+ - lib/melissa_data/web_smart/response_processor.rb
136
137
  - lib/melissa_data/web_smart/xml.rb
137
138
  - melissa_data.gemspec
138
139
  homepage: http://github.com/cometaworks/melissa_data
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  version: '0'
156
157
  requirements: []
157
158
  rubyforge_project:
158
- rubygems_version: 2.4.6
159
+ rubygems_version: 2.4.5.1
159
160
  signing_key:
160
161
  specification_version: 4
161
162
  summary: A simple interface to Melissa Data's Web Smart Property API