Class: Voicearchive::CommonClient

Inherits:
Client
  • Object
show all
Defined in:
lib/voicearchive/common_client.rb

Instance Attribute Summary collapse

Attributes inherited from Client

#api_key, #version

Instance Method Summary collapse

Methods inherited from Client

#call, #initialize, #set_simple_endpoint_default_values

Constructor Details

This class inherits a constructor from Voicearchive::Client

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



5
6
7
# File 'lib/voicearchive/common_client.rb', line 5

def endpoint
  @endpoint
end

Instance Method Details

#all(params = {}) ⇒ Object



7
8
9
10
11
# File 'lib/voicearchive/common_client.rb', line 7

def all(params = {})
  params = set_simple_endpoint_default_values(params)
  response = call("#{@endpoint}", params, 'get')
  JSON.parse(response.body)
end

#create(params = {}) ⇒ Object



19
20
21
22
# File 'lib/voicearchive/common_client.rb', line 19

def create(params = {})
  response = call(@endpoint, params, 'post')
  JSON.parse(response.body)
end

#destroy(id) ⇒ Object



29
30
31
32
# File 'lib/voicearchive/common_client.rb', line 29

def destroy(id)
  response = call("#{@endpoint}/#{id}", params, 'delete')
  JSON.parse(response.body)
end

#find(id, params = {}) ⇒ Object



13
14
15
16
17
# File 'lib/voicearchive/common_client.rb', line 13

def find(id, params = {})
  params = set_simple_endpoint_default_values(params)
  response = call("#{@endpoint}/#{id}", params, 'get')
  JSON.parse(response.body)
end

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



24
25
26
27
# File 'lib/voicearchive/common_client.rb', line 24

def update(id, params = {})
  response = call("#{@endpoint}/#{id}", params, 'put')
  JSON.parse(response.body)
end