Class: HalClient
- Inherits:
-
Object
- Object
- HalClient
- Extended by:
- EntryPointCovenienceMethods
- Defined in:
- lib/hal_client.rb,
lib/hal_client/link.rb,
lib/hal_client/errors.rb,
lib/hal_client/version.rb,
lib/hal_client/collection.rb,
lib/hal_client/links_section.rb,
lib/hal_client/curie_resolver.rb,
lib/hal_client/representation.rb,
lib/hal_client/representation_set.rb,
lib/hal_client/representation_editor.rb
Overview
Adapter used to access resources.
Defined Under Namespace
Modules: EntryPointCovenienceMethods Classes: Collection, CurieResolver, HttpError, Link, LinksSection, NullLogger, Representation, RepresentationEditor, RepresentationSet
Constant Summary collapse
- InvalidRepresentationError =
The representation is not a valid HAL document.
Class.new(StandardError)
- NotACollectionError =
The representation is not a HAL collection
Class.new(StandardError)
- HttpClientError =
Server response with a 4xx status code
Class.new(HttpError)
- HttpServerError =
Server responded with a 5xx status code
Class.new(HttpError)
- TimeoutError =
Class.new(StandardError)
- VERSION =
"3.16.0"
Instance Method Summary collapse
-
#delete(url, headers = {}) ⇒ Object
Delete a
RepresentationorStringto the resource identified aturl. -
#get(url, headers = {}) ⇒ Object
Returns a
Representationof the resource identified byurl.
Methods included from EntryPointCovenienceMethods
Instance Method Details
#delete(url, headers = {}) ⇒ Object
Delete a Representation or String to the resource identified at url.
url - The URL of the resource of interest. headers - custom header fields to use for this request
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/hal_client.rb', line 146 def delete(url, headers={}) headers = auth_headers(url).merge(headers) begin client = client_for_post(override_headers: headers) resp = bmtb("DELETE <#{url}>") { client.request(:delete, url) } interpret_response resp rescue HttpError => e fail e.class.new("DELETE <#{url}> failed with code #{e.response.status}", e.response) end end |
#get(url, headers = {}) ⇒ Object
Returns a Representation of the resource identified by url.
url - The URL of the resource of interest. headers - custom header fields to use for this request
82 83 84 85 86 87 88 89 90 |
# File 'lib/hal_client.rb', line 82 def get(url, headers={}) headers = auth_headers(url).merge(headers) client = client_for_get(override_headers: headers) resp = bmtb("GET <#{url}>") { client.get(url) } interpret_response resp rescue HttpError => e fail e.class.new("GET <#{url}> failed with code #{e.response.status}", e.response) end |