Sha256: d81a759c83ff17891f1a3ec6be63f56923cdc533a4f9097b3b065921b7ba93db

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module VoiceBase
  class Client
    include HTTParty

    attr_accessor :args
    attr_accessor :api_host
    attr_accessor :api_endpoint
    attr_accessor :api_version
    attr_accessor :debug
    attr_accessor :user_agent
    attr_accessor :cookies
    attr_accessor :locale
    attr_accessor :token

    # E.g. "request_status" -> "requestStatus"
    def self.camelize_name(snake_cased_name)
      snake_cased_name.to_s.camelize(:lower)
    end

    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_f < 2.0
        self.extend(VoiceBase::V1::Client)
      else
        self.extend(VoiceBase::V2::Client)
      end
    end

    def uri
      @api_host + @api_endpoint
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voicebase-client-ruby-1.2.4 lib/voicebase/client.rb