Class: Vidibus::Service::Client
- Inherits:
-
Object
- Object
- Vidibus::Service::Client
- Includes:
- HTTParty
- Defined in:
- lib/vidibus/service/client.rb
Defined Under Namespace
Classes: RequestError, ServiceError
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#service ⇒ Object
Returns the value of attribute service.
-
#this ⇒ Object
Returns the value of attribute this.
Instance Method Summary collapse
-
#delete(path, options = {}) ⇒ Object
Sends a DELETE request to given path.
-
#get(path, options = {}) ⇒ Object
Sends a GET request to given path.
-
#initialize(service) ⇒ Client
constructor
Initializes a new client for given service.
-
#post(path, options = {}) ⇒ Object
Sends a POST request to given path.
-
#put(path, options = {}) ⇒ Object
Sends a PUT request to given path.
Constructor Details
#initialize(service) ⇒ Client
Initializes a new client for given service.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vidibus/service/client.rb', line 15 def initialize(service) unless service && service.is_a?(::Service) raise(ServiceError, 'Service required') end unless service.url raise(ServiceError, 'URL of service required') end self.service = service self.this = ::Service.this self.base_uri = service.url end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
12 13 14 |
# File 'lib/vidibus/service/client.rb', line 12 def base_uri @base_uri end |
#service ⇒ Object
Returns the value of attribute service.
12 13 14 |
# File 'lib/vidibus/service/client.rb', line 12 def service @service end |
#this ⇒ Object
Returns the value of attribute this.
12 13 14 |
# File 'lib/vidibus/service/client.rb', line 12 def this @this end |
Instance Method Details
#delete(path, options = {}) ⇒ Object
Sends a DELETE request to given path.
43 44 45 |
# File 'lib/vidibus/service/client.rb', line 43 def delete(path, = {}) request(:delete, path, ) end |
#get(path, options = {}) ⇒ Object
Sends a GET request to given path.
28 29 30 |
# File 'lib/vidibus/service/client.rb', line 28 def get(path, = {}) request(:get, path, ) end |
#post(path, options = {}) ⇒ Object
Sends a POST request to given path.
33 34 35 |
# File 'lib/vidibus/service/client.rb', line 33 def post(path, = {}) request(:post, path, ) end |
#put(path, options = {}) ⇒ Object
Sends a PUT request to given path.
38 39 40 |
# File 'lib/vidibus/service/client.rb', line 38 def put(path, = {}) request(:put, path, ) end |