Class: ShafClient
- Inherits:
-
Object
- Object
- ShafClient
- Extended by:
- Middleware::Cache::Control
- Defined in:
- lib/shaf_client/middleware/cache.rb,
lib/shaf_client.rb,
lib/shaf_client/form.rb,
lib/shaf_client/link.rb,
lib/shaf_client/curie.rb,
lib/shaf_client/resource.rb,
lib/shaf_client/base_resource.rb
Overview
FIXME zip payload
Defined Under Namespace
Modules: Middleware Classes: BaseResource, Curie, Form, Link, Resource
Constant Summary collapse
- MIME_TYPE_JSON =
'application/json'
Instance Method Summary collapse
- #get_doc(uri) ⇒ Object
- #get_form(uri) ⇒ Object
- #get_root ⇒ Object
-
#initialize(root_uri, **options) ⇒ ShafClient
constructor
A new instance of ShafClient.
Methods included from Middleware::Cache::Control
cache_size, clear_cache, clear_stale_cache
Constructor Details
#initialize(root_uri, **options) ⇒ ShafClient
Returns a new instance of ShafClient.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/shaf_client.rb', line 12 def initialize(root_uri, **) @root_uri = root_uri.dup adapter = .fetch(:faraday_adapter, :net_http) setup @client = Faraday.new(url: root_uri) do |conn| conn.basic_auth(@user, @pass) if basic_auth? conn.use Middleware::Cache, auth_header: auth_header conn.adapter adapter end end |
Instance Method Details
#get_doc(uri) ⇒ Object
33 34 35 36 |
# File 'lib/shaf_client.rb', line 33 def get_doc(uri) response = request(method: :get, uri: uri) response&.body || '' end |
#get_form(uri) ⇒ Object
28 29 30 31 |
# File 'lib/shaf_client.rb', line 28 def get_form(uri) response = request(method: :get, uri: uri) Form.new(self, response.body) end |
#get_root ⇒ Object
24 25 26 |
# File 'lib/shaf_client.rb', line 24 def get_root get(@root_uri) end |