abn_search 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abn_search (0.0.2)
4
+ abn_search (0.0.6)
5
5
  nokogiri
6
+ savon
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
10
- nokogiri (1.5.0)
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)
11
44
 
12
45
  PLATFORMS
13
46
  ruby
14
47
 
15
48
  DEPENDENCIES
16
49
  abn_search!
50
+ yard
@@ -18,7 +18,7 @@ Simply add the following line to your Gemfile and run bundle install.
18
18
  # Search by ABN Number
19
19
  abn = ABNSearch.new("YOUR_GUID_HERE")
20
20
  result = abn.search("59001215354")
21
- => {: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"}
21
+ => {: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
22
 
23
23
  puts result[:entity_type]
24
24
  => "Australian Public Company"
@@ -29,6 +29,10 @@ Simply add the following line to your Gemfile and run bundle install.
29
29
  puts result[:name]
30
30
  => "SONY AUSTRALIA LIMITED"
31
31
 
32
+ # Search by ACN Number
33
+ result = abn.search_by_acn("001215354")
34
+ => {: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
+
32
36
  # Search by name
33
37
  results = abn.search_by_name("Sony", ['NSW'], '2000')
34
38
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "abn_search"
6
- s.version = '0.0.6'
6
+ s.version = '0.0.7'
7
7
  s.authors = ["James Martin"]
8
8
  s.email = ["james@visualconnect.net"]
9
9
  s.homepage = "https://github.com/jamsi/abn_search"
@@ -38,6 +38,39 @@ class ABNSearch
38
38
  self.client_options.merge!({ :proxy => self.proxy }) unless self.proxy.nil?
39
39
  end
40
40
 
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
+ def search_by_acn(acn)
46
+ self.errors << "No ACN provided." && return if acn.nil?
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
72
+ end
73
+
41
74
  # Performs an ABR search for the ABN setup upon initialization
42
75
  #
43
76
  # @param [String] abn - the abn you wish to search for
@@ -50,7 +83,21 @@ class ABNSearch
50
83
  client = Savon.client(self.client_options)
51
84
 
52
85
  response = client.call(:abr_search_by_abn, message: { authenticationGuid: self.guid, searchString: abn.gsub(" ", ""), includeHistoricalDetails: "N" })
86
+ # puts "First response: #{response}"
53
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
+
54
101
  return parse_search_result(result)
55
102
  rescue => ex
56
103
  self.errors << ex.to_s
@@ -107,14 +154,21 @@ class ABNSearch
107
154
  # Parses results for a search by ABN
108
155
  def parse_search_result(result)
109
156
  result = {
110
- abn: result[:abn][:identifier_value],
111
- entity_type: result[:entity_type].blank? ? "" : result[:entity_type][:entity_description],
112
- status: result[:entity_status].blank? ? "" : result[:entity_status][:entity_status_code],
113
- main_name: result[:main_name].blank? ? "" : result[:main_name][:organisation_name],
114
- trading_name: result[:main_trading_name].blank? ? "" : result[:main_trading_name][:organisation_name],
115
- legal_name: result[:legal_name].blank? ? "" : "#{result[:legal_name][:given_name]} #{result[:legal_name][:family_name]}",
116
- legal_name2: result[:legal_name].blank? ? "" : result[:legal_name][:full_name],
117
- other_trading_name: result[:other_trading_name].blank? ? "" : result[:other_trading_name][:organisation_name]
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 "")
118
172
  }
119
173
 
120
174
  # Work out what we should return as a name
@@ -127,7 +181,7 @@ class ABNSearch
127
181
  else
128
182
  if !result[:legal_name].blank? && result[:legal_name].length > 2
129
183
  result[:name] = result[:legal_name]
130
- elsif !result[:legal_name].blank?
184
+ elsif !result[:legal_name2].blank?
131
185
  result[:name] = result[:legal_name2]
132
186
  end
133
187
  end
@@ -138,4 +192,4 @@ class ABNSearch
138
192
  def valid?
139
193
  self.errors.size == 0
140
194
  end
141
- end
195
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abn_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-15 00:00:00.000000000 Z
12
+ date: 2015-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -98,3 +98,4 @@ signing_key:
98
98
  specification_version: 3
99
99
  summary: ABNSearch library for Australian businesses.
100
100
  test_files: []
101
+ has_rdoc: