abn_lookup 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2433d9b12d5cabd5307e7232ec143f466c0e5113e23ed588e9ccc66ccc5ccfe3
4
- data.tar.gz: 873a9755fc6cbb0d3f0085e59f66896fd3fdc28a1d22b2c1ddb00894bbdd4a05
3
+ metadata.gz: 77340d319f92cf153e723d1f5adc88140a9adfda2a34662ea2060fbeff1cff68
4
+ data.tar.gz: d09cf718e5936f86662720b0aadcd2b10b5f568a08cb7d348c2ef876dbbb599e
5
5
  SHA512:
6
- metadata.gz: fd2a23982b225238acafe47f68d220e0bbc004205e5dc4e828e9389325d87376753b1f6069e813a82e1f6dae1456be9e6319590a0e50ee7b70435ebc9d2cb091
7
- data.tar.gz: 18f28222b17398787ce99cf2765e0f67cff0429160cb9cac853b8e6fdf73f8ce1c561a9e3f71a27ec56d2cc6fcd873a0e349379cc765a46547d257e26217ac5a
6
+ metadata.gz: ee21879c4884617600703c2914789bc554ef48fb0a0948782d749557f639df361903ce6a3ed010f84b0a310ba451efea4115135a7683dd04d06aef7416ae9d10
7
+ data.tar.gz: 6aee9cdeefc95a90b6ab4f77f95dde290e2190931309fb6acb3b4f0ec7596ddbfe73b137d055d22c3103242a87c451663c2b028566a5867d75e853685f1f3abb
@@ -5,17 +5,19 @@ module AbnLookup
5
5
  class << self
6
6
  attr_accessor :stubs, :default_stub
7
7
 
8
- def fetch(abn)
8
+ def fetch(abn, options = {})
9
9
  stub = stubs[abn] || default_stub
10
+ raise stub if stub.is_a?(Exception)
10
11
  return stub if stub
11
12
 
13
+ parse = options.fetch(:parse, true)
12
14
  response = AbnLookup.connection.get("AbnDetails.aspx?abn=#{abn.gsub(/\s/, '')}")
13
15
  body = response.body
14
16
 
15
17
  raise InvalidGuidError if body["Message"] == "The GUID entered is not recognised as a Registered Party"
16
- raise AbnNotFoundError if body["Abn"].empty?
18
+ raise AbnNotFoundError if body["Abn"].empty? || body["Message"] == "No record found"
17
19
 
18
- Abn.parse(body)
20
+ parse ? Abn.parse(body) : body
19
21
  end
20
22
  end
21
23
 
@@ -5,17 +5,19 @@ module AbnLookup
5
5
  class << self
6
6
  attr_accessor :stubs, :default_stub
7
7
 
8
- def fetch(acn)
8
+ def fetch(acn, options = {})
9
9
  stub = stubs[acn] || default_stub
10
+ raise stub if stub.is_a?(Exception)
10
11
  return stub if stub
11
12
 
13
+ parse = options.fetch(:parse, true)
12
14
  response = AbnLookup.connection.get("AcnDetails.aspx?acn=#{acn.gsub(/\s/, '')}")
13
15
  body = response.body
14
16
 
15
17
  raise InvalidGuidError if body["Message"] == "The GUID entered is not recognised as a Registered Party"
16
- raise AbnNotFoundError if body["Abn"].empty?
18
+ raise AbnNotFoundError if body["Abn"].empty? || body["Message"] == "No record found"
17
19
 
18
- Abn.parse(body)
20
+ parse ? Abn.parse(body) : body
19
21
  end
20
22
  end
21
23
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbnLookup
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.4"
5
5
  end
data/lib/abn_lookup.rb CHANGED
@@ -26,12 +26,12 @@ module AbnLookup
26
26
 
27
27
  def_delegators :@config, :guid, :guid=
28
28
 
29
- def search_by_abn(abn)
30
- SearchByAbn.fetch(abn)
29
+ def search_by_abn(abn, options = {})
30
+ SearchByAbn.fetch(abn, options)
31
31
  end
32
32
 
33
- def search_by_acn(acn)
34
- SearchByAcn.fetch(acn)
33
+ def search_by_acn(acn, options = {})
34
+ SearchByAcn.fetch(acn, options)
35
35
  end
36
36
 
37
37
  def search_by_name(name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abn_lookup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lairton Mendes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-03 00:00:00.000000000 Z
11
+ date: 2024-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday