phl-opa 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.travis.yml +3 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +85 -0
- data/Rakefile +6 -0
- data/lib/phl_opa.rb +2 -0
- data/lib/phl_opa/api.rb +49 -0
- data/lib/phl_opa/version.rb +3 -0
- data/phl-opa.gemspec +23 -0
- data/spec/lib/phl_opa_spec.rb +50 -0
- data/spec/spec_helper.rb +8 -0
- metadata +92 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Casey Thomas
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/caseypt/phl-opa.png?branch=master)](https://travis-ci.org/caseypt/phl-opa)
|
2
|
+
|
3
|
+
# PHL-opa
|
4
|
+
|
5
|
+
A thin wrapper for the Philadelphia Office of Property Assessment API
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'phl_opa'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install phl_opa
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Search by account number
|
24
|
+
|
25
|
+
require 'phl_opa'
|
26
|
+
phl_opa = PHLopa::API.new
|
27
|
+
phl_opa.get_by_account(883309000)
|
28
|
+
|
29
|
+
Response:
|
30
|
+
|
31
|
+
{
|
32
|
+
status: "success",
|
33
|
+
data: {
|
34
|
+
property: {
|
35
|
+
property_id: "5356001234",
|
36
|
+
account_number: "883309000",
|
37
|
+
full_address: "1234 MARKET ST",
|
38
|
+
unit: "",
|
39
|
+
zip: "19107-3615",
|
40
|
+
geometry: {
|
41
|
+
x: -75.16097581817294,
|
42
|
+
y: 39.95166185436387
|
43
|
+
},
|
44
|
+
ownership: {
|
45
|
+
owners: [
|
46
|
+
"SEPTA"
|
47
|
+
],
|
48
|
+
}
|
49
|
+
...
|
50
|
+
|
51
|
+
Search by address
|
52
|
+
|
53
|
+
require 'phl_opa'
|
54
|
+
phl_opa = PHLopa::API.new
|
55
|
+
phl_opa.get_by_address('1234 Market St')
|
56
|
+
|
57
|
+
Response
|
58
|
+
|
59
|
+
{
|
60
|
+
status: "success",
|
61
|
+
total: 1,
|
62
|
+
data: {
|
63
|
+
properties: [{
|
64
|
+
property_id: "5356001234",
|
65
|
+
account_number: "883309000",
|
66
|
+
full_address: "1234 MARKET ST",
|
67
|
+
unit: "",
|
68
|
+
zip: "19107-3615",
|
69
|
+
address_match: {
|
70
|
+
original: "1234 market st",
|
71
|
+
standardized: "1234 MARKET ST",
|
72
|
+
similarity: 100,
|
73
|
+
match_code: "",
|
74
|
+
match_type: "MA"
|
75
|
+
},
|
76
|
+
geometry: {
|
77
|
+
...
|
78
|
+
|
79
|
+
## Contributing
|
80
|
+
|
81
|
+
1. Fork it
|
82
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
83
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
84
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
85
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/phl_opa.rb
ADDED
data/lib/phl_opa/api.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "json"
|
2
|
+
require "open-uri"
|
3
|
+
require "net/http"
|
4
|
+
|
5
|
+
module PHLopa
|
6
|
+
class API
|
7
|
+
attr_accessor :settings
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
@settings = {
|
11
|
+
:api_base => "http://api.phila.gov/opa/v1.0/",
|
12
|
+
:default_query_string => "?format=json"
|
13
|
+
}.merge(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_by_account(account=nil)
|
17
|
+
raise ArgumentError("Account Number must be 9 digits long") unless account.length == 9
|
18
|
+
raise ArgumentError("Account Number must be a string") unless account.is_a? String
|
19
|
+
raise ArgumentError("Account Number must be made up only of numbers") unless account !~ /\D/
|
20
|
+
|
21
|
+
response = invoke_api('account/', account)
|
22
|
+
data = parse_response(response)
|
23
|
+
|
24
|
+
data
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_by_address(address=nil)
|
28
|
+
raise ArgumentError("Address must be a string") unless address.is_a? String
|
29
|
+
|
30
|
+
response = invoke_api('address/', address + '/')
|
31
|
+
data = parse_response(response)
|
32
|
+
|
33
|
+
data
|
34
|
+
end
|
35
|
+
|
36
|
+
def parse_response(response)
|
37
|
+
json = JSON.parse(response.body)
|
38
|
+
|
39
|
+
json
|
40
|
+
end
|
41
|
+
|
42
|
+
def invoke_api(path, parameter)
|
43
|
+
encoded = URI::encode(parameter)
|
44
|
+
url = URI.parse("#{@settings[:api_base]}#{path}#{encoded}#{@settings[:default_query_string]}")
|
45
|
+
|
46
|
+
Net::HTTP.get_response(url)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/phl-opa.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'phl_opa/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "phl-opa"
|
8
|
+
spec.version = PHLopa::VERSION
|
9
|
+
spec.authors = ["Casey Thomas"]
|
10
|
+
spec.email = ["cpthomas@gmail.com"]
|
11
|
+
spec.description = %q{A thin wrapper for the Philadelphia Office of Property Assessment API}
|
12
|
+
spec.summary = %q{Get information about properties in Philadelphia}
|
13
|
+
spec.homepage = "https://www.github.com/caseypt/phl-opa"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PHLopa do
|
4
|
+
|
5
|
+
describe "#new" do
|
6
|
+
before :each do
|
7
|
+
@phl_opa = PHLopa::API.new
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#get_by_account" do
|
12
|
+
before :each do
|
13
|
+
@phl_opa = PHLopa::API.new
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns the property details for the OPA account that is passed" do
|
17
|
+
@phl_opa.get_by_account('883309000')['data']['property']['full_address'] = '1234 MARKET ST'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "raises an error if the account argument is not a string" do
|
21
|
+
lambda { @phl_opa.get_by_account(123456780) }.should raise_error
|
22
|
+
lambda { @phl_opa.get_by_account([123456780]) }.should raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
it "raises an error if the length of the account argument is not exactly 9" do
|
26
|
+
lambda { @phl_opa.get_by_account('12345678') }.should raise_error
|
27
|
+
lambda { @phl_opa.get_by_account('12345678910') }.should raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises an error if the account argument contains anything but numbers" do
|
31
|
+
lambda { @phl_opa.get_by_account('123456780z') }.should raise_error
|
32
|
+
lambda { @phl_opa.get_by_account('12345ddfdf6780') }.should raise_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#get_by_address" do
|
37
|
+
before :each do
|
38
|
+
@phl_opa = PHLopa::API.new
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns the property details for the adress that is passed" do
|
42
|
+
@phl_opa.get_by_address('1234 Market St')['data']['properties'][0]['account_number'] = '883309000'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises an error if the address argument is not a string" do
|
46
|
+
lambda { @phl_opa.get_by_address(123456780) }.should raise_error
|
47
|
+
lambda { @phl_opa.get_by_address(['1234 Market St']) }.should raise_error
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phl-opa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Casey Thomas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A thin wrapper for the Philadelphia Office of Property Assessment API
|
47
|
+
email:
|
48
|
+
- cpthomas@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .travis.yml
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/phl_opa.rb
|
60
|
+
- lib/phl_opa/api.rb
|
61
|
+
- lib/phl_opa/version.rb
|
62
|
+
- phl-opa.gemspec
|
63
|
+
- spec/lib/phl_opa_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: https://www.github.com/caseypt/phl-opa
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.23
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Get information about properties in Philadelphia
|
90
|
+
test_files:
|
91
|
+
- spec/lib/phl_opa_spec.rb
|
92
|
+
- spec/spec_helper.rb
|