Class: Qrfy::Client
- Inherits:
-
Object
- Object
- Qrfy::Client
- Defined in:
- lib/qrfy/client.rb
Overview
# Qrfy Client
Hides actual implementation of HTTP API calls. You can overwrite the global configuration (api key or http adapter) passing values in the initializer.
Constant Summary collapse
- BASE_URL =
"https://qrfy.com/api/public"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #connection ⇒ Object
- #folders ⇒ Object
-
#initialize(config = {}) ⇒ Client
constructor
A new instance of Client.
- #qrs ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 |
# File 'lib/qrfy/client.rb', line 15 def initialize(config = {}) @api_key = config.key?(:api_key) ? config[:api_key] : Qrfy.configuration.api_key @adapter = config.key?(:adapter) ? config[:adapter] : Qrfy.configuration.adapter @stubs = config[:stubs] end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
13 14 15 |
# File 'lib/qrfy/client.rb', line 13 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
13 14 15 |
# File 'lib/qrfy/client.rb', line 13 def api_key @api_key end |
Instance Method Details
#connection ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/qrfy/client.rb', line 22 def connection @connection ||= Faraday.new(url: BASE_URL) do |conn| conn.request :json conn.response :parse_dates conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |