Class: AliyunNlpRuby::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/aliyun_nlp_ruby/client.rb

Constant Summary collapse

SERVICE_URL =
"http://alinlp.cn-hangzhou.aliyuncs.com"

Instance Method Summary collapse

Instance Method Details

#send_request(params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/aliyun_nlp_ruby/client.rb', line 12

def send_request params
  params_without_sig = build_params(params.merge(intrinsic_params))
  params_full= "Signature=#{sign(params_without_sig)}&#{params_without_sig}"

  response = Faraday.get "#{SERVICE_URL}?#{params_full}"
  if response != 200 && defined? Rails
    Rails.logger.error(response.body)
  end
  data = JSON.parse(response.body).dig('Data') || ''
  JSON.parse(data).dig('result')
end