Class: WCC::Data::RESTEndpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/wcc/data/rest_endpoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ RESTEndpoint

Returns a new instance of RESTEndpoint.



6
7
8
# File 'lib/wcc/data/rest_endpoint.rb', line 6

def initialize(args={})
  @service = args[:service]
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



4
5
6
# File 'lib/wcc/data/rest_endpoint.rb', line 4

def service
  @service
end

Instance Method Details

#create(attrs, options = {}) ⇒ Object



18
19
20
# File 'lib/wcc/data/rest_endpoint.rb', line 18

def create(attrs, options={})
  service.post(options.merge(body: attrs))
end

#destroy(id, options = {}) ⇒ Object



26
27
28
# File 'lib/wcc/data/rest_endpoint.rb', line 26

def destroy(id, options={})
  service.delete(options.merge(uri: id.to_s))
end

#index(options = {}) ⇒ Object



10
11
12
# File 'lib/wcc/data/rest_endpoint.rb', line 10

def index(options={})
  service.get(options)
end

#show(id, options = {}) ⇒ Object



14
15
16
# File 'lib/wcc/data/rest_endpoint.rb', line 14

def show(id, options={})
  service.get(options.merge(uri: id.to_s))
end

#update(id, attrs, options = {}) ⇒ Object



22
23
24
# File 'lib/wcc/data/rest_endpoint.rb', line 22

def update(id, attrs, options={})
  service.patch(options.merge(uri: id.to_s, body: attrs))
end