Class | Sawyer::Relation |
In: |
lib/sawyer/relation.rb
|
Parent: | Object |
agent | [R] | |
available_methods | [R] | |
href_template | [R] | |
method | [R] | |
name | [R] |
Public: Builds a single Relation from the given options. These are usually taken from a `_links` property in a resource.
agent - The Sawyer::Agent that made the request. name - The Symbol name of the Relation. options - A Hash containing the other Relation properties.
:href - The String URL of the next action's location. :method - The optional String HTTP method.
Returns a Relation.
Public: Builds an index of Relations from the value of a `_links` property in a resource. :get is the default method. Any links with multiple specified methods will get multiple relations created.
index - The Hash mapping Relation names to the Hash Relation
options.
rels - A Relation::Map to store the Relations.
Returns a Relation::Map
A Relation represents an available next action for a resource.
agent - The Sawyer::Agent that made the request. name - The Symbol name of the relation. href - The String URL of the location of the next action. method - The Symbol HTTP method. Default: :get
Public: Makes an API request with the curent Relation.
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. :method - Symbol HTTP method.
Raises ArgumentError if the :method value is not in @available_methods. Returns a Sawyer::Response.
Public: Makes an API request with the curent Relation using DELETE.
data - The Optional Hash or Resource body to be sent. options - Hash of option to configure the API request.
:headers - Hash of API headers to set. :query - Hash of URL query params to set. :method - Symbol HTTP method.
Returns a Sawyer::Response.
Public: Makes an API request with the curent Relation using GET.
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. :method - Symbol HTTP method.
Returns a Sawyer::Response.
Public: Makes an API request with the curent Relation using HEAD.
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. :method - Symbol HTTP method.
Returns a Sawyer::Response.
Public: Makes an API request with the curent Relation using OPTIONS.
data - The Optional Hash or Resource body to be sent. options - Hash of option to configure the API request.
:headers - Hash of API headers to set. :query - Hash of URL query params to set. :method - Symbol HTTP method.
Returns a Sawyer::Response.
Public: Makes an API request with the curent Relation using PATCH.
data - The Optional Hash or Resource body to be sent. options - Hash of option to configure the API request.
:headers - Hash of API headers to set. :query - Hash of URL query params to set. :method - Symbol HTTP method.
Returns a Sawyer::Response.
Public: Makes an API request with the curent Relation using POST.
data - The Optional Hash or Resource body to be sent. options - Hash of option to configure the API request.
:headers - Hash of API headers to set. :query - Hash of URL query params to set. :method - Symbol HTTP method.
Returns a Sawyer::Response.
Public: Makes an API request with the curent Relation using PUT.
data - The Optional Hash or Resource body to be sent. options - Hash of option to configure the API request.
:headers - Hash of API headers to set. :query - Hash of URL query params to set. :method - Symbol HTTP method.
Returns a Sawyer::Response.