Class: VoiceBase::Client
- Inherits:
-
Object
- Object
- VoiceBase::Client
- Includes:
- HTTParty
- Defined in:
- lib/voicebase/client.rb
Defined Under Namespace
Classes: Token
Instance Attribute Summary collapse
-
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
-
#api_host ⇒ Object
Returns the value of attribute api_host.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#args ⇒ Object
Returns the value of attribute args.
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#token ⇒ Object
Returns the value of attribute token.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Client
constructor
A new instance of Client.
- #uri ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Client
Returns a new instance of Client.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/voicebase/client.rb', line 21 def initialize(args = {}) @args = args @api_version = args[:api_version] || ENV.fetch('VOICEBASE_API_VERSION', '1.1') @auth_key = args[:auth_key] || ENV['VOICEBASE_API_KEY'] @auth_secret = args[:auth_secret] || ENV['VOICEBASE_API_SECRET'] @debug = !!args[:debug] @user_agent = args[:user_agent] || "usertesting-client/#{VoiceBase::version}" @locale = args[:locale] || 'en' # US English if ENV['VOICEBASE_BEARER_TOKEN'] @token = VoiceBase::Client::Token.new(ENV['VOICEBASE_BEARER_TOKEN']) end if @api_version.to_i < 2 self.extend(VoiceBase::V1::Client) elsif @api_version.to_i == 2 self.extend(VoiceBase::V2::Client) elsif @api_version.to_i == 3 self.extend(VoiceBase::V3::Client) else raise UnknownApiVersionError end end |
Instance Attribute Details
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
8 9 10 |
# File 'lib/voicebase/client.rb', line 8 def api_endpoint @api_endpoint end |
#api_host ⇒ Object
Returns the value of attribute api_host.
7 8 9 |
# File 'lib/voicebase/client.rb', line 7 def api_host @api_host end |
#api_version ⇒ Object
Returns the value of attribute api_version.
9 10 11 |
# File 'lib/voicebase/client.rb', line 9 def api_version @api_version end |
#args ⇒ Object
Returns the value of attribute args.
6 7 8 |
# File 'lib/voicebase/client.rb', line 6 def args @args end |
#cookies ⇒ Object
Returns the value of attribute cookies.
12 13 14 |
# File 'lib/voicebase/client.rb', line 12 def @cookies end |
#debug ⇒ Object
Returns the value of attribute debug.
10 11 12 |
# File 'lib/voicebase/client.rb', line 10 def debug @debug end |
#locale ⇒ Object
Returns the value of attribute locale.
13 14 15 |
# File 'lib/voicebase/client.rb', line 13 def locale @locale end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/voicebase/client.rb', line 14 def token @token end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
11 12 13 |
# File 'lib/voicebase/client.rb', line 11 def user_agent @user_agent end |
Class Method Details
.camelize_name(snake_cased_name) ⇒ Object
E.g. “request_status” -> “requestStatus”
17 18 19 |
# File 'lib/voicebase/client.rb', line 17 def self.camelize_name(snake_cased_name) snake_cased_name.to_s.camelize(:lower) end |
Instance Method Details
#uri ⇒ Object
46 47 48 |
# File 'lib/voicebase/client.rb', line 46 def uri @api_host + @api_endpoint end |