Class: Incandescent::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uid, api_key) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
# File 'lib/incandescent/client.rb', line 6

def initialize(uid, api_key)
  @uid        = uid
  @api_key    = api_key
  @image_urls = []
  @project_id = nil
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



4
5
6
# File 'lib/incandescent/client.rb', line 4

def api_key
  @api_key
end

#image_urlsObject (readonly)

Returns the value of attribute image_urls.



4
5
6
# File 'lib/incandescent/client.rb', line 4

def image_urls
  @image_urls
end

#project_idObject (readonly)

Returns the value of attribute project_id.



4
5
6
# File 'lib/incandescent/client.rb', line 4

def project_id
  @project_id
end

#uidObject (readonly)

Returns the value of attribute uid.



4
5
6
# File 'lib/incandescent/client.rb', line 4

def uid
  @uid
end

Instance Method Details

#add_image_url(url) ⇒ Object



13
14
15
# File 'lib/incandescent/client.rb', line 13

def add_image_url(url)
  image_urls << url
end

#get_resultsObject



24
25
26
# File 'lib/incandescent/client.rb', line 24

def get_results
  handle_get_response(Incandescent::ServiceCall.new(:get, project_id: project_id).results)
end

#initiate_searchObject



17
18
19
20
21
22
# File 'lib/incandescent/client.rb', line 17

def initiate_search
  if image_urls.empty?
    raise Incandescent::Error, "Cannot initiate search before adding images to the queue."
  end
  handle_add_response(Incandescent::ServiceCall.new(:add, images: image_urls, multiple: 3).results)
end