Class: Vidibus::Service::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/vidibus/service/client.rb

Defined Under Namespace

Classes: RequestError, ServiceError

Instance Attribute Summary collapse

Instance Method Summary collapse

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_uriObject

Returns the value of attribute base_uri.



12
13
14
# File 'lib/vidibus/service/client.rb', line 12

def base_uri
  @base_uri
end

#serviceObject

Returns the value of attribute service.



12
13
14
# File 'lib/vidibus/service/client.rb', line 12

def service
  @service
end

#thisObject

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, options = {})
  request(:delete, path, options)
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, options = {})
  request(:get, path, options)
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, options = {})
  request(:post, path, options)
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, options = {})
  request(:put, path, options)
end