Class: WatsonAPIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/watson-api-client.rb

Constant Summary collapse

VERSION =
'0.8.2'
Gateways =
api_docs.delete(:gateway)
Options =
api_docs
Services =
JSON.parse(ENV['VCAP_SERVICES'] || '{}')
DefaultParams =
{:user=>'username', :password=>'password'}
AvailableAPIs =
[]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WatsonAPIClient

Note:

VCAP_SERVICES is IBM Bluemix™ environment variable.

All subclass constructors use following hash parameter -

Parameters:

  • options (Hash) (defaults to: {})

    See following..

Options Hash (options):

  • :url (String)

    API URL (default: the url described in listings or VCAP_SERVICES)

  • :user (String)

    USER ID (default: the username described in VCAP_SERVICES)

  • :password (String)

    USER Password (default: the password described in VCAP_SERVICES)

  • :apikey (String)

    or :api_key API key for the Alchemy API (default: the apikey or api_key described in VCAP_SERVICES)

  • :version (String)

    The release date of the version of the Alchemy API.

  • other_options (Object)

    Other options are passed to RestClient::Resource.new as it is.



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/watson-api-client.rb', line 123

def initialize(options={})
  define_api_methods
  set_variables(options)
  @url   ||= Gateways + self.class::API['apis']['basePath']
  @options = {}
  self.class.superclass::DefaultParams.each_pair do |sym, key|
    @options[sym] = @credential[key] if @credential.key?(key)
  end
  @options.update(options)
  @service = RestClient::Resource.new(@url, @options)
end