Class: ClarifaiRuby::MyTagRequest

Inherits:
TagRequest
  • Object
show all
Defined in:
lib/multitagger/provider/clarifai.rb

Instance Method Summary collapse

Instance Method Details

#get(image_url_or_path, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/multitagger/provider/clarifai.rb', line 6

def get(image_url_or_path, opts = {})
  if image_url_or_path =~ URI::regexp
    super
  else
    body = {
      encoded_data: File.new(image_url_or_path),
      model: opts[:model]
    }
    build_request!(body, opts)
    @raw_response = @client.post(TAG_PATH, body).parsed_response
    raise RequestError.new @raw_response["status_msg"] if @raw_response["status_code"] != "OK"
    TagResponse.new(raw_response)
  end
end