| Class | Sawyer::Agent |
| In: |
lib/sawyer/agent.rb
|
| Parent: | Object |
| NO_BODY | = | Set.new([:get, :head]) |
| allow_undefined_methods | [RW] | |
| links_parser | [RW] | |
| serializer | [W] |
Agents handle making the requests, and passing responses to Sawyer::Response.
endpoint - String URI of the API entry point. options - Hash of options.
:allow_undefined_methods - Allow relations to call all the HTTP verbs,
not just the ones defined.
:faraday - Optional Faraday::Connection to use.
:links_parser - Optional parser to parse link relations
Defaults: Sawyer::LinkParsers::Hal.new
:serializer - Optional serializer Class. Defaults to
self.serializer_class.
Yields the Faraday::Connection if a block is given.
Makes a request through Faraday.
method - The Symbol name of an HTTP method. url - The String URL to access. This can be relative to the Agent‘s
endpoint.
data - The Optional Hash or Resource body to be sent. :get or :head
requests can have no body, so this can be the options Hash
instead.
options - Hash of option to configure the API request.
:headers - Hash of API headers to set.
:query - Hash of URL query params to set.
Returns a Sawyer::Response.
Decodes a String response body to a resource.
str - The String body from the response.
Returns an Object resource (Hash by default).
Encodes an object to a string for the API request.
data - The Hash or Resource that is being sent.
Returns a String.
Public: Retains a reference to the root relations of the API.
Returns a Sawyer::Relation::Map.