suchowan / watson-api-client

An IBM Watson™ API client
MIT License
27 stars 10 forks source link

undefined method `PostTone' for ToneAnalyzer? #8

Open dostro opened 7 years ago

dostro commented 7 years ago

Hey suchowan! I'm not sure what happened in the last couple weeks but I'm getting this strange error that PostTone is an undefined method for ToneAnalyzer. Here's what I'm running:

service = WatsonAPIClient::ToneAnalyzer.new(
              user: username, 
              password: password, 
              verify_ssl: OpenSSL::SSL::VERIFY_NONE)

response = service.PostTone(
              "Content-Type"            => content_type,
              "version"                 => ENV["IBM_WATSON_TONE_ANALYZER_VERSION"],
              "body"                    => message_record.message_text )

NoMethodError (undefined method `PostTone' for #):

Any idea what's going on?

suchowan commented 7 years ago

The simple API documentation for the watson-api-client is available on http://rubydoc.info/gems/watson-api-client.

However, most of the classes and methods of this gem are not described in the above document because they are dynamically defined. Instead, by running the lib/watson-api-client.rb directly, we can output to the standard output the actual those list of classes and methods.

Concerning about ToneAnalyzer, lib/watson-api-client.rb outputs the following description:

... [WatsonAPIClient::ToneAnalyzer, "See https://watson-api-explorer.mybluemix.net/listings/tone-analyzer-v3.json",

{"GetTone"=>{"get"=>{"path"=>"/v3/tone", "summary"=>"Analyze general tone"}}, "tone"=>{"post"=>{"path"=>"/v3/tone", "summary"=>"Analyze general tone"}}, "toneChat"=> {"post"=> {"path"=>"/v3/tone_chat", "summary"=>"Analyze customer engagement tone"}}}] ...

The method corresponding to the Post action seems to be 'tone' rather than 'PostTone'