Class: AbnLookup::Client
- Inherits:
-
Object
- Object
- AbnLookup::Client
- Defined in:
- lib/abn_lookup/client.rb
Constant Summary collapse
- BASE_URL =
"https://abr.business.gov.au/json/"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(adapter: Faraday.default_adapter) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(adapter: Faraday.default_adapter) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 |
# File 'lib/abn_lookup/client.rb', line 16 def initialize(adapter: Faraday.default_adapter) @adapter = adapter raise AbnLookup::InvalidGuidError, 'GUID not configued.' if AbnLookup.guid.nil? end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
14 15 16 |
# File 'lib/abn_lookup/client.rb', line 14 def adapter @adapter end |
Instance Method Details
#connection ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/abn_lookup/client.rb', line 22 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.request :json conn.response :json, content_type: "application/json" conn.response :callback_parser conn.use AbnLookup::AddParameter, "guid", AbnLookup.guid conn.use AbnLookup::AddParameter, "callback", "callback" # force to JSONP ever be callback conn.adapter adapter end end |