Class: Incandescent::Client
- Inherits:
-
Object
- Object
- Incandescent::Client
- Defined in:
- lib/incandescent/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#image_urls ⇒ Object
readonly
Returns the value of attribute image_urls.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
- #add_image_url(url) ⇒ Object
- #get_results ⇒ Object
-
#initialize(uid, api_key) ⇒ Client
constructor
A new instance of Client.
- #initiate_search ⇒ Object
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_key ⇒ Object (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_urls ⇒ Object (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_id ⇒ Object (readonly)
Returns the value of attribute project_id.
4 5 6 |
# File 'lib/incandescent/client.rb', line 4 def project_id @project_id end |
#uid ⇒ Object (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_results ⇒ Object
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_search ⇒ Object
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 |