Important: Gem has been rewritten to support ABN objects. Stick with ~>0.0 until you rewrite your application.¶ ↑
A simple library for validating ABNs and ACNs and updating details from the Australian Business Register.
PLEASE NOTE: You will need a GUID to be able to use the ABR business lookup API. You can obtain one at the following link; www.abr.business.gov.au/Register.aspx
Simply add the following line to your Gemfile and run bundle install.
gem 'abn_search'
require 'abn_search' # Connect to ABR ABNSearch::Client.new("YOUR_GUID_HERE") => #<ABNSearch::Client> # Create and validate an entity based on ABN my_entity = ABNSearch::Entity.new({abn: '59001215354'}) => #<ABNSearch::Entity @abn="59001215354"> my_entity.valid? => true # Create and validate an entity using an ACN instead another_entity = ABNSearch::Entity.new({acn: '001215354'}) => #<ABNSearch::Entity @acn="001215354"> another_entity.valid_acn? => true # Just check an ABN or ACN ABNSearch::Entity.valid?('59001215354') => true ABNSearch::Entity.valid?('59001215353') => false ABNSearch::Entity.valid_acn?('001215354') => true # Query the ABR using ABN my_entity.update_from_abr! => #<ABNSearch::Entity @abn="59001215354", @acn="001215354", @abn_current="Y", @entity_type="Australian Public Company", @status="Active", @main_name="SONY AUSTRALIA LIMITED", @trading_name=nil, @legal_name=nil, @legal_name2=nil, @other_trading_name=nil, @active_from_date=#<Date: 2000-04-22 ((2451657j,0s,0n),+0s,2299161j)>, @address_state_code="NSW", @address_post_code="2113", @address_from_date=#<Date: 2014-09-24 ((2456925j,0s,0n),+0s,2299161j)>, @last_updated=#<Date: 2015-06-19 ((2457193j,0s,0n),+0s,2299161j)>, @gst_from_date=#<Date: 2000-07-01 ((2451727j,0s,0n),+0s,2299161j)>> # Query the ABR using ACN another_entity.update_from_abr_using_acn! => #<ABNSearch::Entity @abn="59001215354", @acn="001215354", @abn_current="Y", @entity_type="Australian Public Company", @status="Active", @main_name="SONY AUSTRALIA LIMITED", @trading_name=nil, @legal_name=nil, @legal_name2=nil, @other_trading_name=nil, @active_from_date=#<Date: 2000-04-22 ((2451657j,0s,0n),+0s,2299161j)>, @address_state_code="NSW", @address_post_code="2113", @address_from_date=#<Date: 2014-09-24 ((2456925j,0s,0n),+0s,2299161j)>, @last_updated=#<Date: 2015-06-19 ((2457193j,0s,0n),+0s,2299161j)>, @gst_from_date=#<Date: 2000-07-01 ((2451727j,0s,0n),+0s,2299161j)>> # Select the most appropriate company name my_entity.name => "SONY AUSTRALIA LIMITED" # Search by name ABNSearch::Client.search_by_name("Sony", {states:['NSW'], postcode:'2000'}) => [<#ABNSearch::Entity>,<#ABNSearch::Entity>,<#ABNSearch::Entity>,...]
This gem uses actual error handling from version 1.0.0
-
Australian Business Register: www.abr.business.gov.au/
-
GUID Registration link: www.abr.business.gov.au/Register.aspx