abn_search 0.0.7 → 0.0.9
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +18 -0
- data/README.rdoc +12 -13
- data/Rakefile +4 -0
- data/lib/abn/client.rb +131 -0
- data/lib/abn/entity.rb +38 -0
- data/lib/abn/version.rb +3 -0
- data/lib/abn_search.rb +12 -183
- metadata +22 -28
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -50
- data/abn_search.gemspec +0 -22
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e2cdf6d43d282a188598c853e79ea6caa373f914
|
4
|
+
data.tar.gz: b317c0ded615ff15c7b2ae0970f5269d0d407a0a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 43c1eab4f8285c10e08b71adbdd445c15d5bd57e4327360613cc6f511e6964f5070f320a220a680521779ab1f3f1e04df456bc6598324e86836527b7dab884db
|
7
|
+
data.tar.gz: 233aa630faf93ffced1dbc4b3d6ab807d7d3c2e28f0680d04d11dc05c07290d34a1cf45818ad3b5880c8c810e1188be36174783fc1a6edf511d0307d22bb4322
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
2
|
+
a copy of this software and associated documentation files (the
|
3
|
+
"Software"), to deal in the Software without restriction, including
|
4
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
5
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
6
|
+
permit persons to whom the Software is furnished to do so, subject to
|
7
|
+
the following conditions:
|
8
|
+
|
9
|
+
The above copyright notice and this permission notice shall be
|
10
|
+
included in all copies or substantial portions of the Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
13
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
14
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
15
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
16
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
17
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
18
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
=== Important: Gem has been updated to support searching the Australian Business Registry (ABR) by name as well as abn. The syntax to call and validate ABN's has changed!
|
2
|
-
|
3
1
|
A simple ABN search library for validating and obtaining ABN details from the Australian Business Register.
|
4
2
|
|
5
|
-
|
6
|
-
http://
|
3
|
+
You will need a GUID to be able to use the ABR business lookup API. You can obtain one at the following link;
|
4
|
+
http://abr.business.gov.au/Documentation/UserGuideWebRegistration.aspx
|
7
5
|
|
8
|
-
= Rails
|
6
|
+
= Rails Installation
|
9
7
|
|
10
8
|
Simply add the following line to your Gemfile and run bundle install.
|
11
9
|
|
@@ -16,8 +14,8 @@ Simply add the following line to your Gemfile and run bundle install.
|
|
16
14
|
require 'abn_search'
|
17
15
|
|
18
16
|
# Search by ABN Number
|
19
|
-
|
20
|
-
result =
|
17
|
+
client = Abn::Search.new("YOUR_GUID_HERE")
|
18
|
+
result = client.search("59001215354")
|
21
19
|
=> {:acn=>"001215354", ":abn=>"59001215354", :entity_type=>"Australian Public Company", :status=>"Active", :main_name=>"SONY AUSTRALIA LIMITED", :trading_name=>"", :legal_name=>"", :other_trading_name=>"", :name=>"SONY AUSTRALIA LIMITED"}
|
22
20
|
|
23
21
|
puts result[:entity_type]
|
@@ -30,21 +28,22 @@ Simply add the following line to your Gemfile and run bundle install.
|
|
30
28
|
=> "SONY AUSTRALIA LIMITED"
|
31
29
|
|
32
30
|
# Search by ACN Number
|
33
|
-
result =
|
31
|
+
result = client.search_by_acn("001215354")
|
34
32
|
=> {:acn=>"001215354", ":abn=>"59001215354", :entity_type=>"Australian Public Company", :status=>"Active", :main_name=>"SONY AUSTRALIA LIMITED", :trading_name=>"", :legal_name=>"", :other_trading_name=>"", :name=>"SONY AUSTRALIA LIMITED"}
|
35
33
|
|
36
34
|
# Search by name
|
37
|
-
results =
|
38
|
-
|
39
|
-
|
35
|
+
results = client.search_by_name("Sony", ['NSW'], '2000')
|
36
|
+
results.each do |result|
|
37
|
+
puts result[:name]
|
38
|
+
end
|
40
39
|
|
41
40
|
= Errors
|
42
41
|
If an ABN is missing, invalid or expired - check the errors attribute.
|
43
42
|
|
44
|
-
|
43
|
+
client.errors
|
45
44
|
=> ["Business ABN 89107860122 has expired."]
|
46
45
|
|
47
46
|
= Notes
|
48
47
|
- Australian Business Register: http://www.abr.business.gov.au/
|
49
48
|
- XML API: http://abr.business.gov.au/ABRXMLSearch/AbrXmlSearch.asmx
|
50
|
-
- GUID Registration link: http://
|
49
|
+
- GUID Registration link: http://abr.business.gov.au/Documentation/UserGuideWebRegistration.aspx
|
data/Rakefile
CHANGED
data/lib/abn/client.rb
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
module Abn
|
2
|
+
|
3
|
+
class Client
|
4
|
+
attr_accessor :errors, :guid, :proxy, :client_options
|
5
|
+
|
6
|
+
# Setup a new instance of the ABN search class.
|
7
|
+
#
|
8
|
+
# @param [String] guid - the ABR GUID for Web Services access
|
9
|
+
# @param [Hash] options - options detailed below
|
10
|
+
# @option options [String] :proxy Proxy URL string if required (Example: http://user:pass@host.example.com:443)
|
11
|
+
# @return [ABNSearch]
|
12
|
+
def initialize(guid=nil, options = {})
|
13
|
+
self.errors = []
|
14
|
+
self.guid = guid unless guid.nil?
|
15
|
+
self.proxy = options[:proxy] || nil
|
16
|
+
self.client_options = {}
|
17
|
+
self.client_options = { :wsdl => "http://www.abn.business.gov.au/abrxmlsearch/ABRXMLSearch.asmx?WSDL" }
|
18
|
+
self.client_options.merge!({ :proxy => self.proxy }) unless self.proxy.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
# Performs an ABR search for the ABN setup upon initialization
|
22
|
+
#
|
23
|
+
# @param [String] acn - the acn you wish to search for
|
24
|
+
# @return [Hash] search result in a hash
|
25
|
+
def search_by_acn(acn)
|
26
|
+
self.errors << "No ACN provided." && return if acn.nil?
|
27
|
+
self.errors << "No GUID provided. Please obtain one at - http://www.abr.business.gov.au/Webservices.aspx" && return if self.guid.nil?
|
28
|
+
|
29
|
+
begin
|
30
|
+
client = Savon.client(self.client_options)
|
31
|
+
response = client.call(:abr_search_by_asic, message: { authenticationGuid: self.guid, searchString: acn.gsub(" ", ""), includeHistoricalDetails: "N" })
|
32
|
+
result = response.body[:abr_search_by_asic_response][:abr_payload_search_results][:response][:business_entity]
|
33
|
+
return parse_search_result(result)
|
34
|
+
rescue => ex
|
35
|
+
self.errors << ex.to_s
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Performs an ABR search for the ABN setup upon initialization
|
40
|
+
#
|
41
|
+
# @param [String] abn - the abn you wish to search for
|
42
|
+
# @return [Hash] search result in a hash
|
43
|
+
def search(abn)
|
44
|
+
self.errors << "No ABN provided." && return if abn.nil?
|
45
|
+
self.errors << "No GUID provided. Please obtain one at - http://www.abr.business.gov.au/Webservices.aspx" && return if self.guid.nil?
|
46
|
+
|
47
|
+
begin
|
48
|
+
client = Savon.client(self.client_options)
|
49
|
+
response = client.call(:abr_search_by_abn, message: { authenticationGuid: guid, searchString: abn.gsub(" ", ""), includeHistoricalDetails: "N" })
|
50
|
+
result = response.body[:abr_search_by_abn_response][:abr_payload_search_results][:response][:business_entity]
|
51
|
+
return parse_search_result(result)
|
52
|
+
rescue => ex
|
53
|
+
self.errors << ex.to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Searches the ABR registry by name. Simply pass in the search term and which state(s) to search in.
|
58
|
+
#
|
59
|
+
# @param [String] name - the search term
|
60
|
+
# @param [Array] states - a list of states that you wish to filter by
|
61
|
+
# @param [String] postcode - the postcode you wish to filter by
|
62
|
+
# @return [Array] search results in an array
|
63
|
+
def search_by_name(name, states=["NSW"], postcode="ALL")
|
64
|
+
|
65
|
+
begin
|
66
|
+
client = Savon.client(self.client_options)
|
67
|
+
request = {
|
68
|
+
externalNameSearch: {
|
69
|
+
authenticationGuid: self.guid, name: name,
|
70
|
+
filters: {
|
71
|
+
nameType: {
|
72
|
+
tradingName: "Y", legalName: "Y"
|
73
|
+
},
|
74
|
+
postcode: postcode,
|
75
|
+
"stateCode" => {
|
76
|
+
"QLD" => states.include?("QLD") ? "Y" : "N",
|
77
|
+
"NT" => states.include?("NT") ? "Y" : "N",
|
78
|
+
"SA" => states.include?("SA") ? "Y" : "N",
|
79
|
+
"WA" => states.include?("WA") ? "Y" : "N",
|
80
|
+
"VIC" => states.include?("VIC") ? "Y" : "N",
|
81
|
+
"ACT" => states.include?("ACT") ? "Y" : "N",
|
82
|
+
"TAS" => states.include?("TAS") ? "Y" : "N",
|
83
|
+
"NSW" => states.include?("NSW") ? "Y" : "N"
|
84
|
+
}
|
85
|
+
}
|
86
|
+
},
|
87
|
+
authenticationGuid: self.guid
|
88
|
+
}
|
89
|
+
|
90
|
+
response = client.call(:abr_search_by_name, message: request)
|
91
|
+
result_list = response.body[:abr_search_by_name_response][:abr_payload_search_results][:response][:search_results_list]
|
92
|
+
|
93
|
+
if result_list.blank?
|
94
|
+
return []
|
95
|
+
else
|
96
|
+
results = response.body[:abr_search_by_name_response][:abr_payload_search_results][:response][:search_results_list][:search_results_record]
|
97
|
+
return [parse_search_result(results)] if !results.is_a?(Array)
|
98
|
+
return results.map do |r| parse_search_result(r) end
|
99
|
+
end
|
100
|
+
rescue => ex
|
101
|
+
self.errors << ex.to_s
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def parse_search_result(result)
|
106
|
+
entity = Abn::Entity.new
|
107
|
+
entity.acn = result[:asic_number] rescue nil
|
108
|
+
entity.abn = result[:abn][:identifier_value] rescue nil
|
109
|
+
entity.entity_type = result[:entity_type][:entity_description] rescue nil
|
110
|
+
entity.status = result[:entity_status][:entity_status_code] rescue nil
|
111
|
+
entity.main_name = result[:main_name][:organisation_name] rescue nil
|
112
|
+
entity.trading_name = result[:main_trading_name][:organisation_name] rescue nil
|
113
|
+
entity.legal_name = "#{result[:legal_name][:given_name]} #{result[:legal_name][:family_name]}" rescue nil
|
114
|
+
entity.legal_name2 = result[:full_name] rescue nil
|
115
|
+
entity.other_trading_name = result[:other_trading_name][:organisation_name] rescue nil
|
116
|
+
entity.active_from_date = result[:entity_status][:effective_from] rescue nil
|
117
|
+
entity.address_state_code = result[:main_business_physical_address][:state_code] rescue nil
|
118
|
+
entity.address_post_code = result[:main_business_physical_address][:postcode] rescue nil
|
119
|
+
entity.address_from_date = result[:main_business_physical_address][:effective_from] rescue nil
|
120
|
+
entity.last_updated = result[:record_last_updated_date] rescue nil
|
121
|
+
entity.gst_from_date = result[:goods_and_services_tax][:effective_from] rescue nil
|
122
|
+
entity.name = entity.best_name
|
123
|
+
return entity.instance_values
|
124
|
+
end
|
125
|
+
|
126
|
+
def valid?
|
127
|
+
self.errors.size == 0
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
data/lib/abn/entity.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Abn
|
2
|
+
|
3
|
+
class Entity
|
4
|
+
attr_accessor :acn, :abn, :name, :entity_type, :status, :main_name, :trading_name, :legal_name, :legal_name2, :other_trading_name, :active_from_date, :address_state_code, :address_post_code, :address_from_date, :last_updated, :gst_from_date
|
5
|
+
|
6
|
+
@acn = nil
|
7
|
+
@abn = nil
|
8
|
+
@name = nil
|
9
|
+
@entity_type = nil
|
10
|
+
@status = nil
|
11
|
+
@main_name = nil
|
12
|
+
@trading_name = nil
|
13
|
+
@legal_name = nil
|
14
|
+
@legal_name2 = nil
|
15
|
+
@other_trading_name = nil
|
16
|
+
@active_from_date = nil
|
17
|
+
@address_state_code = nil
|
18
|
+
@address_post_code = nil
|
19
|
+
@address_from_date = nil
|
20
|
+
@last_updated = nil
|
21
|
+
@gst_from_date = nil
|
22
|
+
|
23
|
+
# Choose the most relevant business name
|
24
|
+
#
|
25
|
+
# @return [String] business name
|
26
|
+
def best_name
|
27
|
+
@trading_name || @other_trading_name || @main_name || @legal_name || @legal_name2 || 'Name unknown'
|
28
|
+
end
|
29
|
+
|
30
|
+
# Return the values in a hash. Stolen from ActiveSupport
|
31
|
+
#
|
32
|
+
# @return [Hash] object attributes
|
33
|
+
def instance_values
|
34
|
+
Hash[instance_variables.map { |name| [name[1..-1].to_sym, instance_variable_get(name)] }]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/abn/version.rb
ADDED
data/lib/abn_search.rb
CHANGED
@@ -1,195 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# Request examples;
|
5
|
-
#
|
6
|
-
# Search by ABN number
|
7
|
-
# > a = ABNSearch.new("your-guid")
|
8
|
-
# > result = a.search("56206894472")
|
9
|
-
#
|
10
|
-
# Search by name and return an array of results
|
11
|
-
# > a = ABNSearch.new("your-guid")
|
12
|
-
# > result = a.search_by_name("Sony", ['NSW', 'VIC'])
|
13
|
-
#
|
14
|
-
|
15
|
-
require 'savon'
|
1
|
+
require "savon"
|
2
|
+
require "abn/client"
|
3
|
+
require "abn/entity"
|
16
4
|
|
5
|
+
# Backwards compatibility funtimes.
|
17
6
|
class ABNSearch
|
7
|
+
@fowarder = nil
|
18
8
|
|
19
|
-
module Version
|
20
|
-
VERSION = "0.0.6"
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_accessor :errors, :guid, :proxy, :client_options
|
24
|
-
|
25
|
-
# Setup a new instance of the ABN search class.
|
26
|
-
#
|
27
|
-
# @param [String] guid - the ABR GUID for Web Services access
|
28
|
-
# @param [Hash] options - options detailed below
|
29
|
-
# @option options [String] :proxy Proxy URL string if required (Example: http://user:pass@host.example.com:443)
|
30
|
-
# @return [ABNSearch]
|
31
|
-
#
|
32
9
|
def initialize(guid=nil, options = {})
|
33
|
-
|
34
|
-
self.guid = guid unless guid.nil?
|
35
|
-
self.proxy = options[:proxy] || nil
|
36
|
-
self.client_options = {}
|
37
|
-
self.client_options = { :wsdl => "http://www.abn.business.gov.au/abrxmlsearch/ABRXMLSearch.asmx?WSDL" }
|
38
|
-
self.client_options.merge!({ :proxy => self.proxy }) unless self.proxy.nil?
|
10
|
+
@fowarder = Abn::Client.new(guid, options)
|
39
11
|
end
|
40
12
|
|
41
|
-
# Performs an ABR search for the ABN setup upon initialization
|
42
|
-
#
|
43
|
-
# @param [String] acn - the acn you wish to search for
|
44
|
-
# @return [ABNSearch] search results in class instance
|
45
13
|
def search_by_acn(acn)
|
46
|
-
|
47
|
-
self.errors << "No GUID provided. Please obtain one at - http://www.abr.business.gov.au/Webservices.aspx" && return if self.guid.nil?
|
48
|
-
|
49
|
-
begin
|
50
|
-
client = Savon.client(self.client_options)
|
51
|
-
|
52
|
-
response = client.call(:abr_search_by_asic, message: { authenticationGuid: self.guid, searchString: acn.gsub(" ", ""), includeHistoricalDetails: "N" })
|
53
|
-
# puts "First response: #{response}"
|
54
|
-
result = response.body[:abr_search_by_asic_response][:abr_payload_search_results][:response][:business_entity]
|
55
|
-
# puts "Filtered result: #{result}"
|
56
|
-
# puts "ABN: #{(result[:abn][:identifier_value] rescue "")}"
|
57
|
-
# puts "Entity Type: #{(result[:entity_type][:entity_description] rescue "")}"
|
58
|
-
# puts "Status: #{(result[:entity_status][:entity_status_code] rescue "")}"
|
59
|
-
# puts "Main name: #{(result[:main_name][:organisation_name] rescue "")}"
|
60
|
-
# puts "Trading name: #{(result[:main_trading_name][:organisation_name] rescue "")}"
|
61
|
-
# puts "Legal name: #{(result[:legal_name][:full_name] rescue "")}"
|
62
|
-
# puts "Other Trading name: #{(result[:other_trading_name][:organisation_name] rescue "")}"
|
63
|
-
# puts "Active from date: #{(result[:entity_status][:effective_from] rescue "")}"
|
64
|
-
# puts "Address state code: #{(result[:main_business_physical_address][:state_code] rescue "")}"
|
65
|
-
# puts "Address post code: #{(result[:main_business_physical_address][:postcode] rescue "")}"
|
66
|
-
# puts "Address from date: #{(result[:main_business_physical_address][:effective_from] rescue "")}"
|
67
|
-
|
68
|
-
return parse_search_result(result)
|
69
|
-
rescue => ex
|
70
|
-
self.errors << ex.to_s
|
71
|
-
end
|
14
|
+
@fowarder.search_by_acn(acn)
|
72
15
|
end
|
73
16
|
|
74
|
-
|
75
|
-
|
76
|
-
# @param [String] abn - the abn you wish to search for
|
77
|
-
# @return [ABNSearch] search results in class instance
|
78
|
-
def search(abn)
|
79
|
-
self.errors << "No ABN provided." && return if abn.nil?
|
80
|
-
self.errors << "No GUID provided. Please obtain one at - http://www.abr.business.gov.au/Webservices.aspx" && return if self.guid.nil?
|
81
|
-
|
82
|
-
begin
|
83
|
-
client = Savon.client(self.client_options)
|
84
|
-
|
85
|
-
response = client.call(:abr_search_by_abn, message: { authenticationGuid: self.guid, searchString: abn.gsub(" ", ""), includeHistoricalDetails: "N" })
|
86
|
-
# puts "First response: #{response}"
|
87
|
-
result = response.body[:abr_search_by_abn_response][:abr_payload_search_results][:response][:business_entity]
|
88
|
-
# puts "Filtered result: #{result}"
|
89
|
-
# puts "ABN: #{(result[:abn][:identifier_value] rescue "")}"
|
90
|
-
# puts "Entity Type: #{(result[:entity_type][:entity_description] rescue "")}"
|
91
|
-
# puts "Status: #{(result[:entity_status][:entity_status_code] rescue "")}"
|
92
|
-
# puts "Main name: #{(result[:main_name][:organisation_name] rescue "")}"
|
93
|
-
# puts "Trading name: #{(result[:main_trading_name][:organisation_name] rescue "")}"
|
94
|
-
# puts "Legal name: #{(result[:legal_name][:full_name] rescue "")}"
|
95
|
-
# puts "Other Trading name: #{(result[:other_trading_name][:organisation_name] rescue "")}"
|
96
|
-
# puts "Active from date: #{(result[:entity_status][:effective_from] rescue "")}"
|
97
|
-
# puts "Address state code: #{(result[:main_business_physical_address][:state_code] rescue "")}"
|
98
|
-
# puts "Address post code: #{(result[:main_business_physical_address][:postcode] rescue "")}"
|
99
|
-
# puts "Address from date: #{(result[:main_business_physical_address][:effective_from] rescue "")}"
|
100
|
-
|
101
|
-
return parse_search_result(result)
|
102
|
-
rescue => ex
|
103
|
-
self.errors << ex.to_s
|
104
|
-
end
|
17
|
+
def search_by_name(name, states=["NSW"], postcode="ALL")
|
18
|
+
@fowarder.search_by_name(name, states, postcode)
|
105
19
|
end
|
106
20
|
|
107
|
-
|
108
|
-
|
109
|
-
# @param [String] name - the search term
|
110
|
-
# @param [Array] states - a list of states that you wish to filter by
|
111
|
-
# @param [String] postcode - the postcode you wish to filter by
|
112
|
-
def search_by_name(name, states=['NSW'], postcode='ALL')
|
113
|
-
|
114
|
-
begin
|
115
|
-
client = Savon.client(self.client_options)
|
116
|
-
request = {
|
117
|
-
externalNameSearch: {
|
118
|
-
authenticationGuid: self.guid, name: name,
|
119
|
-
filters: {
|
120
|
-
nameType: {
|
121
|
-
tradingName: 'Y', legalName: 'Y'
|
122
|
-
},
|
123
|
-
postcode: postcode,
|
124
|
-
"stateCode" => {
|
125
|
-
'QLD' => states.include?('QLD') ? "Y" : "N",
|
126
|
-
'NT' => states.include?('NT') ? "Y" : "N",
|
127
|
-
'SA' => states.include?('SA') ? "Y" : "N",
|
128
|
-
'WA' => states.include?('WA') ? "Y" : "N",
|
129
|
-
'VIC' => states.include?('VIC') ? "Y" : "N",
|
130
|
-
'ACT' => states.include?('ACT') ? "Y" : "N",
|
131
|
-
'TAS' => states.include?('TAS') ? "Y" : "N",
|
132
|
-
'NSW' => states.include?('NSW') ? "Y" : "N"
|
133
|
-
}
|
134
|
-
}
|
135
|
-
},
|
136
|
-
authenticationGuid: self.guid
|
137
|
-
}
|
138
|
-
|
139
|
-
response = client.call(:abr_search_by_name, message: request)
|
140
|
-
result_list = response.body[:abr_search_by_name_response][:abr_payload_search_results][:response][:search_results_list]
|
141
|
-
|
142
|
-
if result_list.blank?
|
143
|
-
return []
|
144
|
-
else
|
145
|
-
results = response.body[:abr_search_by_name_response][:abr_payload_search_results][:response][:search_results_list][:search_results_record]
|
146
|
-
return [parse_search_result(results)] if !results.is_a?(Array)
|
147
|
-
return results.map do |r| parse_search_result(r) end
|
148
|
-
end
|
149
|
-
rescue => ex
|
150
|
-
self.errors << ex.to_s
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# Parses results for a search by ABN
|
155
|
-
def parse_search_result(result)
|
156
|
-
result = {
|
157
|
-
acn: (result[:asic_number] rescue ""),
|
158
|
-
abn: (result[:abn][:identifier_value] rescue ""),
|
159
|
-
entity_type: result[:entity_type].blank? ? "" : (result[:entity_type][:entity_description] rescue ""),
|
160
|
-
status: result[:entity_status].blank? ? "" : (result[:entity_status][:entity_status_code] rescue ""),
|
161
|
-
main_name: result[:main_name].blank? ? "" : (result[:main_name][:organisation_name] rescue ""),
|
162
|
-
trading_name: result[:main_trading_name].blank? ? "" : (result[:main_trading_name][:organisation_name] rescue ""),
|
163
|
-
legal_name: result[:legal_name].blank? ? "" : ("#{result[:legal_name][:given_name]} #{result[:legal_name][:family_name]}" rescue ""),
|
164
|
-
legal_name2: result[:legal_name].blank? ? "" : (result[:legal_name][:full_name] rescue ""),
|
165
|
-
other_trading_name: result[:other_trading_name].blank? ? "" : (result[:other_trading_name][:organisation_name] rescue ""),
|
166
|
-
active_from_date: result[:entity_status].blank? ? "" : (result[:entity_status][:effective_from] rescue ""),
|
167
|
-
address_state_code: result[:main_business_physical_address].blank? ? "" : (result[:main_business_physical_address][:state_code] rescue ""),
|
168
|
-
address_post_code: result[:main_business_physical_address].blank? ? "" : (result[:main_business_physical_address][:postcode] rescue ""),
|
169
|
-
address_from_date: result[:main_business_physical_address].blank? ? "" : (result[:main_business_physical_address][:effective_from] rescue ""),
|
170
|
-
last_updated: (result[:record_last_updated_date] rescue ""),
|
171
|
-
gst_from_date: result[:goods_and_services_tax].blank? ? "" : (result[:goods_and_services_tax][:effective_from] rescue "")
|
172
|
-
}
|
173
|
-
|
174
|
-
# Work out what we should return as a name
|
175
|
-
if !result[:trading_name].blank?
|
176
|
-
result[:name] = result[:trading_name]
|
177
|
-
elsif !result[:main_name].blank?
|
178
|
-
result[:name] = result[:main_name]
|
179
|
-
elsif !result[:other_trading_name].blank?
|
180
|
-
result[:name] = result[:other_trading_name]
|
181
|
-
else
|
182
|
-
if !result[:legal_name].blank? && result[:legal_name].length > 2
|
183
|
-
result[:name] = result[:legal_name]
|
184
|
-
elsif !result[:legal_name2].blank?
|
185
|
-
result[:name] = result[:legal_name2]
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
return result
|
190
|
-
end
|
191
|
-
|
192
|
-
def valid?
|
193
|
-
self.errors.size == 0
|
21
|
+
def search(abn)
|
22
|
+
@fowarder.search(abn)
|
194
23
|
end
|
195
|
-
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,101 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abn_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- James Martin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: savon
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: nokogiri
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: yard
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: A simple ABN search library for validating and obtaining ABN details
|
63
56
|
from the Australian Business Register.
|
64
57
|
email:
|
65
|
-
- james@
|
58
|
+
- james@oneflare.com
|
66
59
|
executables: []
|
67
60
|
extensions: []
|
68
61
|
extra_rdoc_files: []
|
69
62
|
files:
|
70
|
-
-
|
71
|
-
- Gemfile.lock
|
63
|
+
- MIT-LICENSE
|
72
64
|
- README.rdoc
|
73
65
|
- Rakefile
|
74
|
-
-
|
66
|
+
- lib/abn/client.rb
|
67
|
+
- lib/abn/entity.rb
|
68
|
+
- lib/abn/version.rb
|
75
69
|
- lib/abn_search.rb
|
76
|
-
homepage: https://github.com/
|
77
|
-
licenses:
|
70
|
+
homepage: https://github.com/oneflare/abn_search
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
78
74
|
post_install_message:
|
79
75
|
rdoc_options: []
|
80
76
|
require_paths:
|
81
77
|
- lib
|
82
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
79
|
requirements:
|
85
|
-
- -
|
80
|
+
- - ">="
|
86
81
|
- !ruby/object:Gem::Version
|
87
82
|
version: '0'
|
88
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
84
|
requirements:
|
91
|
-
- -
|
85
|
+
- - ">="
|
92
86
|
- !ruby/object:Gem::Version
|
93
87
|
version: '0'
|
94
88
|
requirements: []
|
95
89
|
rubyforge_project: abn_search
|
96
|
-
rubygems_version:
|
90
|
+
rubygems_version: 2.4.8
|
97
91
|
signing_key:
|
98
|
-
specification_version:
|
99
|
-
summary:
|
92
|
+
specification_version: 4
|
93
|
+
summary: ABN Search library for Australian businesses.
|
100
94
|
test_files: []
|
101
95
|
has_rdoc:
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
abn_search (0.0.6)
|
5
|
-
nokogiri
|
6
|
-
savon
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: http://rubygems.org/
|
10
|
-
specs:
|
11
|
-
akami (1.2.2)
|
12
|
-
gyoku (>= 0.4.0)
|
13
|
-
nokogiri
|
14
|
-
builder (3.2.2)
|
15
|
-
gyoku (1.1.1)
|
16
|
-
builder (>= 2.1.2)
|
17
|
-
httpi (2.2.5)
|
18
|
-
rack
|
19
|
-
macaddr (1.7.1)
|
20
|
-
systemu (~> 2.6.2)
|
21
|
-
mime-types (1.25.1)
|
22
|
-
mini_portile (0.6.0)
|
23
|
-
nokogiri (1.6.3.1)
|
24
|
-
mini_portile (= 0.6.0)
|
25
|
-
nori (2.4.0)
|
26
|
-
rack (1.5.2)
|
27
|
-
savon (2.6.0)
|
28
|
-
akami (~> 1.2.0)
|
29
|
-
builder (>= 2.1.2)
|
30
|
-
gyoku (~> 1.1.0)
|
31
|
-
httpi (~> 2.2.3)
|
32
|
-
nokogiri (>= 1.4.0)
|
33
|
-
nori (~> 2.4.0)
|
34
|
-
uuid (~> 2.3.7)
|
35
|
-
wasabi (~> 3.3.0)
|
36
|
-
systemu (2.6.4)
|
37
|
-
uuid (2.3.7)
|
38
|
-
macaddr (~> 1.0)
|
39
|
-
wasabi (3.3.0)
|
40
|
-
httpi (~> 2.0)
|
41
|
-
mime-types (< 2.0.0)
|
42
|
-
nokogiri (>= 1.4.0)
|
43
|
-
yard (0.8.7.4)
|
44
|
-
|
45
|
-
PLATFORMS
|
46
|
-
ruby
|
47
|
-
|
48
|
-
DEPENDENCIES
|
49
|
-
abn_search!
|
50
|
-
yard
|
data/abn_search.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = "abn_search"
|
6
|
-
s.version = '0.0.7'
|
7
|
-
s.authors = ["James Martin"]
|
8
|
-
s.email = ["james@visualconnect.net"]
|
9
|
-
s.homepage = "https://github.com/jamsi/abn_search"
|
10
|
-
s.summary = "ABNSearch library for Australian businesses."
|
11
|
-
s.description = "A simple ABN search library for validating and obtaining ABN details from the Australian Business Register."
|
12
|
-
s.rubyforge_project = "abn_search"
|
13
|
-
|
14
|
-
s.files = `git ls-files`.split("\n")
|
15
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
-
s.require_paths = ["lib"]
|
18
|
-
|
19
|
-
s.add_dependency("savon")
|
20
|
-
s.add_dependency("nokogiri")
|
21
|
-
s.add_development_dependency("yard")
|
22
|
-
end
|