Class: Gpdb::REST::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gpdb/rest/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



9
10
11
12
13
14
# File 'lib/gpdb/rest/client.rb', line 9

def initialize
  self.http_client = HttpClient.new

  self.recording_requests = Gpdb::REST::RecordingRequest::Resource.new(self)
  self.pronunciations = Gpdb::REST::Pronunciation::Resource.new(self)
end

Instance Attribute Details

#http_clientObject

Returns the value of attribute http_client.



6
7
8
# File 'lib/gpdb/rest/client.rb', line 6

def http_client
  @http_client
end

#pronunciationsObject

Returns the value of attribute pronunciations.



7
8
9
# File 'lib/gpdb/rest/client.rb', line 7

def pronunciations
  @pronunciations
end

#recording_requestsObject

Returns the value of attribute recording_requests.



7
8
9
# File 'lib/gpdb/rest/client.rb', line 7

def recording_requests
  @recording_requests
end

Instance Method Details

#request(request, namespace: Gpdb.configuration.namespace) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/gpdb/rest/client.rb', line 16

def request(request, namespace: Gpdb.configuration.namespace)
  request.api_url = Gpdb.configuration.api_url
  request.path    = "#{namespace}#{request.path}"
  request.headers = { 'Authorization': Gpdb.configuration.credentials.signature_header }

  response = http_client.request(request)

  Response.new(body: response.body, status: response.status, _response: response)
end