Class: Voicearchive::Client

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

Constant Summary collapse

@@rest_path =
'rest'
@@auth_header =
'X-API-KEY'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key = '', version = 1, host = 'https://system.voicearchive.com') ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
# File 'lib/voicearchive/client.rb', line 15

def initialize(api_key = '', version = 1, host = 'https://system.voicearchive.com')
  @api_key = api_key
  @version = version
  @host = host
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



9
10
11
# File 'lib/voicearchive/client.rb', line 9

def api_key
  @api_key
end

#versionObject

Returns the value of attribute version.



10
11
12
# File 'lib/voicearchive/client.rb', line 10

def version
  @version
end

Instance Method Details

#call(end_point, params = {}, request_type = "get") ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/voicearchive/client.rb', line 21

def call(end_point, params={}, request_type="get")
  url = get_url_object(end_point)
  http = Net::HTTP.new url.host, url.port
  http.read_timeout = 360
  http.use_ssl = false
  if url.scheme == 'https'
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end

  http.start do |http|
    http.request(self.send("get_#{request_type.downcase}_request".to_sym,url, params))
  end
end

#set_simple_endpoint_default_values(params) ⇒ Object



36
37
38
39
40
41
# File 'lib/voicearchive/client.rb', line 36

def set_simple_endpoint_default_values(params)
  if not params.key?(:pageSize)
    params[:pageSize] = 10000000
  end
  params
end