Class: FindworkApi::Client
- Inherits:
-
Object
- Object
- FindworkApi::Client
- Defined in:
- lib/findwork_api/client.rb
Constant Summary collapse
- BASE_URL =
"https://findwork.dev/api/"
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
-
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #jobs ⇒ Object
Constructor Details
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/findwork_api/client.rb', line 9 def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) @api_key = api_key @adapter = adapter @stubs = stubs end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
7 8 9 |
# File 'lib/findwork_api/client.rb', line 7 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/findwork_api/client.rb', line 7 def api_key @api_key end |
Instance Method Details
#connection ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/findwork_api/client.rb', line 15 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = BASE_URL conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#jobs ⇒ Object
24 25 26 |
# File 'lib/findwork_api/client.rb', line 24 def jobs JobsResource.new(self) end |