phl-opa 0.0.2 → 0.0.5
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.
- data/README.md +98 -4
- data/lib/phl_opa/api.rb +34 -1
- data/lib/phl_opa/version.rb +1 -1
- data/spec/lib/phl_opa_spec.rb +70 -4
- metadata +1 -1
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# PHL-opa
|
|
4
4
|
|
|
5
|
-
A thin wrapper for the Philadelphia Office of Property Assessment API
|
|
5
|
+
A thin wrapper for the Philadelphia [Office of Property Assessment API](http://phlapi.com/opaapi.html)
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -20,7 +20,9 @@ Or install it yourself as:
|
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
**#get_by_account**
|
|
24
|
+
|
|
25
|
+
Returns the property details for the provided OPA account number. This method returns the most amount of data about a given property. If you have an address, but not an OPA account number. Use the `#search_by_address` method to find the OPA account number, then this method to get all the details about the property.
|
|
24
26
|
|
|
25
27
|
require 'phl_opa'
|
|
26
28
|
phl_opa = PHLopa::API.new
|
|
@@ -48,11 +50,13 @@ Response:
|
|
|
48
50
|
}
|
|
49
51
|
...
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
**#search_by_address**
|
|
54
|
+
|
|
55
|
+
Searches for properties that match the provided address. In the response, the `data.properties` key is always an array, even if there is only one result
|
|
52
56
|
|
|
53
57
|
require 'phl_opa'
|
|
54
58
|
phl_opa = PHLopa::API.new
|
|
55
|
-
phl_opa.
|
|
59
|
+
phl_opa.search_by_address('1234 Market St')
|
|
56
60
|
|
|
57
61
|
Response
|
|
58
62
|
|
|
@@ -76,6 +80,96 @@ Response
|
|
|
76
80
|
geometry: {
|
|
77
81
|
...
|
|
78
82
|
|
|
83
|
+
**#search_by_block**
|
|
84
|
+
|
|
85
|
+
Searches for properties that are located on the provided block. In the response, the `data.properties` key is always an array, even if there is only one result.
|
|
86
|
+
|
|
87
|
+
require 'phl_opa'
|
|
88
|
+
phl_opa = PHLopa::API.new
|
|
89
|
+
phl_opa.search_by_block('1234 Market St')
|
|
90
|
+
|
|
91
|
+
Response
|
|
92
|
+
|
|
93
|
+
{
|
|
94
|
+
status: "success",
|
|
95
|
+
total: 3,
|
|
96
|
+
data: {
|
|
97
|
+
properties: [{
|
|
98
|
+
property_id: "5356001200",
|
|
99
|
+
account_number: "883705320",
|
|
100
|
+
full_address: "1200 MARKET ST",
|
|
101
|
+
unit: "",
|
|
102
|
+
zip: "191073615",
|
|
103
|
+
address_match: {
|
|
104
|
+
original: "1200-1298 market st",
|
|
105
|
+
standardized: "1200 MARKET ST",
|
|
106
|
+
similarity: 100,
|
|
107
|
+
match_code: "",
|
|
108
|
+
match_type: "MA"
|
|
109
|
+
},
|
|
110
|
+
geometry: {
|
|
111
|
+
...
|
|
112
|
+
|
|
113
|
+
**#search_by_intersection**
|
|
114
|
+
|
|
115
|
+
Searches for properties that are near the provided the intersection. In the response, the `data.properties` key is always an array, even if there is only one result.
|
|
116
|
+
|
|
117
|
+
require 'phl_opa'
|
|
118
|
+
phl_opa = PHLopa::API.new
|
|
119
|
+
phl_opa.search_by_intersection('Market St', '12th')
|
|
120
|
+
|
|
121
|
+
Response
|
|
122
|
+
|
|
123
|
+
{
|
|
124
|
+
status: "success",
|
|
125
|
+
total: 5,
|
|
126
|
+
data: {
|
|
127
|
+
properties: [{
|
|
128
|
+
property_id: "53560011130000001",
|
|
129
|
+
account_number: "883705100",
|
|
130
|
+
full_address: "1113 MARKET ST",
|
|
131
|
+
unit: "0000001",
|
|
132
|
+
zip: "19107-2901",
|
|
133
|
+
address_match: {
|
|
134
|
+
original: null,
|
|
135
|
+
standardized: null,
|
|
136
|
+
similarity: null,
|
|
137
|
+
match_code: null,
|
|
138
|
+
match_type: null
|
|
139
|
+
},
|
|
140
|
+
geometry: {
|
|
141
|
+
...
|
|
142
|
+
|
|
143
|
+
**#search_nearby**
|
|
144
|
+
|
|
145
|
+
Searches for properties that are near the provide latitude/longitude coordinate, and within the provided radius. The default distance for `radius` is 200 feet, and is not required. In the response, the `data.properties` key is always an array, even if there is only one result.
|
|
146
|
+
|
|
147
|
+
require 'phl_opa'
|
|
148
|
+
phl_opa = PHLopa::API.new
|
|
149
|
+
phl_opa.search_nearby(-75.16097, 39.95166, 400)
|
|
150
|
+
|
|
151
|
+
Response
|
|
152
|
+
|
|
153
|
+
{
|
|
154
|
+
status: "success",
|
|
155
|
+
total: 25,
|
|
156
|
+
data: {
|
|
157
|
+
properties: [{
|
|
158
|
+
property_id: "5356001200",
|
|
159
|
+
account_number: "883705320",
|
|
160
|
+
full_address: "1200 MARKET ST",
|
|
161
|
+
unit: "",
|
|
162
|
+
zip: "191073615",
|
|
163
|
+
address_match: {
|
|
164
|
+
original: null,
|
|
165
|
+
standardized: null,
|
|
166
|
+
similarity: null,
|
|
167
|
+
match_code: null,
|
|
168
|
+
match_type: null
|
|
169
|
+
},
|
|
170
|
+
geometry: {
|
|
171
|
+
...
|
|
172
|
+
|
|
79
173
|
## Contributing
|
|
80
174
|
|
|
81
175
|
1. Fork it
|
data/lib/phl_opa/api.rb
CHANGED
|
@@ -24,7 +24,7 @@ module PHLopa
|
|
|
24
24
|
data
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def
|
|
27
|
+
def search_by_address(address=nil)
|
|
28
28
|
raise ArgumentError("Address must be a string") unless address.is_a? String
|
|
29
29
|
|
|
30
30
|
response = invoke_api('address/', address + '/')
|
|
@@ -33,6 +33,39 @@ module PHLopa
|
|
|
33
33
|
data
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
def search_by_block(block=nil)
|
|
37
|
+
raise ArgumentError("Block must be a string") unless block.is_a? String
|
|
38
|
+
|
|
39
|
+
response = invoke_api('block/', block + '/')
|
|
40
|
+
data = parse_response(response)
|
|
41
|
+
|
|
42
|
+
data
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def search_by_intersection(street_a=nil, street_b=nil)
|
|
46
|
+
raise ArgumentError("Street_a must be a string") unless street_a.is_a? String
|
|
47
|
+
raise ArgumentError("Street_b must be a string") unless street_b.is_a? String
|
|
48
|
+
if (street_a.nil? || street_b.nil?); raise ArgumentError("Both parameters are required") end
|
|
49
|
+
|
|
50
|
+
response = invoke_api('intersection/', street_a + '/' + street_b)
|
|
51
|
+
data = parse_response(response)
|
|
52
|
+
|
|
53
|
+
data
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def search_nearby(lat=nil, lng=nil, radius=200)
|
|
57
|
+
raise ArgumentError("Latitude must be a number") unless lat.is_a? Float
|
|
58
|
+
raise ArgumentError("Longitude must be a number") unless lng.is_a? Float
|
|
59
|
+
raise ArgumentError("Radius must be a number") unless radius.is_a? Fixnum
|
|
60
|
+
raise ArgumentError("Radius must be a positive number") unless radius > 0
|
|
61
|
+
if (lat.nil? || lng.nil?); raise ArgumentError("Both latitude and longitude are required") end
|
|
62
|
+
|
|
63
|
+
response = invoke_api('nearby/', "#{lng}/#{lat}/#{radius}")
|
|
64
|
+
data = parse_response(response)
|
|
65
|
+
|
|
66
|
+
data
|
|
67
|
+
end
|
|
68
|
+
|
|
36
69
|
def parse_response(response)
|
|
37
70
|
json = JSON.parse(response.body)
|
|
38
71
|
|
data/lib/phl_opa/version.rb
CHANGED
data/spec/lib/phl_opa_spec.rb
CHANGED
|
@@ -33,18 +33,84 @@ describe PHLopa do
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
describe "#
|
|
36
|
+
describe "#search_by_address" do
|
|
37
37
|
before :each do
|
|
38
38
|
@phl_opa = PHLopa::API.new
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "returns the property details for the adress that is passed" do
|
|
42
|
-
@phl_opa.
|
|
42
|
+
@phl_opa.search_by_address('1234 Market St')['data']['properties'][0]['account_number'] = '883309000'
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "raises an error if the address argument is not a string" do
|
|
46
|
-
lambda { @phl_opa.
|
|
47
|
-
lambda { @phl_opa.
|
|
46
|
+
lambda { @phl_opa.search_by_address(123456780) }.should raise_error
|
|
47
|
+
lambda { @phl_opa.search_by_address(['1234 Market St']) }.should raise_error
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
|
+
|
|
51
|
+
describe "#search_by_block" do
|
|
52
|
+
before :each do
|
|
53
|
+
@phl_opa = PHLopa::API.new
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "returns the property details for all the properties on the searched block" do
|
|
57
|
+
@phl_opa.search_by_block('1200 Market St')['total'] = 3
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "raises an error if the address argument is not a string" do
|
|
61
|
+
lambda { @phl_opa.search_by_block(123456780) }.should raise_error
|
|
62
|
+
lambda { @phl_opa.search_by_block(['1234 Market St']) }.should raise_error
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe "#search_by_intersection" do
|
|
67
|
+
before :each do
|
|
68
|
+
@phl_opa = PHLopa::API.new
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "returns the property details for all the properties near the provided intersection" do
|
|
72
|
+
@phl_opa.search_by_intersection('12th', 'Market')['total'] = 5
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "raises an error if the address argument is not a string" do
|
|
76
|
+
lambda { @phl_opa.search_by_intersection(12, 'Market') }.should raise_error
|
|
77
|
+
lambda { @phl_opa.search_by_intersection('Market', 12) }.should raise_error
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "raises an error if either of the street arguments are nil" do
|
|
81
|
+
lambda { @phl_opa.search_by_intersection('Market') }.should raise_error
|
|
82
|
+
lambda { @phl_opa.search_by_intersection(nil, 'Market') }.should raise_error
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "#search_nearby" do
|
|
87
|
+
before :each do
|
|
88
|
+
@phl_opa = PHLopa::API.new
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "returns the property details for all the properties near the provided point and within the provided radius" do
|
|
92
|
+
@phl_opa.search_nearby(39.95166, -75.16097, 400)['total'] = 25
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "does not require that the user sets the radius argument" do
|
|
96
|
+
@phl_opa.search_nearby(39.95166, -75.16097)['total'] = 4
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "raises an error if the radius argument is not a positive number" do
|
|
100
|
+
lambda { @phl_opa.search_nearby(39.95166, -75.16097, -100) }.should raise_error
|
|
101
|
+
lambda { @phl_opa.search_nearby(39.95166, -75.16097, '1000') }.should raise_error
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "raises an error if either the latitude or longitude arguments are nil" do
|
|
105
|
+
lambda { @phl_opa.search_nearby(nil, -75.16097, 100) }.should raise_error
|
|
106
|
+
lambda { @phl_opa.search_nearby(39.95166, nil, 100) }.should raise_error
|
|
107
|
+
lambda { @phl_opa.search_nearby(nil, nil, 100) }.should raise_error
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "raises an error if either the latitude or longitude arguments are not numbers" do
|
|
111
|
+
lambda { @phl_opa.search_nearby(39.95166, '-75.16097', 100) }.should raise_error
|
|
112
|
+
lambda { @phl_opa.search_nearby('39.95166', -75.16097, 100) }.should raise_error
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
50
116
|
end
|