Class: ShafClient
- Inherits:
-
Object
show all
- Defined in:
- lib/shaf_client.rb,
lib/shaf_client/form.rb,
lib/shaf_client/link.rb,
lib/shaf_client/curie.rb,
lib/shaf_client/error.rb,
lib/shaf_client/field.rb,
lib/shaf_client/hal_form.rb,
lib/shaf_client/resource.rb,
lib/shaf_client/api_error.rb,
lib/shaf_client/shaf_form.rb,
lib/shaf_client/base_resource.rb,
lib/shaf_client/empty_resource.rb,
lib/shaf_client/resource_mapper.rb,
lib/shaf_client/unknown_resource.rb,
lib/shaf_client/middleware/redirect.rb
Defined Under Namespace
Modules: Middleware
Classes: AmbiguousRelError, ApiError, BaseResource, Curie, EmptyResource, Error, Field, Form, HalForm, Link, Resource, ResourceMapper, ShafForm, UnSupportedContentType, UnknownResource
Constant Summary
collapse
- MIME_TYPE_JSON =
'application/json'
- MIME_TYPE_HAL =
'application/hal+json'
- DEFAULT_ADAPTER =
:net_http
Instance Method Summary
collapse
Constructor Details
#initialize(root_uri, **options) ⇒ ShafClient
Returns a new instance of ShafClient.
20
21
22
23
24
25
26
27
|
# File 'lib/shaf_client.rb', line 20
def initialize(root_uri, **options)
@root_uri = root_uri.dup
@options = options
setup_basic_auth
setup_client
end
|
Instance Method Details
#get_doc(uri, **options) ⇒ Object
33
34
35
36
|
# File 'lib/shaf_client.rb', line 33
def get_doc(uri, **options)
response = request(method: :get, uri: uri, opts: options)
response&.body || ''
end
|
#get_root(**options) ⇒ Object
29
30
31
|
# File 'lib/shaf_client.rb', line 29
def get_root(**options)
get(@root_uri, **options)
end
|
#stubs ⇒ Object
54
55
56
57
|
# File 'lib/shaf_client.rb', line 54
def stubs
return unless @adapter == :test
@stubs ||= Faraday::Adapter::Test::Stubs.new
end
|