Class: AbnLookup::SearchByAbn
- Inherits:
-
Object
- Object
- AbnLookup::SearchByAbn
- Defined in:
- lib/abn_lookup/search_by_abn.rb
Class Attribute Summary collapse
-
.default_stub ⇒ Object
Returns the value of attribute default_stub.
-
.stubs ⇒ Object
Returns the value of attribute stubs.
Class Method Summary collapse
Class Attribute Details
.default_stub ⇒ Object
Returns the value of attribute default_stub.
6 7 8 |
# File 'lib/abn_lookup/search_by_abn.rb', line 6 def default_stub @default_stub end |
.stubs ⇒ Object
Returns the value of attribute stubs.
6 7 8 |
# File 'lib/abn_lookup/search_by_abn.rb', line 6 def stubs @stubs end |
Class Method Details
.fetch(abn, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/abn_lookup/search_by_abn.rb', line 8 def fetch(abn, = {}) stub = stubs[abn] || default_stub raise stub if stub.is_a?(Exception) return stub if stub parse = .fetch(:parse, true) response = AbnLookup.connection.get("AbnDetails.aspx?abn=#{abn.gsub(/\s/, '')}") body = response.body raise InvalidGuidError if body["Message"] == "The GUID entered is not recognised as a Registered Party" raise AbnNotFoundError if body["Abn"].empty? || body["Message"] == "No record found" parse ? Abn.parse(body) : body end |