Class: Remetric::RESTEndpoint

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/remetric/endpoints/rest.rb

Instance Method Summary collapse

Methods inherited from Endpoint

#client, #client=, #http

Constructor Details

#initialize(resource, client) ⇒ RESTEndpoint

Returns a new instance of RESTEndpoint.



3
4
5
6
# File 'lib/remetric/endpoints/rest.rb', line 3

def initialize(resource, client)
  @resource = resource
  @client = client
end

Instance Method Details

#create(args = {}) ⇒ Object



24
25
26
# File 'lib/remetric/endpoints/rest.rb', line 24

def create(args = {})
  http.post "/#{client.}/#{resource}", { event: args }
end

#destroy(id) ⇒ Object



32
33
34
# File 'lib/remetric/endpoints/rest.rb', line 32

def destroy(id)
  http.delete "/#{client.}/#{resource}/#{id}"
end

#list(args = {}) ⇒ Object



16
17
18
# File 'lib/remetric/endpoints/rest.rb', line 16

def list(args = {})
  http.get "/#{client.}/#{resource}", args
end

#resourceObject



8
9
10
# File 'lib/remetric/endpoints/rest.rb', line 8

def resource
  @resource
end

#resource=(resource) ⇒ Object



12
13
14
# File 'lib/remetric/endpoints/rest.rb', line 12

def resource=(resource)
  @resource = resource
end

#show(id) ⇒ Object



20
21
22
# File 'lib/remetric/endpoints/rest.rb', line 20

def show(id)
  http.get "/#{client.}/#{resource}/#{id}"
end

#update(id, args = {}) ⇒ Object



28
29
30
# File 'lib/remetric/endpoints/rest.rb', line 28

def update(id, args = {})
  http.patch "/#{client.}/#{resource}/#{id}", { event: args }
end