Class: HypermediaAPI::Link
- Inherits:
-
Object
- Object
- HypermediaAPI::Link
- Defined in:
- lib/api/link.rb
Instance Method Summary collapse
-
#auth ⇒ Object
Returns the HTTP basic auth of this link.
-
#click(options = {}) ⇒ Object
Sends a GET request to the href uri of this link, then returns a HypermediaAPI::Document representing the response.
-
#href ⇒ Object
Returns the href uri of this link.
-
#initialize(href_uri_str, http_basic_auth = nil) ⇒ Link
constructor
Sets the href uri and HTTP basic auth of this link.
Constructor Details
#initialize(href_uri_str, http_basic_auth = nil) ⇒ Link
Sets the href uri and HTTP basic auth of this link.
23 24 25 26 |
# File 'lib/api/link.rb', line 23 def initialize (href_uri_str, http_basic_auth = nil) @href_uri_str = href_uri_str.to_s @http_basic_auth = http_basic_auth || { username: '', password: '' } end |
Instance Method Details
#auth ⇒ Object
Returns the HTTP basic auth of this link.
5 6 7 |
# File 'lib/api/link.rb', line 5 def auth @http_basic_auth end |
#click(options = {}) ⇒ Object
Sends a GET request to the href uri of this link, then returns a HypermediaAPI::Document representing the response.
11 12 13 14 15 |
# File 'lib/api/link.rb', line 11 def click ( = {}) document = HypermediaAPI.get(self.href, { auth: self.auth }.merge()) rescue SocketError raise HypermediaAPI::BadURI, "The client was unable to interact with a resource at #{self.href}." end |
#href ⇒ Object
Returns the href uri of this link.
18 19 20 |
# File 'lib/api/link.rb', line 18 def href @href_uri_str end |