lib/datatxt/nex.rb in datatxt-0.0.1 vs lib/datatxt/nex.rb in datatxt-0.0.2
- old
+ new
@@ -2,37 +2,19 @@
require "faraday_middleware"
require "json"
module Datatxt
- class Nex
+ class Nex < Base
- attr_accessor :endpoint, :text, :url, :html, :html_fragment, :lang, :min_confidence, :min_length, :social_hashtag, :social_mention, :include, :extra_types, :country, :custom_spots
+ ENDPOINT = "/datatxt/nex/v1"
- def initialize
-
- end
+ attr_accessor :text, :url, :html, :html_fragment, :lang, :min_confidence, :min_length, :social_hashtag, :social_mention, :include, :extra_types, :country, :custom_spots
- def post(options)
- call(params)
+ def analyze(options)
+ params = options
+ call(ENDPOINT, params)
end
-
- protected
-
- def call(params)
- begin
- params = params.merge({api_key: Machinereading.config.api_key})
- conn = Faraday.new(url: Machinereading.config.endpoint) do |faraday|
- faraday.request :url_encoded
- faraday.adapter Faraday.default_adapter
- end
- response = conn.post "/#{endpoint}", params
- response.body
- rescue Exception => e
- puts e.inspect
- end
- end
-
end
end
\ No newline at end of file