Class: OpenAmplify::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Request
Defined in:
lib/openamplify/client.rb

Overview

Provides access to the OpenAmplify API portaltnx20.openamplify.com/AmplifyWeb_v20/

Basic usage of the library is to call supported methods via the Client class.

text = "After getting the MX1000 laser mouse and the Z-5500 speakers i fell in love with logitech"
OpenAmplify::Client.new.amplify(text)

Instance Method Summary collapse

Methods included from Request

#get, #post

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



19
20
21
22
23
24
# File 'lib/openamplify/client.rb', line 19

def initialize(options={})
  merged_options = OpenAmplify.options.merge(options)
  Configuration::VALID_CONFIG_KEYS.each do |key|
    send("#{key}=", merged_options[key])
  end
end

Instance Method Details

#amplify(input, options = {}) ⇒ Object



26
27
28
29
# File 'lib/openamplify/client.rb', line 26

def amplify(input, options={})
  options = analysis_options.merge(options)
  Analysis::Context.new(self, input, options)
end

#analysis_optionsObject



31
32
33
# File 'lib/openamplify/client.rb', line 31

def analysis_options
  Hash[ *Configuration::VALID_OPTIONS_KEYS.map { |key| [key, send(key)] }.flatten ]
end

#analyze_text(input) ⇒ Object

Deprecated.

Please use #amplify instead



47
48
49
50
# File 'lib/openamplify/client.rb', line 47

def analyze_text(input)
  warn "[DEPRECATION] `analyze_text` is deprecated.  Please use `amplify` instead."
  amplify input
end

#base_url=(url) ⇒ Object

Deprecated.

Please use #endpoint instead



53
54
55
56
# File 'lib/openamplify/client.rb', line 53

def base_url=(url)
  warn "[DEPRECATION] `base_url` is deprecated.  Please use `endpoint` instead."
  self.endpoint = url
end

#request_analysis(options) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/openamplify/client.rb', line 35

def request_analysis(options)
  params = prepare_request_params(options)

  case self.method
  when :post
    post(self.endpoint, params)
  else
    get(self.endpoint, params)
  end
end