Class: Restcomm::REST::BaseClient

Inherits:
Object
  • Object
show all
Includes:
Utils, Util
Defined in:
lib/restcomm-ruby/rest/client.rb

Direct Known Subclasses

Client, TaskRouterClient

Constant Summary collapse

HTTP_HEADERS =
{
    'Accept' => 'application/json',
    'Accept-Charset' => 'utf-8',
    'User-Agent' => "restcomm-ruby/#{Restcomm::VERSION}" \
                  " (#{RUBY_ENGINE}/#{RUBY_PLATFORM}" \
                  " #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})"
}
DEFAULTS =
{
    host: '',
    port: 8080,
    use_ssl: false,
    ssl_verify_peer: false,
    ssl_ca_file: File.dirname(__FILE__) + '/../../../conf/cacert.pem',
    timeout: 30,
    proxy_addr: nil,
    proxy_port: nil,
    proxy_user: nil,
    proxy_pass: nil,
    retry_limit: 1
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#derestify, #restify

Methods included from Util

#get_string, #url_encode

Constructor Details

#initialize(*args) ⇒ BaseClient

Returns a new instance of BaseClient.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/restcomm-ruby/rest/client.rb', line 25

def initialize(*args)
        options = args.last.is_a?(Hash) ? args.pop : {host: args[2]}
        @config = get_defaults.merge! options

        @account_sid = args[0] || Restcomm.
        @auth_token = args[1] || Restcomm.auth_token
	@host=args[2]


        if @account_sid.nil? || @auth_token.nil?
 raise ArgumentError, 'Account SID and auth token are required'
        end

        if @host.nil?
 raise ArgumentError, 'Destination Host IP cannot is required!'
        end

        set_up_connection
        set_up_subresources

end

Instance Attribute Details

#account_sidObject (readonly)

Returns the value of attribute account_sid.



19
20
21
# File 'lib/restcomm-ruby/rest/client.rb', line 19

def 
  @account_sid
end

#last_requestObject (readonly)

Returns the value of attribute last_request.



19
20
21
# File 'lib/restcomm-ruby/rest/client.rb', line 19

def last_request
  @last_request
end

#last_responseObject (readonly)

Returns the value of attribute last_response.



19
20
21
# File 'lib/restcomm-ruby/rest/client.rb', line 19

def last_response
  @last_response
end